yuxc
2025-01-15 c09f81131e8b7c83937206d7cf76f34d2020be75
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
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();
    }
}