From 1c6d9217cea3eeec4d9e5a47e3765dcc91ea8438 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 15 Jul 2021 10:16:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-55178=20=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=A4=8D=E7=94=A8-=E8=AE=BE=E8=AE=A1=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E7=8E=B0=E5=9C=A8=E9=9C=80=E8=A6=81=E7=82=B9=E4=B8=A4?= =?UTF-8?q?=E4=B8=8B=E9=80=89=E4=B8=AD=E7=BB=84=E4=BB=B6=E6=89=8D=E8=83=BD?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E5=B7=A5=E5=85=B7=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/EditingMouseListener.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 8a2bdcc6c..1c14d739a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -631,9 +631,16 @@ public class EditingMouseListener extends MouseInputAdapter { selectionModel.selectACreatorAtMouseEvent(e); refreshTopXCreator(); XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); - for (XCreator xCreator : xCreators) { - xCreator.setSelected(true); - } + // 放到事件队尾执行 + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + for (XCreator xCreator : xCreators) { + xCreator.setSelected(true); + } + } + }); + } else if (clickedNonCardButton && responseTabLayout(oldCreator, e)) { // do nothing } else { From 428e1e63b11cbfa3feba77a0c46b13e47f99e412 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 15 Jul 2021 10:48:45 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-55188=20=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=A4=8D=E7=94=A8-=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=8F=B3?= =?UTF-8?q?=E4=BE=A7=E7=BB=84=E4=BB=B6=E7=9B=AE=E5=BD=95=E6=A0=91=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E7=BB=84=E4=BB=B6=E5=BA=94=E4=B9=9F=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80=E4=B8=8B=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E5=B7=A5=E5=85=B7=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/ComponentTree.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index 134252487..d96162559 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -4,6 +4,7 @@ import com.fr.design.constants.UIConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.designer.treeview.ComponentTreeCellRenderer; import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.design.file.HistoryTemplateListCache; @@ -378,22 +379,30 @@ public class ComponentTree extends JTree { @Override public void mouseClicked(MouseEvent e) { - // 鼠标左键 双击 - if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) { - Point p = e.getPoint(); - // 解析组件树路径 获取选中的组件 - int selRow = tree.getRowForLocation(p.x, p.y); - TreePath path = tree.getPathForRow(selRow); - Rectangle bounds = tree.getPathBounds(path); - if (bounds != null) { - Point point = bounds.getLocation(); - SwingUtilities.convertPointToScreen(point, tree); - XCreator comp = (XCreator) path.getLastPathComponent(); + Point p = e.getPoint(); + // 解析组件树路径 获取选中的组件 + int selRow = tree.getRowForLocation(p.x, p.y); + TreePath path = tree.getPathForRow(selRow); + Rectangle bounds = tree.getPathBounds(path); + if (bounds != null) { + Point point = bounds.getLocation(); + SwingUtilities.convertPointToScreen(point, tree); + XCreator comp = (XCreator) path.getLastPathComponent(); + // 鼠标左键 双击 + if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) { startEditing(comp, e); + } else if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON1) { + showSelectedPopup(comp); } } } + private void showSelectedPopup(XCreator comp) { + Rectangle rectangle = getRelativeBounds(comp); + comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class)); + comp.setSelected(true); + } + /** * 组件进入编辑状态 * From 2428f726947ac7e5376312af636e99c3b21de888 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 15 Jul 2021 11:13:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-55188=20=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=A4=8D=E7=94=A8-=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=8F=B3?= =?UTF-8?q?=E4=BE=A7=E7=BB=84=E4=BB=B6=E7=9B=AE=E5=BD=95=E6=A0=91=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E7=BB=84=E4=BB=B6=E5=BA=94=E4=B9=9F=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80=E4=B8=8B=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E5=B7=A5=E5=85=B7=E6=A0=8F=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/ComponentTree.java | 58 +++++++++++++++---- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index d96162559..37094494b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -17,6 +17,7 @@ import com.fr.stable.StringUtils; import java.awt.Rectangle; import java.awt.event.MouseListener; import java.util.Stack; +import java.util.function.Consumer; import javax.swing.BorderFactory; import javax.swing.DropMode; import javax.swing.JPanel; @@ -350,6 +351,7 @@ public class ComponentTree extends JTree { private final class ComponetTreeMouseListener extends MouseAdapter { private final JTree tree; + private XCreator selectedCreator; private ComponetTreeMouseListener(JTree tree) { this.tree = tree; @@ -379,6 +381,49 @@ public class ComponentTree extends JTree { @Override public void mouseClicked(MouseEvent e) { + onMouseEvent(e, new Consumer() { + @Override + public void accept(XCreator creator) { + if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) { + startEditing(creator, e); + } + } + }); + + } + + @Override + public void mousePressed(MouseEvent e) { + onMouseEvent(e, new Consumer() { + @Override + public void accept(XCreator creator) { + if (e.getButton() == MouseEvent.BUTTON1) { + selectedCreator = creator; + } + } + }); + } + + @Override + public void mouseReleased(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && selectedCreator != null) { + showSelectedPopup(selectedCreator); + } + } + + private void showSelectedPopup(XCreator comp) { + Rectangle rectangle = getRelativeBounds(comp); + comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class)); + comp.setSelected(true); + } + + /** + * 响应鼠标事件并解析选中的组件 + * + * @param e + * @param consumer + */ + private void onMouseEvent(final MouseEvent e, Consumer consumer) { Point p = e.getPoint(); // 解析组件树路径 获取选中的组件 int selRow = tree.getRowForLocation(p.x, p.y); @@ -388,21 +433,10 @@ public class ComponentTree extends JTree { Point point = bounds.getLocation(); SwingUtilities.convertPointToScreen(point, tree); XCreator comp = (XCreator) path.getLastPathComponent(); - // 鼠标左键 双击 - if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) { - startEditing(comp, e); - } else if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON1) { - showSelectedPopup(comp); - } + consumer.accept(comp); } } - private void showSelectedPopup(XCreator comp) { - Rectangle rectangle = getRelativeBounds(comp); - comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class)); - comp.setSelected(true); - } - /** * 组件进入编辑状态 *