From e49f8cd9c970b44326be9e498f6c79cae3894c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Mon, 15 Nov 2021 18:40:51 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-62275=20=E8=A1=A8=E5=8D=95=E6=8B=96?= =?UTF-8?q?=E5=85=A5=E5=A4=B1=E8=B4=A5-=E8=87=AA=E5=8A=A8=E6=92=A4?= =?UTF-8?q?=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/designer/beans/LayoutAdapter.java | 3 +++ .../adapters/layout/AbstractLayoutAdapter.java | 3 +++ .../adapters/layout/FRFitLayoutAdapter.java | 8 +++++++- .../adapters/layout/FRNoFixLayoutAdapter.java | 7 +++++++ .../designer/beans/models/AddingModel.java | 8 ++++++++ .../designer/beans/models/SelectionModel.java | 6 +++++- .../design/mainframe/FormCreatorDropTarget.java | 17 +++++++++++++++++ .../com/fr/design/mainframe/FormDesigner.java | 1 + 8 files changed, 51 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java index 438699b86..7686709a3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java @@ -3,6 +3,7 @@ package com.fr.design.designer.beans; import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.adapters.layout.DefaultDesignerBaseOperate; import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate; +import com.fr.design.designer.beans.models.AddingModel; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender; @@ -141,4 +142,6 @@ public interface LayoutAdapter { }; + void updateAddingModel(AddingModel model); + } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java index 98b6c8855..a2e9b71ff 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java @@ -4,6 +4,7 @@ import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.beans.models.AddingModel; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.painters.NullPainter; import com.fr.design.designer.creator.XCreator; @@ -210,5 +211,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter { selectionModel.setSelectedCreator(container); } + public void updateAddingModel(AddingModel model) { + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index d17e9689e..747479cbb 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -8,6 +8,7 @@ import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.beans.models.AddingModel; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; @@ -1243,5 +1244,10 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { public void dragOver(XCreator xCreator, SelectionModel selectionModel,int x, int y) { frLayoutState.dragOver(xCreator, selectionModel,x,y); - }; + } + + @Override + public void updateAddingModel(AddingModel model) { + frLayoutState.updateAddingModel(model); + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java index aaeedfc8d..b278e0ffe 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java @@ -1,5 +1,6 @@ package com.fr.design.designer.beans.adapters.layout; +import com.fr.design.designer.beans.models.AddingModel; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.painters.AbstractPainter; import com.fr.design.designer.beans.painters.FRFitLayoutPainter; @@ -144,6 +145,12 @@ public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { @Override public void dragStart(XCreator xCreator, SelectionModel selectionModel) { selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight()); + selectionModel.fireCreatorDeleted(); selectionModel.setSelectedCreator(container); } + + @Override + public void updateAddingModel(AddingModel model) { + model.setNeedUndoWhenAddingFailed(true); + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java index 1926b57b1..c9a9eb330 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java @@ -24,6 +24,7 @@ public class AddingModel { private int currentX; private int currentY; private boolean added; + private boolean needUndoWhenAddingFailed = false; public AddingModel(FormDesigner designer, XCreator xCreator) { this.creator = xCreator; @@ -141,4 +142,11 @@ public class AddingModel { return added; } + public boolean isNeedUndoWhenAddingFailed() { + return needUndoWhenAddingFailed; + } + + public void setNeedUndoWhenAddingFailed(boolean needUndoWhenAddingFailed) { + this.needUndoWhenAddingFailed = needUndoWhenAddingFailed; + } } 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 963f60e6c..28456f799 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 @@ -25,7 +25,6 @@ import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormSelection; import com.fr.design.mainframe.FormSelectionUtils; -import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptSelectionClipboardHandler; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.general.ComparatorUtils; @@ -585,4 +584,9 @@ public class SelectionModel { selection.setSelectedCreators(rebuildSelection); fireCreatorSelected(); } + + public void fireCreatorDeleted() { + designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(), + DesignerEvent.CREATOR_DELETED); + } } 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 82befa273..2b9a4f6be 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.file.HistoryTemplateListPane; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; @@ -25,6 +26,7 @@ import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.mod.bean.ChangeItem; import com.fr.design.mod.bean.ContentChangeItem; import com.fr.design.mod.event.TableDataModifyEvent; +import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.ComponentUtils; import com.fr.event.EventDispatcher; import com.fr.form.share.SharableWidgetProvider; @@ -152,6 +154,9 @@ public class FormCreatorDropTarget extends DropTarget { if (creator != null) { creator.setSelected(false); } + if (designer.getAddingModel().isNeedUndoWhenAddingFailed()) { + undoWhenDropFail(); + } } // 取消提示 designer.setPainter(null); @@ -159,6 +164,18 @@ public class FormCreatorDropTarget extends DropTarget { designer.stopAddingState(); } + private void undoWhenDropFail() { + JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (jt != null && jt.getUndoManager().canUndo()) { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + jt.undo(); + } + }); + } + } + private void entering(int x, int y) { // 将要添加的组件图标移动到鼠标下的位置 addingModel.moveTo(x, y); 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 3eb40b6a2..9cf220ff8 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 @@ -1210,6 +1210,7 @@ public class FormDesigner extends TargetComponent
implements TreeSelection setTransferHandler(handler); handler.exportAsDrag(this, lastPressEvent, TransferHandler.COPY); XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); + parent.getLayoutAdapter().updateAddingModel(addingModel); parent.getLayoutAdapter().dragStart(xCreator, selectionModel); this.setDropTarget(new FormCreatorDropTarget(this)); // 触发状态添加模式事件 From a51db423435c9d8ad5daa6f3fac3e5c6e007e786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Wed, 17 Nov 2021 11:03:43 +0800 Subject: [PATCH 2/4] REPORT-61827 --- .../com/fr/design/mainframe/DesignerTransferHandler.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java b/designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java index 38e6f47a4..013d7c2f1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java @@ -1,12 +1,11 @@ package com.fr.design.mainframe; -import java.awt.datatransfer.Transferable; +import com.fr.design.designer.beans.events.DesignerEvent; +import com.fr.design.designer.beans.models.AddingModel; import javax.swing.JComponent; import javax.swing.TransferHandler; - -import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.beans.models.AddingModel; +import java.awt.datatransfer.Transferable; public class DesignerTransferHandler extends TransferHandler { @@ -20,7 +19,7 @@ public class DesignerTransferHandler extends TransferHandler { } protected void exportDone(JComponent source, Transferable data, int action) { - if (!addingModel.isCreatorAdded()) { + if (!addingModel.isCreatorAdded() && !addingModel.isNeedUndoWhenAddingFailed()) { designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED); } } From 0ae062a012093257e24ac28e39dce5d965c7a9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Thu, 18 Nov 2021 17:46:59 +0800 Subject: [PATCH 3/4] REPORT-62275 --- .../designer/beans/adapters/layout/FRNoFixLayoutAdapter.java | 1 - .../com/fr/design/designer/beans/models/SelectionModel.java | 5 ----- .../java/com/fr/design/mainframe/FormCreatorDropTarget.java | 5 +++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java index b278e0ffe..3f0c61e63 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java @@ -145,7 +145,6 @@ public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { @Override public void dragStart(XCreator xCreator, SelectionModel selectionModel) { selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight()); - selectionModel.fireCreatorDeleted(); selectionModel.setSelectedCreator(container); } 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 28456f799..31bb62531 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 @@ -584,9 +584,4 @@ public class SelectionModel { selection.setSelectedCreators(rebuildSelection); fireCreatorSelected(); } - - public void fireCreatorDeleted() { - designer.getEditListenerTable().fireCreatorModified(selection.getSelectedCreator(), - DesignerEvent.CREATOR_DELETED); - } } 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 2b9a4f6be..6a0ad0952 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 @@ -166,11 +166,12 @@ public class FormCreatorDropTarget extends DropTarget { private void undoWhenDropFail() { JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jt != null && jt.getUndoManager().canUndo()) { + if (jt != null) { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { - jt.undo(); + FormUndoState current = (FormUndoState) jt.getUndoState(); + current.applyState(); } }); } From 60edfb2cbdaa50ba950ed4d1a54982de15cd9cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Thu, 18 Nov 2021 20:35:43 +0800 Subject: [PATCH 4/4] REPORT-62275&REPORT-61827 --- .../com/fr/design/mainframe/JTemplate.java | 17 +++++++++++++---- .../design/designer/beans/LayoutAdapter.java | 4 ---- .../adapters/layout/AbstractLayoutAdapter.java | 7 +------ .../adapters/layout/FRBorderLayoutAdapter.java | 1 - .../layout/FRCardMainBorderLayoutAdapter.java | 14 ++------------ .../adapters/layout/FRFitLayoutAdapter.java | 6 ------ .../adapters/layout/FRNoFixLayoutAdapter.java | 6 ------ .../designer/beans/models/AddingModel.java | 9 --------- .../mainframe/DesignerTransferHandler.java | 13 ++++++++++--- .../mainframe/FormCreatorDropTarget.java | 18 ------------------ .../com/fr/design/mainframe/FormDesigner.java | 1 - 11 files changed, 26 insertions(+), 70 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index c9b223c52..3bbaf2706 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -7,11 +7,11 @@ import com.fr.base.io.BaseBook; import com.fr.base.iofile.attr.DesignBanCopyAttrMark; import com.fr.base.iofile.attr.TemplateIdAttrMark; import com.fr.base.iofile.attr.TemplateThemeAttrMark; +import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateThemeCompatible; +import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.ThemedTemplate; import com.fr.base.vcs.DesignerMode; -import com.fr.base.theme.TemplateTheme; -import com.fr.base.theme.TemplateThemeConfig; import com.fr.decision.config.FSConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; @@ -70,14 +70,13 @@ import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; +import com.fr.nx.app.designer.toolbar.TemplateTransformer; import com.fr.nx.app.designer.utils.CptAndCptxCompatibilityUtil; import com.fr.nx.app.designer.utils.CptCompileUtil; import com.fr.nx.cptx.entry.metadata.CptxMetadata; import com.fr.nx.cptx.utils.CptxFileUtils; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; -import com.fr.nx.app.designer.toolbar.CompileAction; -import com.fr.nx.app.designer.toolbar.TemplateTransformer; import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; @@ -642,6 +641,16 @@ public abstract class JTemplate> fireSuperTargetModified(); } + public void undoToCurrent() { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + BaseUndoState current = JTemplate.this.getUndoState(); + current.applyState(); + } + }); + } + /** * 模板更新 */ diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java index 7686709a3..3c0c2bd5f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java @@ -3,7 +3,6 @@ package com.fr.design.designer.beans; import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.adapters.layout.DefaultDesignerBaseOperate; import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate; -import com.fr.design.designer.beans.models.AddingModel; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender; @@ -141,7 +140,4 @@ public interface LayoutAdapter { default void dragOver(XCreator xCreator, SelectionModel selectionModel, int x, int y) { }; - - void updateAddingModel(AddingModel model); - } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java index a2e9b71ff..7d287e5a5 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java @@ -4,7 +4,6 @@ import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.LayoutAdapter; -import com.fr.design.designer.beans.models.AddingModel; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.painters.NullPainter; import com.fr.design.designer.creator.XCreator; @@ -14,7 +13,7 @@ import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.general.ComparatorUtils; -import java.awt.*; +import java.awt.LayoutManager; public abstract class AbstractLayoutAdapter implements LayoutAdapter { @@ -210,8 +209,4 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter { selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight()); selectionModel.setSelectedCreator(container); } - - public void updateAddingModel(AddingModel model) { - - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java index cbb8f018f..6a9eadf83 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java @@ -184,5 +184,4 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter { public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { return new FRBorderLayoutConstraints(container, creator); } - } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java index dd9e03c8d..00c0d7751 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java @@ -7,7 +7,6 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.form.layout.FRBorderLayout; import com.fr.design.mainframe.JTemplate; -import com.fr.design.ui.util.UIUtil; import com.fr.general.ComparatorUtils; import java.awt.BorderLayout; @@ -65,17 +64,8 @@ public class FRCardMainBorderLayoutAdapter extends FRBorderLayoutAdapter { if (minConstraint > value) { FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jt != null && jt.getUndoManager().canUndo()) { - // 自适应布局平分高度导致变矮的场景,优先做撤销 - UIUtil.invokeLaterIfNeeded(new Runnable() { - @Override - public void run() { - jt.undo(); - } - }); - } else if (container.getBackupBound() != null) { - // 手动拖动导致变矮的场景 - container.setSize(container.getBackupBound().getSize()); + if (jt != null) { + jt.undoToCurrent(); } return true; } else { diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index 747479cbb..9871d1b32 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -8,7 +8,6 @@ import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.LayoutAdapter; -import com.fr.design.designer.beans.models.AddingModel; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; @@ -1245,9 +1244,4 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { public void dragOver(XCreator xCreator, SelectionModel selectionModel,int x, int y) { frLayoutState.dragOver(xCreator, selectionModel,x,y); } - - @Override - public void updateAddingModel(AddingModel model) { - frLayoutState.updateAddingModel(model); - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java index 3f0c61e63..aaeedfc8d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java @@ -1,6 +1,5 @@ package com.fr.design.designer.beans.adapters.layout; -import com.fr.design.designer.beans.models.AddingModel; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.painters.AbstractPainter; import com.fr.design.designer.beans.painters.FRFitLayoutPainter; @@ -147,9 +146,4 @@ public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight()); selectionModel.setSelectedCreator(container); } - - @Override - public void updateAddingModel(AddingModel model) { - model.setNeedUndoWhenAddingFailed(true); - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java index c9a9eb330..b94b21d94 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java @@ -24,7 +24,6 @@ public class AddingModel { private int currentX; private int currentY; private boolean added; - private boolean needUndoWhenAddingFailed = false; public AddingModel(FormDesigner designer, XCreator xCreator) { this.creator = xCreator; @@ -141,12 +140,4 @@ public class AddingModel { y + designer.getVerticalScaleValue() - rect.y); return added; } - - public boolean isNeedUndoWhenAddingFailed() { - return needUndoWhenAddingFailed; - } - - public void setNeedUndoWhenAddingFailed(boolean needUndoWhenAddingFailed) { - this.needUndoWhenAddingFailed = needUndoWhenAddingFailed; - } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java b/designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java index 013d7c2f1..e5b11dd9a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/DesignerTransferHandler.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe; -import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.models.AddingModel; +import com.fr.design.file.HistoryTemplateListPane; import javax.swing.JComponent; import javax.swing.TransferHandler; @@ -19,8 +19,15 @@ public class DesignerTransferHandler extends TransferHandler { } protected void exportDone(JComponent source, Transferable data, int action) { - if (!addingModel.isCreatorAdded() && !addingModel.isNeedUndoWhenAddingFailed()) { - designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED); + if (!addingModel.isCreatorAdded()) { + undoWhenAddingFailed(); + } + } + + private void undoWhenAddingFailed() { + JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (jt != null) { + jt.undoToCurrent(); } } } \ No newline at end of file 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 6a0ad0952..82befa273 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,7 +18,6 @@ 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.file.HistoryTemplateListPane; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; @@ -26,7 +25,6 @@ import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.mod.bean.ChangeItem; import com.fr.design.mod.bean.ContentChangeItem; import com.fr.design.mod.event.TableDataModifyEvent; -import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.ComponentUtils; import com.fr.event.EventDispatcher; import com.fr.form.share.SharableWidgetProvider; @@ -154,9 +152,6 @@ public class FormCreatorDropTarget extends DropTarget { if (creator != null) { creator.setSelected(false); } - if (designer.getAddingModel().isNeedUndoWhenAddingFailed()) { - undoWhenDropFail(); - } } // 取消提示 designer.setPainter(null); @@ -164,19 +159,6 @@ public class FormCreatorDropTarget extends DropTarget { designer.stopAddingState(); } - private void undoWhenDropFail() { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jt != null) { - UIUtil.invokeLaterIfNeeded(new Runnable() { - @Override - public void run() { - FormUndoState current = (FormUndoState) jt.getUndoState(); - current.applyState(); - } - }); - } - } - private void entering(int x, int y) { // 将要添加的组件图标移动到鼠标下的位置 addingModel.moveTo(x, y); 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 9cf220ff8..3eb40b6a2 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 @@ -1210,7 +1210,6 @@ public class FormDesigner extends TargetComponent implements TreeSelection setTransferHandler(handler); handler.exportAsDrag(this, lastPressEvent, TransferHandler.COPY); XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); - parent.getLayoutAdapter().updateAddingModel(addingModel); parent.getLayoutAdapter().dragStart(xCreator, selectionModel); this.setDropTarget(new FormCreatorDropTarget(this)); // 触发状态添加模式事件