package com.vci.client.workflow.editor.ui;
|
|
import java.awt.BorderLayout;
|
import java.awt.GridBagConstraints;
|
import java.awt.GridBagLayout;
|
import java.awt.Insets;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.io.Serializable;
|
|
import javax.swing.JButton;
|
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
import javax.swing.JTextField;
|
import javax.swing.border.LineBorder;
|
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentListener;
|
|
import org.dom4j.Attribute;
|
import org.dom4j.DocumentHelper;
|
import org.dom4j.Element;
|
|
import com.mxgraph.view.mxGraph;
|
import com.vci.client.workflow.editor.FlowConstants;
|
import com.vci.client.workflow.editor.FlowNode;
|
import com.vci.client.workflow.subprocess.SubProcessChoiceDialog;
|
import com.vci.corba.workflow.data.SubprocessTemInfo;
|
|
|
|
|
|
/**
|
* This code was edited or generated using CloudGarden's Jigloo
|
* SWT/Swing GUI Builder, which is free for non-commercial
|
* use. If Jigloo is being used commercially (ie, by a corporation,
|
* company or business for any purpose whatever) then you
|
* should purchase a license for each developer using Jigloo.
|
* Please visit www.cloudgarden.com for details.
|
* Use of Jigloo implies acceptance of these licensing terms.
|
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
|
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
|
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
|
*/
|
/**
|
* 子流程
|
* @author liudi
|
*
|
* 2013-5-14
|
*/
|
public class SubProcesslPanel extends JPanel implements IProcessProperty , Serializable {
|
private static final long serialVersionUID = 1300418480939892949L;
|
|
private JTextField nameField;
|
private JTextField outComeTextField;
|
private JLabel subProcessLab;
|
private JButton subProcessButton;
|
private JTextField subProcessTextField;
|
private JLabel outComeLab;
|
private JLabel nameLab;
|
private mxGraph graph;
|
private FlowNode node;
|
private SubprocessTemInfo subprocessTemInfo;
|
|
public JTextField getOutComeTextField() {
|
return outComeTextField;
|
}
|
|
public void setOutComeTextField(JTextField outComeTextField) {
|
this.outComeTextField = outComeTextField;
|
}
|
|
public JTextField getSubProcessTextField() {
|
return subProcessTextField;
|
}
|
|
public void setSubProcessTextField(JTextField subProcessTextField) {
|
this.subProcessTextField = subProcessTextField;
|
}
|
|
public SubProcesslPanel(mxGraph graph, FlowNode node) {
|
this.graph = graph;
|
this.node = node;
|
initUI();
|
}
|
|
private void initUI() {
|
setLayout(new BorderLayout());
|
JPanel northPanel = new JPanel();
|
GridBagLayout northPanelLayout = new GridBagLayout();
|
northPanel.setLayout(northPanelLayout);
|
northPanelLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1};
|
northPanelLayout.rowHeights = new int[] {7, 7, 7, 7};
|
northPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1};
|
northPanelLayout.columnWidths = new int[] {7, 7, 7, 7};
|
|
add(northPanel,BorderLayout.CENTER);
|
northPanel.setPreferredSize(new java.awt.Dimension(557, 238));
|
{
|
nameLab = new JLabel();
|
northPanel.add(nameLab, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
|
nameLab.setText("名称:");
|
}
|
{
|
nameField = new JTextField();
|
nameField.setText(node.getName());
|
northPanel.add(nameField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
|
nameField.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
|
}
|
// 流向表达式暂不添加
|
{
|
outComeLab = new JLabel();
|
// northPanel.add(outComeLab, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
outComeLab.setText("流向表达式:");
|
}
|
{
|
outComeTextField = new JTextField();
|
// northPanel.add(outComeTextField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
|
outComeTextField.setText("#{result}");
|
outComeTextField.setEditable(true);
|
}
|
{
|
subProcessLab = new JLabel();
|
northPanel.add(subProcessLab, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
subProcessLab.setText("子流程:");
|
}
|
{
|
subProcessTextField = new JTextField();
|
northPanel.add(subProcessTextField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
|
}
|
{
|
subProcessButton = new JButton();
|
northPanel.add(subProcessButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
subProcessButton.setText("选择");
|
subProcessButton.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
SubProcessChoiceDialog dialog = new SubProcessChoiceDialog();
|
String subProcessName = dialog.getSubProcessName();
|
subProcessTextField.setText(subProcessName);
|
}
|
});
|
}
|
DocumentListener documentListener = new DocumentListener() {
|
public void removeUpdate(DocumentEvent e) {
|
updateFlow();
|
}
|
public void insertUpdate(DocumentEvent e) {
|
updateFlow();
|
}
|
public void changedUpdate(DocumentEvent e) {
|
updateFlow();
|
}
|
};
|
nameField.getDocument().addDocumentListener(documentListener);
|
}
|
|
public String getNodeType() {
|
return node.getType();
|
}
|
|
public void createAttribute(Element owner) {
|
Attribute attributeName = DocumentHelper.createAttribute(owner, FlowConstants.XMLNAME, nameField.getText().trim());
|
owner.add(attributeName);
|
|
Attribute subprocessName = DocumentHelper.createAttribute(owner, FlowConstants.SUBPROCESSKEY, subProcessTextField.getText().trim());
|
owner.add(subprocessName);
|
|
Attribute subprocessId = DocumentHelper.createAttribute(owner, FlowConstants.SUBPROCESSID, subProcessTextField.getText().trim());
|
owner.add(subprocessId);
|
|
// 流向表达式暂设置为null
|
Attribute outComeName = DocumentHelper.createAttribute(owner, FlowConstants.OUTCOME, null);
|
owner.add(outComeName);
|
|
subprocessTemInfo = new SubprocessTemInfo();
|
subprocessTemInfo.subProcessName = subProcessTextField.getText().trim();
|
}
|
|
public SubprocessTemInfo getSubprocessTemInfo(){
|
return subprocessTemInfo;
|
}
|
|
public void setValue(String text) {
|
nameField.setText(text);
|
}
|
|
protected void updateFlow() {
|
graph.refresh();
|
}
|
@Override
|
public String toString() {
|
return nameField.getText().trim();
|
}
|
}
|