From afe4c1e5b59c02838ee3ca871eb5ee6b9ca84fa6 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 30 Nov 2021 17:29:21 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-63322=20=E5=86=B3=E7=AD=96=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E5=8F=8A=E8=81=9A=E5=90=88=E6=8A=A5=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=8B=96=E5=8A=A8=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 在某些场景下,组件可能会被破坏或无法被当前设计器解析,从而出现 异常。若拖拽时的异常不被处理,会导致无法完成整个swing拖拽过程, 从而影响后续其他所有的组件拖拽。 【改动思路】 同产品以及交互讨论,新增了一个错误提示信息,当拖拽组件出现 异常时,提示用户,同时终结当前的拖拽。 --- .../mainframe/FormCreatorDropTarget.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index a2c1ba66c..c1a08dded 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -18,6 +18,7 @@ import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; @@ -31,12 +32,15 @@ import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.ShareLoader; import com.fr.form.share.editor.SharableEditorProvider; import com.fr.form.ui.Widget; +import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; +import javax.swing.JOptionPane; import javax.swing.JWindow; import javax.swing.SwingUtilities; +import javax.swing.UIManager; import java.awt.Color; import java.awt.Component; import java.awt.Point; @@ -318,6 +322,24 @@ public class FormCreatorDropTarget extends DropTarget { */ @Override public synchronized void drop(DropTargetDropEvent dtde) { + + try { + dropXCreator(dtde); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + if (addingModel.getXCreator().isShared()) { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Share_Drag_Component_Error_Info"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), + JOptionPane.ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon") + ); + } + dtde.rejectDrop(); + } + } + + private void dropXCreator(DropTargetDropEvent dtde) { Point loc = dtde.getLocation(); this.adding(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y)); // 放到事件末尾执行