package com.vci.client.portal.NewUI;
|
|
import java.awt.BorderLayout;
|
import java.awt.FlowLayout;
|
|
import javax.swing.JButton;
|
import javax.swing.JDialog;
|
import javax.swing.JOptionPane;
|
import javax.swing.JPanel;
|
import javax.swing.border.EmptyBorder;
|
import java.awt.GridBagLayout;
|
import javax.swing.JLabel;
|
import java.awt.GridBagConstraints;
|
import javax.swing.JTextField;
|
import java.awt.Insets;
|
import javax.swing.JComboBox;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.portal.utility.UITools;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.common.utility.ObjectUtility;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.portal.data.PLAction;
|
|
import java.awt.event.ActionListener;
|
import java.awt.event.ActionEvent;
|
import java.util.HashMap;
|
import java.util.Iterator;
|
import java.util.Map;
|
import java.util.Set;
|
|
public class ActionConfDialog extends JDialog {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
private final JPanel contentPanel = new JPanel();
|
private JTextField plcode;
|
private JTextField plname;
|
private JTextField plBSUrl;
|
private JComboBox plTypeType;
|
private JTextField plDesc;
|
private JButton okButton;
|
private JButton cancelButton;
|
private Map<String,String> plTypeTypeMap;
|
private PLAction plAction;
|
private JLabel label_1;
|
private JTextField plCSClassTxt;
|
|
/**
|
* Create the dialog.
|
*/
|
public ActionConfDialog(PLAction plAction) {
|
super(LogonApplication.frame,true);
|
this.plAction = plAction;
|
setBounds(100, 100, 450, 300);
|
init();
|
initplTypeTypeComb();
|
ActionListener();
|
initData();
|
this.setLocationRelativeTo(null);
|
}
|
|
private void init() {
|
getContentPane().setLayout(new BorderLayout());
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
GridBagLayout gbl_contentPanel = new GridBagLayout();
|
gbl_contentPanel.columnWidths = new int[]{0, 0, 0, 0, 0};
|
gbl_contentPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
|
gbl_contentPanel.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
|
gbl_contentPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
contentPanel.setLayout(gbl_contentPanel);
|
{
|
JLabel label = new JLabel("编号");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 5, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 0;
|
contentPanel.add(label, gbc_label);
|
}
|
{
|
plcode = new JTextField();
|
GridBagConstraints gbc_textField = new GridBagConstraints();
|
gbc_textField.insets = new Insets(0, 0, 5, 5);
|
gbc_textField.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField.gridx = 2;
|
gbc_textField.gridy = 0;
|
contentPanel.add(plcode, gbc_textField);
|
plcode.setColumns(10);
|
}
|
{
|
JLabel label = new JLabel("名称");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 5, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 1;
|
contentPanel.add(label, gbc_label);
|
}
|
{
|
plname = new JTextField();
|
GridBagConstraints gbc_textField_1 = new GridBagConstraints();
|
gbc_textField_1.insets = new Insets(0, 0, 5, 5);
|
gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField_1.gridx = 2;
|
gbc_textField_1.gridy = 1;
|
contentPanel.add(plname, gbc_textField_1);
|
plname.setColumns(10);
|
}
|
{
|
label_1 = new JLabel("类路径");
|
GridBagConstraints gbc_label_1 = new GridBagConstraints();
|
gbc_label_1.anchor = GridBagConstraints.EAST;
|
gbc_label_1.insets = new Insets(0, 0, 5, 5);
|
gbc_label_1.gridx = 1;
|
gbc_label_1.gridy = 2;
|
contentPanel.add(label_1, gbc_label_1);
|
}
|
{
|
plCSClassTxt = new JTextField();
|
GridBagConstraints gbc_plCSClassTxt = new GridBagConstraints();
|
gbc_plCSClassTxt.insets = new Insets(0, 0, 5, 5);
|
gbc_plCSClassTxt.fill = GridBagConstraints.HORIZONTAL;
|
gbc_plCSClassTxt.gridx = 2;
|
gbc_plCSClassTxt.gridy = 2;
|
contentPanel.add(plCSClassTxt, gbc_plCSClassTxt);
|
plCSClassTxt.setColumns(10);
|
}
|
{
|
JLabel label = new JLabel("链接地址");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 5, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 3;
|
contentPanel.add(label, gbc_label);
|
}
|
{
|
plBSUrl = new JTextField();
|
GridBagConstraints gbc_textField_2 = new GridBagConstraints();
|
gbc_textField_2.insets = new Insets(0, 0, 5, 5);
|
gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField_2.gridx = 2;
|
gbc_textField_2.gridy = 3;
|
contentPanel.add(plBSUrl, gbc_textField_2);
|
plBSUrl.setColumns(10);
|
}
|
{
|
JLabel label = new JLabel("类型");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 5, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 4;
|
contentPanel.add(label, gbc_label);
|
}
|
{
|
plTypeType = new JComboBox();
|
GridBagConstraints gbc_comboBox = new GridBagConstraints();
|
gbc_comboBox.insets = new Insets(0, 0, 5, 5);
|
gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
|
gbc_comboBox.gridx = 2;
|
gbc_comboBox.gridy = 4;
|
contentPanel.add(plTypeType, gbc_comboBox);
|
}
|
{
|
JLabel label = new JLabel("描述");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 0, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 5;
|
contentPanel.add(label, gbc_label);
|
}
|
{
|
plDesc = new JTextField();
|
GridBagConstraints gbc_textField_3 = new GridBagConstraints();
|
gbc_textField_3.insets = new Insets(0, 0, 0, 5);
|
gbc_textField_3.fill = GridBagConstraints.HORIZONTAL;
|
gbc_textField_3.gridx = 2;
|
gbc_textField_3.gridy = 5;
|
contentPanel.add(plDesc, gbc_textField_3);
|
plDesc.setColumns(10);
|
}
|
{
|
JPanel buttonPane = new JPanel();
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
{
|
okButton = new JButton("确定");
|
buttonPane.add(okButton);
|
}
|
{
|
cancelButton = new JButton("取消");
|
buttonPane.add(cancelButton);
|
}
|
}
|
}
|
|
private void ActionListener() {
|
okButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
if(plcode.getText().trim().equals("")){
|
JOptionPane.showMessageDialog(getThis(), "请输入编号", "请输入编号", JOptionPane.ERROR_MESSAGE);
|
return;
|
}
|
if(plname.getText().trim().equals("")){
|
JOptionPane.showMessageDialog(getThis(), "请输入名称", "请输入名称", JOptionPane.ERROR_MESSAGE);
|
return;
|
}
|
if(plTypeType.getSelectedItem() == null || plTypeType.getSelectedItem().equals("")){
|
JOptionPane.showMessageDialog(getThis(), "请选择类型", "请选择类型", JOptionPane.ERROR_MESSAGE);
|
return;
|
}
|
if(plAction==null){
|
save();
|
}else{
|
edit();
|
}
|
}
|
|
private void edit() {
|
PLAction object = new PLAction();
|
object.plOId = plAction.plOId;
|
object.plCode = plcode.getText()==null?"":plcode.getText();
|
object.plName = plname.getText()==null?"":plname.getText();
|
object.plCSClass = plCSClassTxt.getText()==null?"":plCSClassTxt.getText();
|
object.plBSUrl = plBSUrl.getText()==null?"":plBSUrl.getText();
|
object.plDesc = plDesc.getText()==null?"":plDesc.getText();
|
object.plCreateUser = plAction.plCreateUser;
|
object.plModifyUser = LogonApplication.getUserEntityObject().getUserName();
|
|
object.plTypeType = (String) (plTypeType==null?"":getplTypeTypeValue());
|
try {
|
UITools.getService().updatePLAction(object);
|
VCIOptionPane.showMessage(LogonApplication.frame, "保存成功!");
|
dispose();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
VCIOptionPane.showMessage(LogonApplication.frame, "保存失败!");
|
}
|
}
|
|
private void save() {
|
PLAction plAction = new PLAction();
|
plAction.plOId = ObjectUtility.getNewObjectID36();
|
plAction.plCode = plcode.getText()==null?"":plcode.getText();
|
plAction.plName = plname.getText()==null?"":plname.getText();
|
plAction.plCSClass = plCSClassTxt.getText()==null?"":plCSClassTxt.getText();
|
plAction.plBSUrl = plBSUrl.getText()==null?"":plBSUrl.getText();
|
plAction.plDesc = plDesc.getText()==null?"":plDesc.getText();
|
plAction.plCreateUser = LogonApplication.getUserEntityObject().getUserName();
|
plAction.plModifyUser = LogonApplication.getUserEntityObject().getUserName();
|
|
plAction.plTypeType = (String) (plTypeType==null?"":getplTypeTypeValue());
|
try {
|
UITools.getService().savePLAction(plAction);
|
VCIOptionPane.showMessage(LogonApplication.frame, "保存成功!");
|
dispose();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
VCIOptionPane.showMessage(LogonApplication.frame, "保存失败!");
|
}
|
}
|
|
});
|
cancelButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
dispose();
|
}
|
});
|
}
|
|
private void initplTypeTypeComb(){
|
plTypeType.addItem("");
|
plTypeTypeMap = new HashMap<String,String>();
|
plTypeTypeMap.put("business", "业务类型");
|
plTypeTypeMap.put("link", "链接类型");
|
|
Set<String> keySet = plTypeTypeMap.keySet();
|
Iterator<String> iterator = keySet.iterator();
|
for(;iterator.hasNext();){
|
String next = iterator.next();
|
plTypeType.addItem(plTypeTypeMap.get(next));
|
}
|
}
|
|
private String getplTypeTypeValue() {
|
String value = "";
|
for(Map.Entry<String, String> entry : plTypeTypeMap.entrySet()){
|
if(plTypeType.getSelectedItem().equals(entry.getValue())){
|
value = entry.getKey();
|
break;
|
}
|
}
|
return value;
|
}
|
|
private void initData(){
|
if(plAction!=null){
|
plcode.setText(plAction.plCode);
|
plname.setText(plAction.plName);
|
plCSClassTxt.setText(plAction.plCSClass);
|
plBSUrl.setText(plAction.plBSUrl);
|
plDesc.setText(plAction.plDesc);
|
plTypeType.setSelectedItem(plTypeTypeMap.get(plAction.plTypeType));
|
}
|
}
|
|
private JDialog getThis(){
|
return this;
|
}
|
}
|