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;
|
/**
|
* 存储属性和值的Map,key,用于默认值的显示
|
*/
|
private Map displayValues = new HashMap<String,String>();
|
|
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,Map displayValues){
|
this.tokenUserObject = tokenUserObject;
|
this.owner =owner;
|
rightMainPanel = new CodeApplyFor410MainPanel(transmitTreeObject,tokenUserObject,getCurrentCodeClassifyTemplateVO());
|
this.isIntegrate = isIntegrate;
|
this.clsfName = clsfName;
|
this.deptName = deptName;
|
this.libName = libName;
|
this.displayValues = displayValues;
|
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;
|
}
|
/**
|
* 代码项事件:选择代码项后,自动刷新代码项下对应的规则码段和模板属性信息
|
* <p>Description: </p>
|
*
|
* @author Administrator
|
* @time 2013-3-23
|
*/
|
public void initCodeItemCombo() {
|
CodeClassifyVO [] codeClassifyVOS = new CodeClassifyVO[0];
|
Map<String,String> condtionMap=new HashMap<>();
|
//condtionMap.put("parentOid",);
|
//String url=ConfigUtils.getConfigValue("410.code.url","http://127.0.0.1:36014/codeApplySwingController");
|
/**系统只加载代码项 如果libName不为空,直接获取对应的代码项**/
|
if(libName.length>0) {
|
condtionMap.put("libName", StringUtils.join(libName,",") );
|
}
|
Map<String,String> headerMap=new HashMap<>();
|
headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token());
|
R r= HttpUtil.sendGet(url+"/getRMLibByName",condtionMap,headerMap);
|
List<CodeClassify> codeClassifyList = new ArrayList<>();
|
if(r.isSuccess()){
|
Object object= r.getData();
|
if(object!=null) {
|
ObjectMapper objectMapper = new ObjectMapper();
|
try {
|
codeClassifyList = objectMapper.readValue(object.toString(), new com.fasterxml.jackson.core.type.TypeReference<List<CodeClassify>>() {
|
});
|
} catch (JsonProcessingException e) {
|
e.printStackTrace();
|
}
|
}
|
}else{
|
VCIOptionPane.showMessage(this,r.getMsg());
|
}
|
if(!CollectionUtils.isEmpty(codeClassifyList)){
|
for (CodeClassify codeClassify : codeClassifyList) {
|
codeItemCombo.addItem(codeClassify);
|
}
|
codeItemCombo.setSelectedIndex(0);
|
}
|
initLeftPanel();
|
}
|
|
/***
|
* 初始化按钮事件
|
*/
|
private void initActionListener() {
|
/**代码项下拉事件**/
|
codeItemCombo.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
if(codeItemCombo.getSelectedIndex() == -1) {
|
return;
|
}
|
try {
|
ruleComboActionListener();
|
} catch (Exception ex) {
|
VCIOptionPane.showMessage(owner,ex.getMessage());
|
}
|
}
|
});
|
|
}
|
|
/**
|
* 处理代码项下拉事件
|
* <p>Description: </p>
|
*
|
* @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<String, String> condtionMap = new HashMap<>();
|
condtionMap.put("codeClassifyOid", classOid);
|
Map<String,String> headerMap=new HashMap<>();
|
headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token());
|
|
R r = HttpUtil.sendGet(url+"/getUsedTemplateByClassifyOid", condtionMap, headerMap);
|
boolean res = false;
|
if (r.isSuccess()) {
|
//List<CodeClassifyTemplateVO> codeClassifyTemplateVOList=new ArrayList<>();
|
CodeClassifyTemplateVO codeClassifyTemplateVO = new CodeClassifyTemplateVO();
|
Object object = r.getData();
|
if (object != null) {
|
ObjectMapper objectMapper = new ObjectMapper();
|
try {
|
codeClassifyTemplateVO = objectMapper.readValue(object.toString(), CodeClassifyTemplateVO.class);
|
if (codeClassifyTemplateVO != null) {
|
setCurrentCodeClassifyTemplateVO(codeClassifyTemplateVO);
|
res = true;
|
}
|
} catch (JsonProcessingException e) {
|
e.printStackTrace();
|
}
|
}
|
}/*else{
|
VCIOptionPane.showMessage(this,r.getMsg());
|
}*/
|
initBtnStatus(res);
|
}
|
}
|
rightMainPanel = new CodeApplyFor410MainPanel(transmitTreeObject,tokenUserObject,deptName,getCurrentCodeClassifyTemplateVO(),displayValues);
|
scrollPane.setViewportView(rightMainPanel);
|
rightMainPanel.buildMainPanel(1);
|
int location = jspLeftToRight.getDividerLocation();
|
jspLeftToRight.setDividerLocation(location);
|
scrollLeftTreePane.setViewportView(leftTree);
|
leftTree.scrollPathToVisible(leftTree.getSelectionPath());
|
}
|
|
private void leftTree_valueChanged(TreeSelectionEvent e) {
|
TreePath selectedTreePath = e.getPath();
|
/**校验 判断选择的代码项是否包含模板 Begin**/
|
VCIBaseTreeNode selectedTreeNode = (VCIBaseTreeNode)selectedTreePath.getLastPathComponent();
|
Object obj = selectedTreeNode.getObj();
|
boolean res=false;
|
if(obj instanceof CodeClassify) {
|
CodeClassify curentCodeClassify=(CodeClassify)obj;
|
//String url=ConfigUtils.getConfigValue("410.PDM.clsfTemplate.url","http://127.0.0.1:36014/codeApplySwingController/getUsedTemplateByClassifyOid");
|
/**系统只加载代码项 如果libName不为空,直接获取对应的代码项**/
|
Map<String,String> condtionMap=new HashMap<>();
|
condtionMap.put("codeClassifyOid",curentCodeClassify.getOid());
|
Map<String,String> headerMap=new HashMap<>();
|
headerMap.put("Blade-Auth",this.tokenUserObject.getAccess_token());
|
|
R r=HttpUtil.sendGet(url+"/getUsedTemplateByClassifyOid",condtionMap,headerMap);
|
if(r.isSuccess()) {
|
CodeClassifyTemplateVO codeClassifyTemplateVO=new CodeClassifyTemplateVO();
|
Object object= r.getData();
|
if(object!=null) {
|
ObjectMapper objectMapper = new ObjectMapper();
|
try {
|
codeClassifyTemplateVO = objectMapper.readValue(object.toString(), CodeClassifyTemplateVO.class);
|
if(codeClassifyTemplateVO!=null){
|
setCurrentCodeClassifyTemplateVO(codeClassifyTemplateVO);
|
res=true;
|
}
|
} catch (JsonProcessingException e1) {
|
e1.printStackTrace();
|
}
|
}
|
}/*else{
|
VCIOptionPane.showMessage(this.owner,r.getMsg());
|
}*/
|
|
}
|
initBtnStatus(res);
|
/*******************End**********************/
|
initRightDataTablePanel(selectedTreeNode);
|
}
|
|
private void initBtnStatus(boolean enable) {
|
applyBtn.setEnabled(enable);
|
batchApplyBtn.setEnabled(enable);
|
btnSearch.setEnabled(enable);
|
clearBtn.setEnabled(enable);
|
}
|
private void initRightDataTablePanel(VCIBaseTreeNode selectedTreeNode) {
|
leftTree = typeTreePanel.getTree();
|
leftTreeModel = typeTreePanel.getTreeModel();
|
|
transmitTreeObject.setTree(leftTree);
|
transmitTreeObject.setTreeModel(leftTreeModel);
|
transmitTreeObject.setCurrentTreeNode(selectedTreeNode);
|
if(selectedTreeNode.isRoot() && selectedTreeNode.getObj() instanceof String) return;
|
scrollPane = new JScrollPane();
|
rightMainPanel = new CodeApplyFor410MainPanel(transmitTreeObject,tokenUserObject,deptName,getCurrentCodeClassifyTemplateVO(),displayValues);
|
scrollPane.setViewportView(rightMainPanel);
|
rightMainPanel.buildMainPanel(1);
|
VCIJPanel rightPanel = new VCIJPanel();
|
rightPanel.setLayout(new BorderLayout());
|
rightPanel.add(scrollPane, BorderLayout.CENTER);
|
|
applyTxt.setText("");
|
|
jspLeftToRight.setRightComponent(rightPanel);
|
int location = jspLeftToRight.getDividerLocation();
|
jspLeftToRight.setDividerLocation(location);
|
}
|
private Map<String, String> attrNameAndValMap = new LinkedHashMap();
|
private JScrollPane scrollPane = new JScrollPane();
|
|
public Map<String, String> getAttrNameAndValMap() {
|
return attrNameAndValMap;
|
}
|
|
public void setAttrNameAndValMap(Map<String, String> attrNameAndValMap) {
|
this.attrNameAndValMap = attrNameAndValMap;
|
}
|
|
public String getApplyCode() {
|
return this.applyTxt.getText().trim();
|
}
|
public void setApplyCode(String codeVal) {
|
this.applyTxt.setText(codeVal);
|
}
|
|
public VCIJTextField getApplyTxt() {
|
return applyTxt;
|
}
|
|
public void setApplyTxt(VCIJTextField applyTxt) {
|
this.applyTxt = applyTxt;
|
}
|
|
public CodeClassifyTemplateVO getCurrentCodeClassifyTemplateVO() {
|
return currentCodeClassifyTemplateVO;
|
}
|
|
public void setCurrentCodeClassifyTemplateVO(CodeClassifyTemplateVO currentCodeClassifyTemplateVO) {
|
this.currentCodeClassifyTemplateVO = currentCodeClassifyTemplateVO;
|
}
|
|
public CodeApplyFor410MainPanel getRightMainPanel() {
|
return rightMainPanel;
|
}
|
|
public void setRightMainPanel(CodeApplyFor410MainPanel rightMainPanel) {
|
this.rightMainPanel = rightMainPanel;
|
}
|
|
public TransmitTreeObject getTransmitTreeObject() {
|
return transmitTreeObject;
|
}
|
|
public void setTransmitTreeObject(TransmitTreeObject transmitTreeObject) {
|
this.transmitTreeObject = transmitTreeObject;
|
}
|
|
public TokenUserObject getTokenUserObject() {
|
return tokenUserObject;
|
}
|
|
public void setTokenUserObject(TokenUserObject tokenUserObject) {
|
this.tokenUserObject = tokenUserObject;
|
}
|
}
|