diff --git a/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java b/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java index 1352833e6c..8cf38d00ff 100644 --- a/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java +++ b/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java @@ -10,7 +10,15 @@ public class DesignModeContext { private static DesignerMode mode = DesignerMode.NORMAL; public static void switchTo(DesignerMode mode) { - DesignModeContext.mode = mode; + changeMode(DesignModeContext.mode, mode); + } + + private static void changeMode(DesignerMode oldMode, DesignerMode newMode) { + if (oldMode != newMode) { + DesignModeContext.mode = newMode; + oldMode.closeMode(); + newMode.openMode(); + } } public static DesignerMode getMode() { diff --git a/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java b/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java index d3dc1e5f4a..3ca798f2fb 100644 --- a/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java +++ b/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java @@ -1,9 +1,25 @@ package com.fr.design.base.mode; + +import com.fr.design.mainframe.DesignerContext; + public enum DesignerMode { NORMAL, BAN_COPY_AND_CUT, VCS, - AUTHORITY, - DUCHAMP + AUTHORITY { + @Override + public void closeMode() { + DesignerContext.getDesignerFrame().closeAuthorityMode(); + } + }, + DUCHAMP; + + public void openMode() { + + } + + public void closeMode() { + } + } diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index f7d4d1f571..52fb1bcfa2 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -4,6 +4,7 @@ import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.io.BaseBook; import com.fr.design.DesignerEnvManager; import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.base.mode.DesignerMode; import com.fr.design.data.DesignTableDataManager; import com.fr.design.file.filter.ClassFilter; import com.fr.design.i18n.Toolkit; @@ -69,7 +70,7 @@ public class HistoryTemplateListCache implements CallbackEvent { DesignTableDataManager.closeTemplate(selected); //直接关闭模板的时候(当且仅当设计器tab上只剩一个模板)退出权限编辑 if (DesignModeContext.isAuthorityEditing() && historyList.size() <= 1) { - DesignerContext.getDesignerFrame().closeAuthorityEditing(); + DesignModeContext.switchTo(DesignerMode.NORMAL); } if (contains(selected) == -1) { return; @@ -430,13 +431,13 @@ public class HistoryTemplateListCache implements CallbackEvent { */ @Deprecated public void reloadCurrentTemplate() { - reloadAllEditingTemplate(); + reloadAllEditingTemplate(); } /** * 重绘当前模板 */ - public void repaintCurrentEditingTemplate(){ + public void repaintCurrentEditingTemplate() { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java index 8be4678106..452deb5c8d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java @@ -67,6 +67,9 @@ public class JavaFxNativeFileChooser implements FileChooserProvider { fileChooserParent = DesignerContext.getDesignerFrame(); } Stage stage = showCoverStage(fileChooserParent); + if (stage != null) { + stage.setAlwaysOnTop(true); + } try { if (fileSelectionMode == FileSelectionMode.FILE || fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { FileChooser fileChooser = new FileChooser(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index ae67275bea..6270413f51 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -9,6 +9,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.core.ActionFactory; import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.base.mode.DesignerMode; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; @@ -221,7 +222,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta @Override public void mouseReleased(MouseEvent e) { if (DesignModeContext.isAuthorityEditing()) { - closeAuthorityEditing(); + DesignModeContext.switchTo(DesignerMode.NORMAL); } } @@ -301,8 +302,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().doResize(); } + @Deprecated public void closeAuthorityEditing() { - DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); + DesignModeContext.switchTo(DesignerMode.NORMAL); + } + + public void closeAuthorityMode() { WestRegionContainerPane.getInstance().replaceDownPane( TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); @@ -314,6 +319,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta EventDispatcher.fire(DesignAuthorityEventType.StopEdit, DesignerFrame.this); } + /** * 注册app. * @@ -793,6 +799,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * @param jt 添加的模板. */ public void addAndActivateJTemplate(JTemplate jt) { + DesignModeContext.switchTo(DesignerMode.NORMAL); JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (currentEditingTemplate != null) { currentEditingTemplate.stopEditing(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedFloatElement.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedFloatElement.java new file mode 100644 index 0000000000..e1e2e4c155 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedFloatElement.java @@ -0,0 +1,41 @@ +package com.fr.design.mainframe.theme.utils; + +import com.fr.base.NameStyle; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedCellStyle; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.JTemplate; +import com.fr.report.cell.FloatElement; +import com.fr.stable.unit.UNIT; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/9/9 + */ +public class DefaultThemedFloatElement { + public static FloatElement createInstance() { + return themingFloatElement(new FloatElement()); + } + + public static FloatElement createInstance(Object value) { + return themingFloatElement(new FloatElement(value)); + } + + public static FloatElement createInstance(UNIT leftDistance, UNIT topDistance, UNIT width, UNIT height, Object value) { + return themingFloatElement(new FloatElement(leftDistance, topDistance, width, height, value)); + } + + private static FloatElement themingFloatElement(FloatElement floatElement) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + TemplateTheme theme = template.getTemplateTheme(); + ThemedCellStyle themedCellStyle = theme.getCellStyleList().getUse4Default(); + if (themedCellStyle != null) { + NameStyle nameStyle = NameStyle.getPassiveInstance(themedCellStyle.getName(), themedCellStyle.getStyle()); + floatElement.setStyle(nameStyle); + } + } + return floatElement; + } +} diff --git a/designer-base/src/main/java/com/fr/design/roleAuthority/RolesEditedSourceOP.java b/designer-base/src/main/java/com/fr/design/roleAuthority/RolesEditedSourceOP.java index a21cd20e74..60025e0325 100644 --- a/designer-base/src/main/java/com/fr/design/roleAuthority/RolesEditedSourceOP.java +++ b/designer-base/src/main/java/com/fr/design/roleAuthority/RolesEditedSourceOP.java @@ -18,21 +18,22 @@ import java.util.Map; */ public class RolesEditedSourceOP extends RoleSourceOP { - protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map map) { - List roleList = new ArrayList(); - Iterator> entryIt = map.entrySet().iterator(); - while (entryIt.hasNext()) { - Map.Entry entry = entryIt.next(); - RoleDataWrapper t = entry.getValue(); - - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - PrivilegeEditedRoleProvider pe = (PrivilegeEditedRoleProvider) jt.getTarget(); - - ExpandMutableTreeNode[] expand = t.load(Arrays.asList(pe.getAllEditedRoleSet())); - for (ExpandMutableTreeNode expandMutableTreeNode : expand) { - roleList.add(expandMutableTreeNode); - } - } - return roleList.toArray(new ExpandMutableTreeNode[roleList.size()]); - } + protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map map) { + List roleList = new ArrayList(); + Iterator> entryIt = map.entrySet().iterator(); + while (entryIt.hasNext()) { + Map.Entry entry = entryIt.next(); + RoleDataWrapper t = entry.getValue(); + + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt.getTarget() instanceof PrivilegeEditedRoleProvider) { + PrivilegeEditedRoleProvider pe = (PrivilegeEditedRoleProvider) jt.getTarget(); + ExpandMutableTreeNode[] expand = t.load(Arrays.asList(pe.getAllEditedRoleSet())); + for (ExpandMutableTreeNode expandMutableTreeNode : expand) { + roleList.add(expandMutableTreeNode); + } + } + } + return roleList.toArray(new ExpandMutableTreeNode[roleList.size()]); + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java index f3393366d2..d45bd62f79 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java @@ -23,7 +23,7 @@ public class FixedGradientBarNoTheme extends FixedGradientBar { protected void clickButton(int select) { ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); Color selectColor = getList().get(select).getColorInner() == null ? Color.WHITE : getList().get(select).getColorInner(); - ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, selectColor, FixedGradientBarNoTheme.this); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, selectColor, FixedGradientBarNoTheme.this, true); Color color = FixedGradientBarNoTheme.this.getColor(); if (color != null) { DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java index 8091a78eb0..4cc8466fd4 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java @@ -8,6 +8,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.gradient.FixedGradientBarNoTheme; import com.fr.design.style.color.ColorAdjustPane; import com.fr.design.style.background.gradient.FixedGradientBar; @@ -58,7 +59,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { changeColorSetPane = new JPanel(cardLayout = new CardLayout()); changeColorSetPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); - changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 150), "gradient"); + changeColorSetPane.add(colorGradient = new FixedGradientBarNoTheme(4, 150), "gradient"); changeColorSetPane.add(colorAdjustPane = new ColorAdjustPane(), "acc"); cardLayout.show(changeColorSetPane, "acc"); customPane.add(changeColorSetPane, BorderLayout.CENTER); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java index 945d3bfdd3..6e44ad1963 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java @@ -3,6 +3,11 @@ */ package com.fr.design.designer.creator; +import com.fr.base.theme.FineColorManager; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeAware; +import com.fr.base.theme.TemplateThemeCompatible; import com.fr.design.ExtraDesignClassManager; import com.fr.design.designer.creator.cardlayout.XCardAddButton; import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; @@ -11,11 +16,15 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.ChartWidgetOptionProvider; import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.fun.ParameterWidgetOptionProvider; +import com.fr.design.mainframe.JTemplate; import com.fr.design.module.DesignModuleFactory; import com.fr.design.utils.gui.LayoutUtils; +import com.fr.form.main.Form; +import com.fr.form.main.WidgetGather; import com.fr.form.parameter.FormSubmitButton; import com.fr.form.ui.Button; import com.fr.form.ui.CardAddButton; @@ -216,6 +225,16 @@ public class XCreatorUtils { return xClazz; } + public static XCreator createThemedXCreator(Widget widget) { + XCreator creator = createXCreator(widget); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + TemplateTheme theme = template.getTemplateTheme(); + if (theme instanceof FormTheme) { + setupTemplateTheme(creator, (FormTheme) theme, TemplateThemeCompatible.NONE); + } + return creator; + } + /** * 创建creator * @@ -356,4 +375,21 @@ public class XCreatorUtils { } return null; } + + public static void setupTemplateTheme(XCreator container, final FormTheme currentTemplateUsingTheme, TemplateThemeCompatible compatible) { + FineColorManager.traverse(container.toData(), new FineColorManager.FineColorReplaceByTheme(currentTemplateUsingTheme, compatible)); + + Form.traversalWidget(container.toData(), new WidgetGather() { + @Override + public void dealWith(Widget widget) { + TemplateThemeAware themedWidget = (TemplateThemeAware) widget; + themedWidget.onTemplateUsingThemeChange(currentTemplateUsingTheme, compatible); + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }, TemplateThemeAware.class); + } } \ No newline at end of file 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 636f1f5489..cbe9e87e65 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 @@ -1195,9 +1195,6 @@ 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); @@ -1862,37 +1859,4 @@ 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(); - } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentCreator.java b/designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentCreator.java index b14229df67..126660665a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentCreator.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentCreator.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.share.generate.task; import com.fr.base.TableData; import com.fr.base.iofile.attr.ExtendSharableAttrMark; import com.fr.base.iofile.attr.SharableAttrMark; +import com.fr.base.theme.TemplateTheme; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.share.generate.impl.AbstractComponentCreatorProcessor; @@ -39,6 +40,8 @@ public class ComponentCreator extends AbstractComponentCreatorProcessor { @Override public ComponentReuBean create(JTemplate jt, Map paraMap, Widget widget, DefaultSharableWidget info) throws Exception { + // 适用于共享组件的模版主题 + setSuitableTemplateThemeName(jt, info); // 遍历判断是否存在共享组件 checkOriginStatus(widget, info); @@ -56,6 +59,13 @@ public class ComponentCreator extends AbstractComponentCreatorProcessor { return new ComponentReuBean(generatePath, editor, info); } + private void setSuitableTemplateThemeName(JTemplate jt, DefaultSharableWidget info) { + TemplateTheme theme = jt.getTemplateTheme(); + if (theme != null) { + info.setSuitableTemplateThemeName(theme.getName()); + } + } + protected void checkOriginStatus(Widget widget, final DefaultSharableWidget info) { Form.traversalWidget(widget, new WidgetGatherAdapter() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java index 911ff7b772..d927555021 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java @@ -211,7 +211,8 @@ public class LocalWidgetBlock extends PreviewWidgetBlock creatorSource.setWidgetID(UUID.randomUUID().toString()); ((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); //tab布局WCardMainBorderLayout通过反射出来的大小是960*480 - XCreator xCreator = ShareComponentUtils.createXCreator(creatorSource, shareId, no.getBindInfo()); + String suitableTemplateThemeName = no.getWidget().getSuitableTemplateThemeName(); + XCreator xCreator = ShareComponentUtils.createThemedXCreator(creatorSource, suitableTemplateThemeName, shareId, no.getBindInfo()); WidgetToolBarPane.getTarget().startDraggingBean(xCreator); lastPressEvent = null; this.setBorder(null); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java index b8cb0e6788..8ad419b038 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java @@ -12,6 +12,7 @@ import com.fr.design.login.DesignerLoginHelper; import com.fr.design.login.DesignerLoginSource; import com.fr.design.mainframe.WidgetToolBarPane; import com.fr.design.mainframe.share.collect.ComponentCollector; +import com.fr.form.share.DefaultSharableWidget; import com.fr.form.share.group.DefaultShareGroup; import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane; import com.fr.design.mainframe.share.ui.online.OnlineWidgetRepoPane; @@ -143,7 +144,13 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock { ((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); SharableWidgetProvider bindInfo = ShareUtils.getElCaseBindInfoById(shareId); //tab布局WCardMainBorderLayout通过反射出来的大小是960*480 - XCreator xCreator = ShareComponentUtils.createXCreator(creatorSource, shareId, bindInfo); + XCreator xCreator; + if (bindInfo instanceof DefaultSharableWidget) { + String suitableTemplateThemeName = ((DefaultSharableWidget) bindInfo).getSuitableTemplateThemeName(); + xCreator = ShareComponentUtils.createThemedXCreator(creatorSource, suitableTemplateThemeName, shareId, bindInfo); + } else { + xCreator = ShareComponentUtils.createXCreator(creatorSource, shareId, bindInfo); + } WidgetToolBarPane.getTarget().startDraggingBean(xCreator); lastPressEvent = null; this.setBorder(null); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java index 80162a4065..72418b86be 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java @@ -2,6 +2,9 @@ package com.fr.design.mainframe.share.util; import com.fr.base.io.IOFile; import com.fr.base.iofile.attr.ExtendSharableAttrMark; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeCompatible; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; @@ -50,6 +53,19 @@ public class ShareComponentUtils { return xCreator; } + public static XCreator createThemedXCreator(Widget creatorSource, String suitableTemplateThemeName, String shareId, SharableWidgetProvider provider) { + XCreator creator = createXCreator(creatorSource, shareId, provider); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + TemplateTheme theme = template.getTemplateTheme(); + if (theme instanceof FormTheme) { + boolean isCurrentUsingThemeSuitSharedComponent = StringUtils.isNotEmpty(theme.getName()) && + StringUtils.isNotEmpty(suitableTemplateThemeName) && + StringUtils.equals(theme.getName(), suitableTemplateThemeName); + XCreatorUtils.setupTemplateTheme(creator, (FormTheme) theme, isCurrentUsingThemeSuitSharedComponent ? TemplateThemeCompatible.NONE : TemplateThemeCompatible.ABSENT); + } + return creator; + } + /** * 检查readme.txt文件 */ diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java index 67fcaae594..58292bbf2b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java @@ -13,6 +13,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.theme.utils.DefaultThemedFloatElement; import com.fr.design.menu.MenuKeySet; import com.fr.design.module.DesignModuleFactory; import com.fr.grid.Grid; @@ -90,7 +91,7 @@ public class ChartFloatAction extends ElementCaseAction { public void doOk() { isRecordNeeded = true; FloatElement newFloatElement; - newFloatElement = new FloatElement(chartDialog.getChartCollection()); + newFloatElement = DefaultThemedFloatElement.createInstance(chartDialog.getChartCollection()); newFloatElement.setWidth(new OLDPIX(BaseChartCollection.CHART_DEFAULT_WIDTH)); newFloatElement.setHeight(new OLDPIX(BaseChartCollection.CHART_DEFAULT_HEIGHT)); diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/FormulaFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/FormulaFloatAction.java index 9cbd7e8760..dbd9d4be6e 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/FormulaFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/FormulaFloatAction.java @@ -14,6 +14,7 @@ import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.theme.utils.DefaultThemedFloatElement; import com.fr.design.menu.MenuKeySet; import com.fr.grid.Grid; @@ -99,7 +100,7 @@ public class FormulaFloatAction extends ElementCaseAction { } reportPane.stopEditing(); - final FloatElement floatElement = new FloatElement(); + final FloatElement floatElement = DefaultThemedFloatElement.createInstance(); final UIFormula formulaPane = FormulaFactory.createFormulaPane(); formulaPane.populate(BaseFormula.createFormulaBuilder().build()); diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java index e514c88dfb..7eb9146ea5 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java @@ -12,6 +12,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.theme.utils.DefaultThemedFloatElement; import com.fr.design.menu.MenuKeySet; import com.fr.design.report.SelectImagePane; @@ -73,7 +74,7 @@ public class ImageFloatAction extends ElementCaseAction { reportPane.stopEditing(); - final FloatElement floatElement = new FloatElement(); + final FloatElement floatElement = DefaultThemedFloatElement.createInstance(); final SelectImagePane selectImagePane = new SelectImagePane(); selectImagePane.populate(floatElement); diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/TextBoxFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/TextBoxFloatAction.java index 82aa17f2d9..26aad41e23 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/TextBoxFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/TextBoxFloatAction.java @@ -6,6 +6,7 @@ package com.fr.design.actions.insert.flot; import com.fr.base.DynamicUnitList; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.theme.utils.DefaultThemedFloatElement; import com.fr.design.menu.MenuKeySet; import com.fr.grid.Grid; @@ -59,7 +60,7 @@ public class TextBoxFloatAction extends AbstractShapeAction { if (jws == null) { return; } - FloatElement floatElement = new FloatElement("Text"); + FloatElement floatElement = DefaultThemedFloatElement.createInstance("Text"); this.startDraw(floatElement); doWithDrawingFloatElement(); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java index f28e2c9840..286890303e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java @@ -21,6 +21,8 @@ import com.fr.form.main.Form; import com.fr.form.ui.container.WBorderLayout; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.report.util.ReadXmlType; +import com.fr.report.util.ReadXmlTypeLocalManager; import com.fr.stable.Constants; import com.fr.stable.bridge.StableFactory; import org.jetbrains.annotations.Nullable; @@ -90,13 +92,16 @@ class FormApp extends AbstractAppProvider { @Nullable private Form getForm(FILE tplFile) { + ReadXmlTypeLocalManager.setReadXmlType(ReadXmlType.DESIGN); Form form = asIOFile(tplFile); + ReadXmlTypeLocalManager.remove(); if (form != null) { DesignerAppUtils.dealWithTemplateIOError(tplFile.getPath()); } return form; } + @Override public Form asIOFile(FILE file) {