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
package com.vci.client.workflow.editor.ui;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
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.ui.locale.LocaleDisplay;
import com.vci.client.workflow.delegate.EventConfClientDelegate;
import com.vci.client.workflow.editor.FlowConstants;
import com.vci.client.workflow.editor.FlowNode;
import com.vci.corba.common.VCIError;
import com.vci.corba.workflow.data.PropertyInfo;
 
public class StartEndPanel extends JPanel implements IProcessProperty {
    
    private static final long serialVersionUID = 1724948299848339422L;
    
    private JTextField nameField;
    private mxGraph graph;
    private FlowNode node;
    
    private EventPanel transitionInitEventPropertyPanel;
    private EventPanel transitionEndEventPropertyPanel;
    
    public static PropertyInfo[] transmTrainsitionInfo;
    public static String transTrainsitionEnevtType_Start;
    public static String transTrainsitionEnevtType_End;
    
    public StartEndPanel(mxGraph graph, FlowNode node) {
        this.graph = graph;
        this.node = node;
        
        GridBagLayout gridBagLayout = new GridBagLayout();
        gridBagLayout.columnWidths = new int[]{0, 0, 0};
        gridBagLayout.rowHeights = new int[]{0, 0};
        gridBagLayout.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
        gridBagLayout.rowWeights = new double[]{0.0, Double.MIN_VALUE};
        setLayout(gridBagLayout);
        
        JLabel lblNewLabel = new JLabel("名称:");
        GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
        gbc_lblNewLabel.insets = new Insets(0, 0, 0, 5);
        gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
        gbc_lblNewLabel.gridx = 0;
        gbc_lblNewLabel.gridy = 0;
        add(lblNewLabel, gbc_lblNewLabel);
        
        nameField = new JTextField();
        nameField.setText(node.getName());
        GridBagConstraints gbc_textField = new GridBagConstraints();
        gbc_textField.fill = GridBagConstraints.HORIZONTAL;
        gbc_textField.gridx = 1;
        gbc_textField.gridy = 0;
        add(nameField, gbc_textField);
 
//        //2013-4-27 添加自定义路由事件
//        if(node.getName().equals("")
//                ||node.getName().equals("斜线")
//                ||node.getName().equals("水平折线")
//                ||node.getName().equals("垂直折线")){
//            GridBagConstraints gbc_eventPanel = new GridBagConstraints();
//            gbc_eventPanel.fill = GridBagConstraints.HORIZONTAL;
//            gbc_eventPanel.gridx = 0;
//            gbc_eventPanel.gridy = 1;
//            gbc_eventPanel.weightx = 2;
//            gbc_eventPanel.gridwidth = 2;
//            add(getEventPanel(), gbc_eventPanel);
//        }
        
        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);
    }
 
    protected void updateFlow() {
        graph.refresh();
    }
    
    @Override
    public String toString() {
        return nameField.getText().trim();
    }
 
    public String getNodeType() {
        return node.getType();
    }
 
    public void createAttribute(Element owner) {
        Attribute attributeName = DocumentHelper.createAttribute(owner, FlowConstants.XMLNAME, nameField.getText());
        owner.add(attributeName);
    }
 
    public void setValue(String text) {
        nameField.setText(text);
    }
 
    /**
     * 2013-4-27 添加自定义路由事件
     * @return
     */
    private JComponent getEventPanel() {
        JTabbedPane eventPanel = new JTabbedPane();
        transitionInitEventPropertyPanel = new EventPanel("事件", getEventTypes(FlowConstants.XMLSTART),FlowConstants.XMLSTART);
        transitionEndEventPropertyPanel = new EventPanel("事件", getEventTypes(FlowConstants.XMLEND),FlowConstants.XMLEND);
        eventPanel.add("初始事件", transitionInitEventPropertyPanel);
        eventPanel.add("完成事件", transitionEndEventPropertyPanel);
        return eventPanel;
    }
    
    private PropertyObject[] getEventTypes(String eventType) {
        /*String[] types = EventProperties.getStringProperty("workflow.event.type."+eventType).split(",");*/
        //add by caill start 2016.4.8 通过corba连接服务端
        String[] types = null;
        try {
             types = new EventConfClientDelegate().getStringProperty("workflow.event.type."+eventType).split(",");
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //add by caill end
        List<PropertyObject> taskTypes = new ArrayList<PropertyObject>();
        taskTypes.add(new PropertyObject("", ""));
        for (int i = 0; i < types.length; i++) {
            /*taskTypes.add(new PropertyObject(types[i], EventProperties.getStringProperty("workflow.event.type." + types[i])));*/
            //add by caill start 2016.4.8 通过corba连接服务端
            try {
                taskTypes.add(new PropertyObject(types[i], new EventConfClientDelegate().getStringProperty("workflow.event.type." + types[i])));
            } catch (VCIError e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            //add by caill end
        }
        return taskTypes.toArray(new PropertyObject[0]);
    }
    
    private String getI18nForEvent(String key){
        return LocaleDisplay.getI18nString(key, "RMIPWorkflow", getLocale());
    }
    
    /**
     * 保存路由设置的值
     * @param owner
     * @param eventPanel
     * @param eventType
     */
    private void getTrainsitionXml(Element owner, EventPanel eventPanel, String eventType) {
        PropertyInfo[] customClassInfo = eventPanel.getCustomInfos();
        if (customClassInfo.length > 0) {
            if(FlowConstants.XMLSTART.equals(eventType)){
                transTrainsitionEnevtType_Start = eventType;
            }
            if(FlowConstants.XMLEND.equals(eventType)){
                transTrainsitionEnevtType_End = eventType;
            }
            transmTrainsitionInfo = customClassInfo;
        }
    }
}