From 68f8530144bf8e6db1724fa99e5f9a194141b0e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 17 Mar 2020 11:01:24 +0800 Subject: [PATCH] =?UTF-8?q?CHART-13033=20&&=20CHART-13045=09=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E4=B8=8B=E6=8B=89=E6=A1=86=E6=97=B6=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E5=88=97=E8=A1=A8=20&&=20=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E7=9A=84=E6=95=B0=E6=8D=AE=E9=9B=86=E5=92=8C?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/icombobox/FRTreeComboBox.java | 61 ++++++++++--------- .../chartx/component/MapAreaMatchPane.java | 9 --- .../chartx/component/TableTreeComboBox.java | 42 ++++++++++++- 3 files changed, 73 insertions(+), 39 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java index c3dd64c9d..a7a913335 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java @@ -1,22 +1,14 @@ package com.fr.design.gui.icombobox; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.IllegalComponentStateException; -import java.awt.RenderingHints; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionAdapter; -import java.awt.event.MouseMotionListener; -import java.util.Enumeration; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.ComparatorUtils; +import com.fr.general.NameObject; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; @@ -38,16 +30,23 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; - -import com.fr.design.constants.UIConstants; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.ComparatorUtils; -import com.fr.general.NameObject; -import com.fr.stable.Constants; -import com.fr.stable.StringUtils; +import java.util.Enumeration; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.IllegalComponentStateException; +import java.awt.RenderingHints; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseMotionListener; public class FRTreeComboBox extends UIComboBox { @@ -79,7 +78,7 @@ public class FRTreeComboBox extends UIComboBox { boolean showRoot, boolean editable) { this.setTree(tree); this.tree.setCellRenderer(renderer); - this.setEditor(new FrTreeSearchComboBoxEditor(this)); + this.setEditor(createEditor()); if (!showRoot) { tree.expandPath(new TreePath(tree.getModel().getRoot())); tree.setRootVisible(false); @@ -101,6 +100,10 @@ public class FRTreeComboBox extends UIComboBox { return true; } + protected UIComboBoxEditor createEditor() { + return new FrTreeSearchComboBoxEditor(this); + } + public void setTree(JTree tree) { this.tree = tree; if (tree != null) { @@ -529,7 +532,7 @@ public class FRTreeComboBox extends UIComboBox { } } - class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener { + public class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener { private volatile boolean setting = false; private FRTreeComboBox comboBox; private Object item; diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java index ef9bbd797..cc202fcf1 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java @@ -180,10 +180,6 @@ public class MapAreaMatchPane extends BasicBeanPane { if (matchResult == null) { return; } - if (tableNameCombox.getSelectedItem() != null) { - matchResult.setTableName(tableNameCombox.getSelectedItem().getTableDataName()); - } - matchResult.setColumnName(GeneralUtils.objectToString(areaNameBox.getSelectedItem())); matchResultTable.updateBean(matchResult); } @@ -195,11 +191,6 @@ public class MapAreaMatchPane extends BasicBeanPane { public void populateBean(MapMatchResult matchResult, String tableName, String areaName) { //先取保存的数据集名称和区域名,若不存在,就取数据集面板配置的数据集名称和区域名 matchResultTable.populateBean(matchResult); - - if (matchResult != null && StringUtils.isNotEmpty(matchResult.getTableName())) { - tableName = matchResult.getTableName(); - areaName = matchResult.getColumnName(); - } tableNameCombox.setSelectedTableDataByName(tableName); if (StringUtils.isEmpty(areaName)) { return; diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/TableTreeComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/component/TableTreeComboBox.java index 0eaf75f08..e8f02984f 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/TableTreeComboBox.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/TableTreeComboBox.java @@ -1,6 +1,7 @@ package com.fr.design.chartx.component; import com.fr.design.gui.icombobox.FRTreeComboBox; +import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.itextfield.UITextField; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; @@ -19,6 +20,8 @@ import java.awt.Component; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; /** * @author Bjorn @@ -49,11 +52,16 @@ public class TableTreeComboBox extends FRTreeComboBox { public void resetText() { Object selectedItem = this.getSelectedItem(); - if(!ComparatorUtils.equals(selectedItem, textField.getText())){ + if (!ComparatorUtils.equals(selectedItem, textField.getText())) { textField.setText(GeneralUtils.objectToString(selectedItem)); } } + @Override + protected UIComboBoxEditor createEditor() { + return new TableTreeComboBoxEditor(this); + } + private boolean matchLeafNode(TreePath parent, TreeNode node, UITextField textField) { for (Enumeration e = node.children(); e.hasMoreElements(); ) { TreeNode n = (TreeNode) e.nextElement(); @@ -107,4 +115,36 @@ public class TableTreeComboBox extends FRTreeComboBox { } }; + class TableTreeComboBoxEditor extends FrTreeSearchComboBoxEditor { + + public TableTreeComboBoxEditor(FRTreeComboBox comboBox) { + super(comboBox); + textField.addMouseListener(mouseListener); + } + + private MouseListener mouseListener = new MouseListener() { + + public void mouseClicked(MouseEvent e) { + + } + + public void mousePressed(MouseEvent e) { + + } + + public void mouseReleased(MouseEvent e) { + setPopupVisible(true); + } + + public void mouseEntered(MouseEvent e) { + + } + + public void mouseExited(MouseEvent e) { + + } + }; + + } + }