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();
|
}
|
}
|