package com.vci.rmip.code.client.codeapply.Apply410; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.vci.base.ui.swing.VCIOptionPane; import com.vci.base.ui.swing.VCISwingUtil; import com.vci.base.ui.swing.components.*; import com.vci.base.ui.tree.VCIBaseTree; import com.vci.base.ui.tree.VCIBaseTreeModel; import com.vci.base.ui.tree.VCIBaseTreeNode; import com.vci.rmip.code.client.codeapply.Apply410.object.CodeClassify; import com.vci.rmip.code.client.codeapply.Apply410.object.R; import com.vci.rmip.code.client.codeapply.Apply410.object.TokenUserObject; import com.vci.rmip.code.client.codeapply.Apply410.utils.ConfigUtils; import com.vci.rmip.code.client.codeapply.Apply410.utils.HttpUtil; import com.vci.ubcs.code.vo.pagemodel.CodeClassifyTemplateVO; import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO; import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; import org.apache.commons.collections4.CollectionUtils; import javax.swing.*; import javax.swing.event.TreeSelectionEvent; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; public class CodeApplyPanelFor410 extends VCIJPanel { //右侧面板 private CodeApplyFor410MainPanel rightMainPanel = null; private VCIJScrollPane scrollLeftTreePane = new VCIJScrollPane(); private VCIJSplitPane jspLeftToRight = new VCIJSplitPane(VCIJSplitPane.HORIZONTAL_SPLIT, scrollLeftTreePane, rightMainPanel); private CodeApplyPanelFor410ActionListener actionListener = new CodeApplyPanelFor410ActionListener(this); private VCIJButton applyBtn = VCISwingUtil.createVCIJButton("apply", "申请码值", "申请码值", "arrow-right.png", actionListener); private VCIJButton batchApplyBtn = VCISwingUtil.createVCIJButton("batchApply", "批量导入申请", "批量导入申请", "import.gif", actionListener); private VCIJButton btnSearch= VCISwingUtil.createVCIJButton("btnSearch", "查询代码", "查询代码", "search.png", actionListener); private VCIJButton clearBtn = VCISwingUtil.createVCIJButton("clear", "清空属性", "清空属性", "search.png", actionListener); private JLabel codeItemLabel = new JLabel("选择代码项:"); private VCIJLabel applylbl = new VCIJLabel("申请码值:"); public VCIJTextField applyTxt = new VCIJTextField(40); private JComboBox codeItemCombo = new JComboBox(); private TokenUserObject tokenUserObject = null;; private CodeClassifyTemplateVO currentCodeClassifyTemplateVO; private boolean isIntegrate = false; //集成时不显示批量申请按钮 /** * 存储分类的Map,key:分类名称,value:分类值 */ private String clsfName = null; private CodeApplyFor410Dialog owner; /** * 存储属性和值的Map,key:属性名称,value:属性值 */ private String deptName = null; private String[] libName = new String[]{};//代码项名称 private VCIBaseTree leftTree = null; private VCIBaseTreeModel leftTreeModel = null; //左侧树 private CodeApplyFor410TreePanel typeTreePanel = null; private TransmitTreeObject transmitTreeObject = new TransmitTreeObject(); private String url= ConfigUtils.getConfigValue("410.code.url","http://127.0.0.1:36014/codeApplySwingController"); /*** * * @param tokenUserObject * @param isIntegrate * @param clsfName * @param deptName * @param libName */ public CodeApplyPanelFor410(CodeApplyFor410Dialog owner , TokenUserObject tokenUserObject, boolean isIntegrate, String clsfName, String deptName, String[] libName){ this.tokenUserObject = tokenUserObject; this.owner =owner; rightMainPanel = new CodeApplyFor410MainPanel(transmitTreeObject,tokenUserObject,getCurrentCodeClassifyTemplateVO()); this.isIntegrate = isIntegrate; this.clsfName = clsfName; this.deptName = deptName; this.libName = libName; init(); initActionListener(); } /*** * 初始化界面 */ private void init() { try { this.setLayout(new BorderLayout()); this.add(initCodeItemPal(), BorderLayout.NORTH); this.add(initMiddlePanel(), BorderLayout.CENTER); this.add(initBtnPal(), BorderLayout.SOUTH); this.setVisible(true); }catch (Exception ex){ VCIOptionPane.showMessage(owner,ex.getMessage()); } } private JPanel initMiddlePanel() { JPanel middlePanel = new JPanel(); middlePanel.setLayout(new BorderLayout()); JTextField jTextField1 = new JTextField();//instead of up line JTextField jTextField2 = new JTextField();//instead of down line jTextField1.setPreferredSize(new Dimension(63,2)); jTextField2.setPreferredSize(new Dimension(63,2)); middlePanel.add(jTextField1, BorderLayout.NORTH); middlePanel.add(jTextField2, BorderLayout.SOUTH); jspLeftToRight.setDividerSize(10); jspLeftToRight.setContinuousLayout(true); jspLeftToRight.setOneTouchExpandable(true); jspLeftToRight.setDividerLocation(200); initLeftPanel(); middlePanel.add(jspLeftToRight, BorderLayout.CENTER); return middlePanel; } private JPanel initBtnPal() { JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bottomPanel.add(applylbl); bottomPanel.add(applyTxt); applyTxt.setEditable(false); bottomPanel.add(applyBtn); if (!this.isIntegrate) { bottomPanel.add(batchApplyBtn); } else { bottomPanel.add(btnSearch); } bottomPanel.add(clearBtn); return bottomPanel; } /*** * 初始化代码项目 * @return */ private JPanel initCodeItemPal() { VCIJPanel codeItemPal = new VCIJPanel(new FlowLayout(FlowLayout.LEFT)); codeItemCombo.setPreferredSize(new Dimension(200,25)); initCodeItemCombo();//初始化代码项下拉框数据 codeItemPal.add(codeItemLabel); codeItemPal.add(codeItemCombo); return codeItemPal; } /** * 代码项事件:选择代码项后,自动刷新代码项下对应的规则码段和模板属性信息 *
Description:
* * @author Administrator * @time 2013-3-23 */ public void initCodeItemCombo() { CodeClassifyVO [] codeClassifyVOS = new CodeClassifyVO[0]; MapDescription:
* * @author Administrator * @time 2013-3-23 */ private void ruleComboActionListener() { leftTree.removeAll(); initLeftPanel(); } private void initLeftPanel() { CodeClassify currentCodeClassify= (CodeClassify) this.codeItemCombo.getSelectedItem(); if(currentCodeClassify == null) { return; } String libName=currentCodeClassify.getName(); String classOid=currentCodeClassify.getOid(); final CodeApplyPanelFor410 self = this; typeTreePanel = new CodeApplyFor410TreePanel(currentCodeClassify,tokenUserObject,clsfName, libName) { private static final long serialVersionUID = 8121108576137012228L; @Override public void tree_valueChanged(TreeSelectionEvent e) { self.leftTree_valueChanged(e); } }; typeTreePanel.buildTreePanel(); leftTree = typeTreePanel.getTree(); leftTreeModel = typeTreePanel.getTreeModel(); transmitTreeObject.setCurrentTreeNode(typeTreePanel.getSelNode()); transmitTreeObject.setTree(leftTree); transmitTreeObject.setTreeModel(leftTreeModel); VCIJPanel rightPanel = new VCIJPanel(); rightPanel.setLayout(new BorderLayout()); jspLeftToRight.setRightComponent(rightPanel); rightPanel.add(scrollPane, BorderLayout.CENTER); Object obj =transmitTreeObject.getCurrentTreeNode(); if(obj instanceof VCIBaseTreeNode){ VCIBaseTreeNode vciBaseTreeNode= (VCIBaseTreeNode)obj; Object node=vciBaseTreeNode.getObj(); if(node instanceof CodeClassify) { CodeClassify codeClassify=(CodeClassify)node; classOid = codeClassify.getOid(); //String url = ConfigUtils.getConfigValue("410.PDM.clsfTemplate.url", "http://127.0.0.1:36014/codeApplySwingController/getUsedTemplateByClassifyOid"); /**系统只加载代码项 如果libName不为空,直接获取对应的代码项**/ Map