package com.vci.client.framework.rightConfig.functiontree; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.tree.TreePath; import com.vci.client.LogonApplication; import com.vci.client.common.TransmitTreeObject; import com.vci.client.framework.delegate.FuncOperationClientDelegate; import com.vci.client.framework.rightConfig.object.FuncOperationObject; import com.vci.client.ui.exception.VCIException; import com.vci.client.ui.image.BundleImage; import com.vci.client.ui.locale.LocaleDisplay; import com.vci.client.ui.swing.KTextField; import com.vci.client.ui.swing.VCIOptionPane; import com.vci.client.ui.swing.components.VCIJButton; import com.vci.client.ui.tree.VCIBaseTreeNode; /** * 操作类型的管理是初始化系统中每个功能模块所具有的操作的集合。 * * @author */ public class FuncOperatePanel extends JPanel { private static final long serialVersionUID = -3826623955360533220L; private JLabel operateLab = new JLabel(); private JLabel nameLab = new JLabel(); private KTextField nameText = new KTextField(); private JLabel identifyLab = new JLabel(); private KTextField identifyText = new KTextField(); private JLabel aliasLab = new JLabel(); private KTextField aliasText = new KTextField(); private JLabel numberLab = new JLabel(); private KTextField numberText = new KTextField(); private JLabel describeLab = new JLabel(); private JTextArea describeTxtArea = new JTextArea(); private VCIJButton editOptAlias = new VCIJButton("修改别名"); private JButton delButton = new JButton(); private JTextField top = new JTextField();// 横线 private JTextField bottom = new JTextField();// 横线 private TransmitTreeObject transmitTreeObject = new TransmitTreeObject();// 传递树的信息 /** * 是否有效标识 */ private JCheckBox isValid = new JCheckBox(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.isValid", "RMIPFramework", getLocale())); // 控件的坐标位置变量 private int x = 10; private int y = 20; private int width = 50; private int height = 25; /** * 两控件间水平间隔 */ private int hspan = 5; private FuncOperationClientDelegate funcOperateClient = new FuncOperationClientDelegate(LogonApplication.getUserEntityObject()); private FuncOperationObject curObj = null; public FuncOperatePanel(FuncOperationObject obj,TransmitTreeObject transmitTreeObject) { super(); this.transmitTreeObject = transmitTreeObject; curObj = obj; init(); initData(); this.setOpaque(false); } public void init(){ JPanel palMain = new JPanel(); JPanel contentPanel = new JPanel(); JPanel buttonPanel = new JPanel(); palMain.setLayout(new BorderLayout()); operateLab.setText(LocaleDisplay.getI18nString("rmip.framework.operateType.operateTypeLab.file","RMIPFramework", getLocale())); operateLab.setBounds(new Rectangle(0, 0, 30, 25)); contentItem(contentPanel); jButtonPanl(buttonPanel); palMain.add(operateLab,BorderLayout.NORTH); palMain.add(contentPanel, BorderLayout.CENTER); palMain.add(buttonPanel, BorderLayout.SOUTH); this.setLayout(new BorderLayout()); this.add(palMain, BorderLayout.CENTER); } private void initData(){ try { FuncOperationObject[] objs = new FuncOperationClientDelegate().getFuncOperationByModuleId(curObj.getFuncId(), curObj.getOperId(), false); if(objs.length > 0){ curObj = objs[0]; }else{ return; } } catch (VCIException e) { e.printStackTrace(); } nameText.setText(curObj.getOperName()); identifyText.setText(curObj.getOperIndentify()); aliasText.setText(curObj.getOperAlias()); numberText.setText(String.valueOf(curObj.getNumber())); describeTxtArea.setText(curObj.getOperDesc()); isValid.setSelected(curObj.getIsValid()); nameText.setEditable(false); identifyText.setEditable(false); numberText.setEditable(false); describeTxtArea.setEditable(false); editOptAlias.setEnabled(true); // 显示按钮 delButton.setEnabled(true); // 显示按钮 } /** * 按钮 * * @return */ public void jButtonPanl(JPanel p) { editOptAlias.setIcon(new BundleImage().createImageIcon("edit.png")); editOptAlias.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { String alias = aliasText.getText(); if ("".equals(alias)){ VCIOptionPane.showMessage(LogonApplication.frame, "请填写操作别名!"); return; } boolean isSelected = isValid.isSelected(); String id = curObj.getId(); boolean success = funcOperateClient.updateFuncOperation(id , alias, isSelected); if(success){ curObj.setOperAlias(alias); curObj.setIsValid(isSelected); VCIBaseTreeNode node = new VCIBaseTreeNode(curObj.getOperAlias(), curObj); VCIBaseTreeNode parentNode = (VCIBaseTreeNode)transmitTreeObject.getCurrentTreeNode().getParent(); transmitTreeObject.getTreeModel().removeNodeFromParent(transmitTreeObject.getCurrentTreeNode()); parentNode.add(node); node.setLeaf(true); transmitTreeObject.getTree().setSelectionPath(new TreePath(parentNode.getPath())); transmitTreeObject.setCurrentTreeNode(parentNode); transmitTreeObject.getTree().updateUI(); VCIOptionPane.showMessage(LogonApplication.frame, "操作别名修改成功!"); } } catch (VCIException e1) { e1.printStackTrace(); VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e1, "RMIPFramework", getLocale())); } } }); delButton.setText(LocaleDisplay.getI18nString("rmip.framework.operateType.delButton.file", "RMIPFramework",getLocale())); delButton.setIcon(new BundleImage().createImageIcon("delete.gif")); delButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { int ok = VCIOptionPane.showQuestion(LogonApplication.frame, "移除该操作的同时会将其从用户的权限中移除,确认执行移除吗?"); if(ok != 0){ return; } boolean success = funcOperateClient.deleteFuncOperation(curObj); if(success){ VCIBaseTreeNode parentNode = (VCIBaseTreeNode)transmitTreeObject.getCurrentTreeNode().getParent(); transmitTreeObject.getTreeModel().removeNodeFromParent(transmitTreeObject.getCurrentTreeNode()); transmitTreeObject.getTree().setSelectionPath(new TreePath(parentNode.getPath())); transmitTreeObject.setCurrentTreeNode(parentNode); } } catch (VCIException e1) { e1.printStackTrace(); VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e1, "RMIPFramework", getLocale())); } } }); delButton.setEnabled(false); // 按钮失效 p.add(editOptAlias); p.add(delButton); } /** * 内容项 * * @return */ public void contentItem(JPanel p) { JPanel panel = new JPanel(); top.setPreferredSize(new Dimension(63,2)); bottom.setPreferredSize(new Dimension(63,2)); x = 30;y = 30;width = 80;height = 25; nameLab.setText(LocaleDisplay.getI18nString("rmip.framework.operateType.designationLab.file","RMIPFramework", getLocale())); nameLab.setBounds(new Rectangle(x, y, width, height)); x += nameLab.getWidth() + hspan;y = 30;width = 200;height = 25; nameText.setBounds(new Rectangle(x, y, width, height)); x = 30;y = 70;width = 80;height = 25; identifyLab.setText(LocaleDisplay.getI18nString("rmip.framework.operateType.identifyingLab.file","RMIPFramework", getLocale())); identifyLab.setBounds(new Rectangle(x, y, width, height)); x += identifyLab.getWidth() + hspan;y = 70;width = 200;height = 25; identifyText.setBounds(new Rectangle(x, y, width, height)); x = 30;y = 110;width = 80;height = 25; aliasLab.setText("别名"); aliasLab.setBounds(x, y, width, height); x+= aliasLab.getBounds().width + hspan; width = 200; height = 25; aliasText.setBounds(x, y, width, height); x = 30;y = 150;width = 80;height = 25; numberLab.setText("编号:"); numberLab.setBounds(x, y, width, height); x+= numberLab.getBounds().width + hspan; width = 200; height = 25; numberText.setBounds(x, y, width, height); x = 30;y = 190;width = 80;height = 25; describeLab.setText(LocaleDisplay.getI18nString("rmip.framework.operateType.describeLab.file", "RMIPFramework",getLocale())); describeLab.setBounds(new Rectangle(x, y, width, height)); x += describeLab.getWidth() + hspan;y = 190;width = 200;height = 100; JScrollPane scroll = new JScrollPane(describeTxtArea); scroll.setBounds(new Rectangle(x, y, width, height)); describeTxtArea.setLineWrap(true); x = 30;y = 300;width = 80;height = 25; isValid.setBounds(new Rectangle(x, y, width, height)); panel.setLayout(null); panel.add(nameLab); panel.add(nameText); panel.add(identifyLab); panel.add(identifyText); panel.add(aliasLab); panel.add(aliasText); panel.add(numberLab); panel.add(numberText); panel.add(describeLab); panel.add(scroll); panel.add(isValid); p.setLayout(new BorderLayout()); p.add(top,BorderLayout.NORTH); p.add(panel,BorderLayout.CENTER); p.add(bottom,BorderLayout.SOUTH); } }