package com.vci.client.portal.NewNewUI.actionmng; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; import com.vci.corba.portal.*; import com.vci.corba.portal.data.PLAction; import com.vci.corba.portal.data.PLActionCls; import com.vci.mw.ClientContextVariable; 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; public class ActionEditDialog 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 plTypeTypeMap; private PLAction plAction; private PLActionCls cls; private JLabel label_1; private JTextField plCSClassTxt; private JLabel clsLable; private JTextField clsField; private JButton clsBtn; /** * Create the dialog. */ public ActionEditDialog(PLActionCls cls, PLAction plAction) { super(ClientContextVariable.getFrame(), true); this.plAction = plAction; this.cls = cls; init(); initplTypeTypeComb(); ActionListener(); initData(); this.validate(); this.setLocationRelativeTo(ClientContextVariable.getFrame()); this.setVisible(true); } private void init() { this.setSize(450, 300); 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, 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, 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); } //增加分类 { clsLable = new JLabel("分类"); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.insets = new Insets(0, 0, 5, 5); gbc_label.gridx = 1; gbc_label.gridy = 2; contentPanel.add(clsLable, gbc_label); } { clsField = new JTextField(); clsField.setColumns(10); clsBtn = new JButton("选择"); clsBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectCls(); } }); JPanel tPanel = new JPanel(); tPanel.setLayout(new BorderLayout()); tPanel.add(clsField, BorderLayout.CENTER); tPanel.add(clsBtn, BorderLayout.EAST); 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 = 2; contentPanel.add(tPanel, gbc_textField_1); } { 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 = 3; 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 = 3; 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 = 4; 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 = 4; 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 = 5; 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 = 5; contentPanel.add(plTypeType, gbc_comboBox); } { 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 = 6; contentPanel.add(label, gbc_label); } { plDesc = new JTextField(); GridBagConstraints gbc_textField_3 = new GridBagConstraints(); gbc_textField_3.insets = new Insets(0, 0, 5, 5); gbc_textField_3.fill = GridBagConstraints.HORIZONTAL; gbc_textField_3.gridx = 2; gbc_textField_3.gridy = 6; 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; } System.out.println(plAction); try { PLAction[] actionsInDB= UITools.getService().getAllPLAction(); for(int i =0;i(); plTypeTypeMap.put("business", "业务类型"); plTypeTypeMap.put("link", "链接类型"); Set keySet = plTypeTypeMap.keySet(); Iterator iterator = keySet.iterator(); for(;iterator.hasNext();){ String next = iterator.next(); plTypeType.addItem(plTypeTypeMap.get(next)); } } private String getplTypeTypeValue() { String value = ""; for(Map.Entry entry : plTypeTypeMap.entrySet()){ if(plTypeType.getSelectedItem().equals(entry.getValue())){ value = entry.getKey(); break; } } return value; } private void initData(){ clsField.setEditable(false); 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)); clsField.setText(this.cls.name); } else { clsField.setText(this.cls.name); clsBtn.setEnabled(false); } } private JDialog getThis(){ return this; } }