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 7d1461bf37..a76d92913c 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 @@ -201,7 +201,7 @@ public abstract class JTemplate> } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing() && !DesignModeContext.isDuchampMode()) { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); } - this.template = t; + this.template = getTarget(); this.previewType = parserPreviewProvider(t.getPreviewType()); this.editingFILE = file; this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -213,10 +213,6 @@ public abstract class JTemplate> } addCenterPane(); isNewCreateTpl = isNewFile; - if (isNewCreateTpl) { - // REPORT-58486: 必须在初始的UndoState创建前设置主题,使得初始的UndoState就包含了主题效果 - setUpTheme4NewTemplate(); - } this.undoState = createUndoState(); initAndStartPlugin(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java index 310a051a4e..15895c06a8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java @@ -39,11 +39,7 @@ public final class JTemplateFactory { String[] defaultAppExtensions = app.defaultExtensions(); for (String defaultAppExtension : defaultAppExtensions) { if (defaultAppExtension.equalsIgnoreCase(fileExtension)) { - JTemplate jt = app.openTemplate(file); - if (jt != null) { - jt.checkAndResetTheme(); - return jt; - } + return app.openTemplate(file); } } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/AuthorityTargetObjectCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/AuthorityTargetObjectCollector.java new file mode 100644 index 0000000000..9972c7be37 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/AuthorityTargetObjectCollector.java @@ -0,0 +1,37 @@ +package com.fr.design.mainframe.authority; + +import com.fr.base.CloneCollector; +import com.fr.base.Formula; +import com.fr.data.impl.NameDatabaseConnection; +import com.fr.data.impl.NameTableData; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.stable.FCloneable; + + +import java.util.ArrayList; +import java.util.List; + +public class AuthorityTargetObjectCollector extends CloneCollector { + List targetObject = new ArrayList<>(); + + public AuthorityTargetObjectCollector(FCloneable rootObject) { + super(rootObject); + } + + @Override + public void collect(Object object) { + if (object instanceof DSColumn || object instanceof Formula + || object instanceof NameDatabaseConnection || object instanceof NameTableData) { + targetObject.add(object); + } + } + + public List collectTargetObject() { + CloneCollector.setCollector(this); + this.targetObject = new ArrayList<>(); + this.collect(); + CloneCollector.clearCollector(); + return targetObject; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java index d76031f654..b33f0665c9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java @@ -1,24 +1,24 @@ package com.fr.design.mainframe.authority; +import com.fr.base.CloneCollector; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; -import com.fr.design.mod.ModClassFilter; import com.fr.file.ConnectionConfig; import com.fr.file.TableDataConfig; -import com.fr.invoke.ClassHelper; import com.fr.log.FineLoggerFactory; -import com.fr.stable.Filter; import com.fr.workspace.WorkContext; import com.fr.workspace.server.authority.user.UserAuthority; -import java.util.Collection; + +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -77,24 +77,21 @@ public class JTemplateAuthorityChecker { public boolean isAuthority() { long s = System.currentTimeMillis(); - //遍历模板对象,根据checkerMap.keySet()把感兴趣的对象找出来 - Map> targetObjects = ClassHelper.searchObject(jTemplate.getTarget(), checkerMap.keySet(), ClassFilter.getInstance()); - + List targetObjects = getTargetObjects(); //找到对应的checker,对对象进行检查 - for (String name : targetObjects.keySet()) { + for (Object targetObject : targetObjects) { + String name = targetObject.getClass().getName(); ElementAuthorityChecker checker = checkerMap.get(name); - for (Object object : targetObjects.get(name)) { - if (authConnectionNames != null) { - Set noAuthName = checker.getNoAuthConnectionNames(object, authConnectionNames); - if (noAuthName != null) { - authFailConnectionNames.addAll(noAuthName); - } + if (authConnectionNames != null) { + Set noAuthName = checker.getNoAuthConnectionNames(targetObject, authConnectionNames); + if (noAuthName != null) { + authFailConnectionNames.addAll(noAuthName); } - if (authDatasetNames != null) { - Set noAuthName = checker.getNoAuthDatasetNames(object, authDatasetNames); - if (noAuthName != null) { - authFailDatasetNames.addAll(noAuthName); - } + } + if (authDatasetNames != null) { + Set noAuthName = checker.getNoAuthDatasetNames(targetObject, authDatasetNames); + if (noAuthName != null) { + authFailDatasetNames.addAll(noAuthName); } } } @@ -104,6 +101,18 @@ public class JTemplateAuthorityChecker { return authFailConnectionNames.size() == 0 && authFailDatasetNames.size() == 0; } + private List getTargetObjects() { + List targetObjects = new ArrayList<>(); + try { + AuthorityTargetObjectCollector authorityTargetObjectCollector + = new AuthorityTargetObjectCollector(jTemplate.getTarget()); + targetObjects = authorityTargetObjectCollector.collectTargetObject(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + return targetObjects; + } + public void showAuthorityFailPromptDialog() { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append(Toolkit.i18nText("Fine-Design-Basic_Save_Failure")); @@ -151,38 +160,5 @@ public class JTemplateAuthorityChecker { return stringBuffer.toString(); } - static class ClassFilter implements Filter { - - private static final Set FILTER_SET = new HashSet<>(); - private static final Set START_WITH_SET = new HashSet<>(); - private static final Filter INSTANCE = new ModClassFilter(); - - public static Filter getInstance() { - return INSTANCE; - } - - static { - FILTER_SET.add("java.awt.image.BufferedImage"); - FILTER_SET.add("sun.awt.AppContext"); - FILTER_SET.add("com.fr.poly.creator.ECBlockCreator"); - FILTER_SET.add("io.netty.channel.nio.SelectedSelectionKeySet"); - FILTER_SET.add("com.fr.form.ui.ElementCaseImage"); - FILTER_SET.add("this$0"); - START_WITH_SET.add("com.fr.design"); - } - - @Override - public boolean accept(String s) { - if (FILTER_SET.contains(s)) { - return true; - } - for (String start : START_WITH_SET) { - if (s.startsWith(start)) { - return true; - } - } - return false; - } - } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 0f5b903078..831d245d1a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -664,6 +664,7 @@ public class JForm extends JTemplate implements BaseJForm { try { WorkBook undoWorkBook = (WorkBook) u.getWorkBook().clone(); undoWorkBook.checkAndResetTheme(); + undoWorkBook = (WorkBook) FineColorSynchronizer.flush(undoWorkBook, undoWorkBook.getTemplateTheme()); this.setTarget(undoWorkBook); if (!DesignerMode.isAuthorityEditing()) { if (u.getAuthorityType() != BaseUndoState.NORMAL_STATE) {