From a127c09fdfc1a32e6a48b4b3f1fd596bfbe6f0b4 Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 1 Sep 2021 17:44:45 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-58597=20=E3=80=90FR11=E4=BA=8C=E8=BD=AE?= =?UTF-8?q?=E5=9B=9E=E5=BD=92=E3=80=91=E7=BB=84=E4=BB=B6=E5=A4=8D=E7=94=A8?= =?UTF-8?q?&=E4=B8=BB=E9=A2=98=E5=88=87=E6=8D=A2-=E6=8B=96=E5=85=A5?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E7=BB=84=E4=BB=B6=EF=BC=8C=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=80=89=E6=8B=A9=E7=9A=84=E6=98=AF=E8=B7=9F?= =?UTF-8?q?=E9=9A=8F=E4=B8=BB=E9=A2=98=EF=BC=8C=E8=BF=99=E6=A0=B7=E7=9A=84?= =?UTF-8?q?=E8=AF=9D=E5=A4=8D=E7=94=A8=E7=BB=84=E4=BB=B6=E5=8E=9F=E6=9C=AC?= =?UTF-8?q?=E7=9A=84=E6=A0=B7=E5=BC=8F=E9=83=BD=E6=B2=A1=E6=9C=89=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 设计器面板中拖拽生成新组件的时机提前到拖拽开始时,这样被拖拽的控件 在拖拽过程中就有了主题化的效果 2. 新拖拽的报表块/图表块,仅在拖拽时设置为跟随主题,避免影响共享组件内的 报表块和图表块 【改动思路】 同上 --- .../mainframe/FormCreatorDropTarget.java | 58 ++----------------- .../com/fr/design/mainframe/FormDesigner.java | 42 ++++++++++++++ 2 files changed, 48 insertions(+), 52 deletions(-) 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 9731dd5081..7db972e9be 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 @@ -2,12 +2,8 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.chart.BaseChartCollection; -import com.fr.base.theme.TemplateThemeAware; -import com.fr.base.theme.TemplateThemeCompatible; import com.fr.chart.chartattr.ChartCollection; import com.fr.chartx.attr.ChartProvider; -import com.fr.base.theme.FormTheme; -import com.fr.base.theme.TemplateTheme; import com.fr.design.DesignModelAdapter; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; @@ -22,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.HistoryTemplateListCache; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; @@ -32,24 +27,16 @@ import com.fr.design.mod.bean.ContentChangeItem; import com.fr.design.mod.event.TableDataModifyEvent; import com.fr.design.utils.ComponentUtils; import com.fr.event.EventDispatcher; -import com.fr.form.main.Form; -import com.fr.form.main.WidgetGather; -import com.fr.form.share.editor.SharableEditorProvider; import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.ShareLoader; -import com.fr.form.ui.AbstractBorderStyleWidget; -import com.fr.form.ui.ChartEditor; -import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.share.editor.SharableEditorProvider; import com.fr.form.ui.Widget; import com.fr.stable.Constants; import com.fr.stable.StringUtils; -import java.util.Collections; -import java.util.HashMap; import javax.swing.BorderFactory; import javax.swing.JWindow; -import java.util.List; -import java.util.Map; +import javax.swing.SwingUtilities; import java.awt.Color; import java.awt.Component; import java.awt.Point; @@ -59,7 +46,10 @@ import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; -import javax.swing.SwingUtilities; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 添加模式下鼠标事件处理器。 @@ -150,9 +140,6 @@ public class FormCreatorDropTarget extends DropTarget { EventDispatcher.fire(TableDataModifyEvent.INSTANCE, new ContentChangeItem(tdNameMap, widget, ChangeItem.TABLE_DATA_NAME)); } - // 新疆的图表块和报表块默认主题化 - addThemeToNewWidget(addingXCreator); - designer.getSelectionModel().setSelectedCreators( FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget})); designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED); @@ -363,37 +350,4 @@ public class FormCreatorDropTarget extends DropTarget { public TabDragInner getTabDragInner() { return this.tabDragInner; } - - private void addThemeToNewWidget(XCreator addingXCreator) { - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (template == null) { - return; - } - TemplateTheme theme = template.getTemplateTheme(); - if (!(theme instanceof FormTheme)) { - return; - } - FormTheme formTheme = (FormTheme) theme; - - Form.traversalWidget(addingXCreator.toData(), new WidgetGather() { - @Override - public void dealWith(Widget widget) { - if (widget instanceof AbstractBorderStyleWidget) { - AbstractBorderStyleWidget styleWidget = (AbstractBorderStyleWidget) widget; - if (!styleWidget.supportThemed()) { - return; - } - - boolean followingTheme = (!addingXCreator.isShared()) || styleWidget.isBorderStyleFollowingTheme(); - styleWidget.setBorderStyleFollowingTheme(followingTheme); - if (followingTheme) { - styleWidget.onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE); - } - } - } - @Override - public boolean dealWithAllCards() { return true; } - }, AbstractBorderStyleWidget.class); - addingXCreator.rebuid(); - } } 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 92127c5a86..636f1f5489 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 @@ -2,6 +2,9 @@ package com.fr.design.mainframe; import com.fr.base.Parameter; import com.fr.base.ScreenResolution; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeCompatible; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; @@ -41,6 +44,7 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.DesignerOpenedListener; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.form.util.XCreatorConstants; @@ -57,7 +61,9 @@ import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; import com.fr.form.main.Form; +import com.fr.form.main.WidgetGather; import com.fr.form.parameter.FormSubmitButton; +import com.fr.form.ui.AbstractBorderStyleWidget; import com.fr.form.ui.EditorHolder; import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.Widget; @@ -1189,6 +1195,9 @@ public class FormDesigner extends TargetComponent
implements TreeSelection * @param xCreator 组件 */ public void startDraggingBean(XCreator xCreator) { + + // 新疆的图表块和报表块默认主题化 + addThemeToDroppedNewWidget(xCreator); // 根据所选择的组件的BeanInfo生成相应的AddingModel // AddingModel和StateModel不一样,适合当前选择的组件相关的 addingModel = new AddingModel(this, xCreator); @@ -1853,4 +1862,37 @@ public class FormDesigner extends TargetComponent implements TreeSelection public FormSpacingLineDrawer getSpacingLineDrawer() { return spacingLineDrawer; } + + private void addThemeToDroppedNewWidget(XCreator addingXCreator) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template == null) { + return; + } + TemplateTheme theme = template.getTemplateTheme(); + if (!(theme instanceof FormTheme)) { + return; + } + FormTheme formTheme = (FormTheme) theme; + + Form.traversalWidget(addingXCreator.toData(), new WidgetGather() { + @Override + public void dealWith(Widget widget) { + if (widget instanceof AbstractBorderStyleWidget) { + AbstractBorderStyleWidget styleWidget = (AbstractBorderStyleWidget) widget; + if (!styleWidget.supportThemed()) { + return; + } + + boolean followingTheme = (!addingXCreator.isShared()) || styleWidget.isBorderStyleFollowingTheme(); + styleWidget.setBorderStyleFollowingTheme(followingTheme); + if (followingTheme) { + styleWidget.onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE); + } + } + } + @Override + public boolean dealWithAllCards() { return true; } + }, AbstractBorderStyleWidget.class); + addingXCreator.rebuid(); + } }