package com.vci.client.portal.UI.v3.comptdesign.compt; 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.util.Arrays; import javax.swing.ButtonGroup; import com.vci.client.portal.UI.v3.comptdesign.UIComptDesignDialog; import com.vci.client.portal.UI.v3.comptdesign.compt.al.BtmTypeChooseActionListener; import com.vci.client.portal.UI.v3.comptdesign.compt.al.BtmTypeEditActionListener; import com.vci.client.portal.UI.v3.comptdesign.compt.al.LinkTypeChooseActionListener; import com.vci.client.portal.UI.v3.comptdesign.compt.al.LinkTypeEditActionListener; import com.vci.client.portal.UI.v3.comptdesign.compt.al.QTChooseActionListener; import com.vci.client.portal.UI.v3.comptdesign.compt.al.QTEditActionListener; import com.vci.client.portal.utility.PLDefination; import com.vci.client.ui.swing.VCISwingUtil; import com.vci.client.ui.swing.components.VCIJButton; import com.vci.client.ui.swing.components.VCIJLabel; import com.vci.client.ui.swing.components.VCIJPanel; import com.vci.client.ui.swing.components.VCIJRadioButton; import com.vci.client.ui.swing.components.VCIJScrollPane; import com.vci.client.ui.swing.components.VCIJTextField; /** * 树 组件定义面板 * *

Title:

*

Description:

*

Copyright: Copyright (c) 2016

*

Company: VCI

* @author xiongchao * @time 2017-2-22 * @version 1.0 */ public class TreeComptPanel extends BaseComptPanel { /** * */ private static final long serialVersionUID = -4664149137809084420L; /************************ 关联对象 BtmType ********************************/ private VCIJPanel palBtmType = new VCIJPanel(); private VCIJLabel lblBtmType = new VCIJLabel("业务类型"); private VCIJTextField txtBtmType = new VCIJTextField(true); private VCIJButton btnBtmType = VCISwingUtil.createVCIJButton("btmType", "", "", "search.png"); private VCIJButton btnBtmTypeEdit = VCISwingUtil.createVCIJButton("btmTypeEdit", "", "", "edit.png"); private VCIJLabel lblLinkType = new VCIJLabel("链接类型"); private VCIJTextField txtLinkType = new VCIJTextField(false); private VCIJButton btnLinkType = VCISwingUtil.createVCIJButton("linkType", "", "", "search.png"); private VCIJButton btnLinkTypeEdit = VCISwingUtil.createVCIJButton("linkTypeEdit", "", "", "edit.png"); private VCIJLabel lblQueryTemplateName = new VCIJLabel("查询模板"); private VCIJTextField txtQueryTemplateName = new VCIJTextField(true); private VCIJButton btnChooseQT = VCISwingUtil.createVCIJButton("choosePortalVI", "", "", "search.png"); private VCIJButton btnChooseQTEdit = VCISwingUtil.createVCIJButton("choosePortalVIEdit", "", "", "edit.png"); private VCIJLabel lblShowExpressionRoot = new VCIJLabel("根节点显示表达式"); private VCIJTextField txtShowExpressionRoot = new VCIJTextField(true); private VCIJLabel lblShowExpression = new VCIJLabel("树节点显示表达式"); private VCIJTextField txtShowExpression = new VCIJTextField(true); private VCIJLabel lblRefTreeSet = new VCIJLabel("参照树设置"); private VCIJTextField txtRefTreeSet = new VCIJTextField(true); private VCIJLabel lblSplitChar = new VCIJLabel("分隔符"); private VCIJTextField txtSplitChar = new VCIJTextField(false); private VCIJLabel lblExpandMode = new VCIJLabel("展开方式"); private ButtonGroup expandModeGroup = new ButtonGroup(); private VCIJRadioButton rbtnExpandModeOne = new VCIJRadioButton("逐级展开", true); private VCIJRadioButton rbtnExpandModeAll = new VCIJRadioButton("全部展开"); // private VCIJLabel lblExpandDirect = new VCIJLabel("展开方向"); // private ButtonGroup expandDirectGroup = new ButtonGroup(); // private VCIJRadioButton rbtnExpandDirectPositive = new VCIJRadioButton("正向", true); // private VCIJRadioButton rbtnExpandDirectOpposite = new VCIJRadioButton("反向"); // private VCIJCheckBox cbxShowIcon = new VCIJCheckBox("显示图标"); public TreeComptPanel(UIComptDesignDialog ownedUIComptDesignDialog){ super(ownedUIComptDesignDialog); } @Override public boolean checkInputIsOk(){ boolean res = false; res = checkBtmTypeInputIsOk(); return res; } private boolean checkBtmTypeInputIsOk(){ boolean res = false; if(!(super.checkBtmTypeTxtIsOk(lblBtmType, txtBtmType))){ res = false; return res; } // 链接类型不为空时,需要同时检查链接类型及链接类型下的查询模板是否有效 if(!"".equals(txtLinkType.getText().trim())){ if(!(super.checkLinkTypeTxtIsOk(lblLinkType, txtLinkType))){ res = false; return res; } else if(!(super.checkQTNameTxtIsOk(lblQueryTemplateName, txtQueryTemplateName, txtLinkType))){ res = false; return res; } } else { // 链接类型为空时,只需要检查业务类型下的查询模板是否有效 if(!(super.checkQTNameTxtIsOk(lblQueryTemplateName, txtQueryTemplateName, txtBtmType))){ res = false; return res; } } if(!super.checkRequiredIsOk(lblShowExpressionRoot, txtShowExpressionRoot)){ res = false; } else if(!super.checkRequiredIsOk(lblShowExpression, txtShowExpression)){ res = false; } else if(!super.checkRequiredIsOk(lblRefTreeSet, txtRefTreeSet)){ res = false; } else { res = true; } return res; } @Override public void buildPanel(){ initUI(); } private void initUI(){ init(); } private void init(){ setLayout(new BorderLayout()); add(getCenterDynamicContentPanel(), BorderLayout.CENTER); } private VCIJPanel getCenterDynamicContentPanel(){ palBtmType = initBtmTypePanel(); return palBtmType; } private VCIJPanel initBtmTypePanel(){ VCIJPanel pal = new VCIJPanel(); pal.setLayout(new GridBagLayout()); pal.add(lblBtmType, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); pal.add(txtBtmType, new GridBagConstraints(2, 0, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 1), 0, 0)); pal.add(btnBtmType, new GridBagConstraints(3, 0, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0)); pal.add(btnBtmTypeEdit, new GridBagConstraints(4, 0, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 5), 0, 0)); pal.add(lblLinkType, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); pal.add(txtLinkType, new GridBagConstraints(2, 1, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 1), 0, 0)); pal.add(btnLinkType, new GridBagConstraints(3, 1, 2, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0)); pal.add(btnLinkTypeEdit, new GridBagConstraints(4, 1, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0)); pal.add(lblQueryTemplateName, new GridBagConstraints(1, 2, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); pal.add(txtQueryTemplateName, new GridBagConstraints(2, 2, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 1), 0, 0)); pal.add(btnChooseQT, new GridBagConstraints(3, 2, 2, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 0), 0, 0)); pal.add(btnChooseQTEdit, new GridBagConstraints(4, 2, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 0, 0, 5), 0, 0)); pal.add(lblShowExpressionRoot, new GridBagConstraints(1, 3, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); pal.add(txtShowExpressionRoot, new GridBagConstraints(2, 3, 3, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 5), 0, 0)); pal.add(lblShowExpression, new GridBagConstraints(1, 4, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); pal.add(txtShowExpression, new GridBagConstraints(2, 4, 3, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 5), 0, 0)); pal.add(lblRefTreeSet, new GridBagConstraints(1, 5, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); pal.add(txtRefTreeSet, new GridBagConstraints(2, 5, 3, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 5), 0, 0)); txtSplitChar.setText(","); txtSplitChar.setEditable(false);txtSplitChar.setEnabled(false); pal.add(lblSplitChar, new GridBagConstraints(1, 6, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); pal.add(txtSplitChar, new GridBagConstraints(2, 6, 3, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 5, 0, 5), 0, 0)); expandModeGroup.add(rbtnExpandModeOne); expandModeGroup.add(rbtnExpandModeAll); VCIJPanel palRbtnExpandMode = new VCIJPanel(new FlowLayout(FlowLayout.LEADING)); palRbtnExpandMode.add(rbtnExpandModeOne); palRbtnExpandMode.add(rbtnExpandModeAll); pal.add(lblExpandMode, new GridBagConstraints(1, 7, 1, 1, 0.0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); pal.add(palRbtnExpandMode, new GridBagConstraints(2, 7, 3, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 5, 0, 5), 0, 0)); // expandDirectGroup.add(rbtnExpandDirectPositive); // expandDirectGroup.add(rbtnExpandDirectOpposite); // VCIJPanel palRbtnExpandDirect = new VCIJPanel(new FlowLayout(FlowLayout.LEADING)); // palRbtnExpandDirect.add(rbtnExpandDirectPositive); // palRbtnExpandDirect.add(rbtnExpandDirectOpposite); // palRbtnExpandDirect.add(cbxShowIcon); // pal.add(lblExpandDirect, new GridBagConstraints(1, 8, 1, 1, 0.0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); // pal.add(palRbtnExpandDirect, new GridBagConstraints(2, 8, 3, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 5), 0, 0)); pal.add(new VCIJLabel(""), new GridBagConstraints(1, 15, 4, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 5), 0, 0)); VCIJPanel palRes = new VCIJPanel(new BorderLayout()); palRes.add(new VCIJScrollPane(pal)); return palRes; } @Override protected void initBtmTypeActionListener(){ BtmTypeChooseActionListener btmTypeChooseActionListener = new BtmTypeChooseActionListener( this, super.getOwnedUIComptDesignDialog(), txtBtmType, Arrays.asList( txtLinkType, txtQueryTemplateName)); btnBtmType.addActionListener(btmTypeChooseActionListener); super.getActions().add(btmTypeChooseActionListener); LinkTypeChooseActionListener linkTypeChooseActionListener = new LinkTypeChooseActionListener( this, super.getOwnedUIComptDesignDialog(), txtLinkType, Arrays.asList(txtQueryTemplateName), txtBtmType); btnLinkType.addActionListener(linkTypeChooseActionListener); super.getActions().add(linkTypeChooseActionListener); QTChooseActionListener qTChooseActionListener = new QTChooseActionListener( this, super.getOwnedUIComptDesignDialog(), txtQueryTemplateName, null, txtLinkType){ @Override public void actionPerformed(ActionEvent e) { if(!"".equals(txtLinkType.getText().trim())){ setBtmLinkTypeTextField(txtLinkType); } else { setBtmLinkTypeTextField(txtBtmType); } super.actionPerformed(e); } }; btnChooseQT.addActionListener(qTChooseActionListener); super.getActions().add(qTChooseActionListener); BtmTypeEditActionListener btmTypeEditActionListener = new BtmTypeEditActionListener( this, super.getOwnedUIComptDesignDialog(), txtBtmType, null); btnBtmTypeEdit.addActionListener(btmTypeEditActionListener); super.getActions().add(btmTypeEditActionListener); LinkTypeEditActionListener linkTypeEditActionListener = new LinkTypeEditActionListener( this, super.getOwnedUIComptDesignDialog(), txtLinkType, null); btnLinkTypeEdit.addActionListener(linkTypeEditActionListener); super.getActions().add(linkTypeEditActionListener); QTEditActionListener qtEditAction = new QTEditActionListener( this, super.getOwnedUIComptDesignDialog(), txtQueryTemplateName, null); btnChooseQTEdit.addActionListener(qtEditAction); super.getActions().add(qtEditAction); } @Override protected void initLinkTypeActionListener(){ } @Override public void setDataToUISpec(PLDefination d) { txtBtmType.setText(d.getShowType()); if(!"".equals(d.getLinkType())){ txtLinkType.setText(d.getLinkType()); } txtQueryTemplateName.setText(d.getTemplateId()); txtShowExpressionRoot.setText(d.getRootContent()); txtShowExpression.setText(d.getShowAbs()); txtRefTreeSet.setText(d.getShowLinkAbs()); if(d.getSeparator() == null || "".equals(d.getSeparator())){ txtSplitChar.setText(","); } else { txtSplitChar.setText(d.getSeparator()); } if("1".equals(d.getExpandMode())){ rbtnExpandModeOne.setSelected(true); } else if("0".equals(d.getExpandMode())){ rbtnExpandModeAll.setSelected(true); } // if(d.getOrientation().equals(QTConstants.DIRECTION_POSITIVE)){ // rbtnExpandDirectPositive.setSelected(true); // } // else if(d.getOrientation().equals(QTConstants.DIRECTION_OPPOSITE)){ // rbtnExpandDirectOpposite.setSelected(true); // } // if("1".equals(d.getIsShowImage())){ // cbxShowIcon.setSelected(true); // } } @Override public PLDefination getNewPLDefination(PLDefination d) { if(d == null){ d = new PLDefination(); } d.setShowType(txtBtmType.getText().toString()); d.setLinkType(txtLinkType.getText().toString()); d.setTemplateId(txtQueryTemplateName.getText().toString()); d.setRootContent(txtShowExpressionRoot.getText().trim()); d.setShowAbs(txtShowExpression.getText().trim()); d.setShowLinkAbs(txtRefTreeSet.getText().trim()); d.setSeparator(txtSplitChar.getText().trim()); if(rbtnExpandModeOne.isSelected()){ d.setExpandMode("1"); } else if(rbtnExpandModeAll.isSelected()){ d.setExpandMode("0"); } // if(rbtnExpandDirectPositive.isSelected()){ // d.setOrientation(QTConstants.DIRECTION_POSITIVE); // } else if(rbtnExpandDirectOpposite.isSelected()){ // d.setOrientation(QTConstants.DIRECTION_OPPOSITE); // } // d.setIsShowImage(cbxShowIcon.isSelected() ? "1":"0"); return d; } }