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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
package com.vci.client.workflow.editor.ui;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.io.Serializable;
import javax.swing.BorderFactory;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
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;
 
 
 
/**
* 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-9
 */
public class MailPanel extends JPanel implements IProcessProperty , Serializable {
    private static final long serialVersionUID = 1300418480939892949L;
 
    private JTextField nameField;
    private JTextField subjectTextField;
    private JLabel subjectLab;
    private JTextArea contentTextArea;
    private JTextField ccTextArea;
    private JLabel contentLab;
    private JTextField bccTextArea;
    private JLabel bccLab;
    private JLabel ccLab;
    private JTextField accepterTextArea;
    private JLabel accepterLab;
    private JLabel nameLab;
    private mxGraph graph;
    private FlowNode node;
    
    public JTextArea getContentTextArea() {
        return contentTextArea;
    }
 
    public void setContentTextArea(JTextArea contentTextArea) {
        this.contentTextArea = contentTextArea;
    }
 
    public JTextField getCcTextArea() {
        return ccTextArea;
    }
 
    public void setCcTextArea(JTextField ccTextArea) {
        this.ccTextArea = ccTextArea;
    }
 
    public JTextField getSubjectTextField() {
        return subjectTextField;
    }
 
    public void setSubjectTextField(JTextField subjectTextField) {
        this.subjectTextField = subjectTextField;
    }
 
    public JTextField getBccTextArea() {
        return bccTextArea;
    }
 
    public void setBccTextArea(JTextField bccTextArea) {
        this.bccTextArea = bccTextArea;
    }
 
    public JTextField getAccepterTextArea() {
        return accepterTextArea;
    }
 
    public void setAccepterTextArea(JTextField accepterTextArea) {
        this.accepterTextArea = accepterTextArea;
    }
 
    public MailPanel(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, 0.1, 0.1, 0.1, 0.1};
        northPanelLayout.rowHeights = new int[] {7, 7, 7, 7, 7, 7, 7, 7};
        northPanelLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1};
        northPanelLayout.columnWidths = new int[] {7, 7, 7, 7};
 
        JScrollPane accepterJsp = new JScrollPane();
        accepterJsp.getViewport().add(accepterTextArea);
        accepterJsp.setPreferredSize(new java.awt.Dimension(800, 30));
 
        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.EAST, 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));
        }
        {
            accepterLab = new JLabel();
            northPanel.add(accepterLab, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
            accepterLab.setText("收件人:");
        }
        {
            accepterTextArea = new JTextField();
            northPanel.add(accepterTextArea, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            accepterTextArea.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
        }
        {
            ccLab = new JLabel();
            northPanel.add(ccLab, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
            ccLab.setText("抄送:");
        }
        {
            ccTextArea = new JTextField();
            northPanel.add(ccTextArea, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            ccTextArea.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
        }
        {
            bccLab = new JLabel();
            northPanel.add(bccLab, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
            bccLab.setText("密送:");
        }
        {
            bccTextArea = new JTextField();
            northPanel.add(bccTextArea, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            bccTextArea.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
        }
        {
            contentLab = new JLabel();
            northPanel.add(contentLab, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
            contentLab.setText("内容:");
        }
        {
            contentTextArea = new JTextArea();
            contentTextArea.setLineWrap(true);
            northPanel.add(contentTextArea, new GridBagConstraints(1, 5, 1, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            contentTextArea.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
        }
        {
            subjectLab = new JLabel();
            northPanel.add(subjectLab, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            subjectLab.setText("主题:");
        }
        {
            subjectTextField = new JTextField();
            northPanel.add(subjectTextField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            subjectTextField.setBorder(new LineBorder(new java.awt.Color(0,0,0), 1, false));
        }
        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);
        
        //收件人
        String accepter = accepterTextArea.getText().toString();
        Element addrElement = owner.addElement(FlowConstants.XMLTARGET);
        Attribute addrAttribute = DocumentHelper.createAttribute(addrElement,
                FlowConstants.MAIL_ADDRESSES, accepter);
        addrElement.add(addrAttribute);
        
        //抄送
        String cc = ccTextArea.getText().toString();
        Element ccElement = owner.addElement(FlowConstants.MAIL_CC);
        Attribute ccAttribute = DocumentHelper.createAttribute(ccElement,
                FlowConstants.MAIL_ADDRESSES, cc);
        ccElement.add(ccAttribute);
        
        //密送
        String bcc = bccTextArea.getText().toString();
        Element bccElement = owner.addElement(FlowConstants.MAIL_BCC);
        Attribute bccAttribute = DocumentHelper.createAttribute(bccElement,
                FlowConstants.MAIL_ADDRESSES, bcc);
        bccElement.add(bccAttribute);
        
        //主题
        String subject = subjectTextField.getText().toString();
        Element subjectElement = owner.addElement(FlowConstants.MAIL_SUBJECT);
        subjectElement.addText(subject);
        
        //内容
        String content = contentTextArea.getText().toString();
        Element contentElement = owner.addElement(FlowConstants.MAIL_TEXT);
        contentElement.addText(content);
    }
 
    public void setValue(String text) {
        nameField.setText(text);
    }
    
    protected void updateFlow() {
        graph.refresh();
    }
    @Override
    public String toString() {
        return nameField.getText().trim();
    }
}