package com.vci.client.portal.NewNewUI.actionmng;
|
|
import java.awt.Frame;
|
import java.awt.Rectangle;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
|
import javax.swing.JButton;
|
import javax.swing.JDialog;
|
import javax.swing.JLabel;
|
import javax.swing.JOptionPane;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTextArea;
|
import javax.swing.JTextField;
|
|
import com.vci.client.portal.utility.UITools;
|
import com.vci.common.utility.ObjectUtility;
|
import com.vci.corba.portal.data.PLActionCls;
|
import com.vci.mw.ClientContextVariable;
|
|
public class PLActionClsEditDialog extends JDialog {
|
|
/**
|
* serialVersionUID
|
*/
|
private static final long serialVersionUID = 1L;
|
|
/**
|
* 父窗口
|
*/
|
private Frame owner;
|
/**
|
* 名称标签
|
*/
|
private JLabel nameLabel;
|
/**
|
* 名称文本框
|
*/
|
private JTextField nameField;
|
/**
|
* 序号标签
|
*/
|
private JLabel serialNoLabel;
|
/**
|
* 序号输入框
|
*/
|
private JTextField serialNoField;
|
/**
|
* 所属父分类标签
|
*/
|
private JLabel pNameLabel;
|
/**
|
* 所属父分类输入框
|
*/
|
private JTextField pNameField;
|
/**
|
* 创建者标签
|
*/
|
private JLabel creatorLabel;
|
/**
|
* 创建者文本框
|
*/
|
private JTextField creatorField;
|
/**
|
* 最后修改时间标签
|
*/
|
private JLabel createTimeLabel;
|
/**
|
* 最后修改时间文本框
|
*/
|
private JTextField createTimeField;
|
/**
|
* 备注标签
|
*/
|
private JLabel descLabel;
|
/**
|
* 备注文本域
|
*/
|
private JTextArea descArea;
|
/**
|
* 确定按钮
|
*/
|
private JButton okBtn;
|
/**
|
* 取消按钮
|
*/
|
private JButton cancelBtn;
|
/**
|
* 标记 0创建、1修改
|
*/
|
private int flag;
|
|
/**
|
* 是否保存
|
*/
|
private boolean ok = false;
|
|
/**
|
* 所属父分类
|
*/
|
private PLActionCls parent;
|
/**
|
* 当前分类
|
*/
|
private PLActionCls currentCls;
|
|
/**
|
* 创建,修改Action分类窗口
|
*
|
* @param owner 所属父
|
* @param title 标题
|
* @param flag 标记 0创建、1修改
|
* @param parent 所属父分类
|
*/
|
public PLActionClsEditDialog(Frame owner, String title, int flag, PLActionCls parent, PLActionCls cls) {
|
super(owner, title, true);
|
this.owner = owner;
|
this.flag = flag;
|
this.parent = parent;
|
this.currentCls = cls;
|
this.init();
|
this.setLocationRelativeTo(owner);
|
this.setVisible(true);
|
}
|
|
/**
|
* 绘制界面
|
*/
|
private void init() {
|
this.setSize(480, 320);
|
this.setLayout(null);
|
|
nameLabel = new JLabel("分类名称");
|
nameLabel.setBounds(15, 15, 60, 25);
|
nameField = new JTextField();
|
if (this.flag != 0) {
|
nameField.setText(this.currentCls.name);
|
}
|
nameField.setBounds(70, 15, 150, 25);
|
serialNoLabel = new JLabel("分类序号");
|
serialNoLabel.setBounds(230, 15, 70, 25);
|
serialNoField = new JTextField();
|
if (this.flag != 0) {
|
serialNoField.setText(this.currentCls.serialno + "");
|
}
|
serialNoField.setBounds(300, 15, 150, 25);
|
creatorLabel = new JLabel("创建者");
|
creatorLabel.setBounds(15, 50, 60, 25);
|
creatorField = new JTextField(ClientContextVariable.getInvocationInfo().userName);
|
if (this.flag != 0) {
|
creatorField.setText(this.currentCls.creator);
|
}
|
creatorField.setEditable(false);
|
creatorField.setBounds(70, 50, 150, 25);
|
createTimeLabel = new JLabel("创建时间");
|
if (this.flag != 0) {
|
createTimeLabel.setText("修改时间");
|
}
|
createTimeLabel.setBounds(230, 50, 70, 25);
|
createTimeField = new JTextField(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
createTimeField.setEditable(false);
|
createTimeField.setBounds(300, 50, 150, 25);
|
pNameLabel = new JLabel("父分类");
|
pNameLabel.setBounds(15, 85, 60, 25);
|
pNameField = new JTextField(parent == null ? "Action分类" : parent.name);
|
pNameField.setEditable(false);
|
pNameField.setBounds(70, 85, 380, 25);
|
descLabel = new JLabel("备注");
|
descLabel.setBounds(15, 120, 60, 25);
|
descArea = new JTextArea();
|
descArea.setLineWrap(true);
|
if (this.flag != 0) {
|
descArea.setText(this.currentCls.description);
|
}
|
JScrollPane descScrollPane = new JScrollPane(descArea);
|
descScrollPane.setBounds(70, 120, 380, 110);
|
|
JPanel btnPanel = new JPanel();
|
btnPanel.setLayout(null);
|
btnPanel.setBounds(0, 240, 485, 40);
|
okBtn = new JButton("确定");
|
okBtn.setBounds(new Rectangle(300, 5, 50, 25));
|
okBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
okAction();
|
}
|
});
|
cancelBtn = new JButton("取消");
|
cancelBtn.setBounds(new Rectangle(360, 5, 50, 25));
|
cancelBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
cancelAction();
|
}
|
});
|
btnPanel.add(okBtn);
|
btnPanel.add(cancelBtn);
|
|
this.add(nameLabel);
|
this.add(nameField);
|
this.add(serialNoLabel);
|
this.add(serialNoField);
|
this.add(creatorLabel);
|
this.add(creatorField);
|
this.add(createTimeLabel);
|
this.add(createTimeField);
|
this.add(pNameLabel);
|
this.add(pNameField);
|
this.add(descLabel);
|
this.add(descScrollPane);
|
this.add(btnPanel);
|
this.validate();
|
this.setResizable(false);
|
}
|
|
/**
|
* 创建按钮事件
|
*/
|
private void okAction() {
|
String name = getNotNullString(this.nameField.getText());
|
String pid = this.parent == null ? "" : this.parent.id;
|
String creator = getNotNullString(this.creatorField.getText());
|
String createTime = "";// this.createTimeField.getText();
|
String serialNo = getNotNullString(this.serialNoField.getText());
|
String desc = getNotNullString(this.descArea.getText());
|
if (name == null || name.trim().equals("")) {
|
JOptionPane.showMessageDialog(this, "分类名称不能为空!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
|
return;
|
}
|
if (name.equals("未分类")) {
|
JOptionPane.showMessageDialog(this, "未分类节点已经存在!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
|
return;
|
}
|
short serialNumber = 0;
|
if (serialNo == null || serialNo.trim().equals("")) {
|
JOptionPane.showMessageDialog(this, "分类序号不能为空!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
|
return;
|
} else {
|
try {
|
serialNumber = Short.valueOf(serialNo);
|
} catch (Exception e) {
|
JOptionPane.showMessageDialog(this, "分类序号必须为整数!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
|
return;
|
}
|
}
|
if (this.flag == 0) {
|
PLActionCls pac = new PLActionCls();
|
pac.id = ObjectUtility.getNewObjectID36();
|
pac.name = name;
|
pac.pid = pid;
|
pac.description = desc == null ? "" : desc;
|
pac.creator = creator;
|
pac.createTime = System.currentTimeMillis();
|
pac.serialno = serialNumber;
|
// 保存分类信息
|
String message = UITools.getService().creaetePLActionCls(pac);
|
if (message.startsWith("0")) {
|
if (message.equals("01")) {
|
message = "分类" + pac.name + "已经存在!";
|
} else if (message.equals("02")) {
|
message = "同一分类下序号不能重复!";
|
} else {
|
message = "保存分类时发生异常!" + message.substring(1);
|
}
|
JOptionPane.showMessageDialog(this, message, "系统提示", JOptionPane.INFORMATION_MESSAGE);
|
return;
|
}
|
JOptionPane.showMessageDialog(this, "分类创建成功!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
|
} else {
|
PLActionCls pac = this.currentCls;
|
pac.name = name;
|
pac.description = desc == null ? "" : desc;
|
pac.serialno = serialNumber;
|
// 保存分类信息
|
String message = UITools.getService().editPLActionCls(pac);
|
if (message.startsWith("0")) {
|
if (message.equals("01")) {
|
message = "分类" + pac.name + "已经存在!";
|
} else if (message.equals("02")) {
|
message = "同一分类下序号不能重复!";
|
} else {
|
message = "保存分类时发生异常!" + message.substring(1);
|
}
|
JOptionPane.showMessageDialog(this, message, "系统提示", JOptionPane.INFORMATION_MESSAGE);
|
return;
|
}
|
JOptionPane.showMessageDialog(this, "分类修改成功!", "系统提示", JOptionPane.INFORMATION_MESSAGE);
|
}
|
this.dispose();
|
this.ok = true;
|
}
|
|
/**
|
* 取消按钮事件
|
*/
|
private void cancelAction() {
|
this.dispose();
|
}
|
|
public boolean isOk() {
|
return ok;
|
}
|
|
private String getNotNullString(String str) {
|
if (str == null) {
|
return "";
|
}
|
return str.trim();
|
}
|
}
|