package com.vci.client.workflow.template;
|
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.FlowLayout;
|
import java.awt.image.BufferedImage;
|
import java.io.ByteArrayInputStream;
|
import java.io.InputStream;
|
|
import javax.imageio.ImageIO;
|
import javax.swing.ImageIcon;
|
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
|
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
|
import com.vci.client.workflow.template.object.ProcessDefinitionObject;
|
|
public class ProcessDefinitionPanel extends JPanel {
|
|
private static final long serialVersionUID = 4377484415817081427L;
|
|
private JLabel flowChartLabel;
|
|
public ProcessDefinitionPanel() {
|
init();
|
}
|
|
private void init() {
|
flowChartLabel = new JLabel();
|
JPanel chartPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
chartPanel.setBackground(Color.WHITE);
|
chartPanel.add(flowChartLabel);
|
JScrollPane comp = new JScrollPane(chartPanel);
|
|
setLayout(new BorderLayout());
|
this.add(comp);
|
}
|
|
public void setObject(ProcessDefinitionObject processDefinitionObject) {
|
updateFlowChart(processDefinitionObject);
|
}
|
|
/**
|
* 根据processDefinition刷新流程图
|
* @param processDefinition, 流程定义
|
*/
|
private void updateFlowChart(ProcessDefinitionObject processDefinitionObject){
|
if(processDefinitionObject == null){
|
flowChartLabel.setIcon(null);
|
return;
|
}
|
try {
|
String deploymentId = processDefinitionObject.getJbpmDeploymentId();
|
byte[] jbpmImage = new ProcessCustomClientDelegate().getProcessChart(deploymentId);
|
InputStream buffin = new ByteArrayInputStream(jbpmImage, 0, jbpmImage.length);
|
BufferedImage bi = ImageIO.read(buffin);
|
ImageIcon icon = new ImageIcon(bi);
|
flowChartLabel.setIcon(icon);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
}
|