From dfb4108c7e8ebf6f765aba5cc3fac0806b70f785 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 20 Jun 2022 15:35:35 +0800 Subject: [PATCH 1/3] =?UTF-8?q?KERNEL-11531=20=E6=95=B0=E6=8D=AE=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E8=B6=8A=E6=9D=83=E6=BC=8F=E6=B4=9E=E8=B0=83=E7=94=A8?= =?UTF-8?q?com.fr.invoke.ClassHelper=E4=B8=AD=E9=81=8D=E5=8E=86=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=AF=B9=E8=B1=A1=E5=AD=98=E5=9C=A8=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=95=88=E7=8E=87=E9=97=AE=E9=A2=98=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=AE=95=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthorityTargetObjectCollector.java | 21 +++++ .../authority/JTemplateAuthorityChecker.java | 80 +++++++------------ 2 files changed, 49 insertions(+), 52 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/authority/AuthorityTargetObjectCollector.java 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..8fb5911db9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/AuthorityTargetObjectCollector.java @@ -0,0 +1,21 @@ +package com.fr.design.mainframe.authority; + +import com.fr.base.CloneCollector; + + +import java.util.ArrayList; +import java.util.List; + +public class AuthorityTargetObjectCollector extends CloneCollector { + List targetObject = new ArrayList<>(); + + @Override + public void collect(Object object) { + targetObject.add(object); + } + + public List getTargetObject() { + 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..59257c6c96 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,23 @@ 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.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -77,24 +76,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 +100,19 @@ public class JTemplateAuthorityChecker { return authFailConnectionNames.size() == 0 && authFailDatasetNames.size() == 0; } + private List getTargetObjects() { + AuthorityTargetObjectCollector authorityTargetObjectCollector = new AuthorityTargetObjectCollector(); + CloneCollector.setCollector(authorityTargetObjectCollector); + try { + jTemplate.getTarget().clone(); + } catch (Exception ignore) { + + } + List targetObjects = authorityTargetObjectCollector.getTargetObject(); + CloneCollector.clearCollector(); + 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; - } - } } From 3d43b762187584ad75dc642ec460226d57fbf65f Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 21 Jun 2022 11:51:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?KERNEL-11531=20=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=8B=E8=AE=BE=E8=AE=A1=EF=BC=8CColoneCollector=E4=B8=AD?= =?UTF-8?q?=E8=A7=A6=E5=8F=91clone()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthorityTargetObjectCollector.java | 22 ++++++++++++++++--- .../authority/JTemplateAuthorityChecker.java | 14 ++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) 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 index 8fb5911db9..9972c7be37 100644 --- 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 @@ -1,6 +1,11 @@ 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; @@ -9,13 +14,24 @@ 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) { - targetObject.add(object); + if (object instanceof DSColumn || object instanceof Formula + || object instanceof NameDatabaseConnection || object instanceof NameTableData) { + targetObject.add(object); + } } - public List getTargetObject() { + 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 59257c6c96..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 @@ -15,6 +15,7 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.server.authority.user.UserAuthority; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -101,15 +102,14 @@ public class JTemplateAuthorityChecker { } private List getTargetObjects() { - AuthorityTargetObjectCollector authorityTargetObjectCollector = new AuthorityTargetObjectCollector(); - CloneCollector.setCollector(authorityTargetObjectCollector); + List targetObjects = new ArrayList<>(); try { - jTemplate.getTarget().clone(); - } catch (Exception ignore) { - + AuthorityTargetObjectCollector authorityTargetObjectCollector + = new AuthorityTargetObjectCollector(jTemplate.getTarget()); + targetObjects = authorityTargetObjectCollector.collectTargetObject(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); } - List targetObjects = authorityTargetObjectCollector.getTargetObject(); - CloneCollector.clearCollector(); return targetObjects; } From b93c4902292765fa9ce9e4ecfb0980919f1c5230 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 21 Jun 2022 12:00:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-73996-=E6=96=B0=E5=BB=BAfrm=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E7=A9=BA=E7=99=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 重复创建新Form、WorkBook对象,导致显示和保存用的对象是不同的 2. 代码合并问题导致JTemplate中checkAndResetTheme未能删除 3. 修复undo没有同步主题色的问题 【改动思路】 同上 --- .../src/main/java/com/fr/design/mainframe/JTemplate.java | 6 +----- .../main/java/com/fr/design/mainframe/JTemplateFactory.java | 6 +----- .../src/main/java/com/fr/design/mainframe/JForm.java | 1 + .../src/main/java/com/fr/design/mainframe/JWorkBook.java | 1 + 4 files changed, 4 insertions(+), 10 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 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-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) {