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 b0628efb4..d27407e62 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 @@ -52,7 +52,7 @@ import com.fr.design.menu.NameSeparator; import com.fr.design.menu.ShortCut; import com.fr.design.preview.PagePreview; import com.fr.design.ui.util.UIUtil; -import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.PredefinedStyleUtils; import com.fr.design.write.submit.DBManipulationInWidgetEventPane; import com.fr.design.write.submit.DBManipulationPane; import com.fr.file.FILE; @@ -160,10 +160,10 @@ public abstract class JTemplate> setPredefinedInfo(isNewFile); } - private void setPredefinedInfo(boolean isNewFile){ + private void setPredefinedInfo(boolean isNewFile) { if (this.template.getAttrMark(PredefinedStyleAttrMark.XML_TAG) == null) { - PredefinedStyleAttrMark attrMark = PredefinedStyleAttrMark.createDefaultStyleMark(); - if (!isNewFile || !DesignUtils.isDesignerEnvMatch()) { + PredefinedStyleAttrMark attrMark = PredefinedStyleAttrMark.createDefaultStyleMark(); + if (!isNewFile || !PredefinedStyleUtils.isAllowPredefinedSetting()) { attrMark.setPreferenceStyleName(InterProviderFactory.getProvider().getLocText("Fine-Engine_Predefined_Style_Compatibility")); } this.template.addAttrMark(attrMark); @@ -1362,7 +1362,7 @@ public abstract class JTemplate> } }); - preferenceButton.setEnabled(DesignUtils.isDesignerEnvMatch()); + preferenceButton.setEnabled(PredefinedStyleUtils.isAllowPredefinedSetting()); return preferenceButton; } diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index ca87bb336..3eba512a4 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -63,21 +63,6 @@ public class DesignUtils { private static boolean started = false; - /** - * 设计器和工作目录环境版本是否匹配标志 - */ - private static boolean designerEnvMatch = true; - - - static { - GeneralContext.addEnvChangedListener(new EnvChangedListener() { - @Override - public void envChanged() { - designerEnvMatch = checkDesignerEnvMatch(); - } - }); - } - private DesignUtils() { } @@ -90,10 +75,6 @@ public class DesignUtils { return port; } - public static boolean isDesignerEnvMatch() { - return designerEnvMatch; - } - /** * 判断设计器有没有启动 * @@ -439,17 +420,4 @@ public class DesignUtils { return true; } - - public static boolean checkDesignerEnvMatch() { - if (WorkContext.getCurrent().isLocal()) { - return true; - } - return WorkContext.getCurrent().get(PredefinedStyleOperator.class, new ExceptionHandler() { - @Override - public Object callHandler(RPCInvokerExceptionInfo exceptionInfo) { - FineLoggerFactory.getLogger().error(exceptionInfo.getException().getMessage(), exceptionInfo.getException()); - return false; - } - }).allowPredefinedSetting(); - } } diff --git a/designer-base/src/main/java/com/fr/design/utils/PredefinedStyleUtils.java b/designer-base/src/main/java/com/fr/design/utils/PredefinedStyleUtils.java new file mode 100644 index 000000000..7d3429d01 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/utils/PredefinedStyleUtils.java @@ -0,0 +1,56 @@ +package com.fr.design.utils; + +import com.fr.general.GeneralContext; +import com.fr.log.FineLoggerFactory; +import com.fr.rpc.ExceptionHandler; +import com.fr.rpc.RPCInvokerExceptionInfo; +import com.fr.stable.EnvChangedListener; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.predefined.PredefinedStyleOperator; + +/** + * Created by kerry on 2020-11-06 + */ +public class PredefinedStyleUtils { + /** + * 判断当前环境是否支持预定义样式的设置 + */ + private static Boolean allowPredefinedSetting = null; + + static { + GeneralContext.addEnvChangedListener(new EnvChangedListener() { + @Override + public void envChanged() { + allowPredefinedSetting = checkAllowPredefinedSetting(); + } + }); + } + + /** + * 判断当前环境是否支持预定义样式的设置 + * @return boolean + */ + public synchronized static boolean isAllowPredefinedSetting() { + if (allowPredefinedSetting == null) { + allowPredefinedSetting = checkAllowPredefinedSetting(); + } + return allowPredefinedSetting; + } + + private PredefinedStyleUtils() { + + } + + private static boolean checkAllowPredefinedSetting() { + if (WorkContext.getCurrent().isLocal()) { + return true; + } + return WorkContext.getCurrent().get(PredefinedStyleOperator.class, new ExceptionHandler() { + @Override + public Object callHandler(RPCInvokerExceptionInfo exceptionInfo) { + FineLoggerFactory.getLogger().error(exceptionInfo.getException().getMessage(), exceptionInfo.getException()); + return false; + } + }).allowPredefinedSetting(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/server/predefined/ServerPredefinedStyleAction.java b/designer-realize/src/main/java/com/fr/design/actions/server/predefined/ServerPredefinedStyleAction.java index e0d4b06d1..246b194b7 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/server/predefined/ServerPredefinedStyleAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/server/predefined/ServerPredefinedStyleAction.java @@ -7,7 +7,7 @@ import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.SnapChatUpdateAction; import com.fr.design.notification.SnapChatKey; -import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.PredefinedStyleUtils; import com.fr.general.IOUtils; import javax.swing.KeyStroke; @@ -21,7 +21,7 @@ public class ServerPredefinedStyleAction extends SnapChatUpdateAction { public ServerPredefinedStyleAction(SnapChatKey uniqueKey) { super(uniqueKey); - this.setEnabled(DesignUtils.isDesignerEnvMatch()); + this.setEnabled(PredefinedStyleUtils.isAllowPredefinedSetting()); this.setMenuKeySet(PREDEFINED_STYLES); this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java index 98311cd99..95645acaf 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java @@ -54,7 +54,7 @@ public class CellStylePane extends AbstractCellAttrPane { @Override public void updateBeans() { - Style s = stylePane.updateStyle(); + Style style = stylePane.updateStyle(); TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); int cellRectangleCount = cs.getCellRectangleCount(); for (int rect = 0; rect < cellRectangleCount; rect++) { @@ -68,11 +68,13 @@ public class CellStylePane extends AbstractCellAttrPane { cellElement = new DefaultPredefinedTemplateCellElement(column, row); elementCase.addCellElement(cellElement); } - cellElement.setStyle(s); + cellElement.setStyle(style); } } } + if (!(style instanceof NameStyle)) { stylePane.updateBorder();// border必须特别处理 + } } @Override diff --git a/designer-realize/src/main/java/com/fr/design/style/BorderUtils.java b/designer-realize/src/main/java/com/fr/design/style/BorderUtils.java index 3a7142b4e..176421999 100644 --- a/designer-realize/src/main/java/com/fr/design/style/BorderUtils.java +++ b/designer-realize/src/main/java/com/fr/design/style/BorderUtils.java @@ -517,9 +517,6 @@ public abstract class BorderUtils { report.addCellElement(tmpCellElement); } Style style = tmpCellElement.getStyle(); - if (style instanceof NameStyle && ((NameStyle) style).usePredefinedStyle()) { - continue; - } style = inspectStyle(row, column, rowSpan, columnSpan, cellBorderStyle, newCellBorderStyle, tmpCellElement, style); tmpCellElement.setStyle(style); } diff --git a/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java b/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java index d12920bfd..cf5d87708 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java @@ -8,6 +8,7 @@ import com.fr.base.Margin; import com.fr.base.PaperSize; import com.fr.base.ScreenResolution; import com.fr.base.iofile.attr.WatermarkAttr; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.utils.ComponentUtils; import com.fr.general.Background; @@ -82,6 +83,7 @@ public class PolyDesignUI extends ComponentUI { g2d.setPaint(Color.WHITE); GraphHelper.fillRect(g, 0, 0, d.width, d.height); ReportSettingsProvider rs = report.getReportSettings(); + rs.getNameBackground().resetPreferenceStyle(getGlobalPredefinedStyleName()); if (rs != null) { Background bg = rs.getBackground(); if (bg != null) { @@ -91,6 +93,10 @@ public class PolyDesignUI extends ComponentUI { } } + private String getGlobalPredefinedStyleName() { + return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle(); + } + @Override public void paint(Graphics g, JComponent c) { this.resolution = ((PolyArea)c).getResolution();