From 21bbf8147c1678f7e6bc1316ac0f636eaec0443f Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Tue, 13 Jul 2021 17:15:46 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-53130=20npe=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/designer/beans/models/SelectionModel.java | 9 +++++++-- .../main/java/com/fr/design/mainframe/FormDesigner.java | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index ceb559a2e7..bf1c849906 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -84,9 +84,14 @@ public class SelectionModel { XCreator comp = designer.getComponentAt(e); if (e.getButton() == MouseEvent.BUTTON3 || (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown())) { // 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件 - if (!StringUtils.equals(selection.getSelectedCreator().toData().getWidgetName(), comp.toData().getWidgetName())) { - selection.reset(); + XCreator selectXCreator = selection.getSelectedCreator(); + if (selectXCreator != null && comp != null) { + if (StringUtils.equals(selectXCreator.toData().getWidgetName(), comp.toData().getWidgetName())) { + return; + } } + selection.reset(); + } else { //按下Ctrl或者shift键时鼠标可以进行多选,两次点击同一控件就取消选中 XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index cab59d66e2..65fc96b7e9 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -1477,10 +1477,13 @@ public class FormDesigner extends TargetComponent
implements TreeSelection editingMouseListener.stopEditing(); editingMouseListener.stopEditTopLayout(comp); - if (!StringUtils.equals(editingMouseListener.getSelectionModel().getSelection().getSelectedCreator().toData().getWidgetName(), comp.toData().getWidgetName())) { - editingMouseListener.getSelectionModel().reset(); + XCreator selectXCreator = editingMouseListener.getSelectionModel().getSelection().getSelectedCreator(); + if (selectXCreator != null && comp != null) { + if (StringUtils.equals(selectXCreator.toData().getWidgetName(), comp.toData().getWidgetName())) { + return; + } } - + editingMouseListener.getSelectionModel().reset(); editingMouseListener.getSelectionModel().selectACreator(comp); }