From a93d34c3782ec48493f2722016108de31c6609d5 Mon Sep 17 00:00:00 2001 From: obo Date: Wed, 12 Apr 2023 16:17:31 +0800 Subject: [PATCH 01/59] =?UTF-8?q?REPORT-91074=20=E3=80=90=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E3=80=91=E8=B6=85=E9=93=BE=E6=8E=A5=E5=8C=BA?= =?UTF-8?q?=E5=88=86=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/community/BBSAction.java | 16 +++- .../design/actions/community/BugAction.java | 16 +++- .../actions/community/CenterAction.java | 15 ++- .../actions/community/CusDemandAction.java | 18 +++- .../actions/community/FacebookFansAction.java | 16 +++- .../design/actions/community/NeedAction.java | 16 +++- .../actions/community/QuestionAction.java | 16 +++- .../design/actions/community/SignAction.java | 17 +++- .../actions/community/StudyPlanAction.java | 15 ++- .../actions/community/TechSolutionAction.java | 15 ++- .../community/TemplateStoreAction.java | 19 ++-- .../fr/design/actions/community/UpAction.java | 14 ++- .../community/WorkOrderCenterAction.java | 15 ++- .../design/actions/help/TutorialAction.java | 14 ++- .../data/datapane/ESDStrategyConfigPane.java | 16 +++- .../preview/sql/PreviewPerformedSqlPane.java | 14 ++- .../callback/handle/PluginCallBackHelper.java | 15 ++- .../style/TranslucentBorderSpecialPane.java | 16 +++- .../com/fr/design/i18n/LocaleLinkFactory.java | 94 +++++++++++++++++++ .../JSContentWithDescriptionPane.java | 53 ++++++----- .../design/locale/impl/BbsRegisterMark.java | 32 +++---- .../fr/design/locale/impl/BbsResetMark.java | 34 +++---- .../fr/design/locale/impl/BbsSpaceMark.java | 34 +++---- .../fr/design/login/DesignerLoginBridge.java | 20 +++- .../mainframe/check/CheckFontInfoDialog.java | 16 +++- .../update/actions/NewFeatureAction.java | 20 ++-- .../com/fr/env/RemoteDesignLocaleMark.java | 28 +++--- .../com/fr/env/SyncFailedPluginsDialog.java | 31 ++++-- .../fr/env/detect/base/DetectorConstants.java | 26 ++++- .../share/ui/actions/Jump2DetailAction.java | 21 +++-- .../share/ui/online/OnlineWidgetRepoPane.java | 20 ++-- .../replace/ui/ITReplaceWestPanel.java | 14 ++- .../mainframe/socketio/DesignerSocketIO.java | 14 ++- .../fr/design/report/ExportUniversalPane.java | 14 ++- 34 files changed, 553 insertions(+), 201 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/i18n/LocaleLinkFactory.java diff --git a/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java b/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java index 1acbbe4170..d93e7ff244 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java @@ -1,14 +1,22 @@ package com.fr.design.actions.community; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; -import com.fr.general.CloudCenter; - -import javax.swing.*; +import javax.swing.KeyStroke; public class BBSAction extends AbstractDesignerSSO { + /** + * 云中心帆软社区页在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Bbs"; + + /** + * 云中心帆软社区页默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Bbs_Default"; public BBSAction() { this.setMenuKeySet(BBS); @@ -20,7 +28,7 @@ public class BBSAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs", "http://bbs.fanruan.com/"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); } public static final MenuKeySet BBS = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java b/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java index 5365e556b6..ac732b9481 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java @@ -1,13 +1,23 @@ package com.fr.design.actions.community; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; -import com.fr.general.CloudCenter; -import javax.swing.*; +import javax.swing.KeyStroke; public class BugAction extends AbstractDesignerSSO { + /** + * 云中心产品反馈页在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Bugs"; + + /** + * 云中心产品反馈页默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Bugs_Default"; + public BugAction() { this.setMenuKeySet(BUG); this.setName(getMenuKeySet().getMenuName()); @@ -17,7 +27,7 @@ public class BugAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.bugs", "https://service.fanruan.com/PF/FR/feedback?type=2"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); } public static final MenuKeySet BUG = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java b/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java index 6ae03f1a8a..35affba875 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java @@ -1,7 +1,7 @@ package com.fr.design.actions.community; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.menu.MenuKeySet; -import com.fr.general.CloudCenter; import javax.swing.KeyStroke; @@ -9,6 +9,17 @@ import javax.swing.KeyStroke; * Created by XINZAI on 2018/8/23. */ public class CenterAction extends UpAction { + + /** + * 云中心活动中心页在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Act_Center"; + + /** + * 云中心活动中心页默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Act_Center_Default"; + public CenterAction() { this.setMenuKeySet(CENTER); this.setName(getMenuKeySet().getMenuName()); @@ -18,7 +29,7 @@ public class CenterAction extends UpAction { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.center", "http://bbs.fanruan.com/events/"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); } public static final MenuKeySet CENTER = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java b/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java index 007eeb9abf..6cf96dbae9 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java @@ -1,18 +1,28 @@ package com.fr.design.actions.community; import com.fr.base.BaseUtils; - +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; -import com.fr.general.CloudCenter; -import javax.swing.KeyStroke; +import javax.swing.KeyStroke; import java.awt.event.ActionEvent; /** * Created by XINZAI on 2018/8/23. */ public class CusDemandAction extends UpAction{ + + /** + * 云中心发布需求页在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Demand"; + + /** + * 云中心发布需求页默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Demand_Default"; + public CusDemandAction() { this.setMenuKeySet(DEMAND); @@ -25,7 +35,7 @@ public class CusDemandAction extends UpAction{ @Override public void actionPerformed(ActionEvent arg0) { - String url = CloudCenter.getInstance().acquireUrlByKind("bbs.demand", "https://market.fanruan.com/demand"); + String url = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); BrowseUtils.browser(url); } diff --git a/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java b/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java index e5ff4dd472..179330d299 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java @@ -1,14 +1,24 @@ package com.fr.design.actions.community; -import com.fr.base.svg.IconUtils; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; -import com.fr.general.CloudCenter; + import javax.swing.KeyStroke; import java.awt.event.ActionEvent; public class FacebookFansAction extends UpAction { + /** + * 云中心facebook页在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_FaceBook"; + + /** + * 云中心facebook页默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_FaceBook_Default"; + public FacebookFansAction() { this.setMenuKeySet(FACEBOOKFANS); this.setName(getMenuKeySet().getMenuName()); @@ -18,7 +28,7 @@ public class FacebookFansAction extends UpAction { @Override public void actionPerformed(ActionEvent arg0) { - BrowseUtils.browser(CloudCenter.getInstance().acquireUrlByKind("facebook.fans.tw", "https://www.facebook.com/twfinereport")); + BrowseUtils.browser(LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink()); } public static final MenuKeySet FACEBOOKFANS = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java b/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java index 62d4b9c95f..0116db84bd 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java @@ -1,13 +1,23 @@ package com.fr.design.actions.community; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; -import com.fr.general.CloudCenter; -import javax.swing.*; +import javax.swing.KeyStroke; public class NeedAction extends AbstractDesignerSSO { + /** + * 云中心产品反馈页在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Need"; + + /** + * 云中心产品反馈页默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Need_Default"; + public NeedAction() { this.setMenuKeySet(NEED); this.setName(getMenuKeySet().getMenuName()); @@ -18,7 +28,7 @@ public class NeedAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.needs", "https://service.fanruan.com/PF/FR/feedback?type=1"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); } public static final MenuKeySet NEED = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java b/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java index 5b44112254..fea2df3037 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java @@ -1,13 +1,23 @@ package com.fr.design.actions.community; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; -import com.fr.general.CloudCenter; -import javax.swing.*; +import javax.swing.KeyStroke; public class QuestionAction extends AbstractDesignerSSO { + /** + * 云中心问答页在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Question"; + + /** + * 云中心问答页默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Question_Default"; + public QuestionAction() { this.setMenuKeySet(QUESTIONS); this.setName(getMenuKeySet().getMenuName()); @@ -18,7 +28,7 @@ public class QuestionAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.questions", "http://bbs.fanruan.com/wenda"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); } public static final MenuKeySet QUESTIONS = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java b/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java index 8c29ee5e66..3b785ff43b 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java @@ -1,14 +1,23 @@ package com.fr.design.actions.community; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; -import com.fr.general.CloudCenter; - -import javax.swing.*; +import javax.swing.KeyStroke; public class SignAction extends AbstractDesignerSSO { + /** + * 云中心认证落地页在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Aut"; + + /** + * 云中心认证落地页默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Aut_Default"; + public SignAction() { this.setMenuKeySet(SIGN); this.setName(getMenuKeySet().getMenuName()); @@ -18,7 +27,7 @@ public class SignAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.aut", "https://bbs.fanruan.com/certification/"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); } public static final MenuKeySet SIGN = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java b/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java index d0dcc4195d..757abd8ea8 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java @@ -1,10 +1,21 @@ package com.fr.design.actions.community; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.login.AbstractDesignerSSO; -import com.fr.general.CloudCenter; public class StudyPlanAction extends AbstractDesignerSSO { + + /** + * 云中心帆软学院在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Study"; + + /** + * 云中心帆软学院默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Study_Default"; + public StudyPlanAction() { this.setName(Toolkit.i18nText("Fine-Design_Study_Plan")); this.setSmallIcon("/com/fr/design/images/bbs/studyPlan"); @@ -12,6 +23,6 @@ public class StudyPlanAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.studyPlan", "https://edu.fanruan.com/studypath/finereport"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); } } diff --git a/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java b/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java index 8975555780..7ab6ece6e2 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java @@ -1,8 +1,8 @@ package com.fr.design.actions.community; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; -import com.fr.general.CloudCenter; import javax.swing.KeyStroke; @@ -10,6 +10,17 @@ import javax.swing.KeyStroke; * Created by XINZAI on 2018/8/23. */ public class TechSolutionAction extends AbstractDesignerSSO { + + /** + * 云中心社区在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Community"; + + /** + * 云中心社区默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Community_Default"; + public TechSolutionAction() { this.setMenuKeySet(TSO); this.setName(getMenuKeySet().getMenuName()); @@ -20,7 +31,7 @@ public class TechSolutionAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.solution", "http://bbs.fanruan.com/forum-113-1.html"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); } public static final MenuKeySet TSO = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java b/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java index eec904ebd6..b07c2fb3a7 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java @@ -1,21 +1,28 @@ package com.fr.design.actions.community; import com.fr.base.BaseUtils; -import com.fr.design.actions.UpdateAction; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.menu.MenuKeySet; -import com.fr.design.utils.BrowseUtils; -import com.fr.general.CloudCenter; import javax.swing.KeyStroke; -import java.awt.event.ActionEvent; /** * created by Harrison on 2020/03/24 **/ public class TemplateStoreAction extends AbstractDesignerSSO { - + + /** + * 云中心组件商城模板在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Market_Template"; + + /** + * 云中心组件商城模板默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Template_Default"; + public TemplateStoreAction() { this.setMenuKeySet(TEMPLATE); @@ -47,6 +54,6 @@ public class TemplateStoreAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { ComponentCollector.getInstance().collectTepMenuEnterClick(); - return CloudCenter.getInstance().acquireUrlByKind("design.market.template", "https://market.fanruan.com/template"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); } } diff --git a/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java b/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java index 05022ecf8c..6881019b2d 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java @@ -1,14 +1,24 @@ package com.fr.design.actions.community; import com.fr.base.BaseUtils; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; -import com.fr.general.CloudCenter; import javax.swing.KeyStroke; public class UpAction extends AbstractDesignerSSO { + /** + * 云中心工单中心在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Bbs_Update"; + + /** + * 云中心工单中心默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Bbs_Update_Default"; + public UpAction() { this.setMenuKeySet(UPDATE); this.setName(getMenuKeySet().getMenuName()); @@ -18,7 +28,7 @@ public class UpAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.update", "http://bbs.fanruan.com/forum.php?mod=collection&action=view&ctid=10"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); } public static final MenuKeySet UPDATE = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java b/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java index d1168eca70..4d6508cea9 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java @@ -1,7 +1,7 @@ package com.fr.design.actions.community; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; -import com.fr.general.CloudCenter; /** * @Description 工单中心 @@ -9,6 +9,17 @@ import com.fr.general.CloudCenter; * @Date 2021/3/8 14:02 **/ public class WorkOrderCenterAction extends UpAction { + + /** + * 云中心工单中心在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Work_Order_Center"; + + /** + * 云中心工单中心默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Work_Order_Center_Default"; + public WorkOrderCenterAction() { this.setSmallIcon("/com/fr/design/images/bbs/workOrderCenter"); this.setName(Toolkit.i18nText("Fine-Design_Basic_Commuinity_Work_Order_Center")); @@ -16,6 +27,6 @@ public class WorkOrderCenterAction extends UpAction { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.work.order.center", "https://service.fanruan.com/ticket"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java index 51a390c82d..4f215abc08 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java @@ -1,9 +1,9 @@ package com.fr.design.actions.help; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; -import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; import com.fr.general.http.HttpToolbox; import com.fr.stable.CommonUtils; @@ -18,6 +18,16 @@ import java.awt.event.KeyEvent; public class TutorialAction extends AbstractDesignerSSO { + /** + * 云中心社区帮助文档在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Help"; + + /** + * 云中心社区帮助文档默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Help_Default"; + public TutorialAction() { this.setMenuKeySet(HELP_TUTORIAL); this.setName(getMenuKeySet().getMenuName()); @@ -28,7 +38,7 @@ public class TutorialAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind(createDocKey(), "http://help.finereport.com"); + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); } // 生成帮助文档 sitecenter key, help.zh_CN.10 diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java index f3df21df9c..5643086ecc 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java @@ -6,6 +6,7 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.esd.common.CacheConstants; @@ -29,8 +30,8 @@ import java.net.URI; import java.text.ParseException; import java.util.ArrayList; import java.util.Collections; -import java.util.List; import java.util.Date; +import java.util.List; /** * @author rinoux @@ -38,7 +39,18 @@ import java.util.Date; * Created by rinoux on 2020/7/22 */ public class ESDStrategyConfigPane extends BasicBeanPane { - private static final String CRON_HELP_URL = "http://help.fanruan.com/finereport/doc-view-693.html"; + + /** + * 云中心定时调度执行频率表达式设定帮助文档链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Cron_Help"; + + /** + * 云中心定时调度执行频率表达式设定帮助文档默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Cron_Help_Default"; + + private static final String CRON_HELP_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); private UIRadioButton selectAutoUpdate; private UIRadioButton selectBySchema; private UICheckBox shouldEvolve; diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java index c0239c8fad..55bef18aad 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java @@ -11,12 +11,12 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.parameter.ParameterInputPane; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; import com.fr.plugin.injectable.PluginModule; @@ -63,6 +63,16 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener { private UILabel imageLabel; + /** + * 云中心防止sql注入帮助文档链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design_Basic_Sql_Injection_Prevention_Help"; + + /** + * 云中心防止sql注入帮助文档默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design_Basic_Sql_Injection_Prevention_Help_Default"; + public PreviewPerformedSqlPane(Frame frame, String sql) { this(frame, sql, null, null, false); } @@ -84,7 +94,7 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener { JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Preview_Performed_Sql_Message") + Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention") + Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message")); messagePanel.add(label); } else { - MessageWithLink message = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Front_Message"), Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention"), CloudCenter.getInstance().acquireConf(Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention_Help"), "https://help.fanruan.com/finereport/doc-view-2219.html"), Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message")); + MessageWithLink message = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Front_Message"), Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention"), LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(), Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message")); messagePanel.add(message); } // 提示图标 diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java index fc5f957f63..c2e6d1ab0c 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java @@ -2,6 +2,7 @@ package com.fr.design.extra.exe.callback.handle; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.link.MessageWithLink; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.manage.control.PluginTaskResult; @@ -16,7 +17,19 @@ public class PluginCallBackHelper { private static final String REFERENCE = Toolkit.i18nText("Fine-Design_Basic_Plugin_File_Validate_Reference"); private static final String HELP_DOCUMENT_NAME = Toolkit.i18nText("Fine-Design_Basic_Plugin_File_Validate_HELP_DOCUMENT_NAME"); private static final String CONNECTOR = "-"; - private static final String HELP_DOCUMENT_LINK = Toolkit.i18nText("Fine-Design_Basic_Plugin_File_Validate_HELP_DOCUMENT_LINK"); + + /** + * 云中心第三方插件安装失败说明帮助文档在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design_Basic_Plugin_File_Validate_HELP_DOCUMENT_LINK"; + + /** + * 云中心第三方插件安装失败说明帮助文档默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design_Basic_Plugin_File_Validate_HELP_DOCUMENT_LINK_Default"; + + + private static final String HELP_DOCUMENT_LINK = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); /** diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java index cc49820de5..540984595c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java @@ -16,6 +16,7 @@ import com.fr.design.gui.frpane.UIPercentDragPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -26,8 +27,8 @@ import com.fr.design.style.color.NewColorSelectBox; import com.fr.env.utils.DesignerInteractionHistory; import com.fr.general.Background; import com.fr.general.IOUtils; -import com.fr.i18n.UrlI18nManager; import com.fr.general.act.BorderPacker; +import com.fr.i18n.UrlI18nManager; import com.fr.stable.Constants; import com.fr.stable.GraphDrawHelper; import com.fr.stable.ProjectLibrary; @@ -78,7 +79,18 @@ import java.util.Arrays; public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane implements UIObserver { private final int SETTING_LABEL_WIDTH = 60; private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT); - private final String TWEAK_NINE_POINT_HELP_URL = "https://help.fanruan.com/finereport/doc-view-4135.html"; + + /** + * 云中心点九图帮助文档在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Nine_Patch"; + + /** + * 云中心点九图帮助文档默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Nine_Patch_Default"; + + private final String TWEAK_NINE_POINT_HELP_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); private UIObserverListener uiObserverListener; diff --git a/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkFactory.java b/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkFactory.java new file mode 100644 index 0000000000..0b407c2cdc --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkFactory.java @@ -0,0 +1,94 @@ +package com.fr.design.i18n; + +import com.fr.general.CloudCenter; +import com.fr.stable.StringUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * 生成根据配置项key获取云中心链接对应key的链接获取器的工厂类 + * 目前仅放在设计器模块下使用,拓展可以结合cbb中的内容自定义资源路径 + * + * @author obo + * @since 11.0 + * Created on 2023/4/7 + */ +public final class LocaleLinkFactory { + + private LocaleLinkFactory(){}; + + /** + * 单一实例 + */ + private static final LocaleLinkFactory INSTANCE = new LocaleLinkFactory(); + + /** + * 返回LocaleLinkFactory的单一实例 + * + * @return LocaleLinkFactory单一实例 + */ + public static LocaleLinkFactory getInstance(){ + return INSTANCE; + } + + /** + * 存放特定配置文件key及其对应的LinkProvider + */ + private static final Map MAP = new HashMap<>(); + + /** + * 根据配置文件项中的key初始化对应的生成器 + * + * @param propsKey 配置项key + * @param defaultKey 默认链接项key + * @return 对应的生成器 + */ + public LocaleLinkProvider getOrCreateProvider(String propsKey, String defaultKey) { + if(MAP.containsKey(propsKey)) { + return MAP.get(propsKey); + } else { + LocaleLinkProvider provider = new LocaleLinkProvider(propsKey, defaultKey); + MAP.put(propsKey, provider); + return provider; + } + } + + /** + * 对应配置项key的链接生成器 + * + * @author obo + * @since 11.0 + * Created on 2023/4/7 + */ + public static class LocaleLinkProvider { + + /** + * 配置文件项key + */ + private final String propsKey; + + /** + * 默认跳转链接配置项key + */ + private final String defaultKey; + private LocaleLinkProvider(String propsKey, String defaultKey) { + this.propsKey = propsKey; + this.defaultKey = defaultKey; + } + + /** + * 获取对应链接 + * + * @return 链接 + */ + public String getLink() { + String cloudKey = DesignI18nImpl.getInstance().i18nText(this.propsKey); + String url = CloudCenter.getInstance().acquireUrlByKind(cloudKey); + if(StringUtils.isEmpty(url)) { + return DesignI18nImpl.getInstance().i18nText(this.defaultKey); + } + return url; + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java index 8e8ef45b9f..7e7ac1ff72 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java @@ -14,11 +14,11 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextfield.PlaceholderTextField; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.javascript.jsapi.JSAPITreeHelper; import com.fr.design.javascript.jsapi.JSAPIUserObject; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; @@ -26,6 +26,25 @@ import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -50,24 +69,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; -import javax.swing.BorderFactory; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.JComponent; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTree; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; public class JSContentWithDescriptionPane extends JSContentPane implements KeyListener { @@ -108,8 +109,6 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com"; - private static final String DOCUMENT_SEARCH_URL = "https://help.fanruan.com/finereport/api-helpdoc-title-"; - private String currentValue; private static CardLayout card; @@ -117,6 +116,16 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi private static final String RELOAD_CARD = "reloadCard"; private static final String DOC_LIST_CARD = "docListCard"; + /** + * 云中心Js高级编辑器帮助链接前缀在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Js_Editor"; + + /** + * 云中心Js高级编辑器帮助链接前缀在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Js_Editor_Default"; + public JSContentWithDescriptionPane(String[] args) { this.setLayout(new BorderLayout()); //=============================== @@ -352,7 +361,7 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi private void doHelpDocumentSearch() { Object value = interfaceNameList.getSelectedValue(); if (value != null) { - String url = CloudCenter.getInstance().acquireUrlByKind("af.doc_search", DOCUMENT_SEARCH_URL) + value.toString(); + String url = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); try { String result = HttpToolbox.get(url); JSONObject jsonObject = new JSONObject(result); diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java index afe1c8eef3..5e497fe896 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java @@ -1,13 +1,8 @@ package com.fr.design.locale.impl; -import com.fr.general.CloudCenter; -import com.fr.general.GeneralContext; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.general.locale.LocaleMark; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - /** * @author hades * @version 10.0 @@ -15,24 +10,19 @@ import java.util.Map; */ public class BbsRegisterMark implements LocaleMark { - private final Map map = new HashMap<>(); - private static final String BBS_REGISTER_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.register", "https://id.fanruan.com/register/register.php?clueSource=activityfr"); - private static final String BBS_REGISTER_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.register", "https://id.fanruan.com/register/register.php?clueSource=activityfr"); - private static final String BBS_REGISTER_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US", "https://id.fanruan.com/en/register/register.php"); - private static final String BBS_REGISTER_KR = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US", "https://id.fanruan.com/en/register/register.php"); - private static final String BBS_REGISTER_JP = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US", "https://id.fanruan.com/en/register/register.php"); + /** + * 云中心新账户中心链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_New_Account_Center"; - public BbsRegisterMark() { - map.put(Locale.CHINA, BBS_REGISTER_CN); - map.put(Locale.KOREA, BBS_REGISTER_KR); - map.put(Locale.JAPAN, BBS_REGISTER_JP); - map.put(Locale.US, BBS_REGISTER_EN); - map.put(Locale.TAIWAN, BBS_REGISTER_TW); - } + /** + * 云中心新账户中心链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_New_Account_Center_Default"; + public BbsRegisterMark() {} @Override public String getValue() { - String result = map.get(GeneralContext.getLocale()); - return result == null ? BBS_REGISTER_EN : result; + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); } } diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java index 27db28e416..4a97f68304 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java @@ -1,13 +1,8 @@ package com.fr.design.locale.impl; -import com.fr.general.CloudCenter; -import com.fr.general.GeneralContext; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.general.locale.LocaleMark; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - /** * @author hades * @version 10.0 @@ -15,24 +10,21 @@ import java.util.Map; */ public class BbsResetMark implements LocaleMark { - private final Map map = new HashMap<>(); - private static final String BBS_RESET_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.reset", "https://id.fanruan.com/forget/forget.php?clue=activityfr"); - private static final String BBS_RESET_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.reset", "https://id.fanruan.com/forget/forget.php?clue=activityfr"); - private static final String BBS_RESET_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US", "https://id.fanruan.com/en/forget/forget.php"); - private static final String BBS_RESET_KR = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US", "https://id.fanruan.com/en/forget/forget.php"); - private static final String BBS_RESET_JP = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US", "https://id.fanruan.com/en/forget/forget.php"); - public BbsResetMark() { - map.put(Locale.CHINA, BBS_RESET_CN); - map.put(Locale.KOREA, BBS_RESET_KR); - map.put(Locale.JAPAN, BBS_RESET_JP); - map.put(Locale.US, BBS_RESET_EN); - map.put(Locale.TAIWAN, BBS_RESET_TW); - } + /** + * 云中心老账户中心链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Account_Center"; + + /** + * 云中心老账户中心链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Account_Center_Default"; + + public BbsResetMark() {} @Override public String getValue() { - String result = map.get(GeneralContext.getLocale()); - return result == null ? BBS_RESET_EN : result; + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); } } diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java index 999c732845..1574b4e6b5 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java @@ -1,13 +1,8 @@ package com.fr.design.locale.impl; -import com.fr.general.CloudCenter; -import com.fr.general.GeneralContext; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.general.locale.LocaleMark; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - /** * @author hades * @version 10.0 @@ -15,25 +10,20 @@ import java.util.Map; */ public class BbsSpaceMark implements LocaleMark { - private final Map map = new HashMap<>(); - private static final String BBS_SPACE_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.default", "http://bbs.fanruan.com/home.php?mod=space&do=pm"); - private static final String BBS_SPACE_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.default", "http://bbs.fanruan.com/home.php?mod=space&do=pm"); - private static final String BBS_SPACE_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.default.en_US", "https://community.finereport.com/home.php?mod=space&do=pm"); - private static final String BBS_SPACE_KR = CloudCenter.getInstance().acquireUrlByKind("bbs.default.en_US", "https://community.finereport.com/home.php?mod=space&do=pm"); - private static final String BBS_SPACE_JP = CloudCenter.getInstance().acquireUrlByKind("bbs.default.en_US", "https://community.finereport.com/home.php?mod=space&do=pm"); + /** + * 云中心帆软社区消息中心链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Message_Center"; - public BbsSpaceMark() { - map.put(Locale.CHINA, BBS_SPACE_CN); - map.put(Locale.KOREA, BBS_SPACE_KR); - map.put(Locale.JAPAN, BBS_SPACE_JP); - map.put(Locale.US, BBS_SPACE_EN); - map.put(Locale.TAIWAN, BBS_SPACE_TW); - } + /** + * 云中心帆软社区消息中心链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Message_Center_Default"; + + public BbsSpaceMark() {} @Override public String getValue() { - String result = map.get(GeneralContext.getLocale()); - return result == null ? BBS_SPACE_EN : result; + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); } - } diff --git a/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java b/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java index 4d0ba8a41c..113ee8e6e8 100644 --- a/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java +++ b/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java @@ -5,6 +5,7 @@ import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.locale.impl.BbsResetMark; @@ -23,15 +24,16 @@ import com.fr.log.FineLoggerFactory; import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.JSFunction; import com.teamdev.jxbrowser.chromium.JSObject; + +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; import java.awt.Desktop; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.URI; import java.util.Map; import java.util.Set; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; /** * @author Lanlan @@ -40,6 +42,16 @@ import javax.swing.SwingUtilities; */ public class DesignerLoginBridge { + /** + * 云中心组件商城模板在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Market_Template"; + + /** + * 云中心组件商城模板默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Template_Default"; + private Map params; public static DesignerLoginBridge getBridge(Browser browser, Map params) { @@ -71,7 +83,7 @@ public class DesignerLoginBridge { getHyperlinkPane( com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Guide_Login_Success_Title"), com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Guide_Login_Success_Hyperlink_Text"), - CloudCenter.getInstance().acquireUrlByKind("designer.premium.template", "https://market.fanruan.com/template") + LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink() ) ); } else if (source == DesignerLoginSource.BBS_JUMP) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java index 0671ed1b63..6355b034f6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java @@ -4,10 +4,10 @@ import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.DesignSizeI18nManager; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.CloudCenter; import com.fr.general.IOUtils; import javax.swing.BorderFactory; @@ -39,17 +39,27 @@ public class CheckFontInfoDialog extends JDialog implements ActionListener { private UILabel directUiLabel; private UILabel detailLabel; + /** + * 云中心插件管理帮助文档在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Server_Install_Font"; + + /** + * 云中心插件管理默认帮助文档在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Server_Install_Font_Default"; + public CheckFontInfoDialog(Frame parent, String areaText) { super(parent,true); //提示信息 JPanel imagePanel = new JPanel(); imageLabel = new UILabel(IOUtils.readIcon("com/fr/design/images/warnings/warning32.png")); imagePanel.add(imageLabel); - + String link = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); JPanel messagePanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); MessageWithLink linkMessage = new MessageWithLink(Toolkit.i18nText("Fine_Designer_Check_Font_Message"), Toolkit.i18nText("Fine_Designer_Check_Font_Install_Font"), - CloudCenter.getInstance().acquireUrlByKind("help.install.font", "https://help.fanruan.com/finereport/doc-view-3999.html")); + link); linkMessage.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink")); messagePanel.add(linkMessage); diff --git a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java index 56db4cee9e..785d47c1be 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java @@ -1,9 +1,8 @@ package com.fr.design.update.actions; -import com.fr.common.util.Strings; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.utils.BrowseUtils; -import com.fr.general.CloudCenter; import com.fr.log.FineLoggerFactory; import java.awt.event.ActionEvent; @@ -16,17 +15,22 @@ import java.awt.event.ActionListener; * */ public class NewFeatureAction implements ActionListener { + /** + * 云中心更新日志索引在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Latest_Update_Detail"; - public static String DEFAULT_UPDATE_DETAIL_URL = "https://help.fanruan.com/finereport/doc-view-4699.html"; + /** + * 云中心更新日志索引默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Latest_Update_Detail_Default"; + + public static String DEFAULT_UPDATE_DETAIL_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); @Override public void actionPerformed(ActionEvent e) { try { - String url = CloudCenter.getInstance().acquireConf("fr.latest.update.detil"); - if (Strings.isEmpty(url)) { - url = DEFAULT_UPDATE_DETAIL_URL; - } - BrowseUtils.browser(url); + BrowseUtils.browser(DEFAULT_UPDATE_DETAIL_URL); } catch (Exception ex) { FineLoggerFactory.getLogger().error(ex.getMessage()); } diff --git a/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java b/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java index 877a9224b2..4a06fc2a21 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java +++ b/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java @@ -1,11 +1,7 @@ package com.fr.env; -import com.fr.general.CloudCenter; -import com.fr.general.GeneralContext; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.general.locale.LocaleMark; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; /** * @author hades @@ -14,23 +10,21 @@ import java.util.Map; */ public class RemoteDesignLocaleMark implements LocaleMark { - private Map map = new HashMap<>(); - private static final String REMOTE_DESIGN_CN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.zh_CN", "https://help.fanruan.com/finereport/doc-view-3925.html"); - private static final String REMOTE_DESIGN_EN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.en_US", "https://help.fanruan.com/finereport-en/doc-view-3862.html"); + /** + * 云中心远程设计常见问题链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Remote_Design_Question"; + /** + * 云中心远程设计常见问题链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Remote_Design_Question_Default"; - public RemoteDesignLocaleMark() { - map.put(Locale.CHINA, REMOTE_DESIGN_CN); - map.put(Locale.KOREA, REMOTE_DESIGN_EN); - map.put(Locale.JAPAN, REMOTE_DESIGN_EN); - map.put(Locale.US, REMOTE_DESIGN_EN); - map.put(Locale.TAIWAN, REMOTE_DESIGN_CN); - } + public RemoteDesignLocaleMark() {} @Override public String getValue() { - String result = map.get(GeneralContext.getLocale()); - return result == null ? REMOTE_DESIGN_CN : result; + return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); } } diff --git a/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java b/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java index fd4b98e33e..7eb6327331 100644 --- a/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java +++ b/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java @@ -6,25 +6,18 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.i18n.DesignSizeI18nManager; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.stable.StringUtils; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.Locale; + import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JDialog; @@ -33,6 +26,14 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.UIManager; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.Locale; /** * @author pengda @@ -47,6 +48,16 @@ public class SyncFailedPluginsDialog extends JDialog { private RestartHelper restartHelper = new RestartHelper(); private UIButton restartButton; private boolean show = false; + + /** + * 云中心插件管理帮助文档在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Plugin_Management"; + + /** + * 云中心插件管理默认帮助文档在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Plugin_Management_Default"; public SyncFailedPluginsDialog(JFrame parent, JSONArray syncFailedPlugins) { super(parent, true); JPanel body = FRGUIPaneFactory.createBorderLayout_L_Pane(); @@ -62,7 +73,7 @@ public class SyncFailedPluginsDialog extends JDialog { JPanel messagePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); MessageWithLink messageWithLink = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugin_Fail_Suggestion"),Toolkit.i18nText("Fine-Design_Basic_Sync_Deal_Immediately"), - CloudCenter.getInstance().acquireUrlByKind("help.installplugins", "https://help.fanruan.com/finereport/doc-view-2198.html")); + LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink()); messageWithLink.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.env.SyncFailedPluginsDialog.messageWithLink")); messagePane.add(messageWithLink); diff --git a/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java b/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java index 4e4592dcde..bb157a0811 100644 --- a/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java +++ b/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java @@ -1,13 +1,33 @@ package com.fr.env.detect.base; +import com.fr.design.i18n.LocaleLinkFactory; + /** * created by Harrison on 2022/05/25 **/ public class DetectorConstants { + /** + * 云中心FineDB异常检测帮助文档在配置文件中对应的配置文件key + */ + private static final String FINE_DB_HELP_PROPS_LINK_KEY = "Fine-Design-CloudCenter_FineDB_Exception_Check"; + + /** + * 云中心FineDB异常检测帮助文档默认链接在配置文件中对应的配置文件key + */ + private static final String FINE_DB_HELP_PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_FineDB_Exception_Check_Default"; + + /** + * 云中心FineDB异常检测帮助文档在配置文件中对应的配置文件key + */ + private static final String JAR_HELP_PROPS_LINK_KEY = "Fine-Design-CloudCenter_Jar_Exception_Check"; + + /** + * 云中心FineDB异常检测帮助文档默认链接在配置文件中对应的配置文件key + */ + private static final String JAR_HELP_PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Jar_Exception_Check_Default"; + public static final String JAR_HELP_LINK = LocaleLinkFactory.getInstance().getOrCreateProvider(JAR_HELP_PROPS_LINK_KEY, JAR_HELP_PROPS_LINK_KEY_DEFAULT).getLink();; - public static final String JAR_HELP_LINK = "https://help.fanruan.com/finereport/doc-view-4700.html?source=3"; - - public static final String FINE_DB_HELP_LINK = "https://help.fanruan.com/finereport/doc-view-4701.html?source=3"; + public static final String FINE_DB_HELP_LINK = LocaleLinkFactory.getInstance().getOrCreateProvider(FINE_DB_HELP_PROPS_LINK_KEY, FINE_DB_HELP_PROPS_LINK_KEY_DEFAULT).getLink(); public static final String SEPARATOR = "、"; public static final String BR_TAG = "
"; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java index 9df0313820..6bac549969 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java @@ -1,17 +1,11 @@ package com.fr.design.mainframe.share.ui.actions; -import com.fr.design.actions.UpdateAction; -import com.fr.design.gui.imenu.UIMenuItem; -import com.fr.design.gui.imenu.UIMenuItemUI; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.share.ui.constants.ColorConstants; import com.fr.design.mainframe.share.ui.online.CarouselStateManger; import com.fr.stable.StringUtils; import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.SwingConstants; -import java.awt.Color; import java.awt.Desktop; import java.awt.event.ActionEvent; import java.io.IOException; @@ -24,7 +18,18 @@ import java.net.URISyntaxException; * Created by Starryi on 2021/9/28 */ public class Jump2DetailAction extends SharedComponentPopupAction { - private static final String ONLINE_WIDGET_DETAIL_FORMATTED_URL = "https://market.fanruan.com/reuse/%s"; + + /** + * 云中心组件市场组件详情在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Market_Detail"; + + /** + * 云中心组件市场组件详情默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Detail_Default"; + + private static final String ONLINE_WIDGET_DETAIL_FORMATTED_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); private final String id; public Jump2DetailAction(String id) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java index b4d3bcc68d..6f3a33b0d3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java @@ -2,35 +2,30 @@ package com.fr.design.mainframe.share.ui.online; import com.fr.base.BaseUtils; import com.fr.base.Style; -import com.fr.config.constant.Constant; import com.fr.design.dialog.BasicPane; import com.fr.design.form.util.FontTransformUtil; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.share.ui.base.LoadingPane; import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.design.mainframe.share.ui.online.mini.MiniComponentShopDialog; import com.fr.design.mainframe.share.util.OnlineShopUtils; -import com.fr.design.mainframe.theme.edit.ui.LabelUtils; import com.fr.form.share.bean.OnlineShareWidget; import com.fr.general.FRFont; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; -import com.fr.stable.Constants; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; -import javax.swing.BoxLayout; import javax.swing.JPanel; -import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.SwingWorker; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; -import java.awt.Component; import java.awt.Cursor; import java.awt.Dimension; import java.awt.FlowLayout; @@ -47,7 +42,18 @@ import java.util.concurrent.ExecutionException; * Created by kerry on 2020-10-16 */ public class OnlineWidgetRepoPane extends BasicPane { - private static final String MARKET_URL = "https://market.fanruan.com/reuse"; + + /** + * 云中心组件市场在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Market"; + + /** + * 云中心组件市场默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Default"; + + private static final String MARKET_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); private static List[] sharableWidgets; private OnlineWidgetTabPane componentTabPane; private boolean isShowPackagePanel = false; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java index a01fa3909e..9fbd95ae7b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -4,10 +4,10 @@ import com.fr.base.svg.IconUtils; import com.fr.design.actions.replace.info.Info; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.design.utils.BrowseUtils; -import com.fr.general.CloudCenter; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; @@ -35,7 +35,17 @@ public class ITReplaceWestPanel { private UIToggleButton contentButton; private UIToggleButton settingButton; private static final Icon HELP_ICON = IconUtils.readIcon("com/fr/design/images/buttonicon/replace_help.svg"); - private static final String HELP_URL = CloudCenter.getInstance().acquireUrlByKind("design.replace.help", "https://help.fanruan.com/finereport/doc-view-4954.html?source=3"); + + /** + * 云中心定时调度执行频率表达式设定帮助文档链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Template_Level_Search_Replace"; + + /** + * 云中心定时调度执行频率表达式设定帮助文档默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Template_Level_Search_Replace_Default"; + private static final String HELP_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); private static final int FILL_COUNT = 11; public static final int LEFT_WIDTH = 100; public static final String CONTENT_TEXT = "" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + ""; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index d8f7265f7d..14bb550226 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -7,6 +7,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -17,7 +18,6 @@ import com.fr.design.mainframe.toast.ToastMsgDialog; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.BrowseUtils; import com.fr.event.EventDispatcher; -import com.fr.general.CloudCenter; import com.fr.log.FineLoggerFactory; import com.fr.serialization.SerializerHelper; import com.fr.stable.ArrayUtils; @@ -58,7 +58,17 @@ public class DesignerSocketIO { Disconnecting } - private static final String WEBSOCKET_HELP_DOC = CloudCenter.getInstance().acquireUrlByKind("websocketConnect", "https://help.fanruan.com/finereport/doc-view-2512.html"); + /** + * 云中心特殊字符导出在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_WebSocket"; + + /** + * 云中心特殊字符导出默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_WebSocket_Default"; + + private static final String WEBSOCKET_HELP_DOC = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); private static final String HTTPS = "https"; private static final String HTTP = "http"; private static Socket socket = null; diff --git a/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java b/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java index 5fe52560dc..fe6fbc609e 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java @@ -6,10 +6,10 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.LocaleLinkFactory; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.BrowseUtils; -import com.fr.general.CloudCenter; import com.fr.io.attr.ReportExportAttr; import com.fr.transaction.Configurations; import com.fr.transaction.WorkerFacade; @@ -30,7 +30,17 @@ import java.awt.event.ActionListener; */ public class ExportUniversalPane extends BasicPane { - private static final String HELP_URL = CloudCenter.getInstance().acquireUrlByKind("help.alt_font.zh_CN", "https://help.fanruan.com/finereport/doc-view-4707.html"); + /** + * 云中心特殊字符导出在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Alt_Font_Export"; + + /** + * 云中心特殊字符导出默认链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Alt_Font_Export_Default"; + + private static final String HELP_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); private UICheckBox specialCharacterExport; // 密码支持公式 From 66ea9bec5a9071baaca33c0d9eeedd4cdfc4c23c Mon Sep 17 00:00:00 2001 From: obo Date: Wed, 12 Apr 2023 18:07:57 +0800 Subject: [PATCH 02/59] =?UTF-8?q?REPORT-91074=20=E3=80=90=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E3=80=91=E8=B6=85=E9=93=BE=E6=8E=A5=E5=8C=BA?= =?UTF-8?q?=E5=88=86=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/community/BBSAction.java | 4 +- .../design/actions/community/BugAction.java | 4 +- .../actions/community/CenterAction.java | 4 +- .../actions/community/CusDemandAction.java | 4 +- .../actions/community/FacebookFansAction.java | 4 +- .../design/actions/community/NeedAction.java | 4 +- .../actions/community/QuestionAction.java | 4 +- .../design/actions/community/SignAction.java | 4 +- .../actions/community/StudyPlanAction.java | 4 +- .../actions/community/TechSolutionAction.java | 4 +- .../community/TemplateStoreAction.java | 4 +- .../fr/design/actions/community/UpAction.java | 4 +- .../community/WorkOrderCenterAction.java | 4 +- .../design/actions/help/TutorialAction.java | 4 +- .../data/datapane/ESDStrategyConfigPane.java | 4 +- .../preview/sql/PreviewPerformedSqlPane.java | 4 +- .../callback/handle/PluginCallBackHelper.java | 4 +- .../style/TranslucentBorderSpecialPane.java | 4 +- .../com/fr/design/i18n/LocaleLinkFactory.java | 94 ------------------- .../com/fr/design/i18n/LocaleLinkProvide.java | 47 ++++++++++ .../JSContentWithDescriptionPane.java | 4 +- .../design/locale/impl/BbsRegisterMark.java | 4 +- .../fr/design/locale/impl/BbsResetMark.java | 4 +- .../fr/design/locale/impl/BbsSpaceMark.java | 4 +- .../fr/design/login/DesignerLoginBridge.java | 4 +- .../mainframe/check/CheckFontInfoDialog.java | 4 +- .../update/actions/NewFeatureAction.java | 4 +- .../com/fr/env/RemoteDesignLocaleMark.java | 4 +- .../com/fr/env/SyncFailedPluginsDialog.java | 4 +- .../fr/env/detect/base/DetectorConstants.java | 6 +- .../share/ui/actions/Jump2DetailAction.java | 4 +- .../share/ui/online/OnlineWidgetRepoPane.java | 4 +- .../replace/ui/ITReplaceWestPanel.java | 4 +- .../mainframe/socketio/DesignerSocketIO.java | 4 +- .../fr/design/report/ExportUniversalPane.java | 4 +- 35 files changed, 114 insertions(+), 161 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/LocaleLinkFactory.java create mode 100644 designer-base/src/main/java/com/fr/design/i18n/LocaleLinkProvide.java diff --git a/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java b/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java index d93e7ff244..999d7d59ed 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -28,7 +28,7 @@ public class BBSAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet BBS = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java b/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java index ac732b9481..7e90a3b684 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -27,7 +27,7 @@ public class BugAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet BUG = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java b/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java index 35affba875..e634e58fc7 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.menu.MenuKeySet; import javax.swing.KeyStroke; @@ -29,7 +29,7 @@ public class CenterAction extends UpAction { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet CENTER = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java b/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java index 6cf96dbae9..5afa19cea1 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java @@ -1,7 +1,7 @@ package com.fr.design.actions.community; import com.fr.base.BaseUtils; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; @@ -35,7 +35,7 @@ public class CusDemandAction extends UpAction{ @Override public void actionPerformed(ActionEvent arg0) { - String url = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + String url = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); BrowseUtils.browser(url); } diff --git a/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java b/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java index 179330d299..79b8f57760 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; @@ -28,7 +28,7 @@ public class FacebookFansAction extends UpAction { @Override public void actionPerformed(ActionEvent arg0) { - BrowseUtils.browser(LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink()); + BrowseUtils.browser(LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT)); } public static final MenuKeySet FACEBOOKFANS = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java b/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java index 0116db84bd..cf7bf7c1e0 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -28,7 +28,7 @@ public class NeedAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet NEED = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java b/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java index fea2df3037..fb3bf4ec34 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -28,7 +28,7 @@ public class QuestionAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet QUESTIONS = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java b/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java index 3b785ff43b..7a0b26eb20 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -27,7 +27,7 @@ public class SignAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet SIGN = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java b/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java index 757abd8ea8..402b62eb3f 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.login.AbstractDesignerSSO; @@ -23,6 +23,6 @@ public class StudyPlanAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java b/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java index 7ab6ece6e2..46fdefff45 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -31,7 +31,7 @@ public class TechSolutionAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet TSO = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java b/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java index b07c2fb3a7..ebc8bfbb54 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java @@ -1,7 +1,7 @@ package com.fr.design.actions.community; import com.fr.base.BaseUtils; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.menu.MenuKeySet; @@ -54,6 +54,6 @@ public class TemplateStoreAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { ComponentCollector.getInstance().collectTepMenuEnterClick(); - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java b/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java index 6881019b2d..4385f1d466 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java @@ -1,7 +1,7 @@ package com.fr.design.actions.community; import com.fr.base.BaseUtils; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -28,7 +28,7 @@ public class UpAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet UPDATE = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java b/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java index 4d6508cea9..e34443e720 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; /** @@ -27,6 +27,6 @@ public class WorkOrderCenterAction extends UpAction { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java index 4f215abc08..1712272685 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.help; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -38,7 +38,7 @@ public class TutorialAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } // 生成帮助文档 sitecenter key, help.zh_CN.10 diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java index 5643086ecc..ce3464bc9e 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java @@ -6,7 +6,7 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.esd.common.CacheConstants; @@ -50,7 +50,7 @@ public class ESDStrategyConfigPane extends BasicBeanPane { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Cron_Help_Default"; - private static final String CRON_HELP_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + private static final String CRON_HELP_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private UIRadioButton selectAutoUpdate; private UIRadioButton selectBySchema; private UICheckBox shouldEvolve; diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java index 55bef18aad..c32fa2dcf4 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java @@ -11,7 +11,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -94,7 +94,7 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener { JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Preview_Performed_Sql_Message") + Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention") + Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message")); messagePanel.add(label); } else { - MessageWithLink message = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Front_Message"), Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention"), LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(), Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message")); + MessageWithLink message = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Front_Message"), Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention"), LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT), Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message")); messagePanel.add(message); } // 提示图标 diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java index c2e6d1ab0c..f672eb15bd 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java @@ -2,7 +2,7 @@ package com.fr.design.extra.exe.callback.handle; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.link.MessageWithLink; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.manage.control.PluginTaskResult; @@ -29,7 +29,7 @@ public class PluginCallBackHelper { private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design_Basic_Plugin_File_Validate_HELP_DOCUMENT_LINK_Default"; - private static final String HELP_DOCUMENT_LINK = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + private static final String HELP_DOCUMENT_LINK = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); /** diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java index 540984595c..d126716474 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java @@ -16,7 +16,7 @@ import com.fr.design.gui.frpane.UIPercentDragPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -90,7 +90,7 @@ public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane imple */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Nine_Patch_Default"; - private final String TWEAK_NINE_POINT_HELP_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + private final String TWEAK_NINE_POINT_HELP_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private UIObserverListener uiObserverListener; diff --git a/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkFactory.java b/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkFactory.java deleted file mode 100644 index 0b407c2cdc..0000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkFactory.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.fr.design.i18n; - -import com.fr.general.CloudCenter; -import com.fr.stable.StringUtils; - -import java.util.HashMap; -import java.util.Map; - -/** - * 生成根据配置项key获取云中心链接对应key的链接获取器的工厂类 - * 目前仅放在设计器模块下使用,拓展可以结合cbb中的内容自定义资源路径 - * - * @author obo - * @since 11.0 - * Created on 2023/4/7 - */ -public final class LocaleLinkFactory { - - private LocaleLinkFactory(){}; - - /** - * 单一实例 - */ - private static final LocaleLinkFactory INSTANCE = new LocaleLinkFactory(); - - /** - * 返回LocaleLinkFactory的单一实例 - * - * @return LocaleLinkFactory单一实例 - */ - public static LocaleLinkFactory getInstance(){ - return INSTANCE; - } - - /** - * 存放特定配置文件key及其对应的LinkProvider - */ - private static final Map MAP = new HashMap<>(); - - /** - * 根据配置文件项中的key初始化对应的生成器 - * - * @param propsKey 配置项key - * @param defaultKey 默认链接项key - * @return 对应的生成器 - */ - public LocaleLinkProvider getOrCreateProvider(String propsKey, String defaultKey) { - if(MAP.containsKey(propsKey)) { - return MAP.get(propsKey); - } else { - LocaleLinkProvider provider = new LocaleLinkProvider(propsKey, defaultKey); - MAP.put(propsKey, provider); - return provider; - } - } - - /** - * 对应配置项key的链接生成器 - * - * @author obo - * @since 11.0 - * Created on 2023/4/7 - */ - public static class LocaleLinkProvider { - - /** - * 配置文件项key - */ - private final String propsKey; - - /** - * 默认跳转链接配置项key - */ - private final String defaultKey; - private LocaleLinkProvider(String propsKey, String defaultKey) { - this.propsKey = propsKey; - this.defaultKey = defaultKey; - } - - /** - * 获取对应链接 - * - * @return 链接 - */ - public String getLink() { - String cloudKey = DesignI18nImpl.getInstance().i18nText(this.propsKey); - String url = CloudCenter.getInstance().acquireUrlByKind(cloudKey); - if(StringUtils.isEmpty(url)) { - return DesignI18nImpl.getInstance().i18nText(this.defaultKey); - } - return url; - } - } -} diff --git a/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkProvide.java b/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkProvide.java new file mode 100644 index 0000000000..e7379137ff --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkProvide.java @@ -0,0 +1,47 @@ +package com.fr.design.i18n; + +import com.fr.general.CloudCenter; +import com.fr.stable.StringUtils; + +/** + * 国际化链接获取工具 + * 根据配置文件key获取云中心key对应的链接或者默认链接 + * + * @author obo + * @since 11.0 + * Created on 2023/4/7 + */ +public final class LocaleLinkProvide { + + private LocaleLinkProvide(){}; + + /** + * 单一实例 + */ + private static final LocaleLinkProvide INSTANCE = new LocaleLinkProvide(); + + /** + * 返回LocaleLinkProvide的单一实例 + * + * @return LocaleLinkProvide单一实例 + */ + public static LocaleLinkProvide getInstance(){ + return INSTANCE; + } + + /** + * 根据配置文件项中的key获取链接 + * + * @param propsKey 配置项key + * @param defaultKey 默认链接项key + * @return 对应的生成器 + */ + public String getLink(String propsKey, String defaultKey) { + String cloudKey = DesignI18nImpl.getInstance().i18nText(propsKey); + String url = CloudCenter.getInstance().acquireUrlByKind(cloudKey); + if(StringUtils.isEmpty(url)) { + return DesignI18nImpl.getInstance().i18nText(defaultKey); + } + return url; + } +} diff --git a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java index 7e7ac1ff72..bd7efabe84 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java @@ -14,7 +14,7 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextfield.PlaceholderTextField; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.javascript.jsapi.JSAPITreeHelper; import com.fr.design.javascript.jsapi.JSAPIUserObject; @@ -361,7 +361,7 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi private void doHelpDocumentSearch() { Object value = interfaceNameList.getSelectedValue(); if (value != null) { - String url = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + String url = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); try { String result = HttpToolbox.get(url); JSONObject jsonObject = new JSONObject(result); diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java index 5e497fe896..593a3cae08 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java @@ -1,6 +1,6 @@ package com.fr.design.locale.impl; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.general.locale.LocaleMark; /** @@ -23,6 +23,6 @@ public class BbsRegisterMark implements LocaleMark { @Override public String getValue() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java index 4a97f68304..18431ba23b 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java @@ -1,6 +1,6 @@ package com.fr.design.locale.impl; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.general.locale.LocaleMark; /** @@ -25,6 +25,6 @@ public class BbsResetMark implements LocaleMark { @Override public String getValue() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java index 1574b4e6b5..112521749a 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java @@ -1,6 +1,6 @@ package com.fr.design.locale.impl; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.general.locale.LocaleMark; /** @@ -24,6 +24,6 @@ public class BbsSpaceMark implements LocaleMark { public BbsSpaceMark() {} @Override public String getValue() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java b/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java index 113ee8e6e8..109c19e364 100644 --- a/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java +++ b/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java @@ -5,7 +5,7 @@ import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.locale.impl.BbsResetMark; @@ -83,7 +83,7 @@ public class DesignerLoginBridge { getHyperlinkPane( com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Guide_Login_Success_Title"), com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Guide_Login_Success_Hyperlink_Text"), - LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink() + LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT) ) ); } else if (source == DesignerLoginSource.BBS_JUMP) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java index 6355b034f6..e68282f26a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java @@ -4,7 +4,7 @@ import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.DesignSizeI18nManager; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; @@ -55,7 +55,7 @@ public class CheckFontInfoDialog extends JDialog implements ActionListener { JPanel imagePanel = new JPanel(); imageLabel = new UILabel(IOUtils.readIcon("com/fr/design/images/warnings/warning32.png")); imagePanel.add(imageLabel); - String link = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + String link = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); JPanel messagePanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); MessageWithLink linkMessage = new MessageWithLink(Toolkit.i18nText("Fine_Designer_Check_Font_Message"), Toolkit.i18nText("Fine_Designer_Check_Font_Install_Font"), diff --git a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java index 785d47c1be..09d627b751 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java @@ -1,7 +1,7 @@ package com.fr.design.update.actions; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.utils.BrowseUtils; import com.fr.log.FineLoggerFactory; @@ -25,7 +25,7 @@ public class NewFeatureAction implements ActionListener { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Latest_Update_Detail_Default"; - public static String DEFAULT_UPDATE_DETAIL_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + public static String DEFAULT_UPDATE_DETAIL_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); @Override public void actionPerformed(ActionEvent e) { diff --git a/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java b/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java index 4a06fc2a21..89a28dc3e0 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java +++ b/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java @@ -1,6 +1,6 @@ package com.fr.env; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.general.locale.LocaleMark; /** @@ -24,7 +24,7 @@ public class RemoteDesignLocaleMark implements LocaleMark { @Override public String getValue() { - return LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java b/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java index 7eb6327331..f3a8eb2685 100644 --- a/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java +++ b/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java @@ -6,7 +6,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.i18n.DesignSizeI18nManager; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -73,7 +73,7 @@ public class SyncFailedPluginsDialog extends JDialog { JPanel messagePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); MessageWithLink messageWithLink = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugin_Fail_Suggestion"),Toolkit.i18nText("Fine-Design_Basic_Sync_Deal_Immediately"), - LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink()); + LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT)); messageWithLink.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.env.SyncFailedPluginsDialog.messageWithLink")); messagePane.add(messageWithLink); diff --git a/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java b/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java index bb157a0811..4be5875899 100644 --- a/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java +++ b/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java @@ -1,6 +1,6 @@ package com.fr.env.detect.base; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; /** * created by Harrison on 2022/05/25 @@ -25,9 +25,9 @@ public class DetectorConstants { * 云中心FineDB异常检测帮助文档默认链接在配置文件中对应的配置文件key */ private static final String JAR_HELP_PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Jar_Exception_Check_Default"; - public static final String JAR_HELP_LINK = LocaleLinkFactory.getInstance().getOrCreateProvider(JAR_HELP_PROPS_LINK_KEY, JAR_HELP_PROPS_LINK_KEY_DEFAULT).getLink();; + public static final String JAR_HELP_LINK = LocaleLinkProvide.getInstance().getLink(JAR_HELP_PROPS_LINK_KEY, JAR_HELP_PROPS_LINK_KEY_DEFAULT);; - public static final String FINE_DB_HELP_LINK = LocaleLinkFactory.getInstance().getOrCreateProvider(FINE_DB_HELP_PROPS_LINK_KEY, FINE_DB_HELP_PROPS_LINK_KEY_DEFAULT).getLink(); + public static final String FINE_DB_HELP_LINK = LocaleLinkProvide.getInstance().getLink(FINE_DB_HELP_PROPS_LINK_KEY, FINE_DB_HELP_PROPS_LINK_KEY_DEFAULT); public static final String SEPARATOR = "、"; public static final String BR_TAG = "
"; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java index 6bac549969..8a77b28e04 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.share.ui.actions; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.share.ui.online.CarouselStateManger; import com.fr.stable.StringUtils; @@ -29,7 +29,7 @@ public class Jump2DetailAction extends SharedComponentPopupAction { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Detail_Default"; - private static final String ONLINE_WIDGET_DETAIL_FORMATTED_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + private static final String ONLINE_WIDGET_DETAIL_FORMATTED_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private final String id; public Jump2DetailAction(String id) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java index 6f3a33b0d3..f49924cce6 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java @@ -5,7 +5,7 @@ import com.fr.base.Style; import com.fr.design.dialog.BasicPane; import com.fr.design.form.util.FontTransformUtil; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.share.ui.base.LoadingPane; @@ -53,7 +53,7 @@ public class OnlineWidgetRepoPane extends BasicPane { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Default"; - private static final String MARKET_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + private static final String MARKET_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private static List[] sharableWidgets; private OnlineWidgetTabPane componentTabPane; private boolean isShowPackagePanel = false; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java index 9fbd95ae7b..0ed6b36b45 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -4,7 +4,7 @@ import com.fr.base.svg.IconUtils; import com.fr.design.actions.replace.info.Info; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.design.utils.BrowseUtils; @@ -45,7 +45,7 @@ public class ITReplaceWestPanel { * 云中心定时调度执行频率表达式设定帮助文档默认链接在配置文件中对应的配置文件key */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Template_Level_Search_Replace_Default"; - private static final String HELP_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + private static final String HELP_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private static final int FILL_COUNT = 11; public static final int LEFT_WIDTH = 100; public static final String CONTENT_TEXT = "" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + ""; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 14bb550226..151b7d1e2d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -7,7 +7,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -68,7 +68,7 @@ public class DesignerSocketIO { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_WebSocket_Default"; - private static final String WEBSOCKET_HELP_DOC = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + private static final String WEBSOCKET_HELP_DOC = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private static final String HTTPS = "https"; private static final String HTTP = "http"; private static Socket socket = null; diff --git a/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java b/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java index fe6fbc609e..1e83032abb 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java @@ -6,7 +6,7 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkFactory; +import com.fr.design.i18n.LocaleLinkProvide; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.BrowseUtils; @@ -40,7 +40,7 @@ public class ExportUniversalPane extends BasicPane { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Alt_Font_Export_Default"; - private static final String HELP_URL = LocaleLinkFactory.getInstance().getOrCreateProvider(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT).getLink(); + private static final String HELP_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private UICheckBox specialCharacterExport; // 密码支持公式 From 8166e8dbf948f42df556d95cf49aaa3bcc7e4489 Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 13 Apr 2023 14:12:36 +0800 Subject: [PATCH 03/59] =?UTF-8?q?REPORT-91074=20=E3=80=90=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E3=80=91=E8=B6=85=E9=93=BE=E6=8E=A5=E5=8C=BA?= =?UTF-8?q?=E5=88=86=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/community/BBSAction.java | 4 ++-- .../com/fr/design/actions/community/BugAction.java | 4 ++-- .../fr/design/actions/community/CenterAction.java | 4 ++-- .../fr/design/actions/community/CusDemandAction.java | 4 ++-- .../design/actions/community/FacebookFansAction.java | 4 ++-- .../com/fr/design/actions/community/NeedAction.java | 4 ++-- .../fr/design/actions/community/QuestionAction.java | 4 ++-- .../com/fr/design/actions/community/SignAction.java | 4 ++-- .../fr/design/actions/community/StudyPlanAction.java | 4 ++-- .../design/actions/community/TechSolutionAction.java | 4 ++-- .../actions/community/TemplateStoreAction.java | 4 ++-- .../com/fr/design/actions/community/UpAction.java | 4 ++-- .../actions/community/WorkOrderCenterAction.java | 4 ++-- .../com/fr/design/actions/help/TutorialAction.java | 4 ++-- .../design/data/datapane/ESDStrategyConfigPane.java | 4 ++-- .../preview/sql/PreviewPerformedSqlPane.java | 4 ++-- .../exe/callback/handle/PluginCallBackHelper.java | 4 ++-- .../gui/style/TranslucentBorderSpecialPane.java | 4 ++-- ...ocaleLinkProvide.java => LocaleLinkProvider.java} | 12 ++++++------ .../javascript/JSContentWithDescriptionPane.java | 4 ++-- .../com/fr/design/locale/impl/BbsRegisterMark.java | 4 ++-- .../java/com/fr/design/locale/impl/BbsResetMark.java | 4 ++-- .../java/com/fr/design/locale/impl/BbsSpaceMark.java | 4 ++-- .../com/fr/design/login/DesignerLoginBridge.java | 4 ++-- .../design/mainframe/check/CheckFontInfoDialog.java | 4 ++-- .../fr/design/update/actions/NewFeatureAction.java | 4 ++-- .../main/java/com/fr/env/RemoteDesignLocaleMark.java | 4 ++-- .../java/com/fr/env/SyncFailedPluginsDialog.java | 4 ++-- .../com/fr/env/detect/base/DetectorConstants.java | 6 +++--- .../share/ui/actions/Jump2DetailAction.java | 4 ++-- .../share/ui/online/OnlineWidgetRepoPane.java | 4 ++-- .../actions/replace/ui/ITReplaceWestPanel.java | 4 ++-- .../design/mainframe/socketio/DesignerSocketIO.java | 4 ++-- .../com/fr/design/report/ExportUniversalPane.java | 4 ++-- 34 files changed, 73 insertions(+), 73 deletions(-) rename designer-base/src/main/java/com/fr/design/i18n/{LocaleLinkProvide.java => LocaleLinkProvider.java} (75%) diff --git a/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java b/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java index 999d7d59ed..ed487578c8 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -28,7 +28,7 @@ public class BBSAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet BBS = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java b/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java index 7e90a3b684..9da1539a5a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -27,7 +27,7 @@ public class BugAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet BUG = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java b/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java index e634e58fc7..093070b55c 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.menu.MenuKeySet; import javax.swing.KeyStroke; @@ -29,7 +29,7 @@ public class CenterAction extends UpAction { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet CENTER = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java b/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java index 5afa19cea1..ef4cea39de 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/CusDemandAction.java @@ -1,7 +1,7 @@ package com.fr.design.actions.community; import com.fr.base.BaseUtils; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; @@ -35,7 +35,7 @@ public class CusDemandAction extends UpAction{ @Override public void actionPerformed(ActionEvent arg0) { - String url = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + String url = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); BrowseUtils.browser(url); } diff --git a/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java b/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java index 79b8f57760..05ef85e44f 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; @@ -28,7 +28,7 @@ public class FacebookFansAction extends UpAction { @Override public void actionPerformed(ActionEvent arg0) { - BrowseUtils.browser(LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT)); + BrowseUtils.browser(LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT)); } public static final MenuKeySet FACEBOOKFANS = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java b/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java index cf7bf7c1e0..33279060b6 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -28,7 +28,7 @@ public class NeedAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet NEED = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java b/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java index fb3bf4ec34..e56359139a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -28,7 +28,7 @@ public class QuestionAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet QUESTIONS = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java b/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java index 7a0b26eb20..29817e36a6 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/SignAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -27,7 +27,7 @@ public class SignAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet SIGN = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java b/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java index 402b62eb3f..0d2e79905d 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/StudyPlanAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.login.AbstractDesignerSSO; @@ -23,6 +23,6 @@ public class StudyPlanAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java b/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java index 46fdefff45..f0e4f3ac30 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -31,7 +31,7 @@ public class TechSolutionAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet TSO = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java b/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java index ebc8bfbb54..3c17df9b56 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/TemplateStoreAction.java @@ -1,7 +1,7 @@ package com.fr.design.actions.community; import com.fr.base.BaseUtils; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.menu.MenuKeySet; @@ -54,6 +54,6 @@ public class TemplateStoreAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { ComponentCollector.getInstance().collectTepMenuEnterClick(); - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java b/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java index 4385f1d466..e0c6404836 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java @@ -1,7 +1,7 @@ package com.fr.design.actions.community; import com.fr.base.BaseUtils; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -28,7 +28,7 @@ public class UpAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY ,PROPS_LINK_KEY_DEFAULT); } public static final MenuKeySet UPDATE = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java b/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java index e34443e720..03e634a4ad 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.community; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; /** @@ -27,6 +27,6 @@ public class WorkOrderCenterAction extends UpAction { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java index 1712272685..1a4bccfa4a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java @@ -1,6 +1,6 @@ package com.fr.design.actions.help; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; @@ -38,7 +38,7 @@ public class TutorialAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } // 生成帮助文档 sitecenter key, help.zh_CN.10 diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java index ce3464bc9e..0106654e8f 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java @@ -6,7 +6,7 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.esd.common.CacheConstants; @@ -50,7 +50,7 @@ public class ESDStrategyConfigPane extends BasicBeanPane { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Cron_Help_Default"; - private static final String CRON_HELP_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + private static final String CRON_HELP_URL = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private UIRadioButton selectAutoUpdate; private UIRadioButton selectBySchema; private UICheckBox shouldEvolve; diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java index c32fa2dcf4..c4996d539e 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java @@ -11,7 +11,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -94,7 +94,7 @@ public class PreviewPerformedSqlPane extends JDialog implements ActionListener { JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Preview_Performed_Sql_Message") + Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention") + Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message")); messagePanel.add(label); } else { - MessageWithLink message = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Front_Message"), Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention"), LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT), Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message")); + MessageWithLink message = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Front_Message"), Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention"), LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT), Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message")); messagePanel.add(message); } // 提示图标 diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java index f672eb15bd..8fe64dc29a 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java @@ -2,7 +2,7 @@ package com.fr.design.extra.exe.callback.handle; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.link.MessageWithLink; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.manage.control.PluginTaskResult; @@ -29,7 +29,7 @@ public class PluginCallBackHelper { private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design_Basic_Plugin_File_Validate_HELP_DOCUMENT_LINK_Default"; - private static final String HELP_DOCUMENT_LINK = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + private static final String HELP_DOCUMENT_LINK = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); /** diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java index d126716474..0fb3706afb 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java @@ -16,7 +16,7 @@ import com.fr.design.gui.frpane.UIPercentDragPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -90,7 +90,7 @@ public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane imple */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Nine_Patch_Default"; - private final String TWEAK_NINE_POINT_HELP_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + private final String TWEAK_NINE_POINT_HELP_URL = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private UIObserverListener uiObserverListener; diff --git a/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkProvide.java b/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkProvider.java similarity index 75% rename from designer-base/src/main/java/com/fr/design/i18n/LocaleLinkProvide.java rename to designer-base/src/main/java/com/fr/design/i18n/LocaleLinkProvider.java index e7379137ff..4a819069a7 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkProvide.java +++ b/designer-base/src/main/java/com/fr/design/i18n/LocaleLinkProvider.java @@ -11,21 +11,21 @@ import com.fr.stable.StringUtils; * @since 11.0 * Created on 2023/4/7 */ -public final class LocaleLinkProvide { +public final class LocaleLinkProvider { - private LocaleLinkProvide(){}; + private LocaleLinkProvider(){}; /** * 单一实例 */ - private static final LocaleLinkProvide INSTANCE = new LocaleLinkProvide(); + private static final LocaleLinkProvider INSTANCE = new LocaleLinkProvider(); /** - * 返回LocaleLinkProvide的单一实例 + * 返回LocaleLinkProvider的单一实例 * - * @return LocaleLinkProvide单一实例 + * @return LocaleLinkProvider单一实例 */ - public static LocaleLinkProvide getInstance(){ + public static LocaleLinkProvider getInstance(){ return INSTANCE; } diff --git a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java index bd7efabe84..e204a3342b 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java @@ -14,7 +14,7 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextfield.PlaceholderTextField; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.javascript.jsapi.JSAPITreeHelper; import com.fr.design.javascript.jsapi.JSAPIUserObject; @@ -361,7 +361,7 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi private void doHelpDocumentSearch() { Object value = interfaceNameList.getSelectedValue(); if (value != null) { - String url = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + String url = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); try { String result = HttpToolbox.get(url); JSONObject jsonObject = new JSONObject(result); diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java index 593a3cae08..dfa425a3c0 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java @@ -1,6 +1,6 @@ package com.fr.design.locale.impl; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.general.locale.LocaleMark; /** @@ -23,6 +23,6 @@ public class BbsRegisterMark implements LocaleMark { @Override public String getValue() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java index 18431ba23b..49092d4f25 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java @@ -1,6 +1,6 @@ package com.fr.design.locale.impl; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.general.locale.LocaleMark; /** @@ -25,6 +25,6 @@ public class BbsResetMark implements LocaleMark { @Override public String getValue() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java index 112521749a..a0b21d271a 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BbsSpaceMark.java @@ -1,6 +1,6 @@ package com.fr.design.locale.impl; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.general.locale.LocaleMark; /** @@ -24,6 +24,6 @@ public class BbsSpaceMark implements LocaleMark { public BbsSpaceMark() {} @Override public String getValue() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java b/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java index 109c19e364..4789cc4f9b 100644 --- a/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java +++ b/designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java @@ -5,7 +5,7 @@ import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.locale.impl.BbsResetMark; @@ -83,7 +83,7 @@ public class DesignerLoginBridge { getHyperlinkPane( com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Guide_Login_Success_Title"), com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Guide_Login_Success_Hyperlink_Text"), - LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT) + LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT) ) ); } else if (source == DesignerLoginSource.BBS_JUMP) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java index e68282f26a..8274b65355 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java @@ -4,7 +4,7 @@ import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.DesignSizeI18nManager; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; @@ -55,7 +55,7 @@ public class CheckFontInfoDialog extends JDialog implements ActionListener { JPanel imagePanel = new JPanel(); imageLabel = new UILabel(IOUtils.readIcon("com/fr/design/images/warnings/warning32.png")); imagePanel.add(imageLabel); - String link = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + String link = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); JPanel messagePanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); MessageWithLink linkMessage = new MessageWithLink(Toolkit.i18nText("Fine_Designer_Check_Font_Message"), Toolkit.i18nText("Fine_Designer_Check_Font_Install_Font"), diff --git a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java index 09d627b751..320a2a23dc 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java @@ -1,7 +1,7 @@ package com.fr.design.update.actions; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.utils.BrowseUtils; import com.fr.log.FineLoggerFactory; @@ -25,7 +25,7 @@ public class NewFeatureAction implements ActionListener { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Latest_Update_Detail_Default"; - public static String DEFAULT_UPDATE_DETAIL_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + public static String DEFAULT_UPDATE_DETAIL_URL = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); @Override public void actionPerformed(ActionEvent e) { diff --git a/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java b/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java index 89a28dc3e0..dd95323617 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java +++ b/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java @@ -1,6 +1,6 @@ package com.fr.env; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.general.locale.LocaleMark; /** @@ -24,7 +24,7 @@ public class RemoteDesignLocaleMark implements LocaleMark { @Override public String getValue() { - return LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); } } diff --git a/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java b/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java index f3a8eb2685..a0b07bd2c0 100644 --- a/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java +++ b/designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java @@ -6,7 +6,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.i18n.DesignSizeI18nManager; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -73,7 +73,7 @@ public class SyncFailedPluginsDialog extends JDialog { JPanel messagePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); MessageWithLink messageWithLink = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugin_Fail_Suggestion"),Toolkit.i18nText("Fine-Design_Basic_Sync_Deal_Immediately"), - LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT)); + LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT)); messageWithLink.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.env.SyncFailedPluginsDialog.messageWithLink")); messagePane.add(messageWithLink); diff --git a/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java b/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java index 4be5875899..61f08c344c 100644 --- a/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java +++ b/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java @@ -1,6 +1,6 @@ package com.fr.env.detect.base; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; /** * created by Harrison on 2022/05/25 @@ -25,9 +25,9 @@ public class DetectorConstants { * 云中心FineDB异常检测帮助文档默认链接在配置文件中对应的配置文件key */ private static final String JAR_HELP_PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Jar_Exception_Check_Default"; - public static final String JAR_HELP_LINK = LocaleLinkProvide.getInstance().getLink(JAR_HELP_PROPS_LINK_KEY, JAR_HELP_PROPS_LINK_KEY_DEFAULT);; + public static final String JAR_HELP_LINK = LocaleLinkProvider.getInstance().getLink(JAR_HELP_PROPS_LINK_KEY, JAR_HELP_PROPS_LINK_KEY_DEFAULT);; - public static final String FINE_DB_HELP_LINK = LocaleLinkProvide.getInstance().getLink(FINE_DB_HELP_PROPS_LINK_KEY, FINE_DB_HELP_PROPS_LINK_KEY_DEFAULT); + public static final String FINE_DB_HELP_LINK = LocaleLinkProvider.getInstance().getLink(FINE_DB_HELP_PROPS_LINK_KEY, FINE_DB_HELP_PROPS_LINK_KEY_DEFAULT); public static final String SEPARATOR = "、"; public static final String BR_TAG = "
"; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java index 8a77b28e04..b4d546727b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.share.ui.actions; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.share.ui.online.CarouselStateManger; import com.fr.stable.StringUtils; @@ -29,7 +29,7 @@ public class Jump2DetailAction extends SharedComponentPopupAction { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Detail_Default"; - private static final String ONLINE_WIDGET_DETAIL_FORMATTED_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + private static final String ONLINE_WIDGET_DETAIL_FORMATTED_URL = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private final String id; public Jump2DetailAction(String id) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java index f49924cce6..e7b60ce926 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java @@ -5,7 +5,7 @@ import com.fr.base.Style; import com.fr.design.dialog.BasicPane; import com.fr.design.form.util.FontTransformUtil; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.share.ui.base.LoadingPane; @@ -53,7 +53,7 @@ public class OnlineWidgetRepoPane extends BasicPane { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Market_Default"; - private static final String MARKET_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + private static final String MARKET_URL = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private static List[] sharableWidgets; private OnlineWidgetTabPane componentTabPane; private boolean isShowPackagePanel = false; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java index 0ed6b36b45..c4914c9622 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -4,7 +4,7 @@ import com.fr.base.svg.IconUtils; import com.fr.design.actions.replace.info.Info; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.design.utils.BrowseUtils; @@ -45,7 +45,7 @@ public class ITReplaceWestPanel { * 云中心定时调度执行频率表达式设定帮助文档默认链接在配置文件中对应的配置文件key */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Template_Level_Search_Replace_Default"; - private static final String HELP_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + private static final String HELP_URL = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private static final int FILL_COUNT = 11; public static final int LEFT_WIDTH = 100; public static final String CONTENT_TEXT = "" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + ""; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 151b7d1e2d..4b5c287ff5 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -7,7 +7,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -68,7 +68,7 @@ public class DesignerSocketIO { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_WebSocket_Default"; - private static final String WEBSOCKET_HELP_DOC = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + private static final String WEBSOCKET_HELP_DOC = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private static final String HTTPS = "https"; private static final String HTTP = "http"; private static Socket socket = null; diff --git a/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java b/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java index 1e83032abb..4da3b89e81 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java @@ -6,7 +6,7 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.LocaleLinkProvide; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.BrowseUtils; @@ -40,7 +40,7 @@ public class ExportUniversalPane extends BasicPane { */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Alt_Font_Export_Default"; - private static final String HELP_URL = LocaleLinkProvide.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + private static final String HELP_URL = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); private UICheckBox specialCharacterExport; // 密码支持公式 From 463f8d9e61fe61948944e43a144dec9f07c995f0 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 13 Apr 2023 19:46:07 +0800 Subject: [PATCH 04/59] =?UTF-8?q?REPORT-75308=20FVS=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=94=AF=E6=8C=81=E5=90=8C=E6=97=B6=E6=89=93?= =?UTF-8?q?=E5=BC=80=E5=A4=9A=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../file/CloseCurrentTemplateAction.java | 8 +- .../fr/design/actions/file/RenameAction.java | 4 +- .../design/actions/file/SwitchExistEnv.java | 2 +- .../java/com/fr/design/file/CloseOption.java | 43 ++ .../design/file/HistoryTemplateListCache.java | 41 +- .../file/MultiTemplateTabMenuFactory.java | 346 +++++++++++++ .../fr/design/file/MultiTemplateTabPane.java | 486 ++---------------- .../fr/design/file/MutilTempalteTabPane.java | 6 +- .../com/fr/design/file/NewTemplatePane.java | 6 +- .../fr/design/file/SaveSomeTemplatePane.java | 19 +- .../fr/design/file/TemplateTabManager.java | 253 +++++++++ .../file/TemplateTabOperateProvider.java | 114 ++++ .../file/impl/AbstractTemplateTabOperate.java | 332 ++++++++++++ .../file/impl/DefaultTemplateTabOperate.java | 31 ++ .../file/impl/EmptyTemplateTabOperator.java | 109 ++++ .../mainframe/CenterRegionContainerPane.java | 29 +- .../mainframe/DefaultToolKitConfig.java | 8 + .../fr/design/mainframe/DesignerFrame.java | 8 +- .../DesignerFrameFileDealerPane.java | 15 +- .../com/fr/design/mainframe/JTemplate.java | 21 +- .../mainframe/ToolKitConfigStrategy.java | 10 + .../mainframe/toolbar/ToolBarMenuDock.java | 4 +- .../vcs/ui/FileVersionCellEditor.java | 8 +- .../mainframe/vcs/ui/FileVersionsPanel.java | 8 +- .../com/fr/design/worker/open/OpenWorker.java | 4 +- .../designer/toolbar/TemplateTransformer.java | 8 +- .../main/java/com/fr/start/BaseDesigner.java | 6 +- .../start/common/DesignerOpenEmptyPanel.java | 4 +- .../fr/design/fit/common/TemplateTool.java | 4 +- .../fr/design/preview/DeveloperPreview.java | 5 +- .../com/fr/design/mainframe/JWorkBook.java | 4 +- .../main/java/com/fr/start/MainDesigner.java | 4 +- 32 files changed, 1426 insertions(+), 524 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/file/CloseOption.java create mode 100644 designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java create mode 100644 designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java create mode 100644 designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java create mode 100644 designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java create mode 100644 designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java diff --git a/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java b/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java index 22263a871e..b2ab237d7d 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java @@ -3,7 +3,7 @@ package com.fr.design.actions.file; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; @@ -28,9 +28,9 @@ public class CloseCurrentTemplateAction extends UpdateAction { * @param e 事件 */ public void actionPerformed(ActionEvent e) { - MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); - MultiTemplateTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + TemplateTabManager.getInstance().setCloseCurrent(true); + TemplateTabManager.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + TemplateTabManager.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } @Override diff --git a/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java b/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java index 842292ce2a..33f51b77aa 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java @@ -7,7 +7,7 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.FileOperations; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; @@ -88,7 +88,7 @@ public class RenameAction extends UpdateAction { } new FileRenameDialog(node); - MultiTemplateTabPane.getInstance().repaint(); + TemplateTabManager.getInstance().refresh(); DesignerFrameFileDealerPane.getInstance().stateChange(); } diff --git a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java index 33761a92e2..e38a39895a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java @@ -68,7 +68,7 @@ public class SwitchExistEnv extends MenuDef { EnvChangeEntrance.getInstance().chooseEnv(envName); } else { SaveSomeTemplatePane saveSomeTemplatePane = new SaveSomeTemplatePane(true); - if (saveSomeTemplatePane.showSavePane()) { + if (saveSomeTemplatePane.showSavePane(true)) { // 用户模板保存后,才进行切换目录操作 EnvChangeEntrance.getInstance().switch2Env(envName); } diff --git a/designer-base/src/main/java/com/fr/design/file/CloseOption.java b/designer-base/src/main/java/com/fr/design/file/CloseOption.java new file mode 100644 index 0000000000..c88e7658c8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/CloseOption.java @@ -0,0 +1,43 @@ +package com.fr.design.file; + +import com.fr.design.i18n.Toolkit; + +public enum CloseOption { + Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { + @Override + public boolean shouldClose(int tplIndex, int i) { + return i < tplIndex; + } + }, + + Right(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Right")) { + @Override + public boolean shouldClose(int tplIndex, int i) { + return i > tplIndex; + } + + }, All(Toolkit.i18nText("Fine-Design_Close_All_templates")), + + Others(Toolkit.i18nText("Fine-Design_Close_Other_templates")) { + @Override + public boolean shouldClose(int tplIndex, int i) { + return i != tplIndex; + } + }; + + + private String optionName; + + public String getOptionName() { + return this.optionName; + } + + CloseOption(String optionName) { + this.optionName = optionName; + } + + public boolean shouldClose(int tplIndex, int i) { + return true; + } + +} \ No newline at end of file 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 86820aa227..083aa2ed08 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 @@ -75,7 +75,7 @@ public class HistoryTemplateListCache implements CallbackEvent { historyList.remove(contains(selected)); selected.getEditingFILE().closeTemplate(); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName())); - MultiTemplateTabPane.getInstance().refreshOpenedTemplate(historyList); + TemplateTabManager.getInstance().refreshOpenedTemplate(historyList); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -134,10 +134,10 @@ public class HistoryTemplateListCache implements CallbackEvent { if (contains(jt) == -1) { addHistory(); } - MultiTemplateTabPane.getInstance().refreshOpenedTemplate(historyList); + TemplateTabManager.getInstance().refreshOpenedTemplate(historyList); //设置tab栏为当前选中的那一栏 if (editingTemplate != null) { - MultiTemplateTabPane.getInstance().setSelectedIndex(contains(jt)); + TemplateTabManager.getInstance().resetSelectIndex(jt); } } @@ -268,13 +268,14 @@ public class HistoryTemplateListCache implements CallbackEvent { boolean replaceWithJVirtualTemplate = overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate - && overTemplate.checkEnable(); + && overTemplate.checkEnable() + && overTemplate.supportCache(); if (replaceWithJVirtualTemplate) { closeVirtualSelectedReport(overTemplate); historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE())); } } - MultiTemplateTabPane.getInstance().refreshOpenedTemplate(historyList); + TemplateTabManager.getInstance().refreshOpenedTemplate(historyList); } @@ -285,35 +286,27 @@ public class HistoryTemplateListCache implements CallbackEvent { // path like reportlets/xx/xxx/xxx String path = file.getPath() + suffix; - - ListIterator> iterator = historyList.listIterator(); - + List list = new ArrayList(); + for(JTemplate jTemplate : historyList){ + list.add(jTemplate); + } + ListIterator> iterator = list.listIterator(); while (iterator.hasNext()) { JTemplate template = iterator.next(); String tPath = template.getPath(); if (isDir ? tPath.startsWith(path) : tPath.equals(path)) { - int size = getHistoryCount(); - iterator.remove(); - int index = iterator.nextIndex(); - if (size == index + 1 && index > 0) { - //如果删除的是后一个Tab,则定位到前一个 - MultiTemplateTabPane.getInstance().setSelectedIndex(index - 1); - } + historyList.remove(template); + TemplateTabManager.getInstance().deleteOpenedTemplate(template); } } - //如果打开过,则删除,实时刷新多tab面板 - int openFileCount = getHistoryCount(); - if (openFileCount == 0) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(); - } - JTemplate selectedFile = MultiTemplateTabPane.getInstance().getSelectedFile(); + JTemplate selectedFile = TemplateTabManager.getInstance().getSelectedFile(); if (!isCurrentEditingFile(selectedFile.getPath())) { //如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样 DesignerContext.getDesignerFrame().activateJTemplate(selectedFile); } - MultiTemplateTabPane.getInstance().repaint(); + TemplateTabManager.getInstance().refresh(); } @@ -474,7 +467,7 @@ public class HistoryTemplateListCache implements CallbackEvent { int index = contains(this.editingTemplate); this.editingTemplate = jt; historyList.set(index, jt); - MultiTemplateTabPane.getInstance().refreshOpenedTemplate(historyList); - MultiTemplateTabPane.getInstance().setSelectedIndex(contains(jt)); + TemplateTabManager.getInstance().refreshOpenedTemplate(historyList); + TemplateTabManager.getInstance().resetSelectIndex(jt); } } diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java new file mode 100644 index 0000000000..a67e129f78 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java @@ -0,0 +1,346 @@ +package com.fr.design.file; + +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.gui.imenu.UIScrollPopUpMenu; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.utils.TemplateUtils; +import com.fr.file.FILE; +import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.CollectionUtils; +import com.fr.third.javax.annotation.Nonnull; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author Carlson + * @version 11.0 + * @description + **/ +public class MultiTemplateTabMenuFactory { + + private static final Icon CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png"); + private static final Icon MOUSE_OVER_CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/mouseoverclose icon.png"); + private static final Icon MOUSE_PRESS_CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/pressclose icon.png"); + + private static final int ITEM_SIZE = 25; + + private UIScrollPopUpMenu menu = null; + + private static MultiTemplateTabMenuFactory INSTANCE = new MultiTemplateTabMenuFactory(); + + private MultiTemplateTabMenuFactory() { + + } + + public static MultiTemplateTabMenuFactory getInstance() { + return INSTANCE; + } + + /** + * tab上的下拉菜单 + */ + public UIScrollPopUpMenu createMenu() { + menu = new UIScrollPopUpMenu(); + menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); + + menu.add(initCloseOther()); + menu.add(createEmptyRow()); + menu.addSeparator(); + menu.add(createEmptyRow()); + menu.add(createCategory(Toolkit.i18nText("Fine-Design_Basic_Tab_Current_Category_Templates"))); + Component[] items = createCurrentCategory(); + for (Component item : items) { + menu.add(item); + } + items = createOtherCategory(); + if (items.length > 0) { + menu.addSeparator(); + menu.add(createEmptyRow()); + menu.add(createCategory(Toolkit.i18nText("Fine-Design_Basic_Tab_Other_Category_Templates"))); + for (Component item : items) { + menu.add(item); + } + } + Dimension dimension = menu.getPreferredSize(); + dimension.width += ITEM_SIZE; + menu.setPreferredSize(dimension); + return menu; + } + + /** + * 关闭其它按钮 + */ + private UIMenuItem initCloseOther() { + UIMenuItem closeOther = new UIMenuItem(Toolkit.i18nText("Fine-Design_Basic_Tab_Close_Other_Templates_Of_Current_Category")); + closeOther.setHorizontalAlignment(SwingConstants.CENTER); + Dimension dimension = closeOther.getPreferredSize(); + dimension.height = ITEM_SIZE; + closeOther.setPreferredSize(dimension); + closeOther.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + TemplateTabManager.getInstance().closeOthers(); + } + + }); + if (TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size() <= 1) { + closeOther.setEnabled(false); + } + return closeOther; + } + + private void closeAndFreeLock(@Nonnull JTemplate template) { + FILE file = template.getEditingFILE(); + // 只有是环境内的文件,才执行释放锁 + if (file != null && file.isEnvFile()) { + // release lock + TemplateResourceManager.getResource().closeTemplate(file.getPath()); + } + } + + /** + * 美观用 + */ + private JPanel createEmptyRow() { + return new JPanel() { + @Override + public Dimension getPreferredSize() { + Dimension d = super.getPreferredSize(); + d.height = 1; + return d; + } + }; + } + + /** + * 模板分类item + */ + private UIButton createCategory(String categoryName) { + UIButton button = new UIButton(categoryName); + button.setBorderPainted(false); + button.setExtraPainted(false); + button.setPreferredSize(new Dimension(menu.getWidth(), ITEM_SIZE)); + button.setOpaque(true); + button.setBackground(UIConstants.NORMAL_BACKGROUND); + button.setHorizontalAlignment(SwingConstants.LEFT); + button.setForeground(UIConstants.FLESH_BLUE); + return button; + } + + /** + * 创建 当前分类模板 item数组 + */ + private Component[] createCurrentCategory() { + return createListDownItem(TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates()); + } + + /** + * 创建 其它分类模板 item数组 + */ + private Component[] createOtherCategory() { + List> openedTemplates = new ArrayList<>(); + Map>> map = TemplateTabManager.getInstance().getAllOpenedTemplateMap(); + for (Map.Entry>> entry : map.entrySet()) { + if (!StringUtils.equals(TemplateTabManager.getInstance().getCurrentOperator().getOperatorType(), entry.getKey())) { + openedTemplates.addAll(entry.getValue()); + } + } + return createListDownItem(openedTemplates); + } + + /** + * 根据template列表创建多个item + */ + private Component[] createListDownItem(List> openedTemplates) { + if (!CollectionUtils.isEmpty(openedTemplates)) { + Component[] templates = new Component[openedTemplates.size()]; + for (int i = 0; i < openedTemplates.size(); i++) { + templates[i] = createListDownMenuItem(openedTemplates.get(i)); + } + return templates; + } + return new Component[0]; + } + + /** + * 根据template对象创建item + */ + private Component createListDownMenuItem(JTemplate template) { + JPanel jPanel = new JPanel(); + jPanel.setPreferredSize(new Dimension(menu.getWidth(), ITEM_SIZE)); + jPanel.setLayout(new BorderLayout()); + + MenuItemButtonGroup menuItemButtonGroup = new MenuItemButtonGroup(template); + if (template == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) { + menuItemButtonGroup.templateButton.setForeground(UIConstants.FLESH_BLUE); + } + + jPanel.add(menuItemButtonGroup.iconButton, BorderLayout.WEST); + jPanel.add(menuItemButtonGroup.templateButton, BorderLayout.CENTER); + jPanel.add(menuItemButtonGroup.closeButton, BorderLayout.EAST); + + return jPanel; + } + + /** + * menu的item由模板图标、模板名、模板关闭按钮组成 + */ + private class MenuItemButtonGroup { + + private final UIButton iconButton; + private final UIButton templateButton; + private final UIButton closeButton; + + public MenuItemButtonGroup(JTemplate template) { + iconButton = createIconButton(template); + templateButton = createTemplateButton(template); + closeButton = createCloseButton(); + initListener(template); + } + + /** + * item[0] 模板图标按钮初始化 + */ + private UIButton createIconButton(JTemplate template) { + UIButton button = new UIButton(template.getIcon(), template.getIcon(), template.getIcon()); + button.setPreferredSize(new Dimension(ITEM_SIZE, ITEM_SIZE)); + button.setOpaque(true); + button.setBackground(UIConstants.NORMAL_BACKGROUND); + return button; + } + + /** + * item[1] 切换模板按钮初始化 + */ + private UIButton createTemplateButton(JTemplate template) { + UIButton button = new UIButton(TemplateUtils.createLockeTemplatedName(template, template.getTemplateName())); + button.setBorderPainted(false); + button.setExtraPainted(false); + button.setPreferredSize(new Dimension(menu.getWidth() - ITEM_SIZE * 2, ITEM_SIZE)); + button.setOpaque(true); + button.setBackground(UIConstants.NORMAL_BACKGROUND); + button.setHorizontalAlignment(SwingConstants.LEFT); + return button; + } + + /** + * item[2] 关闭模板图标按钮初始化 + */ + private UIButton createCloseButton() { + UIButton button = new UIButton(CLOSE, MOUSE_OVER_CLOSE, MOUSE_PRESS_CLOSE); + button.setPreferredSize(new Dimension(ITEM_SIZE, ITEM_SIZE)); + button.setOpaque(true); + button.setBackground(UIConstants.NORMAL_BACKGROUND); + button.setVisible(false); + return button; + } + + private void initListener(JTemplate template) { + initIconButtonListener(); + initTemplateButtonListener(template); + initCloseButtonListener(template); + } + + /** + * item[0] 模板图标按钮鼠标事件 + */ + private void initIconButtonListener() { + iconButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + fireMouseEnteredEvent(); + } + + @Override + public void mouseExited(MouseEvent e) { + fireMouseExitedEvent(); + } + }); + } + + /** + * item[1] 切换模板按钮鼠标事件 + */ + private void initTemplateButtonListener(JTemplate template) { + templateButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + menu.setVisible(false); + TemplateTabManager.getInstance().switchByJTemplate(template); + } + + @Override + public void mouseEntered(MouseEvent e) { + fireMouseEnteredEvent(); + } + + @Override + public void mouseExited(MouseEvent e) { + fireMouseExitedEvent(); + } + }); + } + + /** + * item[2] 关闭模板按钮鼠标事件 + */ + private void initCloseButtonListener(JTemplate template) { + closeButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + menu.setVisible(false); + TemplateTabManager.getInstance().closeByJTemplate(template); + } + + @Override + public void mouseEntered(MouseEvent e) { + fireMouseEnteredEvent(); + } + + @Override + public void mouseExited(MouseEvent e) { + fireMouseExitedEvent(); + } + }); + } + + /** + * mouse移入item范围 + */ + private void fireMouseEnteredEvent() { + iconButton.setBackground(UIConstants.HOVER_BLUE); + templateButton.setBackground(UIConstants.HOVER_BLUE); + closeButton.setBackground(UIConstants.HOVER_BLUE); + closeButton.setVisible(true); + } + + /** + * mouse移出item范围 + */ + private void fireMouseExitedEvent() { + iconButton.setBackground(UIConstants.NORMAL_BACKGROUND); + templateButton.setBackground(UIConstants.NORMAL_BACKGROUND); + closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); + closeButton.setVisible(false); + } + + } + +} diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 8e302fd977..efc4565e00 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -1,38 +1,28 @@ package com.fr.design.file; -import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.base.svg.IconUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.file.LocateAction; import com.fr.design.constants.UIConstants; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.TemplateSavingChecker; -import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.TemplateUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; -import com.fr.design.worker.WorkerManager; -import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.file.FILE; -import com.fr.file.FileNodeFILE; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; -import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; import com.fr.third.javax.annotation.Nonnull; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.lock.TplOperator; import javax.swing.BorderFactory; import javax.swing.ButtonModel; @@ -41,7 +31,6 @@ import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JMenu; import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.MenuElement; @@ -69,12 +58,6 @@ import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; -import java.util.List; - -import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; -import static javax.swing.JOptionPane.OK_CANCEL_OPTION; -import static javax.swing.JOptionPane.OK_OPTION; -import static javax.swing.JOptionPane.WARNING_MESSAGE; /** * 改个名字,一个拼写 n 个错误 @@ -114,10 +97,6 @@ public class MultiTemplateTabPane extends JComponent { private static MultiTemplateTabPane THIS; - //用于存放工作簿 - private java.util.List> openedTemplate; - //选中的Tab项 - private int selectedIndex = 0; // private int mouseOveredIndex = -1; @@ -136,16 +115,11 @@ public class MultiTemplateTabPane extends JComponent { //记录关闭按钮的状态 private int closeIconIndex = -1; - private boolean isCloseCurrent = false; + private Icon clodeMode = CLOSE; private Icon listDownMode = LIST_DOWN; private boolean isShowList = false; - //自动新建的模板B若没有进行任何编辑,切换到其他 - // - // 模板时,模板B会自动关闭 - private JTemplate temTemplate = null; - public static MultiTemplateTabPane getInstance() { if (THIS == null) { @@ -165,8 +139,6 @@ public class MultiTemplateTabPane extends JComponent { this.setBorder(null); this.setForeground(new Color(58, 56, 58)); this.setFont(DesignUtils.getDefaultGUIFont().applySize(12)); - openedTemplate = HistoryTemplateListCache.getInstance().getHistoryList(); - selectedIndex = openedTemplate.size() - 1; AWTEventListener awt = new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { @@ -206,45 +178,13 @@ public class MultiTemplateTabPane extends JComponent { //根据当前i18n语言环境,动态调整popupMenu的宽度 menu.setPreferredSize(new Dimension((int) DesignSizeI18nManager.getInstance(). i18nDimension("com.fr.design.file.MultiTemplateTabPane.popUpMenu").getWidth(), height)); - GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.getInstance(), e.getX(), MultiTemplateTabPane.getInstance().getY() - 1 + MultiTemplateTabPane.getInstance().getHeight()); + GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.this, e.getX(), MultiTemplateTabPane.this.getY() - 1 + MultiTemplateTabPane.this.getHeight()); } } } }); } - enum CloseOption { - Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { - @Override - boolean shouldClose(int tplIndex, int i) { - return i < tplIndex; - } - }, - Right(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Right")) { - @Override - boolean shouldClose(int tplIndex, int i) { - return i > tplIndex; - } - }, - All(Toolkit.i18nText("Fine-Design_Close_All_templates")), - Others(Toolkit.i18nText("Fine-Design_Close_Other_templates")) { - @Override - boolean shouldClose(int tplIndex, int i) { - return i != tplIndex; - } - }; - - - String optionName; - - CloseOption(String optionName) { - this.optionName = optionName; - } - - boolean shouldClose(int tplIndex, int i) { - return true; - } - } private static class CloseMenuItemJSeparator extends JSeparator { @Override @@ -272,41 +212,10 @@ public class MultiTemplateTabPane extends JComponent { @Override public void actionPerformed(ActionEvent e) { - //处于搜索模式时,先退出搜索模式,再定位 - if (TemplateTreeSearchManager.getInstance().isInSearchMode()) { - TemplateTreeSearchManager.getInstance().outOfSearchMode(); - TemplateTreePane.getInstance().refreshDockingView(); - } - JTemplate template = openedTemplate.get(this.tplIndex); - locateTemplate(template); + //DefaultTemplateTabOperate.getInstance().locateTemplateInTree(this.tplIndex); + TemplateTabManager.getInstance().getCurrentOperator().locateTemplateInTree(this.tplIndex); } - private void locateTemplate(JTemplate template) { - FILE currentTemplate = template.getEditingFILE(); - //模板不属于当前环境,跟预览一样先提示保存,再定位模板 - //如果是拖拽进来的模板单单用exist不能判断,这边参考预览的判断逻辑(browserTemplate),补充一下 - if (!currentTemplate.exists() || !(currentTemplate instanceof FileNodeFILE)) { - int selVal = showConfirmDialog( - DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), - Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), - OK_CANCEL_OPTION, - WARNING_MESSAGE - ); - if (OK_OPTION == selVal) { - CallbackSaveWorker worker = template.saveAs(); - worker.start(template.getRuntimeId()); - worker.addSuccessCallback(new Runnable() { - @Override - public void run() { - gotoEditingTemplateLeaf(template.getPath()); - } - }); - } - } else { - gotoEditingTemplateLeaf(template.getPath()); - } - } } private class RightMenuCloseAction extends UpdateAction { @@ -316,80 +225,15 @@ public class MultiTemplateTabPane extends JComponent { public RightMenuCloseAction(CloseOption option, int tplIndex) { this.option = option; - this.setName(option.optionName); + this.setName(option.getOptionName()); this.tplIndex = tplIndex; } @Override public void actionPerformed(ActionEvent e) { - SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); - if (saveSomeTempaltePane.showSavePane()) { - - JTemplate[] templates = new JTemplate[openedTemplate.size()]; - for (int i = 0; i < openedTemplate.size(); i++) { - templates[i] = openedTemplate.get(i); - } - JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - closeTemplate(templates, currentTemplate); - - if (option == CloseOption.All) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(); - } else { - DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); - } - - MultiTemplateTabPane.getInstance().repaint(); - } - } - - private void closeTemplate(JTemplate[] templates, JTemplate currentTemplate) { - for (int i = 0; i < templates.length; i++) { - if (option.shouldClose(tplIndex, i)) { - JTemplate jTemplate = templates[i]; - if (jTemplate == currentTemplate) { - currentTemplate = option == CloseOption.All ? null : templates[tplIndex]; - } - //判断关闭的模板是不是格式刷的被参照的模板 - openedTemplate.remove(jTemplate); - if (jTemplate != currentTemplate) { - MultiTemplateTabPane.getInstance().closeFormat(jTemplate); - HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); - closeAndFreeLock(jTemplate); - } - } - } - } - - private void closeAndFreeLock(@Nonnull JTemplate template) { - FILE file = template.getEditingFILE(); - // 只有是环境内的文件,才执行释放锁 - if (file != null && file.isEnvFile()) { - // release lock - WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath()); - } - } - } - - public JTemplate getSelectedFile() { - if (openedTemplate.size() == selectedIndex) { - selectedIndex = Math.max(--selectedIndex, 0); - } - return openedTemplate.get(selectedIndex); - } - - - /** - * 关闭掉当前已打开文件列表中指定的文件 - * - * @param file 指定的文件 - */ - public void closeFileTemplate(FILE file) { - for (JTemplate temp : openedTemplate) { - if (ComparatorUtils.equals(file, temp.getEditingFILE())) { - closeSpecifiedTemplate(temp); - break; - } + TemplateTabManager.getInstance().getCurrentOperator().closeAction(option, this.tplIndex); + MultiTemplateTabPane.this.repaint(); } } @@ -409,7 +253,9 @@ public class MultiTemplateTabPane extends JComponent { closeOther.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if (openedTemplate.size() == 1) { + //int tabSize = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); + int tabSize = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); + if (tabSize == 1) { return; } if (!TemplateSavingChecker.check()) { @@ -418,29 +264,28 @@ public class MultiTemplateTabPane extends JComponent { SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); //点击关闭其他模板,并且点击确定保存 if (saveSomeTempaltePane.showSavePane()) { - JTemplate[] panes = new JTemplate[openedTemplate.size()]; - for (int i = 0; i < openedTemplate.size(); i++) { - panes[i] = openedTemplate.get(i); + JTemplate[] panes = new JTemplate[tabSize]; + for (int i = 0; i < tabSize; i++) { + panes[i] = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(i); } for (int i = 0; i < panes.length; i++) { - if (i != selectedIndex) { + if (i != TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex()) { JTemplate jTemplate = panes[i]; //判断关闭的模板是不是格式刷的被参照的模板 - openedTemplate.remove(jTemplate); - closeFormat(jTemplate); + TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().remove(jTemplate); + TemplateTabManager.getInstance().closeFormat(jTemplate); HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); closeAndFreeLock(jTemplate); } } JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - HistoryTemplateListCache.getInstance().removeAllHistory(); - DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); + TemplateTabManager.getInstance().resetSelectIndex(currentTemplate); THIS.repaint(); } //如果取消保存了,则不关闭其他模板 } }); - if (openedTemplate.size() == 1) { + if (TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size() == 1) { closeOther.setEnabled(false); } return closeOther; @@ -448,21 +293,22 @@ public class MultiTemplateTabPane extends JComponent { private UIMenuItem[] createListDownTemplate() { - UIMenuItem[] templates = new UIMenuItem[openedTemplate.size()]; - for (int i = 0; i < openedTemplate.size(); i++) { + int templateTabCount = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); + UIMenuItem[] templates = new UIMenuItem[templateTabCount]; + for (int i = 0; i < templateTabCount; i++) { final int index = i; - final JTemplate tem = openedTemplate.get(i); + final JTemplate tem = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(i); templates[i] = new UIMenuItem(tempalteShowName(tem), tem.getIcon()); templates[i].setUI(new UIListDownItemUI()); setListDownItemPreferredSize(templates[i]); - if (i == selectedIndex) { + if (i == TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex()) { //画选中的高亮 templates[i].setBackground(UIConstants.SHADOW_CENTER); } templates[i].addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - selectedIndex = index; + TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(index); tem.activeNewJTemplate(); } }); @@ -478,68 +324,13 @@ public class MultiTemplateTabPane extends JComponent { private String tempalteShowName(JTemplate template) { - String name = TemplateUtils.createLockeTemplatedName(template, template.getTemplateName()); - if (!template.isSaved() && !name.endsWith(" *")) { - name += " *"; - } - return name; - } - - /** - * 刷新打开模板 - * - * @param history 模板 - */ - public void refreshOpenedTemplate(List> history) { - openedTemplate = history; - } - - public void setTemTemplate(JTemplate auotCreate) { - temTemplate = auotCreate; + return TemplateTabManager.getInstance().getTemplateShowName(template); } private void showListDown() { - - UIScrollPopUpMenu menu = new UIScrollPopUpMenu(); - menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); - menu.add(initCloseOther()); - JSeparator separator = new JSeparator() { - @Override - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - d.height = 1; - return d; - } - }; - menu.add(new JPanel() { - @Override - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - d.height = 1; - return d; - } - }); - separator.setForeground(UIConstants.LINE_COLOR); - menu.add(separator); - menu.add(new JPanel() { - @Override - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - d.height = 1; - return d; - } - }); - UIMenuItem[] items = createListDownTemplate(); - for (int i = 0; i < items.length; i++) { - menu.add(items[i]); - } - GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.getInstance(), MultiTemplateTabPane.getInstance().getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); - } - - - public void setSelectedIndex(int index) { - selectedIndex = index; + UIScrollPopUpMenu menu = MultiTemplateTabMenuFactory.getInstance().createMenu(); + GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.this, MultiTemplateTabPane.this.getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); } @@ -566,15 +357,18 @@ public class MultiTemplateTabPane extends JComponent { paintDefaultBackground(g2d); //最多能画的个数 int maxTemplateNum = (int) (maxWidth) / MINWIDTH; + int templateTabCount = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); + int currentSelectedIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); //计算开始画的最小模板index和最大模板index calMinAndMaxIndex(maxTemplateNum); calculateRealAverageWidth(maxWidth, maxTemplateNum); int maxStringlength = calculateStringMaxLength(); - if (selectedIndex >= openedTemplate.size()) { - selectedIndex = openedTemplate.size() - 1; + if ( currentSelectedIndex >= templateTabCount) { + TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex( + templateTabCount - 1); } - if (selectedIndex < 0) { - selectedIndex = 0; + if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() < 0) { + TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(0); } double templateStartX = 0; startX = new int[maxPaintIndex - minPaintIndex + 1]; @@ -582,7 +376,7 @@ public class MultiTemplateTabPane extends JComponent { //从可以开始展示在tab面板上的tab开始画 for (int i = minPaintIndex; i <= maxPaintIndex; i++) { - JTemplate template = openedTemplate.get(i); + JTemplate template = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(i); Icon icon = template.getIcon(); String name = tempalteShowName(template); //如果tab名字的长度大于最大能显示的英文字符长度,则进行省略号处理 @@ -599,7 +393,7 @@ public class MultiTemplateTabPane extends JComponent { } else { selectedIcon = CLOSE; } - if (i == selectedIndex) { + if (i == TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex()) { if (template.isSaving()) { selectedIcon = WHITE_SAVING_CLOSE_ICON; } @@ -608,7 +402,7 @@ public class MultiTemplateTabPane extends JComponent { if (template.isSaving()) { selectedIcon = GREY_SAVING_CLOSE_ICON; } - boolean isLeft = i < selectedIndex; + boolean isLeft = i < TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, isLeft, mouseOveredIndex, i); } templateStartX += realWidth; @@ -684,38 +478,39 @@ public class MultiTemplateTabPane extends JComponent { } private void calMinAndMaxIndex(int maxTemplateNum) { + int templateTabCount = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); //如果个数大于最多能容纳的个数,则多余的进行处理 - if (openedTemplate.size() > maxTemplateNum) { + if (templateTabCount > maxTemplateNum) { //所点击列表中的标签页处在标签页栏最后一个标签页之后,则标签页栏左移至所点击标签页出现 - if (selectedIndex >= maxPaintIndex) { - minPaintIndex = selectedIndex - maxTemplateNum + 1; - maxPaintIndex = selectedIndex; + if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() >= maxPaintIndex) { + minPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() - maxTemplateNum + 1; + maxPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); if (minPaintIndex <= 0) { minPaintIndex = 0; maxPaintIndex = maxTemplateNum - 1; } - } else if (selectedIndex <= minPaintIndex) { + } else if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() <= minPaintIndex) { //所点击列表中的标签页处在标签页栏第一个标签页之前,则标签页栏右移至所点击标签页出现 - minPaintIndex = selectedIndex; + minPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); maxPaintIndex = minPaintIndex + maxTemplateNum - 1; - if (maxPaintIndex > openedTemplate.size() - 1) { - maxPaintIndex = openedTemplate.size() - 1; + if (maxPaintIndex > templateTabCount- 1) { + maxPaintIndex = templateTabCount - 1; } } else { - if (selectedIndex >= openedTemplate.size() - 1) { - selectedIndex = openedTemplate.size() - 1; - maxPaintIndex = selectedIndex; - minPaintIndex = selectedIndex - maxTemplateNum + 1; + if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() >= templateTabCount - 1) { + TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(templateTabCount - 1); + maxPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); + minPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() - maxTemplateNum + 1; } else { maxPaintIndex = minPaintIndex + maxTemplateNum - 1; - if (maxPaintIndex > openedTemplate.size() - 1) { - maxPaintIndex = openedTemplate.size() - 1; + if (maxPaintIndex > templateTabCount - 1) { + maxPaintIndex = templateTabCount - 1; } } } } else { minPaintIndex = 0; - maxPaintIndex = openedTemplate.size() - 1; + maxPaintIndex = templateTabCount - 1; } } @@ -723,7 +518,7 @@ public class MultiTemplateTabPane extends JComponent { //个数小于最多能容纳的个数的情况下,看看宽度每个要画多少 private void calculateRealAverageWidth(double maxwidth, int templateNum) { - int num = openedTemplate.size() > templateNum ? templateNum : openedTemplate.size(); + int num = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size() > templateNum ? templateNum : TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); realWidth = (int) (maxwidth / (num)); if (realWidth > MAXWIDTH) { realWidth = MAXWIDTH; @@ -888,50 +683,6 @@ public class MultiTemplateTabPane extends JComponent { } - public void setIsCloseCurrent(boolean isCloseCurrent) { - this.isCloseCurrent = isCloseCurrent; - - } - - /** - * 关闭模板 - * - * @param specifiedTemplate 模板 - */ - public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { - if (specifiedTemplate == null) { - return; - } - - if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { - specifiedTemplate.stopEditing(); - int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", - Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); - if (returnVal == JOptionPane.YES_OPTION) { - CallbackSaveWorker worker = specifiedTemplate.save(); - worker.addSuccessCallback(new Runnable() { - @Override - public void run() { - FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); - closeTpl(specifiedTemplate); - } - }); - worker.start(specifiedTemplate.getRuntimeId()); - } else if (returnVal == JOptionPane.NO_OPTION) { - closeTpl(specifiedTemplate); - } - } else { - closeTpl(specifiedTemplate); - } - - } - - private void closeTpl(@Nonnull JTemplate specifiedTemplate) { - HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); - closeAndFreeLock(specifiedTemplate); - activePrevTemplateAfterClose(); - } - private void closeAndFreeLock(@Nonnull JTemplate template) { FILE file = template.getEditingFILE(); // 只有是环境内的文件,才执行释放锁 @@ -941,70 +692,6 @@ public class MultiTemplateTabPane extends JComponent { } } - /** - * 后台关闭当前编辑模板 - */ - public void closeCurrentTpl() { - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - this.setIsCloseCurrent(true); - this.closeFormat(jTemplate); - this.closeSpecifiedTemplate(jTemplate); - } - - /** - * 关闭模板 - * - * @param closedTemplate 模板 - */ - public void closeFormat(JTemplate closedTemplate) { - //表单不需要处理 - if (!closedTemplate.isJWorkBook()) { - return; - } - - if (DesignerContext.getFormatState() == DesignerContext.FORMAT_STATE_NULL) { - return; - } - - //是被参照的模板被关闭,则重置格式刷 - closedTemplate.doConditionCancelFormat(); - } - - /** - * 关闭掉一个模板之后激活新的待显示模板 - */ - public void activePrevTemplateAfterClose() { - if (openedTemplate.isEmpty()) { - //新建并激活模板 - DesignerContext.getDesignerFrame().addAndActivateJTemplate(); - selectedIndex = 0; - //此时刚自动新建的模板在HistoryTemplateListCache的editingTemplate - temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - - } else { - // 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板; - // selectIndex 没有变化,但是对应的模板已经变成了前一张模板 - if (closeIconIndex == selectedIndex || isCloseCurrent) { - // 如果当前关闭的模板在最右侧,那么预览上一个,防止数组越界 - if (selectedIndex >= maxPaintIndex) { - // selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true - selectedIndex--; - } - isCloseCurrent = false; - } - // 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index - else { - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - selectedIndex = HistoryTemplateListCache.getInstance().contains(template); - } - if (selectedIndex < openedTemplate.size()) { - //如果是已后台关闭的模板,则重新打开文件 - openedTemplate.get(selectedIndex).activeOldJTemplate(); - } - - } - } - private boolean isOverCloseIcon(int evtX) { boolean isOverCloseIcon = false; @@ -1036,29 +723,6 @@ public class MultiTemplateTabPane extends JComponent { return -1; } - - /** - * 处理自动新建的模板 在切换时的处理 - */ - public void doWithtemTemplate() { - //temtemplate保存的一定是手动新建的没有编辑或是编辑了没有保存的模板 - //没有保存,说明有编辑;已经保存在磁盘里的文件,说明有过处理,并且已经保存,此时切换都不将其自动关闭 - if (temTemplate == null || temTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) { - return; - } - - if (!temTemplate.isSaved() || !temTemplate.getEditingFILE().isMemFile()) { - temTemplate = null; - } - - //自动新建的模板B若没有进行任何编辑(新建模板没有进行任何编辑时saved都是true):还没有存盘 - if (temTemplate != null && temTemplate.getEditingFILE().isMemFile() && temTemplate.isSaved()) { - HistoryTemplateListCache.getInstance().closeSelectedReport(temTemplate); - temTemplate = null; - setSelectedIndex(HistoryTemplateListCache.getInstance().contains(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())); - } - } - private class UIListDownItemUI extends BasicMenuItemUI { @Override protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { @@ -1161,44 +825,13 @@ public class MultiTemplateTabPane extends JComponent { closeIconIndex = getTemplateIndex(evtX); clodeMode = MOUSE_PRESS_CLOSE; //关闭close图标所在的模板{ - JTemplate template = openedTemplate.get(closeIconIndex); - if (template.isOpening()) { - WorkerManager.getInstance().cancelWorker(template.getPath()); - } else if (template.isSaving()) { - boolean completed = WorkerManager.getInstance().isCompleted(template.getTarget().getTemplateID()); - if (!completed) { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Close_Template_Tip", template.getEditingFILE().getName())); - return; - } - } - //参考CloseCurrentTemplateAction,在closeFormat与closeSpecifiedTemplate之前要先设定isCloseCurrent,这样关闭之后才会自动切换tab - if (checkCurrentClose(template)) { - setIsCloseCurrent(true); - } - closeFormat(template); - closeSpecifiedTemplate(template); - DesignerContext.getDesignerFrame().getContentFrame().repaint(); + TemplateTabManager.getInstance().getCurrentOperator().closeByIndex(closeIconIndex); isShowList = false; } else { //没有点击关闭和ListDown按钮,则切换到点击的模板处 closeIconIndex = -1; clodeMode = CLOSE; - int tempSelectedIndex = selectedIndex; - if (selectedIndex != getTemplateIndex(evtX) && getTemplateIndex(evtX) != -1) { - openedTemplate.get(selectedIndex).stopEditing(); - selectedIndex = getTemplateIndex(evtX); - //如果在权限编辑情况下,不允许切换到表单类型的工作簿 - if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") - + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); - MultiTemplateTabPane.this.repaint(); - return; - } - JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX)); - evtXTemplate.activeNewJTemplate(); - } + TemplateTabManager.getInstance().getCurrentOperator().switchTpl(getTemplateIndex(evtX)); isShowList = false; } MultiTemplateTabPane.this.repaint(); @@ -1209,11 +842,6 @@ public class MultiTemplateTabPane extends JComponent { } - private boolean checkCurrentClose(JTemplate template) { - JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - return JTemplate.isValid(currentTemplate) && ComparatorUtils.equals(template.getPath(), currentTemplate.getPath()); - } - private class MultiTemplateTabMouseMotionListener implements MouseMotionListener { /** * 鼠标拖拽 @@ -1237,7 +865,7 @@ public class MultiTemplateTabPane extends JComponent { //看是否需要显示toolTip if (mouseOveredIndex != -1 && isNeedToolTips[mouseOveredIndex - minPaintIndex]) { - setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName()); + setToolTipText(TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(mouseOveredIndex).getEditingFILE().getName()); } else { setToolTipText(null); } diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 36e0b58754..d92533552c 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -1,5 +1,7 @@ package com.fr.design.file; +import com.fr.design.file.impl.DefaultTemplateTabOperate; + /** * @author shine * @version 10.0 @@ -14,11 +16,11 @@ public class MutilTempalteTabPane { } public void setIsCloseCurrent(boolean b) { - MultiTemplateTabPane.getInstance().setIsCloseCurrent(b); + TemplateTabManager.getInstance().setCloseCurrent(b); } public void activePrevTemplateAfterClose() { - MultiTemplateTabPane.getInstance().activePrevTemplateAfterClose(); + DefaultTemplateTabOperate.getInstance().activePrevTemplateAfterClose(true); } } diff --git a/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java index dae921a1c8..9949888349 100644 --- a/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java @@ -81,11 +81,15 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene } if (isOverNewIcon(evtX) && newWorkBookIconMode != GRAY_NEW_CPT) { newWorkBookIconMode = getMousePressNew(); - DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + createNewTemplate(); } this.repaint(); } + protected void createNewTemplate() { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + } + /** *鼠标松开 * @param e 事件 diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index 72945b31c9..96d72d34c1 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -3,8 +3,8 @@ package com.fr.design.file; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.StateChangeListener; +import com.fr.design.file.impl.DefaultTemplateTabOperate; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; @@ -19,10 +19,10 @@ import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import javax.swing.*; -import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; +import java.util.List; /** * Author : daisy @@ -152,7 +152,16 @@ public class SaveSomeTemplatePane extends BasicPane { public boolean showSavePane() { - populate(); + return showSavePane(false); + } + + public boolean showSavePane(boolean switchEnv) { + return switchEnv ? + showSavePane(DefaultTemplateTabOperate.getInstance().getOpenedJTemplates()) : + showSavePane(HistoryTemplateListPane.getInstance().getHistoryList()); + } + public boolean showSavePane(List> jTemplates) { + populate(jTemplates); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); @@ -162,8 +171,8 @@ public class SaveSomeTemplatePane extends BasicPane { return isAllSaved; } - public void populate() { - java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); + + private void populate(java.util.List> opendedTemplate) { JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (int i = 0; i < opendedTemplate.size(); i++) { if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java new file mode 100644 index 0000000000..22a0bc37e4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java @@ -0,0 +1,253 @@ +package com.fr.design.file; + +import com.finebi.cbb.utils.CompareUtils; +import com.fr.design.file.impl.DefaultTemplateTabOperate; +import com.fr.design.file.impl.EmptyTemplateTabOperator; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILE; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class TemplateTabManager { + private static class HOLDER { + private static final TemplateTabManager singleton = new TemplateTabManager(); + } + + public static TemplateTabManager getInstance() { + return HOLDER.singleton; + } + + private TemplateTabManager() { + list.add(DefaultTemplateTabOperate.getInstance()); + } + + private List list = new ArrayList<>(); + + public void register(TemplateTabOperateProvider templateTabOperateProvider) { + this.list.add(templateTabOperateProvider); + } + + public void remove(TemplateTabOperateProvider templateTabOperateProvider) { + this.list.remove(templateTabOperateProvider); + } + + private boolean isCloseCurrent = false; + //自动新建的模板B若没有进行任何编辑,切换到其他 + + // 模板时,模板B会自动关闭 + private JTemplate temTemplate = null; + + + public boolean isCloseCurrent() { + return isCloseCurrent; + } + + public void setCloseCurrent(boolean closeCurrent) { + isCloseCurrent = closeCurrent; + } + + public void setTemTemplate(JTemplate temTemplate) { + this.temTemplate = temTemplate; + } + + public void refresh() { + getCurrentOperator().refresh(); + } + + /** + * 从模板树删除文件 + */ + public void deleteOpenedTemplate(JTemplate template) { + TemplateTabOperateProvider provider = getOperatorByTemplate(template); + provider.deleteOpenedTemplate(template); + this.refresh(); + } + + public JTemplate getSelectedFile() { + return getCurrentOperator().getSelectedFile(); + } + + /** + * 关闭掉当前文件列表中指定的文件 + * + * @param file 指定的文件 + */ + public void closeFileTemplate(FILE file) { + for (TemplateTabOperateProvider provider : list) { + provider.closeFileTemplate(file); + } + } + + /** + * 关闭指定模板 + * + * @param specifiedTemplate + */ + public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { + getCurrentOperator().closeSpecifiedTemplate(specifiedTemplate); + } + + + /** + * 刷新打开模板 + * + * @param tempalteLsit + */ + public void refreshOpenedTemplate(List> tempalteLsit) { + for (TemplateTabOperateProvider provider : list) { + provider.refreshOpenedTemplate(tempalteLsit); + } + } + + + /** + * 处理自动新建的模板 在切换时的处理 + */ + public void doWithtemTemplate() { + //temtemplate保存的一定是手动新建的没有编辑或是编辑了没有保存的模板 + //没有保存,说明有编辑;已经保存在磁盘里的文件,说明有过处理,并且已经保存,此时切换都不将其自动关闭 + if (temTemplate == null || temTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) { + return; + } + + if (!temTemplate.isSaved() || !temTemplate.getEditingFILE().isMemFile()) { + temTemplate = null; + } + + //自动新建的模板B若没有进行任何编辑(新建模板没有进行任何编辑时saved都是true):还没有存盘 + if (temTemplate != null && temTemplate.getEditingFILE().isMemFile() && temTemplate.isSaved()) { + HistoryTemplateListCache.getInstance().closeSelectedReport(temTemplate); + temTemplate = null; + resetSelectIndex(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); + } + } + + + public void resetSelectIndex(JTemplate jTemplate) { + getCurrentOperator().resetSelectIndex(jTemplate); + } + + + public void activeNewTemplate() { + //先看其他模式中是否有已打开的模板,有的话切换过去 + for (TemplateTabOperateProvider templateTabOperateProvider : list) { + if (templateTabOperateProvider.getOpenedJTemplates().size() != 0) { + templateTabOperateProvider.getSelectedFile().activeNewJTemplate(); + refresh(); + return; + + } + } + //都没有的话,新建并激活模板 + DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + //此时刚自动新建的模板在HistoryTemplateListCache的editingTemplate + TemplateTabManager.getInstance().setTemTemplate(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); + refresh(); + } + + /** + * 后台关闭当前编辑模板 + */ + public void closeCurrentTpl() { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + this.setCloseCurrent(true); + this.closeFormat(jTemplate); + this.closeSpecifiedTemplate(jTemplate); + } + + + /** + * 关闭指定索引值模板 + * + * @param index + */ + public void closeByIndex(int index) { + getCurrentOperator().closeByIndex(index); + } + + /** + * 关闭指定索引值模板 + * + * @param jTemplate + */ + public void closeByJTemplate(JTemplate jTemplate) { + TemplateTabOperateProvider operator = getOperatorByOperatorType(jTemplate.getTemplateTabOperatorType()); + operator.closeByIndex(operator.getJTemplateIndex(jTemplate)); + } + + /** + * 切换到指定tab栏的指定索引值模板 + * + * @param jTemplate + */ + public void switchByJTemplate(JTemplate jTemplate) { + TemplateTabOperateProvider operator = getOperatorByOperatorType(jTemplate.getTemplateTabOperatorType()); + operator.switchTpl(operator.getJTemplateIndex(jTemplate)); + } + + /** + * 获取所有打开的模板map + * + * @return + */ + public Map>> getAllOpenedTemplateMap() { + Map>> resultMap = new HashMap<>(); + for (TemplateTabOperateProvider provider : list) { + resultMap.put(provider.getOperatorType(), provider.getOpenedJTemplates()); + } + return resultMap; + } + + public void closeOthers() { + TemplateTabOperateProvider currentOperator = getCurrentOperator(); + currentOperator.closeAction(CloseOption.Others, + currentOperator.getJTemplateIndex(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())); + } + + public String getTemplateShowName(JTemplate temTemplate){ + return getCurrentOperator().getTemplateShowName(temTemplate); + } + + + /** + * 关闭模板 + * + * @param closedTemplate 模板 + */ + public void closeFormat(JTemplate closedTemplate) { + //表单不需要处理 + if (!closedTemplate.isJWorkBook()) { + return; + } + + if (DesignerContext.getFormatState() == DesignerContext.FORMAT_STATE_NULL) { + return; + } + + //是被参照的模板被关闭,则重置格式刷 + closedTemplate.doConditionCancelFormat(); + } + + + public TemplateTabOperateProvider getCurrentOperator() { + return getOperatorByTemplate(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); + } + + private TemplateTabOperateProvider getOperatorByTemplate(JTemplate jTemplate) { + return getOperatorByOperatorType(jTemplate.getTemplateTabOperatorType()); + } + + private TemplateTabOperateProvider getOperatorByOperatorType(String type) { + for (TemplateTabOperateProvider provider : list) { + if (CompareUtils.isEqual(provider.getOperatorType(), type)) { + return provider; + } + } + return EmptyTemplateTabOperator.getInstance(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java new file mode 100644 index 0000000000..ff913f3342 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java @@ -0,0 +1,114 @@ +package com.fr.design.file; + + +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILE; + +import java.util.List; + +public interface TemplateTabOperateProvider { + /** + * 找到模板树中的位置 + */ + void locateTemplateInTree(int tplIndex); + + + /** + * 右键一系列关闭操作 + * + * @param option closeType + * @param index + */ + void closeAction(CloseOption option, int index); + + + /** + * 切换模板 + * + * @param templateIndex 模板索引值 + */ + void switchTpl(int templateIndex); + + + /** + * 获取打开模板的基本信息 + * + * @return + */ + List> getOpenedJTemplates(); + + + void closeByIndex(int index); + /** + * 关闭指定模板 + * + * @param specifiedTemplate + */ + void closeSpecifiedTemplate(JTemplate specifiedTemplate); + /** + * 删除已打开的模板 + */ + void deleteOpenedTemplate(JTemplate template); + + /** + * 获取选中模板 + * @return + */ + JTemplate getSelectedFile(); + + /** + * 刷新ui + */ + void refresh(); + + /** + * 重置下选中的Index + * @param jTemplate + */ + void resetSelectIndex(JTemplate jTemplate); + + /** + * 刷新下打开的模板list + * @param list + */ + void refreshOpenedTemplate(List> list); + + /** + * 关闭指定节点 + * @param file + */ + void closeFileTemplate(FILE file); + + /** + * 获取操作类型标识 + * @return + */ + String getOperatorType(); + + /** + * 获取当前选中模板的index + * @return + */ + int getSelectIndex(); + + /** + * 设置当前选中模板的index + * @return + */ + void setSelectIndex(int index); + + /** + * 获取指定模板在operator中的索引值 + * @param jTemplate + * @return + */ + int getJTemplateIndex(JTemplate jTemplate); + + /** + * 获取template在tab中显示的名称 + * @param jTemplate + * @return + */ + String getTemplateShowName(JTemplate jTemplate); + +} diff --git a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java new file mode 100644 index 0000000000..b6bee6e6d8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java @@ -0,0 +1,332 @@ +package com.fr.design.file.impl; + +import com.finebi.cbb.utils.CompareUtils; +import com.fr.base.vcs.DesignerMode; +import com.fr.design.actions.file.LocateAction; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.file.CloseOption; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.SaveSomeTemplatePane; +import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.TemplateTabOperateProvider; +import com.fr.design.file.TemplateTreePane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; +import com.fr.design.utils.TemplateUtils; +import com.fr.design.worker.WorkerManager; +import com.fr.design.worker.save.CallbackSaveWorker; +import com.fr.file.FILE; +import com.fr.file.FileNodeFILE; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.third.javax.annotation.Nonnull; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.lock.TplOperator; + +import javax.swing.*; +import java.util.ArrayList; +import java.util.List; + +import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; +import static javax.swing.JOptionPane.*; + +public abstract class AbstractTemplateTabOperate implements TemplateTabOperateProvider { + //用于存放工作簿 + protected java.util.List> openedTemplate = new ArrayList<>(); + //选中的Tab项 + protected int selectedIndex = -1; + + public AbstractTemplateTabOperate() { + + } + + @Override + public void locateTemplateInTree(int tplIndex) { + //处于搜索模式时,先退出搜索模式,再定位 + if (TemplateTreeSearchManager.getInstance().isInSearchMode()) { + TemplateTreeSearchManager.getInstance().outOfSearchMode(); + TemplateTreePane.getInstance().refreshDockingView(); + } + JTemplate template = openedTemplate.get(tplIndex); + locateTemplate(template); + } + + private void locateTemplate(JTemplate template) { + FILE currentTemplate = template.getEditingFILE(); + //模板不属于当前环境,跟预览一样先提示保存,再定位模板 + //如果是拖拽进来的模板单单用exist不能判断,这边参考预览的判断逻辑(browserTemplate),补充一下 + if ((!currentTemplate.exists() || !(currentTemplate instanceof FileNodeFILE)) && template.canBeSaved()) { + int selVal = showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), OK_CANCEL_OPTION, WARNING_MESSAGE); + if (OK_OPTION == selVal) { + CallbackSaveWorker worker = template.saveAs(); + worker.start(template.getRuntimeId()); + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + LocateAction.gotoEditingTemplateLeaf(template.getPath()); + } + }); + } + } else { + LocateAction.gotoEditingTemplateLeaf(template.getPath()); + } + } + + @Override + public void closeAction(CloseOption option, int index) { + SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); + if (saveSomeTempaltePane.showSavePane(this.openedTemplate)) { + + JTemplate[] templates = new JTemplate[openedTemplate.size()]; + for (int i = 0; i < openedTemplate.size(); i++) { + templates[i] = openedTemplate.get(i); + } + JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + + closeTemplate(templates, currentTemplate, option, index); + + if (openedTemplate.isEmpty()) { + TemplateTabManager.getInstance().activeNewTemplate(); + selectedIndex = 0; + } else { + DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); + } + } + } + + public void closeByIndex(int index) { + //关闭close图标所在的模板{ + JTemplate template = openedTemplate.get(index); + if (template.isOpening()) { + WorkerManager.getInstance().cancelWorker(template.getPath()); + } else if (template.isSaving()) { + boolean completed = WorkerManager.getInstance().isCompleted(template.getTarget().getTemplateID()); + if (!completed) { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Close_Template_Tip", template.getEditingFILE().getName())); + return; + } + } + //参考CloseCurrentTemplateAction,在closeFormat与closeSpecifiedTemplate之前要先设定isCloseCurrent,这样关闭之后才会自动切换tab + if (checkCurrentClose(template)) { + TemplateTabManager.getInstance().setCloseCurrent(true); + } + TemplateTabManager.getInstance().closeFormat(template); + closeSpecifiedTemplate(template); + DesignerContext.getDesignerFrame().getContentFrame().repaint(); + } + + private boolean checkCurrentClose(JTemplate template) { + JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return JTemplate.isValid(currentTemplate) && ComparatorUtils.equals(template.getPath(), currentTemplate.getPath()); + } + + private void closeTemplate(JTemplate[] templates, JTemplate currentTemplate, CloseOption option, int tplIndex) { + for (int i = 0; i < templates.length; i++) { + if (option.shouldClose(tplIndex, i)) { + JTemplate jTemplate = templates[i]; + if (jTemplate == currentTemplate) { + currentTemplate = option == CloseOption.All ? null : templates[tplIndex]; + } + //判断关闭的模板是不是格式刷的被参照的模板 + openedTemplate.remove(jTemplate); + if (jTemplate != currentTemplate) { + TemplateTabManager.getInstance().closeFormat(jTemplate); + HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); + closeAndFreeLock(jTemplate); + } + } + } + } + + private void closeAndFreeLock(@Nonnull JTemplate template) { + FILE file = template.getEditingFILE(); + // 只有是环境内的文件,才执行释放锁 + if (file != null && file.isEnvFile()) { + // release lock + WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath()); + } + } + + @Override + public void switchTpl(int templateIndex) { + int tempSelectedIndex = selectedIndex; + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if ((selectedIndex != templateIndex || !this.accept(jTemplate.getTemplateTabOperatorType())) + && templateIndex != -1) { + openedTemplate.get(selectedIndex).stopEditing(); + selectedIndex = templateIndex; + //如果在权限编辑情况下,不允许切换到表单类型的工作簿 + if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); + return; + } + JTemplate evtXTemplate = openedTemplate.get(templateIndex); + evtXTemplate.activeNewJTemplate(); + } + } + + @Override + public void deleteOpenedTemplate(JTemplate template) { + if (!openedTemplate.contains(template)) { + return; + } + openedTemplate.remove(template); + if (openedTemplate.size() == 0) { + TemplateTabManager.getInstance().activeNewTemplate(); + return; + } + if (openedTemplate.size() == selectedIndex) { + //如果删除的是后一个Tab,则定位到前一个 + this.selectedIndex--; + } + } + + @Override + public JTemplate getSelectedFile() { + if (openedTemplate.size() == selectedIndex) { + selectedIndex = Math.max(--selectedIndex, 0); + } + return openedTemplate.get(selectedIndex); + } + + + /** + * 关闭掉当前已打开文件列表中指定的文件 + * + * @param file 指定的文件 + */ + public void closeFileTemplate(FILE file) { + for (JTemplate temp : openedTemplate) { + if (ComparatorUtils.equals(file, temp.getEditingFILE())) { + closeSpecifiedTemplate(temp); + break; + } + } + + } + + + /** + * 关闭模板 + * + * @param specifiedTemplate 模板 + */ + public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { + if (specifiedTemplate == null && !openedTemplate.contains(specifiedTemplate)) { + return; + } + + if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { + specifiedTemplate.stopEditing(); + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.YES_OPTION) { + CallbackSaveWorker worker = specifiedTemplate.save(); + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + closeTpl(specifiedTemplate); + } + }); + worker.start(specifiedTemplate.getRuntimeId()); + } else if (returnVal == JOptionPane.NO_OPTION) { + closeTpl(specifiedTemplate); + } + } else { + closeTpl(specifiedTemplate); + } + + } + + private void closeTpl(@Nonnull JTemplate specifiedTemplate) { + HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); + closeAndFreeLock(specifiedTemplate); + activePrevTemplateAfterClose(specifiedTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); + } + + /** + * 关闭掉一个模板之后激活新的待显示模板 + */ + public void activePrevTemplateAfterClose(boolean isCurrentSelectedTpl) { + if (openedTemplate.isEmpty()) { + TemplateTabManager.getInstance().activeNewTemplate(); + selectedIndex = 0; + } else { + // 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板; + // selectIndex 没有变化,但是对应的模板已经变成了前一张模板 + if (isCurrentSelectedTpl || TemplateTabManager.getInstance().isCloseCurrent()) { + // 如果当前关闭的模板在最右侧,那么预览上一个,防止数组越界 + if (selectedIndex >= openedTemplate.size()) { + // selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true + selectedIndex--; + } + TemplateTabManager.getInstance().setCloseCurrent(false); + } + // 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index + else { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + selectedIndex = this.openedTemplate.indexOf(template); + } + if (selectedIndex < openedTemplate.size()) { + //如果是已后台关闭的模板,则重新打开文件 + openedTemplate.get(selectedIndex).activeOldJTemplate(); + } + + } + TemplateTabManager.getInstance().refresh(); + } + + @Override + public void resetSelectIndex(JTemplate jTemplate) { + this.selectedIndex = openedTemplate.indexOf(jTemplate); + TemplateTabManager.getInstance().refresh(); + } + + public void refreshOpenedTemplate(List> list) { + List> result = new ArrayList<>(); + for (JTemplate jTemplate : list) { + if (this.accept(jTemplate.getTemplateTabOperatorType())) { + result.add(jTemplate); + } + } + this.openedTemplate = result; + TemplateTabManager.getInstance().refresh(); + } + + public List> getOpenedJTemplates() { + return this.openedTemplate; + } + + @Override + public void setSelectIndex(int index) { + this.selectedIndex = index; + } + + @Override + public int getSelectIndex() { + return this.selectedIndex; + } + + @Override + public int getJTemplateIndex(JTemplate jTemplate) { + return this.openedTemplate.indexOf(jTemplate); + } + + public boolean accept(String type) { + return CompareUtils.isEqual(getOperatorType(), type); + } + + + @Override + public String getTemplateShowName(JTemplate template) { + String name = TemplateUtils.createLockeTemplatedName(template, template.getTemplateName()); + if (!template.isSaved() && !name.endsWith(" *")) { + name += " *"; + } + return name; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java new file mode 100644 index 0000000000..511b74894f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java @@ -0,0 +1,31 @@ +package com.fr.design.file.impl; + +import com.fr.design.file.MultiTemplateTabPane; + +public class DefaultTemplateTabOperate extends AbstractTemplateTabOperate { + + public static final String OPERATOR_TYPE = "DEFAULT_TEMPLATE_TAB_OPERATOR"; + + private static class HOLDER { + private static final DefaultTemplateTabOperate singleton = new DefaultTemplateTabOperate(); + } + + private DefaultTemplateTabOperate() { + super(); + } + + public static DefaultTemplateTabOperate getInstance() { + return HOLDER.singleton; + } + + @Override + public void refresh() { + MultiTemplateTabPane.getInstance().repaint(); + } + + @Override + public String getOperatorType() { + return OPERATOR_TYPE; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java new file mode 100644 index 0000000000..804874138d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java @@ -0,0 +1,109 @@ +package com.fr.design.file.impl; + +import com.fr.design.file.CloseOption; +import com.fr.design.file.TemplateTabOperateProvider; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILE; +import com.fr.stable.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +public class EmptyTemplateTabOperator implements TemplateTabOperateProvider { + private static class HOLDER { + private static final EmptyTemplateTabOperator singleton = new EmptyTemplateTabOperator(); + } + + + private EmptyTemplateTabOperator() { + + } + + public static EmptyTemplateTabOperator getInstance() { + return HOLDER.singleton; + } + + @Override + public void locateTemplateInTree(int tplIndex) { + + } + + @Override + public void closeAction(CloseOption option, int index) { + + } + + @Override + public void closeByIndex(int index) { + + } + + @Override + public void switchTpl(int templateIndex) { + + } + + @Override + public List> getOpenedJTemplates() { + return new ArrayList<>(); + } + + @Override + public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { + + } + + @Override + public void deleteOpenedTemplate(JTemplate template) { + + } + + @Override + public JTemplate getSelectedFile() { + return null; + } + + @Override + public void refresh() { + + } + + @Override + public void resetSelectIndex(JTemplate jTemplate) { + + } + + @Override + public void refreshOpenedTemplate(List> list) { + + } + + @Override + public void closeFileTemplate(FILE file) { + + } + @Override + public String getOperatorType() { + return StringUtils.EMPTY; + } + + @Override + public int getSelectIndex() { + return 0; + } + + @Override + public void setSelectIndex(int index) { + + } + + @Override + public int getJTemplateIndex(JTemplate jTemplate) { + return 0; + } + + @Override + public String getTemplateShowName(JTemplate jTemplate) { + return StringUtils.EMPTY; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java index b18b346525..63c00deaaf 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java @@ -230,12 +230,11 @@ public class CenterRegionContainerPane extends JPanel { // 颜色,字体那些按钮的工具栏 toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); - if (strategy.hasToolBarPane(plus)) { - this.add(toolbarPane, BorderLayout.NORTH); - } else { - this.remove(toolbarPane); + JPanel customNorthPane = strategy.customNorthPane(toolbarPane,plus); + if (!isExist(customNorthPane)){ + this.removeNorth(); + this.add(customNorthPane, BorderLayout.NORTH); } - if (strategy.hasTemplateTabPane(plus)) { eastCenterPane.add(templateTabPane, BorderLayout.CENTER); } else { @@ -250,6 +249,26 @@ public class CenterRegionContainerPane extends JPanel { resetByDesignMode(); } + private void removeNorth(){ + Component[] components = this.getComponents(); + for(Component c : components){ + if (c!= centerTemplateCardPane){ + this.remove(c); + } + } + } + + + private boolean isExist(JPanel customNorthPane) { + Component[] components = this.getComponents(); + for (Component component : components) { + if (component == customNorthPane) { + return true; + } + } + return false; + } + private void resetByDesignMode() { if (DesignModeContext.isDuchampMode()) { eastPane.remove(largeToolbar); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DefaultToolKitConfig.java b/designer-base/src/main/java/com/fr/design/mainframe/DefaultToolKitConfig.java index 305c44aa21..581dc54cb8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DefaultToolKitConfig.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DefaultToolKitConfig.java @@ -3,6 +3,9 @@ package com.fr.design.mainframe; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; +import javax.swing.JPanel; + + public class DefaultToolKitConfig implements ToolKitConfigStrategy { @Override public boolean hasTemplateTabPane(ToolBarMenuDockPlus plus) { @@ -18,4 +21,9 @@ public class DefaultToolKitConfig implements ToolKitConfigStrategy { public boolean hasToolBarPane(ToolBarMenuDockPlus plus) { return plus.hasToolBarPane(); } + + @Override + public JPanel customNorthPane(JPanel toolBarPane, ToolBarMenuDockPlus plus) { + return toolBarPane; + } } 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 e88d0c946c..2f05dbbeb2 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 @@ -19,11 +19,7 @@ import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; -import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.MultiTemplateTabPane; -import com.fr.design.file.SaveSomeTemplatePane; -import com.fr.design.file.TemplateTreePane; +import com.fr.design.file.*; import com.fr.design.fun.OemProcessor; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; import com.fr.design.gui.iprogressbar.ProgressDialog; @@ -1110,7 +1106,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta // 新的form不往前兼容 if (inValidDesigner(jt)) { this.addAndActivateJTemplate(); - MultiTemplateTabPane.getInstance().setTemTemplate( + TemplateTabManager.getInstance().setTemTemplate( HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); } else { this.addAndActivateJTemplate(jt); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 8cfd263421..a07bfe1f1d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -17,12 +17,7 @@ import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager; import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.file.FileOperations; -import com.fr.design.file.FileToolbarStateChangeListener; -import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.MultiTemplateTabPane; -import com.fr.design.file.TemplateTreePane; +import com.fr.design.file.*; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuHighLight; @@ -275,7 +270,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt); //处理自动新建的模板 - MultiTemplateTabPane.getInstance().doWithtemTemplate(); + TemplateTabManager.getInstance().doWithtemTemplate(); if (DesignerMode.isAuthorityEditing()) { RolesAlreadyEditedPane.getInstance().refreshDockingView(); } @@ -547,10 +542,10 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) { if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) { if (isCurrentEditing) { - MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); + TemplateTabManager.getInstance().setCloseCurrent(true); } - MultiTemplateTabPane.getInstance().closeFormat(jTemplate); - MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(jTemplate); + TemplateTabManager.getInstance().closeFormat(jTemplate); + TemplateTabManager.getInstance().closeSpecifiedTemplate(jTemplate); return; } } 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 0082e091f3..b8fef1b007 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 @@ -30,9 +30,8 @@ import com.fr.design.designer.DesignerProxy; import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.InformationWarnPane; -import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.TemplateResourceManager; +import com.fr.design.file.*; +import com.fr.design.file.impl.DefaultTemplateTabOperate; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.PreviewProvider; @@ -615,7 +614,7 @@ public abstract class JTemplate> * @return 是则返回true */ public boolean isALLSaved() { - return this.saved && this.authoritySaved; + return this.saved && this.authoritySaved && this.canBeSaved(); } @@ -1979,7 +1978,11 @@ public abstract class JTemplate> public void setDesignerUIMode() { DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode(); } - + + public String getTemplateTabOperatorType(){ + return DefaultTemplateTabOperate.OPERATOR_TYPE; + } + /** * 判断当前的模板是否是有效的模板 * @@ -1989,4 +1992,12 @@ public abstract class JTemplate> public static boolean isValid(JTemplate jt) { return jt != null && jt != JNullTemplate.NULL; } + + public boolean canBeSaved(){ + return true; + } + + public boolean supportCache(){ + return true; + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/ToolKitConfigStrategy.java b/designer-base/src/main/java/com/fr/design/mainframe/ToolKitConfigStrategy.java index 67b1409b36..f2feff8042 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/ToolKitConfigStrategy.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/ToolKitConfigStrategy.java @@ -2,6 +2,9 @@ package com.fr.design.mainframe; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; +import javax.swing.JPanel; + + public interface ToolKitConfigStrategy { /** @@ -24,4 +27,11 @@ public interface ToolKitConfigStrategy { * @return */ boolean hasToolBarPane(ToolBarMenuDockPlus plus); + /** + * 定制工具栏 + * @param toolBarPane + * @param plus + * @return + */ + JPanel customNorthPane(JPanel toolBarPane, ToolBarMenuDockPlus plus); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 3372e2ad13..37812c106f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -416,9 +416,7 @@ public abstract class ToolBarMenuDock { menuDef.addShortCut(new OpenRecentReportMenuDef()); - if (!DesignModeContext.isDuchampMode()) { - addCloseCurrentTemplateAction(menuDef); - } + addCloseCurrentTemplateAction(menuDef); scs = plus.shortcut4FileMenu(); if (!ArrayUtils.isEmpty(scs)) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java index 8cff3ffbb1..6bfc39b78e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.vcs.ui; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.JTemplate; @@ -57,9 +57,9 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe jt.stopEditing(); //只有模板路径一致时关闭当前模板 if (ComparatorUtils.equals(fileOfVersion, jt.getPath())) { - MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); - MultiTemplateTabPane.getInstance().closeFormat(jt); - MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(jt); + TemplateTabManager.getInstance().setCloseCurrent(true); + TemplateTabManager.getInstance().closeFormat(jt); + TemplateTabManager.getInstance().closeSpecifiedTemplate(jt); } //再打开cache中的模板 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java index 4dd14bce6d..47a95f2620 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java @@ -5,7 +5,7 @@ import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignerMode; import com.fr.design.dialog.BasicPane; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; @@ -115,9 +115,9 @@ public class FileVersionsPanel extends BasicPane { // 关闭当前打开的版本 JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); - MultiTemplateTabPane.getInstance().closeFormat(jt); - MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(jt); + TemplateTabManager.getInstance().setCloseCurrent(true); + TemplateTabManager.getInstance().closeFormat(jt); + TemplateTabManager.getInstance().closeSpecifiedTemplate(jt); updateDesignerFrame(true); diff --git a/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java index d9c8568bf9..baa73fc53a 100644 --- a/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java @@ -3,7 +3,7 @@ package com.fr.design.worker.open; import com.fr.base.chart.exception.ChartNotFoundException; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.file.TemplateTreePane; import com.fr.design.i18n.Toolkit; import com.fr.design.lock.LockInfoDialog; @@ -87,7 +87,7 @@ public class OpenWorker extends SwingWorker { UIManager.getIcon("OptionPane.errorIcon")); } if (cause.getCause() instanceof TplLockedException) { - MultiTemplateTabPane.getInstance().closeCurrentTpl(); + TemplateTabManager.getInstance().closeCurrentTpl(); TemplateTreePane.getInstance().getFileNode().setLock(UUID.randomUUID().toString()); LockInfoDialog.show(null); } diff --git a/designer-base/src/main/java/com/fr/nx/app/designer/toolbar/TemplateTransformer.java b/designer-base/src/main/java/com/fr/nx/app/designer/toolbar/TemplateTransformer.java index 1a6e2bf1c8..f277320dd0 100644 --- a/designer-base/src/main/java/com/fr/nx/app/designer/toolbar/TemplateTransformer.java +++ b/designer-base/src/main/java/com/fr/nx/app/designer/toolbar/TemplateTransformer.java @@ -2,7 +2,7 @@ package com.fr.nx.app.designer.toolbar; import com.fr.base.extension.FileExtension; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.file.FILE; @@ -103,9 +103,9 @@ public enum TemplateTransformer { DesignerContext.getDesignerFrame().openTemplate(file); return; } - MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); - MultiTemplateTabPane.getInstance().closeFormat(jt); - MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(jt); + TemplateTabManager.getInstance().setCloseCurrent(true); + TemplateTabManager.getInstance().closeFormat(jt); + TemplateTabManager.getInstance().closeSpecifiedTemplate(jt); DesignerContext.getDesignerFrame().openTemplate(file); } diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 44228c2a4a..50f2cd35c0 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -8,7 +8,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerStartOpenFileProcessor; import com.fr.design.fun.impl.DesignerStartWithEmptyFile; @@ -193,7 +193,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } else { df.addAndActivateJTemplate(); // 如果没有模板,则需要确认一下 - MultiTemplateTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + TemplateTabManager.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } } @@ -253,7 +253,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { private boolean createNewTemplate(DesignerFrame df) { df.addAndActivateJTemplate(); // 如果没有模板,则需要确认一下 - MultiTemplateTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + TemplateTabManager.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); return true; } diff --git a/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java b/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java index b42cc4ed8f..5dcaa147ac 100644 --- a/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java +++ b/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java @@ -3,7 +3,7 @@ package com.fr.start.common; import com.fr.base.svg.IconUtils; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; @@ -59,7 +59,7 @@ public class DesignerOpenEmptyPanel extends JPanel { HistoryTemplateListCache.getInstance().setCurrentEditingTemplate(null); df.addAndActivateJTemplate(); // 如果没有模板,则需要确认一下 - MultiTemplateTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + TemplateTabManager.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } }); createButton.setBorder(new EmptyBorder(0, 10, 0, 10)); diff --git a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java index 04633435be..c362ae76d1 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java @@ -1,7 +1,7 @@ package com.fr.design.fit.common; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.fit.NewJForm; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; @@ -86,7 +86,7 @@ public class TemplateTool { JTemplate oldJTemplate = jTemplateList.get(i); if (oldJTemplate != null && ComparatorUtils.equals(oldJTemplate.getEditingFILE(), newJTemplate.getEditingFILE())) { jTemplateList.set(i, newJTemplate); - MultiTemplateTabPane.getInstance().refreshOpenedTemplate(jTemplateList); + TemplateTabManager.getInstance().refreshOpenedTemplate(jTemplateList); return; } } diff --git a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java index 4afacee781..03e8e2b445 100644 --- a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java +++ b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java @@ -1,7 +1,8 @@ package com.fr.design.preview; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.impl.AbstractPreviewProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JForm; @@ -66,7 +67,7 @@ public class DeveloperPreview extends AbstractPreviewProvider { } private void onPreview(JTemplate jt) { - MultiTemplateTabPane.getInstance().closeCurrentTpl(); + TemplateTabManager.getInstance().closeCurrentTpl(); jt.generateForBiddenTemplate(); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index f9c086a50b..5ba4838d6e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -39,7 +39,7 @@ import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.fun.ReportSupportedFileUIProvider; @@ -1175,7 +1175,7 @@ public class JWorkBook extends JTemplate { public boolean saveShareFile() { FILE newFile = createNewEmptyFile(); //如果文件已经打开, 那么就覆盖关闭掉他 - MultiTemplateTabPane.getInstance().closeFileTemplate(newFile); + TemplateTabManager.getInstance().closeFileTemplate(newFile); final WorkBook tpl = this.getTarget(); // 弹出输入参数 java.util.Map parameterMap = inputParameters(tpl); diff --git a/designer-realize/src/main/java/com/fr/start/MainDesigner.java b/designer-realize/src/main/java/com/fr/start/MainDesigner.java index 7b974d871c..55b6548ac5 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.java @@ -17,6 +17,7 @@ import com.fr.design.deeplink.DeepLinkManager; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MultiTemplateTabPane; +import com.fr.design.file.TemplateTabManager; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.OemProcessor; import com.fr.design.gui.ibutton.UIButton; @@ -409,8 +410,7 @@ public class MainDesigner extends BaseDesigner { return; } saveButton.setEnabled(!jt.isSaved() && !DesignModeContext.isVcsMode() && jt.checkEnable()); - MultiTemplateTabPane.getInstance().refreshOpenedTemplate(HistoryTemplateListCache.getInstance().getHistoryList()); - MultiTemplateTabPane.getInstance().repaint(); + TemplateTabManager.getInstance().refreshOpenedTemplate(HistoryTemplateListCache.getInstance().getHistoryList()); if (DesignerEnvManager.getEnvManager().isSupportUndo()) { undo.setEnabled(jt.canUndo()); redo.setEnabled(jt.canRedo()); From 7f70d695d6d9e226c9a5ec0b75dd7290e3690fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Fri, 14 Apr 2023 11:08:09 +0800 Subject: [PATCH 05/59] =?UTF-8?q?REPORT-83195=20=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E7=82=B9=E4=BC=98=E5=8C=96-=E4=BF=9D=E5=AD=98=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 115 ++++++++++++++---- .../com/fr/design/worker/save/SaveWorker.java | 51 +++++--- .../fr/design/worker/save/type/SaveType.java | 50 ++++++++ .../worker/save/type/SaveTypeWorker.java | 75 ++++++++++++ 4 files changed, 255 insertions(+), 36 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/worker/save/type/SaveType.java create mode 100644 designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java 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 0082e091f3..229ba848d8 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 @@ -61,6 +61,8 @@ import com.fr.design.utils.DesignUtils; import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.design.worker.save.EmptyCallBackSaveWorker; import com.fr.design.worker.save.SaveFailureHandler; +import com.fr.design.worker.save.type.SaveType; +import com.fr.design.worker.save.type.SaveTypeWorker; import com.fr.design.write.submit.DBManipulationInWidgetEventPane; import com.fr.design.write.submit.DBManipulationPane; import com.fr.event.EventDispatcher; @@ -1687,24 +1689,7 @@ public abstract class JTemplate> if (!editingFILE.exists()) { return saveAs(showLoc); } - - CallbackSaveWorker worker = new CallbackSaveWorker(new Callable() { - @Override - public Boolean call() throws Exception { - return saveRealFileByWorker(); - } - }, this); - - worker.addSuccessCallback(new Runnable() { - @Override - public void run() { - callBackForSave(); - //在保存后的回调中执行预编译流程 - CptCompileUtil.compile(JTemplate.this); - } - }); - - return worker; + return getSaveCallBackSaveWorker(); } /** @@ -1750,6 +1735,8 @@ public abstract class JTemplate> } } + + private CallbackSaveWorker saveAs(boolean showLoc) { FILE editingFILE = this.getEditingFILE(); if (editingFILE == null) { @@ -1771,7 +1758,6 @@ public abstract class JTemplate> // 目标文件 editingFILE = fileChooser.getSelectedFILE(); } - FILE finalEditingFILE = editingFILE; CallbackSaveWorker worker = new CallbackSaveWorker(new Callable() { @Override @@ -1872,10 +1858,95 @@ public abstract class JTemplate> return saveAs(true); } + /** + * 获取保存用到的saveWorker + */ + private CallbackSaveWorker getSaveCallBackSaveWorker() { + CallbackSaveWorker worker = new CallbackSaveWorker(new Callable() { + @Override + public Boolean call() throws Exception { + return saveRealFileByWorker(); + } + }, this); + + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + callBackForSave(); + //在保存后的回调中执行预编译流程 + CptCompileUtil.compile(JTemplate.this); + } + }); + return worker; + } + + /** + * 获取保存的类别执行的callable + */ + private Callable getSaveTypeCallable() { + return () -> { + fireJTemplateSaveBefore(); + FILE editingFILE = getEditingFILE(); + // carl:editingFILE没有,当然不存了,虽然不会有这种情况 + if (editingFILE == null) { + return SaveType.TypeEnum.EMPTY; + } + // 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs + if (!editingFILE.exists()) { + return SaveType.TypeEnum.SAVE_AS; + } + return SaveType.TypeEnum.SAVE; + }; + } + + /** + * 根据保存类型获取对应的saveWorker + * + * @param saveType 保存类型 + */ + private CallbackSaveWorker getSaveTypeWorker(SaveType saveType) { + CallbackSaveWorker callbackSaveWorker; + switch (saveType.getType()) { + case EMPTY: + callbackSaveWorker = new EmptyCallBackSaveWorker(); + break; + case SAVE: + callbackSaveWorker = getSaveCallBackSaveWorker(); + break; + default: + callbackSaveWorker = saveAs(true); + } + return callbackSaveWorker; + } + + + @Override public void saveDirectly() { - CallbackSaveWorker worker = save(); - worker.start(getRuntimeId()); + new SaveTypeWorker(getSaveTypeCallable(), this) { + @Override + protected void done() { + try { + SaveType saveType = get(); + CallbackSaveWorker callbackSaveWorker = getSaveTypeWorker(saveType); + //告诉一下后面执行的saveWorker,当前判断文件是否存在的操作是否已经进行了开始转圈的那个等待动画,避免重复 + callbackSaveWorker.setSlowly(saveType.isSlowly()); + callbackSaveWorker.start(getRuntimeId()); + //如果是空也就是不保存,需要恢复一下界面(如果saveTypeWorker里进行了操作的话) + if (callbackSaveWorker instanceof EmptyCallBackSaveWorker) { + setSaving(false); + if (saveType.isSlowly()) { + if (ComparatorUtils.equals(getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) { + DesignerContext.getDesignerFrame().getCenterTemplateCardPane().hideCover(); + } + } + DesignerFrameFileDealerPane.getInstance().stateChange(); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + }.start(); } @Override @@ -1979,7 +2050,7 @@ public abstract class JTemplate> public void setDesignerUIMode() { DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode(); } - + /** * 判断当前的模板是否是有效的模板 * diff --git a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java index 60d797c3e9..188aedacb9 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java @@ -5,12 +5,15 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.JTemplate; +import com.fr.design.ui.util.UIUtil; import com.fr.design.worker.WorkerManager; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; + import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; + +import com.fr.third.org.apache.commons.lang3.time.StopWatch; + import javax.swing.SwingWorker; /** @@ -34,6 +37,14 @@ public class SaveWorker extends SwingWorker { private boolean slowly; + public boolean isSlowly() { + return slowly; + } + + public void setSlowly(boolean slowly) { + this.slowly = slowly; + } + public SaveWorker(Callable callable, JTemplate template) { this.callable = callable; this.template = template; @@ -47,10 +58,11 @@ public class SaveWorker extends SwingWorker { @Override protected void done() { try { - success = get(); + success = get(); } catch (Exception e) { processResult(); FineLoggerFactory.getLogger().error(e.getMessage(), e); + WorkerManager.getInstance().removeWorker(taskName); SaveFailureHandler.getInstance().process(e); return; } @@ -62,6 +74,7 @@ public class SaveWorker extends SwingWorker { // 恢复界面 if (slowly && ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) { DesignerContext.getDesignerFrame().getCenterTemplateCardPane().hideCover(); + slowly = false; } DesignerFrameFileDealerPane.getInstance().stateChange(); WorkerManager.getInstance().removeWorker(taskName); @@ -69,21 +82,31 @@ public class SaveWorker extends SwingWorker { public void start(String taskName) { this.taskName = taskName; + StopWatch stopWatch = StopWatch.createStarted(); this.template.setSaving(true); this.execute(); // worker纳入管理 WorkerManager.getInstance().registerWorker(taskName, this); - try { - this.get(TIME_OUT, TimeUnit.MILLISECONDS); - } catch (TimeoutException timeoutException) { - slowly = true; - // 开始禁用 - EastRegionContainerPane.getInstance().updateAllPropertyPane(); - DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover(); - DesignerFrameFileDealerPane.getInstance().stateChange(); - } catch (Exception exception) { - FineLoggerFactory.getLogger().error(exception.getMessage(), exception); - WorkerManager.getInstance().removeWorker(taskName); + if (!slowly) { + new Thread(() -> { + while (true) { + if (stopWatch.getTime() > TIME_OUT || isDone()) { + if (!isDone()) { + slowly = true; + UIUtil.invokeLaterIfNeeded(() -> { + // 开始禁用 + if (slowly) { + EastRegionContainerPane.getInstance().updateAllPropertyPane(); + DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover(); + DesignerFrameFileDealerPane.getInstance().stateChange(); + } + }); + } + stopWatch.stop(); + break; + } + } + }).start(); } } } diff --git a/designer-base/src/main/java/com/fr/design/worker/save/type/SaveType.java b/designer-base/src/main/java/com/fr/design/worker/save/type/SaveType.java new file mode 100644 index 0000000000..63cf6c4c7e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/worker/save/type/SaveType.java @@ -0,0 +1,50 @@ +package com.fr.design.worker.save.type; + +/** + * 保存的类别 + * + * @author John.Ying + * @since 11.0 + * Created on 2023/4/14 + */ +public class SaveType { + + private TypeEnum type; + //保存时间是否慢(是否展示了保存中的UI界面) + private boolean slowly; + + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum saveType) { + this.type = saveType; + } + + public boolean isSlowly() { + return slowly; + } + + public void setSlowly(boolean slowly) { + this.slowly = slowly; + } + + /** + * 保存类型:save or saveAs or empty + */ + public enum TypeEnum { + /** + * 保存 + */ + SAVE, + /** + * 另存 + */ + SAVE_AS, + /** + * 空保存 + */ + EMPTY; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java new file mode 100644 index 0000000000..e087f701f7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java @@ -0,0 +1,75 @@ +package com.fr.design.worker.save.type; + + +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrameFileDealerPane; +import com.fr.design.mainframe.EastRegionContainerPane; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.ui.util.UIUtil; +import com.fr.third.org.apache.commons.lang3.time.StopWatch; + +import javax.swing.SwingWorker; +import java.util.concurrent.Callable; + +/** + * 判断保存类别时执行的worker + * + * @author John.Ying + * @since 11.0 + * Created on 2023/4/14 + */ +public class SaveTypeWorker extends SwingWorker { + + private final Callable callable; + + private static final int TIME_OUT = 400; + + private final JTemplate template; + + private final SaveType saveType; + + public SaveTypeWorker(Callable callable, JTemplate template) { + this.callable = callable; + this.template = template; + this.saveType = new SaveType(); + } + + @Override + protected SaveType doInBackground() throws Exception { + this.saveType.setType(callable.call()); + return this.saveType; + } + + @Override + protected void done() { + + } + + /** + * 启动saveTypeWorker + */ + public void start() { + StopWatch stopWatch = StopWatch.createStarted(); + this.template.setSaving(true); + this.execute(); + new Thread(() -> { + while (true) { + //大于最大等待时间或者worker已经完成该线程都要结束循环 + if (stopWatch.getTime() > TIME_OUT || isDone()) { + //如果是大于最大等待时间结束的,就需要进行等待中界面的覆盖 + if (!isDone()) { + saveType.setSlowly(true); + UIUtil.invokeLaterIfNeeded(() -> { + // 开始禁用 + EastRegionContainerPane.getInstance().updateAllPropertyPane(); + DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover(); + DesignerFrameFileDealerPane.getInstance().stateChange(); + }); + } + stopWatch.stop(); + break; + } + } + }).start(); + } +} From 437c05bbc0959de6b61fa468c2877f77338e6988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Fri, 14 Apr 2023 11:39:01 +0800 Subject: [PATCH 06/59] =?UTF-8?q?REPORT-83195=20=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E7=82=B9=E4=BC=98=E5=8C=96-=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E5=88=9D=E6=AC=A1=E6=B7=BB=E5=8A=A0=E5=9B=BE=E8=A1=A8=E5=8D=A1?= =?UTF-8?q?=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/ChartPropertyPane.java | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java index 4efe977ff3..8e6b80c53a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java @@ -9,6 +9,7 @@ import com.fr.base.chart.BaseChartCollection; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; +import com.fr.decision.webservice.v10.map.geojson.helper.GEOJSONHelper; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.designer.TargetComponent; import com.fr.design.gui.chart.BaseChartPropertyPane; @@ -19,6 +20,7 @@ import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.BorderFactory; import javax.swing.Icon; +import javax.swing.SwingWorker; import java.awt.BorderLayout; import java.awt.Component; @@ -95,16 +97,25 @@ public class ChartPropertyPane extends BaseChartPropertyPane { * @param ePane 面板 */ public void populateChartPropertyPane(ChartCollection collection, TargetComponent ePane) { - String chartID = collection.getSelectedChartProvider(ChartProvider.class).getID(); - updateChartEditPane(collection.getSelectedChartProvider(ChartProvider.class).getID()); - setSupportCellData(true); - this.container.setEPane(ePane); - - if (ChartTypeManager.getInstance().chartExit(chartID)) { - chartEditPane.populate(collection); - } else { - GUICoreUtils.setEnabled(chartEditPane, false); - } + new SwingWorker() { + @Override + protected Void doInBackground() throws Exception { + GEOJSONHelper.getInstance(); + return null; + } + @Override + protected void done() { + String chartID = collection.getSelectedChartProvider(ChartProvider.class).getID(); + updateChartEditPane(collection.getSelectedChartProvider(ChartProvider.class).getID()); + setSupportCellData(true); + container.setEPane(ePane); + if (ChartTypeManager.getInstance().chartExit(chartID)) { + chartEditPane.populate(collection); + } else { + GUICoreUtils.setEnabled(chartEditPane, false); + } + } + }.execute(); } /** From ca53cd0f6e84fa93a91795747b631f58b301b543 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 14 Apr 2023 13:35:38 +0800 Subject: [PATCH 07/59] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/file/CloseOption.java | 11 +++++ .../file/MultiTemplateTabMenuFactory.java | 8 +++- .../fr/design/file/SaveSomeTemplatePane.java | 15 +++++++ .../fr/design/file/TemplateTabManager.java | 40 ++++++++++++++--- .../file/TemplateTabOperateProvider.java | 9 ++++ .../file/impl/AbstractTemplateTabOperate.java | 44 ++++++++++++++----- .../file/impl/DefaultTemplateTabOperate.java | 13 +++++- .../file/impl/EmptyTemplateTabOperator.java | 13 +++++- .../fr/design/mainframe/DesignerFrame.java | 6 ++- .../DesignerFrameFileDealerPane.java | 7 ++- .../com/fr/design/mainframe/JTemplate.java | 13 +++++- 11 files changed, 154 insertions(+), 25 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/CloseOption.java b/designer-base/src/main/java/com/fr/design/file/CloseOption.java index c88e7658c8..79667dec0f 100644 --- a/designer-base/src/main/java/com/fr/design/file/CloseOption.java +++ b/designer-base/src/main/java/com/fr/design/file/CloseOption.java @@ -2,6 +2,11 @@ package com.fr.design.file; import com.fr.design.i18n.Toolkit; +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public enum CloseOption { Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { @Override @@ -36,6 +41,12 @@ public enum CloseOption { this.optionName = optionName; } + /** + * 判断指定索引模板是否应该被关闭 + * @param tplIndex + * @param i + * @return + */ public boolean shouldClose(int tplIndex, int i) { return true; } diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java index a67e129f78..edbe9cbab3 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java @@ -30,8 +30,8 @@ import java.util.Map; /** * @author Carlson - * @version 11.0 - * @description + * @since 11.0 + * created on 2023-04-14 **/ public class MultiTemplateTabMenuFactory { @@ -49,6 +49,10 @@ public class MultiTemplateTabMenuFactory { } + /** + * 返回右侧下拉菜单的工厂类 + * @return + */ public static MultiTemplateTabMenuFactory getInstance() { return INSTANCE; } diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index 96d72d34c1..715cc94ba0 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -151,15 +151,30 @@ public class SaveSomeTemplatePane extends BasicPane { } + /** + * 显示未保存弹窗 + * @return + */ public boolean showSavePane() { return showSavePane(false); } + /** + * 显示未保存弹窗 + * @param switchEnv + * @return + */ public boolean showSavePane(boolean switchEnv) { return switchEnv ? showSavePane(DefaultTemplateTabOperate.getInstance().getOpenedJTemplates()) : showSavePane(HistoryTemplateListPane.getInstance().getHistoryList()); } + + /** + * 显示未保存弹窗 + * @param jTemplates + * @return + */ public boolean showSavePane(List> jTemplates) { populate(jTemplates); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java index 22a0bc37e4..da151d9b0f 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java @@ -12,13 +12,22 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public class TemplateTabManager { private static class HOLDER { - private static final TemplateTabManager singleton = new TemplateTabManager(); + private static final TemplateTabManager SINGLETON = new TemplateTabManager(); } + /** + * 返回TemplateTabManager单例对象 + * @return + */ public static TemplateTabManager getInstance() { - return HOLDER.singleton; + return HOLDER.SINGLETON; } private TemplateTabManager() { @@ -27,15 +36,23 @@ public class TemplateTabManager { private List list = new ArrayList<>(); + /** + * 支持注册新的Operator + * @param templateTabOperateProvider + */ public void register(TemplateTabOperateProvider templateTabOperateProvider) { this.list.add(templateTabOperateProvider); } + /** + * 移除operator + * @param templateTabOperateProvider + */ public void remove(TemplateTabOperateProvider templateTabOperateProvider) { this.list.remove(templateTabOperateProvider); } - private boolean isCloseCurrent = false; + private boolean closeCurrent = false; //自动新建的模板B若没有进行任何编辑,切换到其他 // 模板时,模板B会自动关闭 @@ -43,17 +60,20 @@ public class TemplateTabManager { public boolean isCloseCurrent() { - return isCloseCurrent; + return closeCurrent; } public void setCloseCurrent(boolean closeCurrent) { - isCloseCurrent = closeCurrent; + this.closeCurrent = closeCurrent; } public void setTemTemplate(JTemplate temTemplate) { this.temTemplate = temTemplate; } + /** + * 刷新tab栏 + */ public void refresh() { getCurrentOperator().refresh(); } @@ -127,11 +147,18 @@ public class TemplateTabManager { } + /** + * 重置选中index + * @param jTemplate + */ public void resetSelectIndex(JTemplate jTemplate) { getCurrentOperator().resetSelectIndex(jTemplate); } + /** + * 激活新模板 + */ public void activeNewTemplate() { //先看其他模式中是否有已打开的模板,有的话切换过去 for (TemplateTabOperateProvider templateTabOperateProvider : list) { @@ -202,6 +229,9 @@ public class TemplateTabManager { return resultMap; } + /** + * 关闭其他 + */ public void closeOthers() { TemplateTabOperateProvider currentOperator = getCurrentOperator(); currentOperator.closeAction(CloseOption.Others, diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java index ff913f3342..7bcc816526 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java @@ -6,6 +6,11 @@ import com.fr.file.FILE; import java.util.List; +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public interface TemplateTabOperateProvider { /** * 找到模板树中的位置 @@ -38,6 +43,10 @@ public interface TemplateTabOperateProvider { List> getOpenedJTemplates(); + /** + * 根据指定索引关闭模板 + * @param index + */ void closeByIndex(int index); /** * 关闭指定模板 diff --git a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java index b6bee6e6d8..e42b336f57 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java @@ -25,18 +25,25 @@ import com.fr.third.javax.annotation.Nonnull; import com.fr.workspace.WorkContext; import com.fr.workspace.server.lock.TplOperator; -import javax.swing.*; +import javax.swing.JOptionPane; import java.util.ArrayList; import java.util.List; import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; -import static javax.swing.JOptionPane.*; - +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.OK_OPTION; +import static javax.swing.JOptionPane.WARNING_MESSAGE; + +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public abstract class AbstractTemplateTabOperate implements TemplateTabOperateProvider { //用于存放工作簿 - protected java.util.List> openedTemplate = new ArrayList<>(); + private java.util.List> openedTemplate = new ArrayList<>(); //选中的Tab项 - protected int selectedIndex = -1; + private int selectedIndex = -1; public AbstractTemplateTabOperate() { @@ -57,7 +64,8 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr FILE currentTemplate = template.getEditingFILE(); //模板不属于当前环境,跟预览一样先提示保存,再定位模板 //如果是拖拽进来的模板单单用exist不能判断,这边参考预览的判断逻辑(browserTemplate),补充一下 - if ((!currentTemplate.exists() || !(currentTemplate instanceof FileNodeFILE)) && template.canBeSaved()) { + boolean needSave = (!currentTemplate.exists() || !(currentTemplate instanceof FileNodeFILE)) && template.canBeSaved(); + if (needSave) { int selVal = showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), OK_CANCEL_OPTION, WARNING_MESSAGE); if (OK_OPTION == selVal) { CallbackSaveWorker worker = template.saveAs(); @@ -96,6 +104,10 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr } } + /** + * 根据指定索引值关闭模板 + * @param index + */ public void closeByIndex(int index) { //关闭close图标所在的模板{ JTemplate template = openedTemplate.get(index); @@ -153,18 +165,19 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr public void switchTpl(int templateIndex) { int tempSelectedIndex = selectedIndex; JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if ((selectedIndex != templateIndex || !this.accept(jTemplate.getTemplateTabOperatorType())) - && templateIndex != -1) { + boolean shouldSwitch = (selectedIndex != templateIndex || !this.accept(jTemplate.getTemplateTabOperatorType())) + && templateIndex != -1; + if (shouldSwitch) { openedTemplate.get(selectedIndex).stopEditing(); selectedIndex = templateIndex; //如果在权限编辑情况下,不允许切换到表单类型的工作簿 if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), WARNING_MESSAGE); return; } - JTemplate evtXTemplate = openedTemplate.get(templateIndex); - evtXTemplate.activeNewJTemplate(); + JTemplate evtTemplate = openedTemplate.get(templateIndex); + evtTemplate.activeNewJTemplate(); } } @@ -285,6 +298,10 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr TemplateTabManager.getInstance().refresh(); } + /** + * 刷新已打开的模板 + * @param list + */ public void refreshOpenedTemplate(List> list) { List> result = new ArrayList<>(); for (JTemplate jTemplate : list) { @@ -315,6 +332,11 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr return this.openedTemplate.indexOf(jTemplate); } + /** + * 是否支持指定操作类型 + * @param type + * @return + */ public boolean accept(String type) { return CompareUtils.isEqual(getOperatorType(), type); } diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java index 511b74894f..ae8ea292a9 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java @@ -2,20 +2,29 @@ package com.fr.design.file.impl; import com.fr.design.file.MultiTemplateTabPane; +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public class DefaultTemplateTabOperate extends AbstractTemplateTabOperate { public static final String OPERATOR_TYPE = "DEFAULT_TEMPLATE_TAB_OPERATOR"; private static class HOLDER { - private static final DefaultTemplateTabOperate singleton = new DefaultTemplateTabOperate(); + private static final DefaultTemplateTabOperate SINGLETON = new DefaultTemplateTabOperate(); } private DefaultTemplateTabOperate() { super(); } + /** + * 返回DefaultTemplateTabOperate 单例 + * @return + */ public static DefaultTemplateTabOperate getInstance() { - return HOLDER.singleton; + return HOLDER.SINGLETON; } @Override diff --git a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java index 804874138d..4afe59f16b 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java @@ -9,9 +9,14 @@ import com.fr.stable.StringUtils; import java.util.ArrayList; import java.util.List; +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public class EmptyTemplateTabOperator implements TemplateTabOperateProvider { private static class HOLDER { - private static final EmptyTemplateTabOperator singleton = new EmptyTemplateTabOperator(); + private static final EmptyTemplateTabOperator SINGLETON = new EmptyTemplateTabOperator(); } @@ -19,8 +24,12 @@ public class EmptyTemplateTabOperator implements TemplateTabOperateProvider { } + /** + * 返回空的模板taboperator单例 + * @return + */ public static EmptyTemplateTabOperator getInstance() { - return HOLDER.singleton; + return HOLDER.SINGLETON; } @Override 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 2f05dbbeb2..8b63b73e96 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 @@ -19,7 +19,11 @@ import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; -import com.fr.design.file.*; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.SaveSomeTemplatePane; +import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.OemProcessor; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; import com.fr.design.gui.iprogressbar.ProgressDialog; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index a07bfe1f1d..80fccc95cb 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -17,7 +17,12 @@ import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager; import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.file.*; +import com.fr.design.file.FileOperations; +import com.fr.design.file.FileToolbarStateChangeListener; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.TemplateTreePane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuHighLight; 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 b8fef1b007..dbf63e077c 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 @@ -30,7 +30,9 @@ import com.fr.design.designer.DesignerProxy; import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.InformationWarnPane; -import com.fr.design.file.*; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.TemplateResourceManager; import com.fr.design.file.impl.DefaultTemplateTabOperate; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; @@ -1993,10 +1995,19 @@ public abstract class JTemplate> return jt != null && jt != JNullTemplate.NULL; } + /** + * 当前模板是否可以被保存 + * @return 是/否 + */ public boolean canBeSaved(){ return true; } + /** + * 当前的模板是否支持缓存 + * + * @return 是/否 + */ public boolean supportCache(){ return true; } From 808f940df284f1f95e0d4550383f65dedba6ec64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Fri, 14 Apr 2023 13:41:06 +0800 Subject: [PATCH 08/59] =?UTF-8?q?REPORT-83195=20=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E7=82=B9=E4=BC=98=E5=8C=96-=E5=BC=80=E5=8F=91=E8=80=85?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/carton/SwitchForSwingChecker.java | 74 ++++++++- .../design/carton/developer/AwtEventInfo.java | 73 +++++++++ .../developer/EventDispatchDeveloperMode.java | 146 ++++++++++++++++++ 3 files changed, 288 insertions(+), 5 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/carton/developer/AwtEventInfo.java create mode 100644 designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java diff --git a/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java b/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java index 683179293e..837bdb1c8b 100644 --- a/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java +++ b/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java @@ -1,6 +1,7 @@ package com.fr.design.carton; +import com.fr.design.carton.developer.EventDispatchDeveloperMode; import com.fr.design.i18n.Toolkit; import com.fr.general.GeneralUtils; import com.fr.json.JSON; @@ -29,11 +30,22 @@ import java.util.Map; import java.util.Date; import java.util.Calendar; + public class SwitchForSwingChecker implements XMLReadable, XMLWriter { /** * Designer4Debug类名 */ private static final String DEBUG_MAIN_CLASS_NAME = "com.fr.start.Designer4Debug"; + + /** + * 真正主类 + */ + private static final String NORMAL_MAIN_CLASS_NAME = "com.fr.start.MainDesigner"; + + /** + * 开发者模式jvm参数 + */ + private static final String CARTON_DEVELOPER_JVM_PARAM = "cartonDeveloper"; /** * XML标签 */ @@ -249,11 +261,7 @@ public class SwitchForSwingChecker implements XMLReadable, XMLWriter { */ public static void initThreadMonitoring () { String mainClass = System.getProperty("sun.java.command"); - //判断一下,如果是以Designer4Debug启动,就不注册代码,不然会覆盖掉SwingExplorer,导致其无法使用 - if (!StringUtils.equals(mainClass, DEBUG_MAIN_CLASS_NAME)) { - EventDispatchThreadHangMonitor.initMonitoring(); - AppContext.getAppContext().put(SwingWorker.class, CartonThreadExecutorPool.getTimerThreadExecutorPool()); - } + MainClassType.getMainClassType(mainClass).initEventQueue(); } /** @@ -309,4 +317,60 @@ public class SwitchForSwingChecker implements XMLReadable, XMLWriter { writer.end(); } + /** + * 根据程序启动类路径进行区分 + * + * @author John.Ying + * @since 11.0 + * Created on 2023/4/14 + */ + enum MainClassType { + /** + * 用mainDesigner启动 + */ + MAIN(NORMAL_MAIN_CLASS_NAME) { + @Override + void initEventQueue() { + if (StringUtils.equals("true", System.getProperty(CARTON_DEVELOPER_JVM_PARAM))) { + EventDispatchDeveloperMode.INSTANCE.initMonitoring(); + } else { + EventDispatchThreadHangMonitor.initMonitoring(); + AppContext.getAppContext().put(SwingWorker.class, CartonThreadExecutorPool.getTimerThreadExecutorPool()); + } + } + }, + + /** + * designer4debug启动 + */ + DEBUG_MAIN(DEBUG_MAIN_CLASS_NAME) { + @Override + void initEventQueue() { + + } + }; + + MainClassType(String classPath) { + this.classPath = classPath; + } + + String classPath; + + /** + * 初始化重写的EDT + */ + abstract void initEventQueue(); + + /** + * @param classPath 启动类路径 + */ + static MainClassType getMainClassType(String classPath) { + for (MainClassType mainClassType : MainClassType.values()) { + if (StringUtils.equals(classPath, mainClassType.classPath)) { + return mainClassType; + } + } + return MAIN; + } + } } diff --git a/designer-base/src/main/java/com/fr/design/carton/developer/AwtEventInfo.java b/designer-base/src/main/java/com/fr/design/carton/developer/AwtEventInfo.java new file mode 100644 index 0000000000..77274a36ab --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/carton/developer/AwtEventInfo.java @@ -0,0 +1,73 @@ +package com.fr.design.carton.developer; + +import java.awt.AWTEvent; + +/** + * EDT事件的包装类,用来额外处理信息 + * + * @author John.Ying + * @since 11.0 + * Created on 2023/4/14 + */ +public class AwtEventInfo { + //获取执行该事件的线程 + private final Thread eventDispatchThread = Thread.currentThread(); + //在队列中等待执行的事件最后未执行的时间,当有一个事件执行完后就遍历dispatches给该值赋当前时间 + private long lastDispatchTimeMillis = System.currentTimeMillis(); + //事件开始的时间 + private final long startDispatchTimeMillis = System.currentTimeMillis(); + //awt事件 + private AWTEvent awtEvent; + //事件堆栈 + private StackTraceElement[] stackTrace; + + /** + * 检查是否要给堆栈赋值 + */ + public void checkForHang() { + if (isNeedToStackTrace()) { + this.stackTrace = eventDispatchThread.getStackTrace(); + } + } + + /** + * 是否需要赋值堆栈满足 + * 耗时>20ms + */ + private boolean isNeedToStackTrace() { + return (System.currentTimeMillis() - startDispatchTimeMillis) > EventDispatchDeveloperMode.MAX_TIME + && stackTrace == null; + } + + public Thread getEventDispatchThread() { + return eventDispatchThread; + } + + public long getLastDispatchTimeMillis() { + return lastDispatchTimeMillis; + } + + public void setLastDispatchTimeMillis(long lastDispatchTimeMillis) { + this.lastDispatchTimeMillis = lastDispatchTimeMillis; + } + + public long getStartDispatchTimeMillis() { + return startDispatchTimeMillis; + } + + public AWTEvent getAwtEvent() { + return awtEvent; + } + + public void setAwtEvent(AWTEvent awtEvent) { + this.awtEvent = awtEvent; + } + + public StackTraceElement[] getStackTrace() { + return stackTrace; + } + + public void setStackTrace(StackTraceElement[] stackTrace) { + this.stackTrace = stackTrace; + } +} diff --git a/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java b/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java new file mode 100644 index 0000000000..4fd136da37 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java @@ -0,0 +1,146 @@ +package com.fr.design.carton.developer; + + +import com.fr.concurrent.FineExecutors; +import com.fr.design.carton.EventDispatchThreadHangMonitor; +import com.fr.design.ui.util.UIUtil; +import com.fr.log.FineLoggerFactory; + +import java.awt.AWTEvent; +import java.awt.EventQueue; +import java.awt.Toolkit; +import java.util.LinkedList; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * 开发者模式重写的EDT + * + * @author John.Ying + * @since 11.0 + * Created on 2023/4/14 + */ +public final class EventDispatchDeveloperMode extends EventQueue { + + /** + * 该链表为主要的实现定时任务的容器,在重写的dispatchEvent中由pre方法将DispatchInfo加入到链表,由post方法remove + */ + private final LinkedList dispatches = new LinkedList<>(); + /** + * 开启间隔检测后两次检测的相隔时间ms + */ + public static final long CHECK_INTERVAL_MS = 5; + + private Timer timer; + + /** + * edt事件最大允许的时间 + */ + public static final long MAX_TIME = 20; + public static final EventDispatchDeveloperMode INSTANCE = new EventDispatchDeveloperMode(); + + @Override + protected void dispatchEvent(AWTEvent event) { + try { + preDispatchEvent(event); + super.dispatchEvent(event); + } finally { + postDispatchEvent(); + } + } + + /** + * 事件分发前处理 + */ + private synchronized void preDispatchEvent(AWTEvent event) { + synchronized (dispatches) { + AwtEventInfo awtEventInfo = new AwtEventInfo(); + awtEventInfo.setAwtEvent(event); + dispatches.addLast(awtEventInfo); + } + } + + /** + * 事件分发后处理 + */ + private synchronized void postDispatchEvent() { + synchronized (dispatches) { + AwtEventInfo awtEventInfo = dispatches.removeLast(); + //嵌套最深的事件执行完毕后刷新链表中其他事件的lastDispatchTimeMillis + Thread currentEventDispatchThread = Thread.currentThread(); + for (AwtEventInfo info : dispatches) { + info.setLastDispatchTimeMillis(System.currentTimeMillis()); + } + long nowTime = System.currentTimeMillis(); + long totalTime = nowTime - awtEventInfo.getStartDispatchTimeMillis(); + long continuationTime = nowTime - awtEventInfo.getLastDispatchTimeMillis(); + if (continuationTime > MAX_TIME) { + FineLoggerFactory.getLogger() + .warn("awt event spend time more than 20ms, totalTime {} continuationTime {} the stack is {}" + , totalTime, continuationTime, EventDispatchThreadHangMonitor.stackTraceToStringForConsole(awtEventInfo.getStackTrace())); + } + } + } + + /** + * 将swing中默认的EventQueue换成自己的 + */ + public void initMonitoring() { + UIUtil.invokeLaterIfNeeded(() -> Toolkit.getDefaultToolkit().getSystemEventQueue().push(INSTANCE)); + initTimer(); + startFilterModalWindow(); + } + + /** + * Sets up a timer to check for hangs frequently. + * 初始化一个Timer + */ + public void initTimer() { + final long initialDelayMs = 0; + final boolean daemon = true; + timer = new Timer("EventDispatchDeveloperMode", daemon); + timer.schedule(new HangChecker(), initialDelayMs, CHECK_INTERVAL_MS); + } + + /** + * /消除Timer + */ + public void stopTimer() { + if (timer != null) { + timer.cancel(); + } + } + + /** + * /定时执行的任务 + */ + public class HangChecker extends TimerTask { + @Override + public void run() { + synchronized (dispatches) { + //如果链表为空定时检测就不进行 + if (dispatches.isEmpty()) { + return; + } + dispatches.getLast().checkForHang(); + } + } + } + + /** + * 消除模态框影响 + */ + public void startFilterModalWindow() { + ScheduledExecutorService scheduledExecutorService = FineExecutors.newSingleThreadScheduledExecutor(); + scheduledExecutorService.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + UIUtil.invokeLaterIfNeeded(() -> { + //不用干事,切个片就可以 + }); + } + }, 0, 10, TimeUnit.MILLISECONDS); + } +} From b682394b3ec451d4b7b75e4a9f448628f9196269 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 14 Apr 2023 13:51:00 +0800 Subject: [PATCH 09/59] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/file/CloseOption.java | 16 +++++++++++++++- .../com/fr/design/file/MultiTemplateTabPane.java | 4 ++-- .../com/fr/design/file/TemplateTabManager.java | 4 ++-- .../file/impl/AbstractTemplateTabOperate.java | 5 +++-- .../file/impl/DefaultTemplateTabOperate.java | 4 ++-- .../file/impl/EmptyTemplateTabOperator.java | 4 ++-- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/CloseOption.java b/designer-base/src/main/java/com/fr/design/file/CloseOption.java index 79667dec0f..ecb70d6a5f 100644 --- a/designer-base/src/main/java/com/fr/design/file/CloseOption.java +++ b/designer-base/src/main/java/com/fr/design/file/CloseOption.java @@ -8,6 +8,10 @@ import com.fr.design.i18n.Toolkit; * created on 2023-04-14 **/ public enum CloseOption { + + /** + * 关闭左侧所有模板 + */ Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { @Override public boolean shouldClose(int tplIndex, int i) { @@ -15,14 +19,24 @@ public enum CloseOption { } }, + /** + * 关闭右侧所有模板 + */ Right(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Right")) { @Override public boolean shouldClose(int tplIndex, int i) { return i > tplIndex; } + }, - }, All(Toolkit.i18nText("Fine-Design_Close_All_templates")), + /** + * 关闭所有模板 + */ + All(Toolkit.i18nText("Fine-Design_Close_All_templates")), + /** + * 关闭其他模板 + */ Others(Toolkit.i18nText("Fine-Design_Close_Other_templates")) { @Override public boolean shouldClose(int tplIndex, int i) { diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index efc4565e00..0fd4bdecf9 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -402,8 +402,8 @@ public class MultiTemplateTabPane extends JComponent { if (template.isSaving()) { selectedIcon = GREY_SAVING_CLOSE_ICON; } - boolean isLeft = i < TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); - startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, isLeft, mouseOveredIndex, i); + boolean left = i < TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); + startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, left, mouseOveredIndex, i); } templateStartX += realWidth; } diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java index da151d9b0f..f7fb354b3f 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java @@ -18,7 +18,7 @@ import java.util.Map; * created on 2023-04-14 **/ public class TemplateTabManager { - private static class HOLDER { + private static class Holder { private static final TemplateTabManager SINGLETON = new TemplateTabManager(); } @@ -27,7 +27,7 @@ public class TemplateTabManager { * @return */ public static TemplateTabManager getInstance() { - return HOLDER.SINGLETON; + return Holder.SINGLETON; } private TemplateTabManager() { diff --git a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java index e42b336f57..1f089c5773 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java @@ -40,6 +40,7 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE; * created on 2023-04-14 **/ public abstract class AbstractTemplateTabOperate implements TemplateTabOperateProvider { + private static final String UNSAVED_SUFFIX = " *"; //用于存放工作簿 private java.util.List> openedTemplate = new ArrayList<>(); //选中的Tab项 @@ -345,8 +346,8 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr @Override public String getTemplateShowName(JTemplate template) { String name = TemplateUtils.createLockeTemplatedName(template, template.getTemplateName()); - if (!template.isSaved() && !name.endsWith(" *")) { - name += " *"; + if (!template.isSaved() && !name.endsWith(UNSAVED_SUFFIX)) { + name += UNSAVED_SUFFIX; } return name; } diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java index ae8ea292a9..1dec669cc4 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java @@ -11,7 +11,7 @@ public class DefaultTemplateTabOperate extends AbstractTemplateTabOperate { public static final String OPERATOR_TYPE = "DEFAULT_TEMPLATE_TAB_OPERATOR"; - private static class HOLDER { + private static class Holder { private static final DefaultTemplateTabOperate SINGLETON = new DefaultTemplateTabOperate(); } @@ -24,7 +24,7 @@ public class DefaultTemplateTabOperate extends AbstractTemplateTabOperate { * @return */ public static DefaultTemplateTabOperate getInstance() { - return HOLDER.SINGLETON; + return Holder.SINGLETON; } @Override diff --git a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java index 4afe59f16b..f5e2b93d5b 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java @@ -15,7 +15,7 @@ import java.util.List; * created on 2023-04-14 **/ public class EmptyTemplateTabOperator implements TemplateTabOperateProvider { - private static class HOLDER { + private static class Holder { private static final EmptyTemplateTabOperator SINGLETON = new EmptyTemplateTabOperator(); } @@ -29,7 +29,7 @@ public class EmptyTemplateTabOperator implements TemplateTabOperateProvider { * @return */ public static EmptyTemplateTabOperator getInstance() { - return HOLDER.SINGLETON; + return Holder.SINGLETON; } @Override From 196d9182e7095473304b13fc2344c68cfb1d0fe6 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 14 Apr 2023 14:03:26 +0800 Subject: [PATCH 10/59] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/file/TemplateTabManager.java | 1 + .../main/java/com/fr/design/file/TemplateTabOperateProvider.java | 1 + .../java/com/fr/design/file/impl/AbstractTemplateTabOperate.java | 1 + .../java/com/fr/design/file/impl/DefaultTemplateTabOperate.java | 1 + .../java/com/fr/design/file/impl/EmptyTemplateTabOperator.java | 1 + 5 files changed, 5 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java index f7fb354b3f..f5dca0c005 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; /** + * 模板tab的操作统一管理类 * @author kerry * @since 11.0 * created on 2023-04-14 diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java index 7bcc816526..98d48ad4af 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java @@ -7,6 +7,7 @@ import com.fr.file.FILE; import java.util.List; /** + * 模板tab的操作接口 * @author kerry * @since 11.0 * created on 2023-04-14 diff --git a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java index 1f089c5773..7793a26dcf 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java @@ -35,6 +35,7 @@ import static javax.swing.JOptionPane.OK_OPTION; import static javax.swing.JOptionPane.WARNING_MESSAGE; /** + * 模板tab的操作抽象类 * @author kerry * @since 11.0 * created on 2023-04-14 diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java index 1dec669cc4..90853568dd 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java @@ -3,6 +3,7 @@ package com.fr.design.file.impl; import com.fr.design.file.MultiTemplateTabPane; /** + * 默认的模板tab的操作类 * @author kerry * @since 11.0 * created on 2023-04-14 diff --git a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java index f5e2b93d5b..3f4ef4d99f 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.List; /** + * 空的模板tab的操作类 * @author kerry * @since 11.0 * created on 2023-04-14 From c65ac20bb1b75ebd6f96f846fcb20e4e0df09934 Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 14 Apr 2023 14:35:28 +0800 Subject: [PATCH 11/59] =?UTF-8?q?REPORT-92161=20=E5=8F=8D=E8=89=B2?= =?UTF-8?q?=E9=97=AE=E9=A2=98,=E6=8A=8A=E9=80=89=E4=B8=AD=E5=8F=98?= =?UTF-8?q?=E8=89=B2=E7=9A=84=E9=80=BB=E8=BE=91=E6=8F=90=E5=87=BA,?= =?UTF-8?q?=E5=92=8CsetIcon=E5=88=86=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/controlpane/JListControlPane.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index 37134ec995..4e1ce9c617 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -377,15 +377,15 @@ public abstract class JListControlPane extends JControlPane implements ListContr this.textLabel.setText(nameable.getName()); boolean iconSet = false; for (NameableCreator creator : JListControlPane.this.creators()) { + if(isSelected) { + this.textLabel.setBackground(selectedBgColor); + this.textLabel.setForeground(Color.WHITE); + } else { + this.textLabel.setBackground(Color.WHITE); + this.textLabel.setForeground(Color.BLACK); + } if (creator.menuIcon() != null && creator.acceptObject2Populate(nameable) != null) { this.iconLabel.setIcon(creator.menuIcon()); - if(isSelected) { - this.textLabel.setBackground(selectedBgColor); - this.textLabel.setForeground(Color.WHITE); - } else { - this.textLabel.setBackground(Color.WHITE); - this.textLabel.setForeground(Color.BLACK); - } this.setToolTipText(creator.createTooltip()); iconSet = true; break; From dcdbd2ac61b22ebae997972f4bf9c0e2b906d291 Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 14 Apr 2023 14:45:36 +0800 Subject: [PATCH 12/59] =?UTF-8?q?REPORT-92161=20=E5=8F=8D=E8=89=B2?= =?UTF-8?q?=E9=97=AE=E9=A2=98,=E6=8A=8A=E9=80=89=E4=B8=AD=E5=8F=98?= =?UTF-8?q?=E8=89=B2=E7=9A=84=E9=80=BB=E8=BE=91=E6=8F=90=E5=87=BA,?= =?UTF-8?q?=E5=92=8CsetIcon=E5=88=86=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/controlpane/JListControlPane.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index 4e1ce9c617..93cdc4e4e2 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -376,14 +376,14 @@ public abstract class JListControlPane extends JControlPane implements ListContr Nameable nameable = element.wrapper; this.textLabel.setText(nameable.getName()); boolean iconSet = false; + if(isSelected) { + this.textLabel.setBackground(selectedBgColor); + this.textLabel.setForeground(Color.WHITE); + } else { + this.textLabel.setBackground(Color.WHITE); + this.textLabel.setForeground(Color.BLACK); + } for (NameableCreator creator : JListControlPane.this.creators()) { - if(isSelected) { - this.textLabel.setBackground(selectedBgColor); - this.textLabel.setForeground(Color.WHITE); - } else { - this.textLabel.setBackground(Color.WHITE); - this.textLabel.setForeground(Color.BLACK); - } if (creator.menuIcon() != null && creator.acceptObject2Populate(nameable) != null) { this.iconLabel.setIcon(creator.menuIcon()); this.setToolTipText(creator.createTooltip()); From 0b4917e0ea6f21117bcd9d90897689a1abeb44e0 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 14 Apr 2023 14:47:04 +0800 Subject: [PATCH 13/59] =?UTF-8?q?fix=EF=BC=9A=E5=A4=84=E7=90=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/file/MultiTemplateTabPane.java | 184 +++++++++--------- .../fr/design/file/SaveSomeTemplatePane.java | 7 + .../fr/design/file/TemplateTabManager.java | 7 + .../file/TemplateTabOperateProvider.java | 5 + .../file/impl/AbstractTemplateTabOperate.java | 8 + 5 files changed, 123 insertions(+), 88 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 0fd4bdecf9..01e45816eb 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -13,16 +13,13 @@ import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; -import com.fr.design.mainframe.TemplateSavingChecker; import com.fr.design.utils.DesignUtils; -import com.fr.design.utils.TemplateUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.file.FILE; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.stable.Constants; -import com.fr.third.javax.annotation.Nonnull; import javax.swing.BorderFactory; import javax.swing.ButtonModel; @@ -31,10 +28,8 @@ import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JMenu; import javax.swing.JMenuItem; -import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.MenuElement; -import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.plaf.basic.BasicMenuItemUI; import java.awt.AWTEvent; @@ -48,7 +43,6 @@ import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.event.AWTEventListener; import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -58,6 +52,7 @@ import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; +import java.util.List; /** * 改个名字,一个拼写 n 个错误 @@ -238,90 +233,60 @@ public class MultiTemplateTabPane extends JComponent { } - @Override - public Dimension getPreferredSize() { - Dimension dimension = super.getPreferredSize(); - dimension.height = HEIGHT; - return dimension; + /** + * 留作兼容 + * @return + */ + @Deprecated + public JTemplate getSelectedFile() { + return TemplateTabManager.getInstance().getSelectedFile(); } - private UIMenuItem initCloseOther() { - UIMenuItem closeOther = new UIMenuItem(Toolkit.i18nText("Fine-Design_Basic_FS_Close_Other_Templates")); - // Yvan: 英文下文本显示不全,后续发现如果将模板名设置的比较短,其它语言也会出现显示不全的问题,所以设置一下文本水平居中 - closeOther.setHorizontalAlignment(SwingConstants.CENTER); - setListDownItemPreferredSize(closeOther); - closeOther.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - //int tabSize = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); - int tabSize = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); - if (tabSize == 1) { - return; - } - if (!TemplateSavingChecker.check()) { - return; - } - SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); - //点击关闭其他模板,并且点击确定保存 - if (saveSomeTempaltePane.showSavePane()) { - JTemplate[] panes = new JTemplate[tabSize]; - for (int i = 0; i < tabSize; i++) { - panes[i] = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(i); - } - for (int i = 0; i < panes.length; i++) { - if (i != TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex()) { - JTemplate jTemplate = panes[i]; - //判断关闭的模板是不是格式刷的被参照的模板 - TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().remove(jTemplate); - TemplateTabManager.getInstance().closeFormat(jTemplate); - HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); - closeAndFreeLock(jTemplate); - } - } - JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - TemplateTabManager.getInstance().resetSelectIndex(currentTemplate); - THIS.repaint(); - } - //如果取消保存了,则不关闭其他模板 - } - }); - if (TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size() == 1) { - closeOther.setEnabled(false); - } - return closeOther; + /** + * 关闭掉当前已打开文件列表中指定的文件 + * + * @param file 指定的文件 + */ + @Deprecated + public void closeFileTemplate(FILE file) { + TemplateTabManager.getInstance().closeFileTemplate(file); } - private UIMenuItem[] createListDownTemplate() { - int templateTabCount = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); - UIMenuItem[] templates = new UIMenuItem[templateTabCount]; - for (int i = 0; i < templateTabCount; i++) { - final int index = i; - final JTemplate tem = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(i); - templates[i] = new UIMenuItem(tempalteShowName(tem), tem.getIcon()); - templates[i].setUI(new UIListDownItemUI()); - setListDownItemPreferredSize(templates[i]); - if (i == TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex()) { - //画选中的高亮 - templates[i].setBackground(UIConstants.SHADOW_CENTER); - } - templates[i].addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(index); - tem.activeNewJTemplate(); - } - }); - } - return templates; + /** + * 刷新打开模板 + * + * @param history 模板 + */ + @Deprecated + public void refreshOpenedTemplate(List> history) { + TemplateTabManager.getInstance().refreshOpenedTemplate(history); } - private void setListDownItemPreferredSize(UIMenuItem item) { - Dimension dimension = item.getPreferredSize(); - dimension.height = LIST_DOWN_HEIGHT; - item.setPreferredSize(dimension); + /** + * 设置临时Template + * @param auotCreate + */ + @Deprecated + public void setTemTemplate(JTemplate auotCreate) { + TemplateTabManager.getInstance().setTemTemplate(auotCreate); } + /** + * 设置选中模板索引 + * @param index + */ + @Deprecated + public void setSelectedIndex(int index) { + TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(index); + } + + @Override + public Dimension getPreferredSize() { + Dimension dimension = super.getPreferredSize(); + dimension.height = HEIGHT; + return dimension; + } private String tempalteShowName(JTemplate template) { return TemplateTabManager.getInstance().getTemplateShowName(template); @@ -682,14 +647,23 @@ public class MultiTemplateTabPane extends JComponent { generalPath.closePath(); } + /** + * 设置是否关闭当前打开的模板 + * @param isCloseCurrent + */ + @Deprecated + public void setIsCloseCurrent(boolean isCloseCurrent) { + TemplateTabManager.getInstance().setCloseCurrent(isCloseCurrent); + } - private void closeAndFreeLock(@Nonnull JTemplate template) { - FILE file = template.getEditingFILE(); - // 只有是环境内的文件,才执行释放锁 - if (file != null && file.isEnvFile()) { - // release lock - TemplateResourceManager.getResource().closeTemplate(file.getPath()); - } + /** + * 关闭模板 + * + * @param specifiedTemplate 模板 + */ + @Deprecated + public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { + TemplateTabManager.getInstance().closeSpecifiedTemplate(specifiedTemplate); } @@ -710,6 +684,40 @@ public class MultiTemplateTabPane extends JComponent { return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); } + /** + * 后台关闭当前编辑模板 + */ + @Deprecated + public void closeCurrentTpl() { + TemplateTabManager.getInstance().closeCurrentTpl(); + } + + /** + * 关闭模板 + * + * @param closedTemplate 模板 + */ + @Deprecated + public void closeFormat(JTemplate closedTemplate) { + TemplateTabManager.getInstance().closeFormat(closedTemplate); + } + + /** + * 关闭掉一个模板之后激活新的待显示模板 + */ + @Deprecated + public void activePrevTemplateAfterClose() { + TemplateTabManager.getInstance().activePrevTemplateAfterClose(); + } + + /** + * 处理自动新建的模板 在切换时的处理 + */ + @Deprecated + public void doWithtemTemplate() { + TemplateTabManager.getInstance().doWithtemTemplate(); + } + private int getTemplateIndex(int evtX) { int textX = 0; diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index 715cc94ba0..c83c5ca800 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -186,6 +186,13 @@ public class SaveSomeTemplatePane extends BasicPane { return isAllSaved; } + /** + * 兼容方法 + */ + @Deprecated + public void populate() { + populate(HistoryTemplateListPane.getInstance().getHistoryList()); + } private void populate(java.util.List> opendedTemplate) { JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java index f5dca0c005..499706f523 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java @@ -230,6 +230,13 @@ public class TemplateTabManager { return resultMap; } + /** + * 留作兼容 + */ + public void activePrevTemplateAfterClose(){ + getCurrentOperator().activePrevTemplateAfterClose(); + } + /** * 关闭其他 */ diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java index 98d48ad4af..a9a317a8b4 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java @@ -121,4 +121,9 @@ public interface TemplateTabOperateProvider { */ String getTemplateShowName(JTemplate jTemplate); + + /** + * 留作兼容,在关闭模板后激活前一个模板 + */ + void activePrevTemplateAfterClose(); } diff --git a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java index 7793a26dcf..3f67fb69b2 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java @@ -262,6 +262,14 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr activePrevTemplateAfterClose(specifiedTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); } + /** + * 关闭掉一个模板之后激活新的待显示模板 + */ + @Override + public void activePrevTemplateAfterClose(){ + activePrevTemplateAfterClose(TemplateTabManager.getInstance().isCloseCurrent()); + } + /** * 关闭掉一个模板之后激活新的待显示模板 */ From c600233de6061525f41c6945b1414e1217899f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Fri, 14 Apr 2023 15:08:58 +0800 Subject: [PATCH 14/59] =?UTF-8?q?REPORT-83195=20=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E7=82=B9=E4=BC=98=E5=8C=96-=E6=A0=B9=E6=8D=AE=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8F=90=E7=A4=BA=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../developer/EventDispatchDeveloperMode.java | 37 ++++++++----------- .../com/fr/design/worker/save/SaveWorker.java | 37 +++++++++---------- .../worker/save/type/SaveTypeWorker.java | 10 ++++- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java b/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java index 4fd136da37..a87e900ac1 100644 --- a/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java +++ b/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java @@ -1,6 +1,7 @@ package com.fr.design.carton.developer; +import com.aspose.words.Run; import com.fr.concurrent.FineExecutors; import com.fr.design.carton.EventDispatchThreadHangMonitor; import com.fr.design.ui.util.UIUtil; @@ -33,7 +34,9 @@ public final class EventDispatchDeveloperMode extends EventQueue { */ public static final long CHECK_INTERVAL_MS = 5; - private Timer timer; + private static final int CORE_THREAD_SIZE = 5; + + private ScheduledExecutorService timer; /** * edt事件最大允许的时间 @@ -76,6 +79,7 @@ public final class EventDispatchDeveloperMode extends EventQueue { long nowTime = System.currentTimeMillis(); long totalTime = nowTime - awtEventInfo.getStartDispatchTimeMillis(); long continuationTime = nowTime - awtEventInfo.getLastDispatchTimeMillis(); + //判断连续执行时间是否超过了20ms,超过了则进行提示 if (continuationTime > MAX_TIME) { FineLoggerFactory.getLogger() .warn("awt event spend time more than 20ms, totalTime {} continuationTime {} the stack is {}" @@ -99,26 +103,8 @@ public final class EventDispatchDeveloperMode extends EventQueue { */ public void initTimer() { final long initialDelayMs = 0; - final boolean daemon = true; - timer = new Timer("EventDispatchDeveloperMode", daemon); - timer.schedule(new HangChecker(), initialDelayMs, CHECK_INTERVAL_MS); - } - - /** - * /消除Timer - */ - public void stopTimer() { - if (timer != null) { - timer.cancel(); - } - } - - /** - * /定时执行的任务 - */ - public class HangChecker extends TimerTask { - @Override - public void run() { + timer = FineExecutors.newScheduledThreadPool(CORE_THREAD_SIZE); + timer.schedule(() -> { synchronized (dispatches) { //如果链表为空定时检测就不进行 if (dispatches.isEmpty()) { @@ -126,6 +112,15 @@ public final class EventDispatchDeveloperMode extends EventQueue { } dispatches.getLast().checkForHang(); } + }, initialDelayMs, TimeUnit.MILLISECONDS); + } + + /** + * /消除Timer + */ + public void stopTimer() { + if (timer != null) { + timer.shutdown(); } } diff --git a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java index 188aedacb9..cd1fcb3dd0 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java @@ -7,6 +7,7 @@ import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.ui.util.UIUtil; import com.fr.design.worker.WorkerManager; +import com.fr.design.worker.save.type.SaveTypeWorker; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -87,26 +88,24 @@ public class SaveWorker extends SwingWorker { this.execute(); // worker纳入管理 WorkerManager.getInstance().registerWorker(taskName, this); - if (!slowly) { - new Thread(() -> { - while (true) { - if (stopWatch.getTime() > TIME_OUT || isDone()) { - if (!isDone()) { - slowly = true; - UIUtil.invokeLaterIfNeeded(() -> { - // 开始禁用 - if (slowly) { - EastRegionContainerPane.getInstance().updateAllPropertyPane(); - DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover(); - DesignerFrameFileDealerPane.getInstance().stateChange(); - } - }); - } - stopWatch.stop(); - break; + SaveTypeWorker.saveTypePool.execute(() -> { + while (true) { + if (stopWatch.getTime() > TIME_OUT || isDone()) { + if (!isDone()) { + slowly = true; + UIUtil.invokeLaterIfNeeded(() -> { + // 开始禁用 + if (slowly) { + EastRegionContainerPane.getInstance().updateAllPropertyPane(); + DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover(); + DesignerFrameFileDealerPane.getInstance().stateChange(); + } + }); } + stopWatch.stop(); + break; } - }).start(); - } + } + }); } } diff --git a/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java index e087f701f7..b004dea7d2 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java @@ -1,6 +1,7 @@ package com.fr.design.worker.save.type; +import com.fr.concurrent.FineExecutors; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.EastRegionContainerPane; @@ -10,6 +11,7 @@ import com.fr.third.org.apache.commons.lang3.time.StopWatch; import javax.swing.SwingWorker; import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; /** * 判断保存类别时执行的worker @@ -20,6 +22,8 @@ import java.util.concurrent.Callable; */ public class SaveTypeWorker extends SwingWorker { + public static final ExecutorService saveTypePool = FineExecutors.newSingleThreadExecutor(); + private final Callable callable; private static final int TIME_OUT = 400; @@ -28,6 +32,8 @@ public class SaveTypeWorker extends SwingWorker { private final SaveType saveType; + + public SaveTypeWorker(Callable callable, JTemplate template) { this.callable = callable; this.template = template; @@ -52,7 +58,7 @@ public class SaveTypeWorker extends SwingWorker { StopWatch stopWatch = StopWatch.createStarted(); this.template.setSaving(true); this.execute(); - new Thread(() -> { + saveTypePool.execute(() -> { while (true) { //大于最大等待时间或者worker已经完成该线程都要结束循环 if (stopWatch.getTime() > TIME_OUT || isDone()) { @@ -70,6 +76,6 @@ public class SaveTypeWorker extends SwingWorker { break; } } - }).start(); + }); } } From e1c6e99c1b7fbf674b5d208276c5cdbe7a914588 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 14 Apr 2023 15:09:14 +0800 Subject: [PATCH 15/59] =?UTF-8?q?fix=EF=BC=9A=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/file/MultiTemplateTabPane.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 01e45816eb..3078c54d1e 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -668,14 +668,14 @@ public class MultiTemplateTabPane extends JComponent { private boolean isOverCloseIcon(int evtX) { - boolean isOverCloseIcon = false; + boolean overCloseIcon = false; for (int i = 0; i < startX.length; i++) { if (evtX >= startX[i] && evtX <= startX[i] + CLOSE.getIconWidth()) { - isOverCloseIcon = true; + overCloseIcon = true; break; } } - return isOverCloseIcon; + return overCloseIcon; } From e2c4db30a80b8686c87b9ee7b151bf6456f21a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Fri, 14 Apr 2023 15:10:03 +0800 Subject: [PATCH 16/59] =?UTF-8?q?REPORT-83195=20=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E7=82=B9=E4=BC=98=E5=8C=96-=E6=A0=B9=E6=8D=AE=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8F=90=E7=A4=BA=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/carton/developer/EventDispatchDeveloperMode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java b/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java index a87e900ac1..5381ff7ff2 100644 --- a/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java +++ b/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java @@ -34,7 +34,7 @@ public final class EventDispatchDeveloperMode extends EventQueue { */ public static final long CHECK_INTERVAL_MS = 5; - private static final int CORE_THREAD_SIZE = 5; + private static final int CORE_THREAD_SIZE = 1; private ScheduledExecutorService timer; From 135f588ff103020ae0f75b28ff8bcdedd714c1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Fri, 14 Apr 2023 15:15:38 +0800 Subject: [PATCH 17/59] =?UTF-8?q?REPORT-83195=20=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E7=82=B9=E4=BC=98=E5=8C=96-=E6=A0=B9=E6=8D=AE=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8F=90=E7=A4=BA=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/carton/SwitchForSwingChecker.java | 5 +++-- .../src/main/java/com/fr/design/worker/save/SaveWorker.java | 2 +- .../java/com/fr/design/worker/save/type/SaveTypeWorker.java | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java b/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java index 837bdb1c8b..2f884bc301 100644 --- a/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java +++ b/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java @@ -58,6 +58,7 @@ public class SwitchForSwingChecker implements XMLReadable, XMLWriter { * 简单记录事件执行时间的开关 */ private static boolean easyChecker = false; + /** * 一个标识位用于区分耗时任务时长检测(简单检测)和timer检测 */ @@ -331,7 +332,7 @@ public class SwitchForSwingChecker implements XMLReadable, XMLWriter { MAIN(NORMAL_MAIN_CLASS_NAME) { @Override void initEventQueue() { - if (StringUtils.equals("true", System.getProperty(CARTON_DEVELOPER_JVM_PARAM))) { + if (StringUtils.equals(TURE_JVM, System.getProperty(CARTON_DEVELOPER_JVM_PARAM))) { EventDispatchDeveloperMode.INSTANCE.initMonitoring(); } else { EventDispatchThreadHangMonitor.initMonitoring(); @@ -353,7 +354,7 @@ public class SwitchForSwingChecker implements XMLReadable, XMLWriter { MainClassType(String classPath) { this.classPath = classPath; } - + public static final String TURE_JVM = "true"; String classPath; /** diff --git a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java index cd1fcb3dd0..83b7c50d49 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java @@ -88,7 +88,7 @@ public class SaveWorker extends SwingWorker { this.execute(); // worker纳入管理 WorkerManager.getInstance().registerWorker(taskName, this); - SaveTypeWorker.saveTypePool.execute(() -> { + SaveTypeWorker.SAVE_TYPE_POOL.execute(() -> { while (true) { if (stopWatch.getTime() > TIME_OUT || isDone()) { if (!isDone()) { diff --git a/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java index b004dea7d2..d415537eb4 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/type/SaveTypeWorker.java @@ -22,7 +22,7 @@ import java.util.concurrent.ExecutorService; */ public class SaveTypeWorker extends SwingWorker { - public static final ExecutorService saveTypePool = FineExecutors.newSingleThreadExecutor(); + public static final ExecutorService SAVE_TYPE_POOL = FineExecutors.newSingleThreadExecutor(); private final Callable callable; @@ -58,7 +58,7 @@ public class SaveTypeWorker extends SwingWorker { StopWatch stopWatch = StopWatch.createStarted(); this.template.setSaving(true); this.execute(); - saveTypePool.execute(() -> { + SAVE_TYPE_POOL.execute(() -> { while (true) { //大于最大等待时间或者worker已经完成该线程都要结束循环 if (stopWatch.getTime() > TIME_OUT || isDone()) { From b1486e5031b001c6334a7c04325d1121355c6f8b Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 14 Apr 2023 15:50:10 +0800 Subject: [PATCH 18/59] =?UTF-8?q?fix=EF=BC=9A=E4=BB=A3=E7=A0=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/file/impl/EmptyTemplateTabOperator.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java index 3f4ef4d99f..9951157fde 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java @@ -116,4 +116,9 @@ public class EmptyTemplateTabOperator implements TemplateTabOperateProvider { public String getTemplateShowName(JTemplate jTemplate) { return StringUtils.EMPTY; } + + @Override + public void activePrevTemplateAfterClose() { + + } } From 5155311b6e203d96432a8db4019fd75b05b6bd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Fri, 14 Apr 2023 16:04:58 +0800 Subject: [PATCH 19/59] =?UTF-8?q?REPORT-83195=20=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E7=82=B9=E4=BC=98=E5=8C=96-=E5=9B=9E=E9=80=80=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E5=BC=80=E5=8F=91=E8=80=85=E6=A8=A1=E5=BC=8F=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81=EF=BC=8C=E8=AE=BE=E8=AE=A1=E6=9C=89?= =?UTF-8?q?=E7=82=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/carton/SwitchForSwingChecker.java | 75 +--------- .../design/carton/developer/AwtEventInfo.java | 73 --------- .../developer/EventDispatchDeveloperMode.java | 141 ------------------ 3 files changed, 5 insertions(+), 284 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/carton/developer/AwtEventInfo.java delete mode 100644 designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java diff --git a/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java b/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java index 2f884bc301..683179293e 100644 --- a/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java +++ b/designer-base/src/main/java/com/fr/design/carton/SwitchForSwingChecker.java @@ -1,7 +1,6 @@ package com.fr.design.carton; -import com.fr.design.carton.developer.EventDispatchDeveloperMode; import com.fr.design.i18n.Toolkit; import com.fr.general.GeneralUtils; import com.fr.json.JSON; @@ -30,22 +29,11 @@ import java.util.Map; import java.util.Date; import java.util.Calendar; - public class SwitchForSwingChecker implements XMLReadable, XMLWriter { /** * Designer4Debug类名 */ private static final String DEBUG_MAIN_CLASS_NAME = "com.fr.start.Designer4Debug"; - - /** - * 真正主类 - */ - private static final String NORMAL_MAIN_CLASS_NAME = "com.fr.start.MainDesigner"; - - /** - * 开发者模式jvm参数 - */ - private static final String CARTON_DEVELOPER_JVM_PARAM = "cartonDeveloper"; /** * XML标签 */ @@ -58,7 +46,6 @@ public class SwitchForSwingChecker implements XMLReadable, XMLWriter { * 简单记录事件执行时间的开关 */ private static boolean easyChecker = false; - /** * 一个标识位用于区分耗时任务时长检测(简单检测)和timer检测 */ @@ -262,7 +249,11 @@ public class SwitchForSwingChecker implements XMLReadable, XMLWriter { */ public static void initThreadMonitoring () { String mainClass = System.getProperty("sun.java.command"); - MainClassType.getMainClassType(mainClass).initEventQueue(); + //判断一下,如果是以Designer4Debug启动,就不注册代码,不然会覆盖掉SwingExplorer,导致其无法使用 + if (!StringUtils.equals(mainClass, DEBUG_MAIN_CLASS_NAME)) { + EventDispatchThreadHangMonitor.initMonitoring(); + AppContext.getAppContext().put(SwingWorker.class, CartonThreadExecutorPool.getTimerThreadExecutorPool()); + } } /** @@ -318,60 +309,4 @@ public class SwitchForSwingChecker implements XMLReadable, XMLWriter { writer.end(); } - /** - * 根据程序启动类路径进行区分 - * - * @author John.Ying - * @since 11.0 - * Created on 2023/4/14 - */ - enum MainClassType { - /** - * 用mainDesigner启动 - */ - MAIN(NORMAL_MAIN_CLASS_NAME) { - @Override - void initEventQueue() { - if (StringUtils.equals(TURE_JVM, System.getProperty(CARTON_DEVELOPER_JVM_PARAM))) { - EventDispatchDeveloperMode.INSTANCE.initMonitoring(); - } else { - EventDispatchThreadHangMonitor.initMonitoring(); - AppContext.getAppContext().put(SwingWorker.class, CartonThreadExecutorPool.getTimerThreadExecutorPool()); - } - } - }, - - /** - * designer4debug启动 - */ - DEBUG_MAIN(DEBUG_MAIN_CLASS_NAME) { - @Override - void initEventQueue() { - - } - }; - - MainClassType(String classPath) { - this.classPath = classPath; - } - public static final String TURE_JVM = "true"; - String classPath; - - /** - * 初始化重写的EDT - */ - abstract void initEventQueue(); - - /** - * @param classPath 启动类路径 - */ - static MainClassType getMainClassType(String classPath) { - for (MainClassType mainClassType : MainClassType.values()) { - if (StringUtils.equals(classPath, mainClassType.classPath)) { - return mainClassType; - } - } - return MAIN; - } - } } diff --git a/designer-base/src/main/java/com/fr/design/carton/developer/AwtEventInfo.java b/designer-base/src/main/java/com/fr/design/carton/developer/AwtEventInfo.java deleted file mode 100644 index 77274a36ab..0000000000 --- a/designer-base/src/main/java/com/fr/design/carton/developer/AwtEventInfo.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.fr.design.carton.developer; - -import java.awt.AWTEvent; - -/** - * EDT事件的包装类,用来额外处理信息 - * - * @author John.Ying - * @since 11.0 - * Created on 2023/4/14 - */ -public class AwtEventInfo { - //获取执行该事件的线程 - private final Thread eventDispatchThread = Thread.currentThread(); - //在队列中等待执行的事件最后未执行的时间,当有一个事件执行完后就遍历dispatches给该值赋当前时间 - private long lastDispatchTimeMillis = System.currentTimeMillis(); - //事件开始的时间 - private final long startDispatchTimeMillis = System.currentTimeMillis(); - //awt事件 - private AWTEvent awtEvent; - //事件堆栈 - private StackTraceElement[] stackTrace; - - /** - * 检查是否要给堆栈赋值 - */ - public void checkForHang() { - if (isNeedToStackTrace()) { - this.stackTrace = eventDispatchThread.getStackTrace(); - } - } - - /** - * 是否需要赋值堆栈满足 - * 耗时>20ms - */ - private boolean isNeedToStackTrace() { - return (System.currentTimeMillis() - startDispatchTimeMillis) > EventDispatchDeveloperMode.MAX_TIME - && stackTrace == null; - } - - public Thread getEventDispatchThread() { - return eventDispatchThread; - } - - public long getLastDispatchTimeMillis() { - return lastDispatchTimeMillis; - } - - public void setLastDispatchTimeMillis(long lastDispatchTimeMillis) { - this.lastDispatchTimeMillis = lastDispatchTimeMillis; - } - - public long getStartDispatchTimeMillis() { - return startDispatchTimeMillis; - } - - public AWTEvent getAwtEvent() { - return awtEvent; - } - - public void setAwtEvent(AWTEvent awtEvent) { - this.awtEvent = awtEvent; - } - - public StackTraceElement[] getStackTrace() { - return stackTrace; - } - - public void setStackTrace(StackTraceElement[] stackTrace) { - this.stackTrace = stackTrace; - } -} diff --git a/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java b/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java deleted file mode 100644 index 5381ff7ff2..0000000000 --- a/designer-base/src/main/java/com/fr/design/carton/developer/EventDispatchDeveloperMode.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.fr.design.carton.developer; - - -import com.aspose.words.Run; -import com.fr.concurrent.FineExecutors; -import com.fr.design.carton.EventDispatchThreadHangMonitor; -import com.fr.design.ui.util.UIUtil; -import com.fr.log.FineLoggerFactory; - -import java.awt.AWTEvent; -import java.awt.EventQueue; -import java.awt.Toolkit; -import java.util.LinkedList; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -/** - * 开发者模式重写的EDT - * - * @author John.Ying - * @since 11.0 - * Created on 2023/4/14 - */ -public final class EventDispatchDeveloperMode extends EventQueue { - - /** - * 该链表为主要的实现定时任务的容器,在重写的dispatchEvent中由pre方法将DispatchInfo加入到链表,由post方法remove - */ - private final LinkedList dispatches = new LinkedList<>(); - /** - * 开启间隔检测后两次检测的相隔时间ms - */ - public static final long CHECK_INTERVAL_MS = 5; - - private static final int CORE_THREAD_SIZE = 1; - - private ScheduledExecutorService timer; - - /** - * edt事件最大允许的时间 - */ - public static final long MAX_TIME = 20; - public static final EventDispatchDeveloperMode INSTANCE = new EventDispatchDeveloperMode(); - - @Override - protected void dispatchEvent(AWTEvent event) { - try { - preDispatchEvent(event); - super.dispatchEvent(event); - } finally { - postDispatchEvent(); - } - } - - /** - * 事件分发前处理 - */ - private synchronized void preDispatchEvent(AWTEvent event) { - synchronized (dispatches) { - AwtEventInfo awtEventInfo = new AwtEventInfo(); - awtEventInfo.setAwtEvent(event); - dispatches.addLast(awtEventInfo); - } - } - - /** - * 事件分发后处理 - */ - private synchronized void postDispatchEvent() { - synchronized (dispatches) { - AwtEventInfo awtEventInfo = dispatches.removeLast(); - //嵌套最深的事件执行完毕后刷新链表中其他事件的lastDispatchTimeMillis - Thread currentEventDispatchThread = Thread.currentThread(); - for (AwtEventInfo info : dispatches) { - info.setLastDispatchTimeMillis(System.currentTimeMillis()); - } - long nowTime = System.currentTimeMillis(); - long totalTime = nowTime - awtEventInfo.getStartDispatchTimeMillis(); - long continuationTime = nowTime - awtEventInfo.getLastDispatchTimeMillis(); - //判断连续执行时间是否超过了20ms,超过了则进行提示 - if (continuationTime > MAX_TIME) { - FineLoggerFactory.getLogger() - .warn("awt event spend time more than 20ms, totalTime {} continuationTime {} the stack is {}" - , totalTime, continuationTime, EventDispatchThreadHangMonitor.stackTraceToStringForConsole(awtEventInfo.getStackTrace())); - } - } - } - - /** - * 将swing中默认的EventQueue换成自己的 - */ - public void initMonitoring() { - UIUtil.invokeLaterIfNeeded(() -> Toolkit.getDefaultToolkit().getSystemEventQueue().push(INSTANCE)); - initTimer(); - startFilterModalWindow(); - } - - /** - * Sets up a timer to check for hangs frequently. - * 初始化一个Timer - */ - public void initTimer() { - final long initialDelayMs = 0; - timer = FineExecutors.newScheduledThreadPool(CORE_THREAD_SIZE); - timer.schedule(() -> { - synchronized (dispatches) { - //如果链表为空定时检测就不进行 - if (dispatches.isEmpty()) { - return; - } - dispatches.getLast().checkForHang(); - } - }, initialDelayMs, TimeUnit.MILLISECONDS); - } - - /** - * /消除Timer - */ - public void stopTimer() { - if (timer != null) { - timer.shutdown(); - } - } - - /** - * 消除模态框影响 - */ - public void startFilterModalWindow() { - ScheduledExecutorService scheduledExecutorService = FineExecutors.newSingleThreadScheduledExecutor(); - scheduledExecutorService.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - UIUtil.invokeLaterIfNeeded(() -> { - //不用干事,切个片就可以 - }); - } - }, 0, 10, TimeUnit.MILLISECONDS); - } -} From 5ea46e516d6a1f8fa6643cb542241be882f4ddf7 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 14 Apr 2023 16:28:08 +0800 Subject: [PATCH 20/59] =?UTF-8?q?fix=EF=BC=9A=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/file/MultiTemplateTabMenuFactory.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java index edbe9cbab3..3ba3fe79eb 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.Map; /** + * 右侧下拉菜单的工厂类 * @author Carlson * @since 11.0 * created on 2023-04-14 From 16259563b3f8da9b3d107c17bff763b77d9101f0 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 14 Apr 2023 16:50:47 +0800 Subject: [PATCH 21/59] =?UTF-8?q?fix=EF=BC=9A=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/file/MultiTemplateTabPane.java | 2 +- .../src/main/java/com/fr/design/mainframe/JTemplate.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 3078c54d1e..0292bb8f95 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -56,7 +56,7 @@ import java.util.List; /** * 改个名字,一个拼写 n 个错误 - * + * 模板tab的操作和ui已拆分,后续需要添加模板tab的操作在 TemplateTabManager 中添加 * @author daisy * @version 11.0 *

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 dbf63e077c..cb2831fc33 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 @@ -616,7 +616,7 @@ public abstract class JTemplate> * @return 是则返回true */ public boolean isALLSaved() { - return this.saved && this.authoritySaved && this.canBeSaved(); + return this.canBeSaved() && this.saved && this.authoritySaved; } From 6584f614a4e46d66f39278c593fedaf451a545ac Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 14 Apr 2023 17:05:18 +0800 Subject: [PATCH 22/59] =?UTF-8?q?=E6=94=B9=E4=B8=8B=E7=B1=BB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/file/TemplateTabManager.java | 4 ++-- ...plateTabOperator.java => EmptyTemplateTabOperate.java} | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) rename designer-base/src/main/java/com/fr/design/file/impl/{EmptyTemplateTabOperator.java => EmptyTemplateTabOperate.java} (87%) diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java index 499706f523..fe294f222f 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java @@ -2,7 +2,7 @@ package com.fr.design.file; import com.finebi.cbb.utils.CompareUtils; import com.fr.design.file.impl.DefaultTemplateTabOperate; -import com.fr.design.file.impl.EmptyTemplateTabOperator; +import com.fr.design.file.impl.EmptyTemplateTabOperate; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.file.FILE; @@ -285,7 +285,7 @@ public class TemplateTabManager { return provider; } } - return EmptyTemplateTabOperator.getInstance(); + return EmptyTemplateTabOperate.getInstance(); } } diff --git a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperate.java similarity index 87% rename from designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java rename to designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperate.java index 9951157fde..c35a4bf655 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperate.java @@ -15,13 +15,13 @@ import java.util.List; * @since 11.0 * created on 2023-04-14 **/ -public class EmptyTemplateTabOperator implements TemplateTabOperateProvider { +public class EmptyTemplateTabOperate implements TemplateTabOperateProvider { private static class Holder { - private static final EmptyTemplateTabOperator SINGLETON = new EmptyTemplateTabOperator(); + private static final EmptyTemplateTabOperate SINGLETON = new EmptyTemplateTabOperate(); } - private EmptyTemplateTabOperator() { + private EmptyTemplateTabOperate() { } @@ -29,7 +29,7 @@ public class EmptyTemplateTabOperator implements TemplateTabOperateProvider { * 返回空的模板taboperator单例 * @return */ - public static EmptyTemplateTabOperator getInstance() { + public static EmptyTemplateTabOperate getInstance() { return Holder.SINGLETON; } From 2fd647f030254ba91ad79b14edb253219c204bbc Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 14 Apr 2023 17:26:45 +0800 Subject: [PATCH 23/59] =?UTF-8?q?REPORT-91074=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JSContentWithDescriptionPane.java | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java index e2a8dd0d5c..c42e3b80d4 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java @@ -18,7 +18,6 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.javascript.jsapi.JSAPITreeHelper; import com.fr.design.javascript.jsapi.JSAPIUserObject; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; @@ -26,6 +25,26 @@ import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.SwingWorker; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -51,25 +70,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.concurrent.ExecutionException; -import javax.swing.BorderFactory; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.JComponent; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTree; -import javax.swing.SwingWorker; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; public class JSContentWithDescriptionPane extends JSContentPane implements KeyListener { @@ -119,6 +119,15 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi private static final String RELOAD_CARD = "reloadCard"; private static final String DOC_LIST_CARD = "docListCard"; + /** + * 云中心Js高级编辑器帮助链接前缀在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Js_Editor"; + + /** + * 云中心Js高级编辑器帮助链接前缀在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Js_Editor_Default"; public JSContentWithDescriptionPane(String[] args) { this.setLayout(new BorderLayout()); //=============================== @@ -381,7 +390,7 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi } private void updateHelpDocuments(Object value, List helpDocuments) { - String url = CloudCenter.getInstance().acquireUrlByKind("af.doc_search", DOCUMENT_SEARCH_URL) + value.toString(); + String url = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); try { String result = HttpToolbox.get(url); JSONObject jsonObject = new JSONObject(result); From 69f2982c2bdd19c69e3d2285016b8666cb02a0ca Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 14 Apr 2023 17:31:14 +0800 Subject: [PATCH 24/59] =?UTF-8?q?REPORT-91074=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/javascript/JSContentWithDescriptionPane.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java index c42e3b80d4..3b8d04ffb3 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java @@ -14,6 +14,7 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextfield.PlaceholderTextField; +import com.fr.design.i18n.LocaleLinkProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.javascript.jsapi.JSAPITreeHelper; import com.fr.design.javascript.jsapi.JSAPIUserObject; From 817eed5c799360a1aaac93b69b2c0df58725187e Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 17 Apr 2023 18:48:58 +0800 Subject: [PATCH 25/59] =?UTF-8?q?REPORT-75308=20FVS=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=94=AF=E6=8C=81=E5=90=8C=E6=97=B6=E6=89=93?= =?UTF-8?q?=E5=BC=80=E5=A4=9A=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/SwitchExistEnv.java | 2 +- .../fr/design/file/SaveSomeTemplatePane.java | 19 ++++----------- .../file/impl/AbstractTemplateTabOperate.java | 24 ++++++++++++++----- .../com/fr/design/mainframe/JTemplate.java | 8 +++++++ 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java index e38a39895a..33761a92e2 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java @@ -68,7 +68,7 @@ public class SwitchExistEnv extends MenuDef { EnvChangeEntrance.getInstance().chooseEnv(envName); } else { SaveSomeTemplatePane saveSomeTemplatePane = new SaveSomeTemplatePane(true); - if (saveSomeTemplatePane.showSavePane(true)) { + if (saveSomeTemplatePane.showSavePane()) { // 用户模板保存后,才进行切换目录操作 EnvChangeEntrance.getInstance().switch2Env(envName); } diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index c83c5ca800..23dfe83a57 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -84,6 +84,7 @@ public class SaveSomeTemplatePane extends BasicPane { for (int i = 0; i < unSavedTemplate.size(); i++) { templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); templateCheckBoxes[i].setSelected(true); + templateCheckBoxes[i].setEnabled(!unSavedTemplate.get(i).mustSaveBeforeSwitchEnv()); } final UIList templatesList = new UIList(templateCheckBoxes); @@ -103,7 +104,9 @@ public class SaveSomeTemplatePane extends BasicPane { boolean isSelected = chooseAllCheckBox.isSelected(); for (int i = 0; i < templatesList.getModel().getSize(); i++) { UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); - checkBox.setSelected(isSelected); + boolean mustSaveBeforeSwitchEnv = unSavedTemplate.get(i).mustSaveBeforeSwitchEnv(); + checkBox.setSelected(mustSaveBeforeSwitchEnv || isSelected); + templateCheckBoxes[i].setEnabled(!mustSaveBeforeSwitchEnv); } templatesList.repaint(); } @@ -150,24 +153,12 @@ public class SaveSomeTemplatePane extends BasicPane { return count; } - /** * 显示未保存弹窗 * @return */ public boolean showSavePane() { - return showSavePane(false); - } - - /** - * 显示未保存弹窗 - * @param switchEnv - * @return - */ - public boolean showSavePane(boolean switchEnv) { - return switchEnv ? - showSavePane(DefaultTemplateTabOperate.getInstance().getOpenedJTemplates()) : - showSavePane(HistoryTemplateListPane.getInstance().getHistoryList()); + return showSavePane(HistoryTemplateListPane.getInstance().getHistoryList()); } /** diff --git a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java index 3f67fb69b2..75319d7e70 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java @@ -45,7 +45,7 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr //用于存放工作簿 private java.util.List> openedTemplate = new ArrayList<>(); //选中的Tab项 - private int selectedIndex = -1; + private int selectedIndex = 0; public AbstractTemplateTabOperate() { @@ -257,9 +257,10 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr } private void closeTpl(@Nonnull JTemplate specifiedTemplate) { + JTemplate currentSelectedFile = getSelectedFile(); HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); closeAndFreeLock(specifiedTemplate); - activePrevTemplateAfterClose(specifiedTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); + activePrevTemplateAfterClose(specifiedTemplate == currentSelectedFile, currentSelectedFile); } /** @@ -270,12 +271,24 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr activePrevTemplateAfterClose(TemplateTabManager.getInstance().isCloseCurrent()); } + /** * 关闭掉一个模板之后激活新的待显示模板 */ public void activePrevTemplateAfterClose(boolean isCurrentSelectedTpl) { + activePrevTemplateAfterClose(isCurrentSelectedTpl, HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); + } + + /** + * 关闭掉一个模板之后激活新的待显示模板 + */ + public void activePrevTemplateAfterClose(boolean isCurrentSelectedTpl, JTemplate currentSelectedJTemplate) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + boolean couldSwitch = template != null && this.accept(template.getTemplateTabOperatorType()); if (openedTemplate.isEmpty()) { - TemplateTabManager.getInstance().activeNewTemplate(); + if (couldSwitch){ + TemplateTabManager.getInstance().activeNewTemplate(); + } selectedIndex = 0; } else { // 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板; @@ -290,10 +303,9 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr } // 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index else { - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - selectedIndex = this.openedTemplate.indexOf(template); + selectedIndex = this.openedTemplate.indexOf(currentSelectedJTemplate); } - if (selectedIndex < openedTemplate.size()) { + if ( selectedIndex < openedTemplate.size() && couldSwitch) { //如果是已后台关闭的模板,则重新打开文件 openedTemplate.get(selectedIndex).activeOldJTemplate(); } 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 3ede09d5ec..a92d59d072 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 @@ -2082,4 +2082,12 @@ public abstract class JTemplate> public boolean supportCache(){ return true; } + + /** + * 切换环境之前是否一定要保存 + * @return + */ + public boolean mustSaveBeforeSwitchEnv(){ + return false; + } } From cb75658d64b6b329175f601404ee57beacbed867 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 18 Apr 2023 10:03:55 +0800 Subject: [PATCH 26/59] =?UTF-8?q?fix=EF=BC=9A=E5=85=88=E6=94=B9=E5=9B=9E?= =?UTF-8?q?=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/file/impl/AbstractTemplateTabOperate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java index 75319d7e70..6406c1d46b 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java @@ -45,7 +45,7 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr //用于存放工作簿 private java.util.List> openedTemplate = new ArrayList<>(); //选中的Tab项 - private int selectedIndex = 0; + private int selectedIndex = -1; public AbstractTemplateTabOperate() { From cb2f63f31d52b38ccd56365827b4e5acfb5f4a8c Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 18 Apr 2023 17:30:53 +0800 Subject: [PATCH 27/59] =?UTF-8?q?REPORT-75308=20=20=E6=96=B9=E6=A1=88?= =?UTF-8?q?=E5=9B=9E=E9=80=80=EF=BC=8C=E4=BD=BF=E7=94=A8=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../file/CloseCurrentTemplateAction.java | 8 +- .../fr/design/actions/file/RenameAction.java | 4 +- .../java/com/fr/design/file/CloseOption.java | 68 --- .../design/file/HistoryTemplateListCache.java | 41 +- .../file/MultiTemplateTabMenuFactory.java | 351 ----------- .../fr/design/file/MultiTemplateTabPane.java | 576 ++++++++++++++---- .../fr/design/file/MutilTempalteTabPane.java | 6 +- .../com/fr/design/file/NewTemplatePane.java | 6 +- .../fr/design/file/SaveSomeTemplatePane.java | 34 +- .../fr/design/file/TemplateTabManager.java | 291 --------- .../file/TemplateTabOperateProvider.java | 129 ---- .../file/impl/AbstractTemplateTabOperate.java | 376 ------------ .../file/impl/DefaultTemplateTabOperate.java | 41 -- .../file/impl/EmptyTemplateTabOperate.java | 124 ---- .../fr/design/mainframe/DesignerFrame.java | 4 +- .../DesignerFrameFileDealerPane.java | 10 +- .../com/fr/design/mainframe/JTemplate.java | 32 +- .../mainframe/toolbar/ToolBarMenuDock.java | 4 +- .../vcs/ui/FileVersionCellEditor.java | 8 +- .../mainframe/vcs/ui/FileVersionsPanel.java | 8 +- .../com/fr/design/worker/open/OpenWorker.java | 4 +- .../designer/toolbar/TemplateTransformer.java | 8 +- .../main/java/com/fr/start/BaseDesigner.java | 6 +- .../start/common/DesignerOpenEmptyPanel.java | 4 +- .../fr/design/fit/common/TemplateTool.java | 4 +- .../fr/design/preview/DeveloperPreview.java | 5 +- .../com/fr/design/mainframe/JWorkBook.java | 4 +- .../main/java/com/fr/start/MainDesigner.java | 4 +- 28 files changed, 547 insertions(+), 1613 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/file/CloseOption.java delete mode 100644 designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java delete mode 100644 designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java delete mode 100644 designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java delete mode 100644 designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java delete mode 100644 designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java delete mode 100644 designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperate.java diff --git a/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java b/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java index b2ab237d7d..22263a871e 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java @@ -3,7 +3,7 @@ package com.fr.design.actions.file; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; @@ -28,9 +28,9 @@ public class CloseCurrentTemplateAction extends UpdateAction { * @param e 事件 */ public void actionPerformed(ActionEvent e) { - TemplateTabManager.getInstance().setCloseCurrent(true); - TemplateTabManager.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - TemplateTabManager.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); + MultiTemplateTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } @Override diff --git a/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java b/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java index 33f51b77aa..842292ce2a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java @@ -7,7 +7,7 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.FileOperations; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; @@ -88,7 +88,7 @@ public class RenameAction extends UpdateAction { } new FileRenameDialog(node); - TemplateTabManager.getInstance().refresh(); + MultiTemplateTabPane.getInstance().repaint(); DesignerFrameFileDealerPane.getInstance().stateChange(); } diff --git a/designer-base/src/main/java/com/fr/design/file/CloseOption.java b/designer-base/src/main/java/com/fr/design/file/CloseOption.java deleted file mode 100644 index ecb70d6a5f..0000000000 --- a/designer-base/src/main/java/com/fr/design/file/CloseOption.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.fr.design.file; - -import com.fr.design.i18n.Toolkit; - -/** - * @author kerry - * @since 11.0 - * created on 2023-04-14 - **/ -public enum CloseOption { - - /** - * 关闭左侧所有模板 - */ - Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { - @Override - public boolean shouldClose(int tplIndex, int i) { - return i < tplIndex; - } - }, - - /** - * 关闭右侧所有模板 - */ - Right(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Right")) { - @Override - public boolean shouldClose(int tplIndex, int i) { - return i > tplIndex; - } - }, - - /** - * 关闭所有模板 - */ - All(Toolkit.i18nText("Fine-Design_Close_All_templates")), - - /** - * 关闭其他模板 - */ - Others(Toolkit.i18nText("Fine-Design_Close_Other_templates")) { - @Override - public boolean shouldClose(int tplIndex, int i) { - return i != tplIndex; - } - }; - - - private String optionName; - - public String getOptionName() { - return this.optionName; - } - - CloseOption(String optionName) { - this.optionName = optionName; - } - - /** - * 判断指定索引模板是否应该被关闭 - * @param tplIndex - * @param i - * @return - */ - public boolean shouldClose(int tplIndex, int i) { - return true; - } - -} \ No newline at end of file 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 083aa2ed08..86820aa227 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 @@ -75,7 +75,7 @@ public class HistoryTemplateListCache implements CallbackEvent { historyList.remove(contains(selected)); selected.getEditingFILE().closeTemplate(); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName())); - TemplateTabManager.getInstance().refreshOpenedTemplate(historyList); + MultiTemplateTabPane.getInstance().refreshOpenedTemplate(historyList); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -134,10 +134,10 @@ public class HistoryTemplateListCache implements CallbackEvent { if (contains(jt) == -1) { addHistory(); } - TemplateTabManager.getInstance().refreshOpenedTemplate(historyList); + MultiTemplateTabPane.getInstance().refreshOpenedTemplate(historyList); //设置tab栏为当前选中的那一栏 if (editingTemplate != null) { - TemplateTabManager.getInstance().resetSelectIndex(jt); + MultiTemplateTabPane.getInstance().setSelectedIndex(contains(jt)); } } @@ -268,14 +268,13 @@ public class HistoryTemplateListCache implements CallbackEvent { boolean replaceWithJVirtualTemplate = overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate - && overTemplate.checkEnable() - && overTemplate.supportCache(); + && overTemplate.checkEnable(); if (replaceWithJVirtualTemplate) { closeVirtualSelectedReport(overTemplate); historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE())); } } - TemplateTabManager.getInstance().refreshOpenedTemplate(historyList); + MultiTemplateTabPane.getInstance().refreshOpenedTemplate(historyList); } @@ -286,27 +285,35 @@ public class HistoryTemplateListCache implements CallbackEvent { // path like reportlets/xx/xxx/xxx String path = file.getPath() + suffix; - List list = new ArrayList(); - for(JTemplate jTemplate : historyList){ - list.add(jTemplate); - } - ListIterator> iterator = list.listIterator(); + + ListIterator> iterator = historyList.listIterator(); + while (iterator.hasNext()) { JTemplate template = iterator.next(); String tPath = template.getPath(); if (isDir ? tPath.startsWith(path) : tPath.equals(path)) { - historyList.remove(template); - TemplateTabManager.getInstance().deleteOpenedTemplate(template); + int size = getHistoryCount(); + iterator.remove(); + int index = iterator.nextIndex(); + if (size == index + 1 && index > 0) { + //如果删除的是后一个Tab,则定位到前一个 + MultiTemplateTabPane.getInstance().setSelectedIndex(index - 1); + } } } + //如果打开过,则删除,实时刷新多tab面板 + int openFileCount = getHistoryCount(); + if (openFileCount == 0) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + } - JTemplate selectedFile = TemplateTabManager.getInstance().getSelectedFile(); + JTemplate selectedFile = MultiTemplateTabPane.getInstance().getSelectedFile(); if (!isCurrentEditingFile(selectedFile.getPath())) { //如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样 DesignerContext.getDesignerFrame().activateJTemplate(selectedFile); } - TemplateTabManager.getInstance().refresh(); + MultiTemplateTabPane.getInstance().repaint(); } @@ -467,7 +474,7 @@ public class HistoryTemplateListCache implements CallbackEvent { int index = contains(this.editingTemplate); this.editingTemplate = jt; historyList.set(index, jt); - TemplateTabManager.getInstance().refreshOpenedTemplate(historyList); - TemplateTabManager.getInstance().resetSelectIndex(jt); + MultiTemplateTabPane.getInstance().refreshOpenedTemplate(historyList); + MultiTemplateTabPane.getInstance().setSelectedIndex(contains(jt)); } } diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java deleted file mode 100644 index 3ba3fe79eb..0000000000 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java +++ /dev/null @@ -1,351 +0,0 @@ -package com.fr.design.file; - -import com.fr.design.constants.UIConstants; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.imenu.UIMenuItem; -import com.fr.design.gui.imenu.UIScrollPopUpMenu; -import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.utils.TemplateUtils; -import com.fr.file.FILE; -import com.fr.general.IOUtils; -import com.fr.stable.StringUtils; -import com.fr.stable.collections.CollectionUtils; -import com.fr.third.javax.annotation.Nonnull; - -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JPanel; -import javax.swing.SwingConstants; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * 右侧下拉菜单的工厂类 - * @author Carlson - * @since 11.0 - * created on 2023-04-14 - **/ -public class MultiTemplateTabMenuFactory { - - private static final Icon CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png"); - private static final Icon MOUSE_OVER_CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/mouseoverclose icon.png"); - private static final Icon MOUSE_PRESS_CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/pressclose icon.png"); - - private static final int ITEM_SIZE = 25; - - private UIScrollPopUpMenu menu = null; - - private static MultiTemplateTabMenuFactory INSTANCE = new MultiTemplateTabMenuFactory(); - - private MultiTemplateTabMenuFactory() { - - } - - /** - * 返回右侧下拉菜单的工厂类 - * @return - */ - public static MultiTemplateTabMenuFactory getInstance() { - return INSTANCE; - } - - /** - * tab上的下拉菜单 - */ - public UIScrollPopUpMenu createMenu() { - menu = new UIScrollPopUpMenu(); - menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); - - menu.add(initCloseOther()); - menu.add(createEmptyRow()); - menu.addSeparator(); - menu.add(createEmptyRow()); - menu.add(createCategory(Toolkit.i18nText("Fine-Design_Basic_Tab_Current_Category_Templates"))); - Component[] items = createCurrentCategory(); - for (Component item : items) { - menu.add(item); - } - items = createOtherCategory(); - if (items.length > 0) { - menu.addSeparator(); - menu.add(createEmptyRow()); - menu.add(createCategory(Toolkit.i18nText("Fine-Design_Basic_Tab_Other_Category_Templates"))); - for (Component item : items) { - menu.add(item); - } - } - Dimension dimension = menu.getPreferredSize(); - dimension.width += ITEM_SIZE; - menu.setPreferredSize(dimension); - return menu; - } - - /** - * 关闭其它按钮 - */ - private UIMenuItem initCloseOther() { - UIMenuItem closeOther = new UIMenuItem(Toolkit.i18nText("Fine-Design_Basic_Tab_Close_Other_Templates_Of_Current_Category")); - closeOther.setHorizontalAlignment(SwingConstants.CENTER); - Dimension dimension = closeOther.getPreferredSize(); - dimension.height = ITEM_SIZE; - closeOther.setPreferredSize(dimension); - closeOther.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - TemplateTabManager.getInstance().closeOthers(); - } - - }); - if (TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size() <= 1) { - closeOther.setEnabled(false); - } - return closeOther; - } - - private void closeAndFreeLock(@Nonnull JTemplate template) { - FILE file = template.getEditingFILE(); - // 只有是环境内的文件,才执行释放锁 - if (file != null && file.isEnvFile()) { - // release lock - TemplateResourceManager.getResource().closeTemplate(file.getPath()); - } - } - - /** - * 美观用 - */ - private JPanel createEmptyRow() { - return new JPanel() { - @Override - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - d.height = 1; - return d; - } - }; - } - - /** - * 模板分类item - */ - private UIButton createCategory(String categoryName) { - UIButton button = new UIButton(categoryName); - button.setBorderPainted(false); - button.setExtraPainted(false); - button.setPreferredSize(new Dimension(menu.getWidth(), ITEM_SIZE)); - button.setOpaque(true); - button.setBackground(UIConstants.NORMAL_BACKGROUND); - button.setHorizontalAlignment(SwingConstants.LEFT); - button.setForeground(UIConstants.FLESH_BLUE); - return button; - } - - /** - * 创建 当前分类模板 item数组 - */ - private Component[] createCurrentCategory() { - return createListDownItem(TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates()); - } - - /** - * 创建 其它分类模板 item数组 - */ - private Component[] createOtherCategory() { - List> openedTemplates = new ArrayList<>(); - Map>> map = TemplateTabManager.getInstance().getAllOpenedTemplateMap(); - for (Map.Entry>> entry : map.entrySet()) { - if (!StringUtils.equals(TemplateTabManager.getInstance().getCurrentOperator().getOperatorType(), entry.getKey())) { - openedTemplates.addAll(entry.getValue()); - } - } - return createListDownItem(openedTemplates); - } - - /** - * 根据template列表创建多个item - */ - private Component[] createListDownItem(List> openedTemplates) { - if (!CollectionUtils.isEmpty(openedTemplates)) { - Component[] templates = new Component[openedTemplates.size()]; - for (int i = 0; i < openedTemplates.size(); i++) { - templates[i] = createListDownMenuItem(openedTemplates.get(i)); - } - return templates; - } - return new Component[0]; - } - - /** - * 根据template对象创建item - */ - private Component createListDownMenuItem(JTemplate template) { - JPanel jPanel = new JPanel(); - jPanel.setPreferredSize(new Dimension(menu.getWidth(), ITEM_SIZE)); - jPanel.setLayout(new BorderLayout()); - - MenuItemButtonGroup menuItemButtonGroup = new MenuItemButtonGroup(template); - if (template == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) { - menuItemButtonGroup.templateButton.setForeground(UIConstants.FLESH_BLUE); - } - - jPanel.add(menuItemButtonGroup.iconButton, BorderLayout.WEST); - jPanel.add(menuItemButtonGroup.templateButton, BorderLayout.CENTER); - jPanel.add(menuItemButtonGroup.closeButton, BorderLayout.EAST); - - return jPanel; - } - - /** - * menu的item由模板图标、模板名、模板关闭按钮组成 - */ - private class MenuItemButtonGroup { - - private final UIButton iconButton; - private final UIButton templateButton; - private final UIButton closeButton; - - public MenuItemButtonGroup(JTemplate template) { - iconButton = createIconButton(template); - templateButton = createTemplateButton(template); - closeButton = createCloseButton(); - initListener(template); - } - - /** - * item[0] 模板图标按钮初始化 - */ - private UIButton createIconButton(JTemplate template) { - UIButton button = new UIButton(template.getIcon(), template.getIcon(), template.getIcon()); - button.setPreferredSize(new Dimension(ITEM_SIZE, ITEM_SIZE)); - button.setOpaque(true); - button.setBackground(UIConstants.NORMAL_BACKGROUND); - return button; - } - - /** - * item[1] 切换模板按钮初始化 - */ - private UIButton createTemplateButton(JTemplate template) { - UIButton button = new UIButton(TemplateUtils.createLockeTemplatedName(template, template.getTemplateName())); - button.setBorderPainted(false); - button.setExtraPainted(false); - button.setPreferredSize(new Dimension(menu.getWidth() - ITEM_SIZE * 2, ITEM_SIZE)); - button.setOpaque(true); - button.setBackground(UIConstants.NORMAL_BACKGROUND); - button.setHorizontalAlignment(SwingConstants.LEFT); - return button; - } - - /** - * item[2] 关闭模板图标按钮初始化 - */ - private UIButton createCloseButton() { - UIButton button = new UIButton(CLOSE, MOUSE_OVER_CLOSE, MOUSE_PRESS_CLOSE); - button.setPreferredSize(new Dimension(ITEM_SIZE, ITEM_SIZE)); - button.setOpaque(true); - button.setBackground(UIConstants.NORMAL_BACKGROUND); - button.setVisible(false); - return button; - } - - private void initListener(JTemplate template) { - initIconButtonListener(); - initTemplateButtonListener(template); - initCloseButtonListener(template); - } - - /** - * item[0] 模板图标按钮鼠标事件 - */ - private void initIconButtonListener() { - iconButton.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - fireMouseEnteredEvent(); - } - - @Override - public void mouseExited(MouseEvent e) { - fireMouseExitedEvent(); - } - }); - } - - /** - * item[1] 切换模板按钮鼠标事件 - */ - private void initTemplateButtonListener(JTemplate template) { - templateButton.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - menu.setVisible(false); - TemplateTabManager.getInstance().switchByJTemplate(template); - } - - @Override - public void mouseEntered(MouseEvent e) { - fireMouseEnteredEvent(); - } - - @Override - public void mouseExited(MouseEvent e) { - fireMouseExitedEvent(); - } - }); - } - - /** - * item[2] 关闭模板按钮鼠标事件 - */ - private void initCloseButtonListener(JTemplate template) { - closeButton.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - menu.setVisible(false); - TemplateTabManager.getInstance().closeByJTemplate(template); - } - - @Override - public void mouseEntered(MouseEvent e) { - fireMouseEnteredEvent(); - } - - @Override - public void mouseExited(MouseEvent e) { - fireMouseExitedEvent(); - } - }); - } - - /** - * mouse移入item范围 - */ - private void fireMouseEnteredEvent() { - iconButton.setBackground(UIConstants.HOVER_BLUE); - templateButton.setBackground(UIConstants.HOVER_BLUE); - closeButton.setBackground(UIConstants.HOVER_BLUE); - closeButton.setVisible(true); - } - - /** - * mouse移出item范围 - */ - private void fireMouseExitedEvent() { - iconButton.setBackground(UIConstants.NORMAL_BACKGROUND); - templateButton.setBackground(UIConstants.NORMAL_BACKGROUND); - closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); - closeButton.setVisible(false); - } - - } - -} diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 0292bb8f95..8e302fd977 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -1,25 +1,38 @@ package com.fr.design.file; +import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.base.svg.IconUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.file.LocateAction; import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.TemplateSavingChecker; +import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.TemplateUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; +import com.fr.design.worker.WorkerManager; +import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.file.FILE; +import com.fr.file.FileNodeFILE; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; +import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; +import com.fr.third.javax.annotation.Nonnull; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.lock.TplOperator; import javax.swing.BorderFactory; import javax.swing.ButtonModel; @@ -28,8 +41,11 @@ import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JMenu; import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.MenuElement; +import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.plaf.basic.BasicMenuItemUI; import java.awt.AWTEvent; @@ -43,6 +59,7 @@ import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.event.AWTEventListener; import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -54,9 +71,14 @@ import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; import java.util.List; +import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.OK_OPTION; +import static javax.swing.JOptionPane.WARNING_MESSAGE; + /** * 改个名字,一个拼写 n 个错误 - * 模板tab的操作和ui已拆分,后续需要添加模板tab的操作在 TemplateTabManager 中添加 + * * @author daisy * @version 11.0 *

@@ -92,6 +114,10 @@ public class MultiTemplateTabPane extends JComponent { private static MultiTemplateTabPane THIS; + //用于存放工作簿 + private java.util.List> openedTemplate; + //选中的Tab项 + private int selectedIndex = 0; // private int mouseOveredIndex = -1; @@ -110,11 +136,16 @@ public class MultiTemplateTabPane extends JComponent { //记录关闭按钮的状态 private int closeIconIndex = -1; - + private boolean isCloseCurrent = false; private Icon clodeMode = CLOSE; private Icon listDownMode = LIST_DOWN; private boolean isShowList = false; + //自动新建的模板B若没有进行任何编辑,切换到其他 + // + // 模板时,模板B会自动关闭 + private JTemplate temTemplate = null; + public static MultiTemplateTabPane getInstance() { if (THIS == null) { @@ -134,6 +165,8 @@ public class MultiTemplateTabPane extends JComponent { this.setBorder(null); this.setForeground(new Color(58, 56, 58)); this.setFont(DesignUtils.getDefaultGUIFont().applySize(12)); + openedTemplate = HistoryTemplateListCache.getInstance().getHistoryList(); + selectedIndex = openedTemplate.size() - 1; AWTEventListener awt = new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { @@ -173,13 +206,45 @@ public class MultiTemplateTabPane extends JComponent { //根据当前i18n语言环境,动态调整popupMenu的宽度 menu.setPreferredSize(new Dimension((int) DesignSizeI18nManager.getInstance(). i18nDimension("com.fr.design.file.MultiTemplateTabPane.popUpMenu").getWidth(), height)); - GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.this, e.getX(), MultiTemplateTabPane.this.getY() - 1 + MultiTemplateTabPane.this.getHeight()); + GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.getInstance(), e.getX(), MultiTemplateTabPane.getInstance().getY() - 1 + MultiTemplateTabPane.getInstance().getHeight()); } } } }); } + enum CloseOption { + Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { + @Override + boolean shouldClose(int tplIndex, int i) { + return i < tplIndex; + } + }, + Right(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Right")) { + @Override + boolean shouldClose(int tplIndex, int i) { + return i > tplIndex; + } + }, + All(Toolkit.i18nText("Fine-Design_Close_All_templates")), + Others(Toolkit.i18nText("Fine-Design_Close_Other_templates")) { + @Override + boolean shouldClose(int tplIndex, int i) { + return i != tplIndex; + } + }; + + + String optionName; + + CloseOption(String optionName) { + this.optionName = optionName; + } + + boolean shouldClose(int tplIndex, int i) { + return true; + } + } private static class CloseMenuItemJSeparator extends JSeparator { @Override @@ -207,10 +272,41 @@ public class MultiTemplateTabPane extends JComponent { @Override public void actionPerformed(ActionEvent e) { - //DefaultTemplateTabOperate.getInstance().locateTemplateInTree(this.tplIndex); - TemplateTabManager.getInstance().getCurrentOperator().locateTemplateInTree(this.tplIndex); + //处于搜索模式时,先退出搜索模式,再定位 + if (TemplateTreeSearchManager.getInstance().isInSearchMode()) { + TemplateTreeSearchManager.getInstance().outOfSearchMode(); + TemplateTreePane.getInstance().refreshDockingView(); + } + JTemplate template = openedTemplate.get(this.tplIndex); + locateTemplate(template); } + private void locateTemplate(JTemplate template) { + FILE currentTemplate = template.getEditingFILE(); + //模板不属于当前环境,跟预览一样先提示保存,再定位模板 + //如果是拖拽进来的模板单单用exist不能判断,这边参考预览的判断逻辑(browserTemplate),补充一下 + if (!currentTemplate.exists() || !(currentTemplate instanceof FileNodeFILE)) { + int selVal = showConfirmDialog( + DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), + Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), + OK_CANCEL_OPTION, + WARNING_MESSAGE + ); + if (OK_OPTION == selVal) { + CallbackSaveWorker worker = template.saveAs(); + worker.start(template.getRuntimeId()); + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + gotoEditingTemplateLeaf(template.getPath()); + } + }); + } + } else { + gotoEditingTemplateLeaf(template.getPath()); + } + } } private class RightMenuCloseAction extends UpdateAction { @@ -220,82 +316,230 @@ public class MultiTemplateTabPane extends JComponent { public RightMenuCloseAction(CloseOption option, int tplIndex) { this.option = option; - this.setName(option.getOptionName()); + this.setName(option.optionName); this.tplIndex = tplIndex; } @Override public void actionPerformed(ActionEvent e) { - TemplateTabManager.getInstance().getCurrentOperator().closeAction(option, this.tplIndex); - MultiTemplateTabPane.this.repaint(); + SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); + if (saveSomeTempaltePane.showSavePane()) { + + JTemplate[] templates = new JTemplate[openedTemplate.size()]; + for (int i = 0; i < openedTemplate.size(); i++) { + templates[i] = openedTemplate.get(i); + } + JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + closeTemplate(templates, currentTemplate); + + if (option == CloseOption.All) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + } else { + DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); + } + + MultiTemplateTabPane.getInstance().repaint(); + } + } + + private void closeTemplate(JTemplate[] templates, JTemplate currentTemplate) { + for (int i = 0; i < templates.length; i++) { + if (option.shouldClose(tplIndex, i)) { + JTemplate jTemplate = templates[i]; + if (jTemplate == currentTemplate) { + currentTemplate = option == CloseOption.All ? null : templates[tplIndex]; + } + //判断关闭的模板是不是格式刷的被参照的模板 + openedTemplate.remove(jTemplate); + if (jTemplate != currentTemplate) { + MultiTemplateTabPane.getInstance().closeFormat(jTemplate); + HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); + closeAndFreeLock(jTemplate); + } + } + } } + private void closeAndFreeLock(@Nonnull JTemplate template) { + FILE file = template.getEditingFILE(); + // 只有是环境内的文件,才执行释放锁 + if (file != null && file.isEnvFile()) { + // release lock + WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath()); + } + } } - /** - * 留作兼容 - * @return - */ - @Deprecated public JTemplate getSelectedFile() { - return TemplateTabManager.getInstance().getSelectedFile(); + if (openedTemplate.size() == selectedIndex) { + selectedIndex = Math.max(--selectedIndex, 0); + } + return openedTemplate.get(selectedIndex); } + /** * 关闭掉当前已打开文件列表中指定的文件 * * @param file 指定的文件 */ - @Deprecated public void closeFileTemplate(FILE file) { - TemplateTabManager.getInstance().closeFileTemplate(file); + for (JTemplate temp : openedTemplate) { + if (ComparatorUtils.equals(file, temp.getEditingFILE())) { + closeSpecifiedTemplate(temp); + break; + } + } + } + @Override + public Dimension getPreferredSize() { + Dimension dimension = super.getPreferredSize(); + dimension.height = HEIGHT; + return dimension; + } + + private UIMenuItem initCloseOther() { + UIMenuItem closeOther = new UIMenuItem(Toolkit.i18nText("Fine-Design_Basic_FS_Close_Other_Templates")); + // Yvan: 英文下文本显示不全,后续发现如果将模板名设置的比较短,其它语言也会出现显示不全的问题,所以设置一下文本水平居中 + closeOther.setHorizontalAlignment(SwingConstants.CENTER); + setListDownItemPreferredSize(closeOther); + closeOther.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (openedTemplate.size() == 1) { + return; + } + if (!TemplateSavingChecker.check()) { + return; + } + SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); + //点击关闭其他模板,并且点击确定保存 + if (saveSomeTempaltePane.showSavePane()) { + JTemplate[] panes = new JTemplate[openedTemplate.size()]; + for (int i = 0; i < openedTemplate.size(); i++) { + panes[i] = openedTemplate.get(i); + } + for (int i = 0; i < panes.length; i++) { + if (i != selectedIndex) { + JTemplate jTemplate = panes[i]; + //判断关闭的模板是不是格式刷的被参照的模板 + openedTemplate.remove(jTemplate); + closeFormat(jTemplate); + HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); + closeAndFreeLock(jTemplate); + } + } + JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + HistoryTemplateListCache.getInstance().removeAllHistory(); + DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); + THIS.repaint(); + } + //如果取消保存了,则不关闭其他模板 + } + }); + if (openedTemplate.size() == 1) { + closeOther.setEnabled(false); + } + return closeOther; + } + + + private UIMenuItem[] createListDownTemplate() { + UIMenuItem[] templates = new UIMenuItem[openedTemplate.size()]; + for (int i = 0; i < openedTemplate.size(); i++) { + final int index = i; + final JTemplate tem = openedTemplate.get(i); + templates[i] = new UIMenuItem(tempalteShowName(tem), tem.getIcon()); + templates[i].setUI(new UIListDownItemUI()); + setListDownItemPreferredSize(templates[i]); + if (i == selectedIndex) { + //画选中的高亮 + templates[i].setBackground(UIConstants.SHADOW_CENTER); + } + templates[i].addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + selectedIndex = index; + tem.activeNewJTemplate(); + } + }); + } + return templates; + } + + private void setListDownItemPreferredSize(UIMenuItem item) { + Dimension dimension = item.getPreferredSize(); + dimension.height = LIST_DOWN_HEIGHT; + item.setPreferredSize(dimension); + } + + + private String tempalteShowName(JTemplate template) { + String name = TemplateUtils.createLockeTemplatedName(template, template.getTemplateName()); + if (!template.isSaved() && !name.endsWith(" *")) { + name += " *"; + } + return name; + } /** * 刷新打开模板 * * @param history 模板 */ - @Deprecated public void refreshOpenedTemplate(List> history) { - TemplateTabManager.getInstance().refreshOpenedTemplate(history); + openedTemplate = history; } - /** - * 设置临时Template - * @param auotCreate - */ - @Deprecated public void setTemTemplate(JTemplate auotCreate) { - TemplateTabManager.getInstance().setTemTemplate(auotCreate); + temTemplate = auotCreate; } - /** - * 设置选中模板索引 - * @param index - */ - @Deprecated - public void setSelectedIndex(int index) { - TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(index); - } - @Override - public Dimension getPreferredSize() { - Dimension dimension = super.getPreferredSize(); - dimension.height = HEIGHT; - return dimension; - } + private void showListDown() { - private String tempalteShowName(JTemplate template) { - return TemplateTabManager.getInstance().getTemplateShowName(template); + UIScrollPopUpMenu menu = new UIScrollPopUpMenu(); + menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); + menu.add(initCloseOther()); + JSeparator separator = new JSeparator() { + @Override + public Dimension getPreferredSize() { + Dimension d = super.getPreferredSize(); + d.height = 1; + return d; + } + }; + menu.add(new JPanel() { + @Override + public Dimension getPreferredSize() { + Dimension d = super.getPreferredSize(); + d.height = 1; + return d; + } + }); + separator.setForeground(UIConstants.LINE_COLOR); + menu.add(separator); + menu.add(new JPanel() { + @Override + public Dimension getPreferredSize() { + Dimension d = super.getPreferredSize(); + d.height = 1; + return d; + } + }); + UIMenuItem[] items = createListDownTemplate(); + for (int i = 0; i < items.length; i++) { + menu.add(items[i]); + } + GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.getInstance(), MultiTemplateTabPane.getInstance().getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); } - private void showListDown() { - UIScrollPopUpMenu menu = MultiTemplateTabMenuFactory.getInstance().createMenu(); - GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.this, MultiTemplateTabPane.this.getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); + public void setSelectedIndex(int index) { + selectedIndex = index; } @@ -322,18 +566,15 @@ public class MultiTemplateTabPane extends JComponent { paintDefaultBackground(g2d); //最多能画的个数 int maxTemplateNum = (int) (maxWidth) / MINWIDTH; - int templateTabCount = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); - int currentSelectedIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); //计算开始画的最小模板index和最大模板index calMinAndMaxIndex(maxTemplateNum); calculateRealAverageWidth(maxWidth, maxTemplateNum); int maxStringlength = calculateStringMaxLength(); - if ( currentSelectedIndex >= templateTabCount) { - TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex( - templateTabCount - 1); + if (selectedIndex >= openedTemplate.size()) { + selectedIndex = openedTemplate.size() - 1; } - if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() < 0) { - TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(0); + if (selectedIndex < 0) { + selectedIndex = 0; } double templateStartX = 0; startX = new int[maxPaintIndex - minPaintIndex + 1]; @@ -341,7 +582,7 @@ public class MultiTemplateTabPane extends JComponent { //从可以开始展示在tab面板上的tab开始画 for (int i = minPaintIndex; i <= maxPaintIndex; i++) { - JTemplate template = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(i); + JTemplate template = openedTemplate.get(i); Icon icon = template.getIcon(); String name = tempalteShowName(template); //如果tab名字的长度大于最大能显示的英文字符长度,则进行省略号处理 @@ -358,7 +599,7 @@ public class MultiTemplateTabPane extends JComponent { } else { selectedIcon = CLOSE; } - if (i == TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex()) { + if (i == selectedIndex) { if (template.isSaving()) { selectedIcon = WHITE_SAVING_CLOSE_ICON; } @@ -367,8 +608,8 @@ public class MultiTemplateTabPane extends JComponent { if (template.isSaving()) { selectedIcon = GREY_SAVING_CLOSE_ICON; } - boolean left = i < TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); - startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, left, mouseOveredIndex, i); + boolean isLeft = i < selectedIndex; + startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, isLeft, mouseOveredIndex, i); } templateStartX += realWidth; } @@ -443,39 +684,38 @@ public class MultiTemplateTabPane extends JComponent { } private void calMinAndMaxIndex(int maxTemplateNum) { - int templateTabCount = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); //如果个数大于最多能容纳的个数,则多余的进行处理 - if (templateTabCount > maxTemplateNum) { + if (openedTemplate.size() > maxTemplateNum) { //所点击列表中的标签页处在标签页栏最后一个标签页之后,则标签页栏左移至所点击标签页出现 - if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() >= maxPaintIndex) { - minPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() - maxTemplateNum + 1; - maxPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); + if (selectedIndex >= maxPaintIndex) { + minPaintIndex = selectedIndex - maxTemplateNum + 1; + maxPaintIndex = selectedIndex; if (minPaintIndex <= 0) { minPaintIndex = 0; maxPaintIndex = maxTemplateNum - 1; } - } else if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() <= minPaintIndex) { + } else if (selectedIndex <= minPaintIndex) { //所点击列表中的标签页处在标签页栏第一个标签页之前,则标签页栏右移至所点击标签页出现 - minPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); + minPaintIndex = selectedIndex; maxPaintIndex = minPaintIndex + maxTemplateNum - 1; - if (maxPaintIndex > templateTabCount- 1) { - maxPaintIndex = templateTabCount - 1; + if (maxPaintIndex > openedTemplate.size() - 1) { + maxPaintIndex = openedTemplate.size() - 1; } } else { - if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() >= templateTabCount - 1) { - TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(templateTabCount - 1); - maxPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); - minPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() - maxTemplateNum + 1; + if (selectedIndex >= openedTemplate.size() - 1) { + selectedIndex = openedTemplate.size() - 1; + maxPaintIndex = selectedIndex; + minPaintIndex = selectedIndex - maxTemplateNum + 1; } else { maxPaintIndex = minPaintIndex + maxTemplateNum - 1; - if (maxPaintIndex > templateTabCount - 1) { - maxPaintIndex = templateTabCount - 1; + if (maxPaintIndex > openedTemplate.size() - 1) { + maxPaintIndex = openedTemplate.size() - 1; } } } } else { minPaintIndex = 0; - maxPaintIndex = templateTabCount - 1; + maxPaintIndex = openedTemplate.size() - 1; } } @@ -483,7 +723,7 @@ public class MultiTemplateTabPane extends JComponent { //个数小于最多能容纳的个数的情况下,看看宽度每个要画多少 private void calculateRealAverageWidth(double maxwidth, int templateNum) { - int num = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size() > templateNum ? templateNum : TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); + int num = openedTemplate.size() > templateNum ? templateNum : openedTemplate.size(); realWidth = (int) (maxwidth / (num)); if (realWidth > MAXWIDTH) { realWidth = MAXWIDTH; @@ -647,13 +887,10 @@ public class MultiTemplateTabPane extends JComponent { generalPath.closePath(); } - /** - * 设置是否关闭当前打开的模板 - * @param isCloseCurrent - */ - @Deprecated + public void setIsCloseCurrent(boolean isCloseCurrent) { - TemplateTabManager.getInstance().setCloseCurrent(isCloseCurrent); + this.isCloseCurrent = isCloseCurrent; + } /** @@ -661,35 +898,57 @@ public class MultiTemplateTabPane extends JComponent { * * @param specifiedTemplate 模板 */ - @Deprecated public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { - TemplateTabManager.getInstance().closeSpecifiedTemplate(specifiedTemplate); - } - + if (specifiedTemplate == null) { + return; + } - private boolean isOverCloseIcon(int evtX) { - boolean overCloseIcon = false; - for (int i = 0; i < startX.length; i++) { - if (evtX >= startX[i] && evtX <= startX[i] + CLOSE.getIconWidth()) { - overCloseIcon = true; - break; + if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { + specifiedTemplate.stopEditing(); + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", + Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.YES_OPTION) { + CallbackSaveWorker worker = specifiedTemplate.save(); + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + closeTpl(specifiedTemplate); + } + }); + worker.start(specifiedTemplate.getRuntimeId()); + } else if (returnVal == JOptionPane.NO_OPTION) { + closeTpl(specifiedTemplate); } + } else { + closeTpl(specifiedTemplate); } - return overCloseIcon; + } + private void closeTpl(@Nonnull JTemplate specifiedTemplate) { + HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); + closeAndFreeLock(specifiedTemplate); + activePrevTemplateAfterClose(); + } - private boolean isOverListDown(int evtX) { - int maxWidth = getWidth() - LIST_BUTTON_WIDTH; - return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); + private void closeAndFreeLock(@Nonnull JTemplate template) { + FILE file = template.getEditingFILE(); + // 只有是环境内的文件,才执行释放锁 + if (file != null && file.isEnvFile()) { + // release lock + TemplateResourceManager.getResource().closeTemplate(file.getPath()); + } } /** * 后台关闭当前编辑模板 */ - @Deprecated public void closeCurrentTpl() { - TemplateTabManager.getInstance().closeCurrentTpl(); + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + this.setIsCloseCurrent(true); + this.closeFormat(jTemplate); + this.closeSpecifiedTemplate(jTemplate); } /** @@ -697,25 +956,71 @@ public class MultiTemplateTabPane extends JComponent { * * @param closedTemplate 模板 */ - @Deprecated public void closeFormat(JTemplate closedTemplate) { - TemplateTabManager.getInstance().closeFormat(closedTemplate); + //表单不需要处理 + if (!closedTemplate.isJWorkBook()) { + return; + } + + if (DesignerContext.getFormatState() == DesignerContext.FORMAT_STATE_NULL) { + return; + } + + //是被参照的模板被关闭,则重置格式刷 + closedTemplate.doConditionCancelFormat(); } /** * 关闭掉一个模板之后激活新的待显示模板 */ - @Deprecated public void activePrevTemplateAfterClose() { - TemplateTabManager.getInstance().activePrevTemplateAfterClose(); + if (openedTemplate.isEmpty()) { + //新建并激活模板 + DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + selectedIndex = 0; + //此时刚自动新建的模板在HistoryTemplateListCache的editingTemplate + temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + + } else { + // 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板; + // selectIndex 没有变化,但是对应的模板已经变成了前一张模板 + if (closeIconIndex == selectedIndex || isCloseCurrent) { + // 如果当前关闭的模板在最右侧,那么预览上一个,防止数组越界 + if (selectedIndex >= maxPaintIndex) { + // selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true + selectedIndex--; + } + isCloseCurrent = false; + } + // 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index + else { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + selectedIndex = HistoryTemplateListCache.getInstance().contains(template); + } + if (selectedIndex < openedTemplate.size()) { + //如果是已后台关闭的模板,则重新打开文件 + openedTemplate.get(selectedIndex).activeOldJTemplate(); + } + + } } - /** - * 处理自动新建的模板 在切换时的处理 - */ - @Deprecated - public void doWithtemTemplate() { - TemplateTabManager.getInstance().doWithtemTemplate(); + + private boolean isOverCloseIcon(int evtX) { + boolean isOverCloseIcon = false; + for (int i = 0; i < startX.length; i++) { + if (evtX >= startX[i] && evtX <= startX[i] + CLOSE.getIconWidth()) { + isOverCloseIcon = true; + break; + } + } + return isOverCloseIcon; + } + + + private boolean isOverListDown(int evtX) { + int maxWidth = getWidth() - LIST_BUTTON_WIDTH; + return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); } @@ -731,6 +1036,29 @@ public class MultiTemplateTabPane extends JComponent { return -1; } + + /** + * 处理自动新建的模板 在切换时的处理 + */ + public void doWithtemTemplate() { + //temtemplate保存的一定是手动新建的没有编辑或是编辑了没有保存的模板 + //没有保存,说明有编辑;已经保存在磁盘里的文件,说明有过处理,并且已经保存,此时切换都不将其自动关闭 + if (temTemplate == null || temTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) { + return; + } + + if (!temTemplate.isSaved() || !temTemplate.getEditingFILE().isMemFile()) { + temTemplate = null; + } + + //自动新建的模板B若没有进行任何编辑(新建模板没有进行任何编辑时saved都是true):还没有存盘 + if (temTemplate != null && temTemplate.getEditingFILE().isMemFile() && temTemplate.isSaved()) { + HistoryTemplateListCache.getInstance().closeSelectedReport(temTemplate); + temTemplate = null; + setSelectedIndex(HistoryTemplateListCache.getInstance().contains(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())); + } + } + private class UIListDownItemUI extends BasicMenuItemUI { @Override protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { @@ -833,13 +1161,44 @@ public class MultiTemplateTabPane extends JComponent { closeIconIndex = getTemplateIndex(evtX); clodeMode = MOUSE_PRESS_CLOSE; //关闭close图标所在的模板{ - TemplateTabManager.getInstance().getCurrentOperator().closeByIndex(closeIconIndex); + JTemplate template = openedTemplate.get(closeIconIndex); + if (template.isOpening()) { + WorkerManager.getInstance().cancelWorker(template.getPath()); + } else if (template.isSaving()) { + boolean completed = WorkerManager.getInstance().isCompleted(template.getTarget().getTemplateID()); + if (!completed) { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Close_Template_Tip", template.getEditingFILE().getName())); + return; + } + } + //参考CloseCurrentTemplateAction,在closeFormat与closeSpecifiedTemplate之前要先设定isCloseCurrent,这样关闭之后才会自动切换tab + if (checkCurrentClose(template)) { + setIsCloseCurrent(true); + } + closeFormat(template); + closeSpecifiedTemplate(template); + DesignerContext.getDesignerFrame().getContentFrame().repaint(); isShowList = false; } else { //没有点击关闭和ListDown按钮,则切换到点击的模板处 closeIconIndex = -1; clodeMode = CLOSE; - TemplateTabManager.getInstance().getCurrentOperator().switchTpl(getTemplateIndex(evtX)); + int tempSelectedIndex = selectedIndex; + if (selectedIndex != getTemplateIndex(evtX) && getTemplateIndex(evtX) != -1) { + openedTemplate.get(selectedIndex).stopEditing(); + selectedIndex = getTemplateIndex(evtX); + //如果在权限编辑情况下,不允许切换到表单类型的工作簿 + if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); + MultiTemplateTabPane.this.repaint(); + return; + } + JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX)); + evtXTemplate.activeNewJTemplate(); + } isShowList = false; } MultiTemplateTabPane.this.repaint(); @@ -850,6 +1209,11 @@ public class MultiTemplateTabPane extends JComponent { } + private boolean checkCurrentClose(JTemplate template) { + JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return JTemplate.isValid(currentTemplate) && ComparatorUtils.equals(template.getPath(), currentTemplate.getPath()); + } + private class MultiTemplateTabMouseMotionListener implements MouseMotionListener { /** * 鼠标拖拽 @@ -873,7 +1237,7 @@ public class MultiTemplateTabPane extends JComponent { //看是否需要显示toolTip if (mouseOveredIndex != -1 && isNeedToolTips[mouseOveredIndex - minPaintIndex]) { - setToolTipText(TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(mouseOveredIndex).getEditingFILE().getName()); + setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName()); } else { setToolTipText(null); } diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index d92533552c..36e0b58754 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -1,7 +1,5 @@ package com.fr.design.file; -import com.fr.design.file.impl.DefaultTemplateTabOperate; - /** * @author shine * @version 10.0 @@ -16,11 +14,11 @@ public class MutilTempalteTabPane { } public void setIsCloseCurrent(boolean b) { - TemplateTabManager.getInstance().setCloseCurrent(b); + MultiTemplateTabPane.getInstance().setIsCloseCurrent(b); } public void activePrevTemplateAfterClose() { - DefaultTemplateTabOperate.getInstance().activePrevTemplateAfterClose(true); + MultiTemplateTabPane.getInstance().activePrevTemplateAfterClose(); } } diff --git a/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java index 9949888349..dae921a1c8 100644 --- a/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java @@ -81,15 +81,11 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene } if (isOverNewIcon(evtX) && newWorkBookIconMode != GRAY_NEW_CPT) { newWorkBookIconMode = getMousePressNew(); - createNewTemplate(); + DesignerContext.getDesignerFrame().addAndActivateJTemplate(); } this.repaint(); } - protected void createNewTemplate() { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(); - } - /** *鼠标松开 * @param e 事件 diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index 23dfe83a57..72945b31c9 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -3,8 +3,8 @@ package com.fr.design.file; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.StateChangeListener; -import com.fr.design.file.impl.DefaultTemplateTabOperate; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; @@ -19,10 +19,10 @@ import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import javax.swing.*; +import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; -import java.util.List; /** * Author : daisy @@ -84,7 +84,6 @@ public class SaveSomeTemplatePane extends BasicPane { for (int i = 0; i < unSavedTemplate.size(); i++) { templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); templateCheckBoxes[i].setSelected(true); - templateCheckBoxes[i].setEnabled(!unSavedTemplate.get(i).mustSaveBeforeSwitchEnv()); } final UIList templatesList = new UIList(templateCheckBoxes); @@ -104,9 +103,7 @@ public class SaveSomeTemplatePane extends BasicPane { boolean isSelected = chooseAllCheckBox.isSelected(); for (int i = 0; i < templatesList.getModel().getSize(); i++) { UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); - boolean mustSaveBeforeSwitchEnv = unSavedTemplate.get(i).mustSaveBeforeSwitchEnv(); - checkBox.setSelected(mustSaveBeforeSwitchEnv || isSelected); - templateCheckBoxes[i].setEnabled(!mustSaveBeforeSwitchEnv); + checkBox.setSelected(isSelected); } templatesList.repaint(); } @@ -153,21 +150,9 @@ public class SaveSomeTemplatePane extends BasicPane { return count; } - /** - * 显示未保存弹窗 - * @return - */ - public boolean showSavePane() { - return showSavePane(HistoryTemplateListPane.getInstance().getHistoryList()); - } - /** - * 显示未保存弹窗 - * @param jTemplates - * @return - */ - public boolean showSavePane(List> jTemplates) { - populate(jTemplates); + public boolean showSavePane() { + populate(); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); @@ -177,15 +162,8 @@ public class SaveSomeTemplatePane extends BasicPane { return isAllSaved; } - /** - * 兼容方法 - */ - @Deprecated public void populate() { - populate(HistoryTemplateListPane.getInstance().getHistoryList()); - } - - private void populate(java.util.List> opendedTemplate) { + java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (int i = 0; i < opendedTemplate.size(); i++) { if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java deleted file mode 100644 index fe294f222f..0000000000 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java +++ /dev/null @@ -1,291 +0,0 @@ -package com.fr.design.file; - -import com.finebi.cbb.utils.CompareUtils; -import com.fr.design.file.impl.DefaultTemplateTabOperate; -import com.fr.design.file.impl.EmptyTemplateTabOperate; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.JTemplate; -import com.fr.file.FILE; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 模板tab的操作统一管理类 - * @author kerry - * @since 11.0 - * created on 2023-04-14 - **/ -public class TemplateTabManager { - private static class Holder { - private static final TemplateTabManager SINGLETON = new TemplateTabManager(); - } - - /** - * 返回TemplateTabManager单例对象 - * @return - */ - public static TemplateTabManager getInstance() { - return Holder.SINGLETON; - } - - private TemplateTabManager() { - list.add(DefaultTemplateTabOperate.getInstance()); - } - - private List list = new ArrayList<>(); - - /** - * 支持注册新的Operator - * @param templateTabOperateProvider - */ - public void register(TemplateTabOperateProvider templateTabOperateProvider) { - this.list.add(templateTabOperateProvider); - } - - /** - * 移除operator - * @param templateTabOperateProvider - */ - public void remove(TemplateTabOperateProvider templateTabOperateProvider) { - this.list.remove(templateTabOperateProvider); - } - - private boolean closeCurrent = false; - //自动新建的模板B若没有进行任何编辑,切换到其他 - - // 模板时,模板B会自动关闭 - private JTemplate temTemplate = null; - - - public boolean isCloseCurrent() { - return closeCurrent; - } - - public void setCloseCurrent(boolean closeCurrent) { - this.closeCurrent = closeCurrent; - } - - public void setTemTemplate(JTemplate temTemplate) { - this.temTemplate = temTemplate; - } - - /** - * 刷新tab栏 - */ - public void refresh() { - getCurrentOperator().refresh(); - } - - /** - * 从模板树删除文件 - */ - public void deleteOpenedTemplate(JTemplate template) { - TemplateTabOperateProvider provider = getOperatorByTemplate(template); - provider.deleteOpenedTemplate(template); - this.refresh(); - } - - public JTemplate getSelectedFile() { - return getCurrentOperator().getSelectedFile(); - } - - /** - * 关闭掉当前文件列表中指定的文件 - * - * @param file 指定的文件 - */ - public void closeFileTemplate(FILE file) { - for (TemplateTabOperateProvider provider : list) { - provider.closeFileTemplate(file); - } - } - - /** - * 关闭指定模板 - * - * @param specifiedTemplate - */ - public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { - getCurrentOperator().closeSpecifiedTemplate(specifiedTemplate); - } - - - /** - * 刷新打开模板 - * - * @param tempalteLsit - */ - public void refreshOpenedTemplate(List> tempalteLsit) { - for (TemplateTabOperateProvider provider : list) { - provider.refreshOpenedTemplate(tempalteLsit); - } - } - - - /** - * 处理自动新建的模板 在切换时的处理 - */ - public void doWithtemTemplate() { - //temtemplate保存的一定是手动新建的没有编辑或是编辑了没有保存的模板 - //没有保存,说明有编辑;已经保存在磁盘里的文件,说明有过处理,并且已经保存,此时切换都不将其自动关闭 - if (temTemplate == null || temTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) { - return; - } - - if (!temTemplate.isSaved() || !temTemplate.getEditingFILE().isMemFile()) { - temTemplate = null; - } - - //自动新建的模板B若没有进行任何编辑(新建模板没有进行任何编辑时saved都是true):还没有存盘 - if (temTemplate != null && temTemplate.getEditingFILE().isMemFile() && temTemplate.isSaved()) { - HistoryTemplateListCache.getInstance().closeSelectedReport(temTemplate); - temTemplate = null; - resetSelectIndex(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); - } - } - - - /** - * 重置选中index - * @param jTemplate - */ - public void resetSelectIndex(JTemplate jTemplate) { - getCurrentOperator().resetSelectIndex(jTemplate); - } - - - /** - * 激活新模板 - */ - public void activeNewTemplate() { - //先看其他模式中是否有已打开的模板,有的话切换过去 - for (TemplateTabOperateProvider templateTabOperateProvider : list) { - if (templateTabOperateProvider.getOpenedJTemplates().size() != 0) { - templateTabOperateProvider.getSelectedFile().activeNewJTemplate(); - refresh(); - return; - - } - } - //都没有的话,新建并激活模板 - DesignerContext.getDesignerFrame().addAndActivateJTemplate(); - //此时刚自动新建的模板在HistoryTemplateListCache的editingTemplate - TemplateTabManager.getInstance().setTemTemplate(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); - refresh(); - } - - /** - * 后台关闭当前编辑模板 - */ - public void closeCurrentTpl() { - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - this.setCloseCurrent(true); - this.closeFormat(jTemplate); - this.closeSpecifiedTemplate(jTemplate); - } - - - /** - * 关闭指定索引值模板 - * - * @param index - */ - public void closeByIndex(int index) { - getCurrentOperator().closeByIndex(index); - } - - /** - * 关闭指定索引值模板 - * - * @param jTemplate - */ - public void closeByJTemplate(JTemplate jTemplate) { - TemplateTabOperateProvider operator = getOperatorByOperatorType(jTemplate.getTemplateTabOperatorType()); - operator.closeByIndex(operator.getJTemplateIndex(jTemplate)); - } - - /** - * 切换到指定tab栏的指定索引值模板 - * - * @param jTemplate - */ - public void switchByJTemplate(JTemplate jTemplate) { - TemplateTabOperateProvider operator = getOperatorByOperatorType(jTemplate.getTemplateTabOperatorType()); - operator.switchTpl(operator.getJTemplateIndex(jTemplate)); - } - - /** - * 获取所有打开的模板map - * - * @return - */ - public Map>> getAllOpenedTemplateMap() { - Map>> resultMap = new HashMap<>(); - for (TemplateTabOperateProvider provider : list) { - resultMap.put(provider.getOperatorType(), provider.getOpenedJTemplates()); - } - return resultMap; - } - - /** - * 留作兼容 - */ - public void activePrevTemplateAfterClose(){ - getCurrentOperator().activePrevTemplateAfterClose(); - } - - /** - * 关闭其他 - */ - public void closeOthers() { - TemplateTabOperateProvider currentOperator = getCurrentOperator(); - currentOperator.closeAction(CloseOption.Others, - currentOperator.getJTemplateIndex(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())); - } - - public String getTemplateShowName(JTemplate temTemplate){ - return getCurrentOperator().getTemplateShowName(temTemplate); - } - - - /** - * 关闭模板 - * - * @param closedTemplate 模板 - */ - public void closeFormat(JTemplate closedTemplate) { - //表单不需要处理 - if (!closedTemplate.isJWorkBook()) { - return; - } - - if (DesignerContext.getFormatState() == DesignerContext.FORMAT_STATE_NULL) { - return; - } - - //是被参照的模板被关闭,则重置格式刷 - closedTemplate.doConditionCancelFormat(); - } - - - public TemplateTabOperateProvider getCurrentOperator() { - return getOperatorByTemplate(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); - } - - private TemplateTabOperateProvider getOperatorByTemplate(JTemplate jTemplate) { - return getOperatorByOperatorType(jTemplate.getTemplateTabOperatorType()); - } - - private TemplateTabOperateProvider getOperatorByOperatorType(String type) { - for (TemplateTabOperateProvider provider : list) { - if (CompareUtils.isEqual(provider.getOperatorType(), type)) { - return provider; - } - } - return EmptyTemplateTabOperate.getInstance(); - } - -} diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java deleted file mode 100644 index a9a317a8b4..0000000000 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.fr.design.file; - - -import com.fr.design.mainframe.JTemplate; -import com.fr.file.FILE; - -import java.util.List; - -/** - * 模板tab的操作接口 - * @author kerry - * @since 11.0 - * created on 2023-04-14 - **/ -public interface TemplateTabOperateProvider { - /** - * 找到模板树中的位置 - */ - void locateTemplateInTree(int tplIndex); - - - /** - * 右键一系列关闭操作 - * - * @param option closeType - * @param index - */ - void closeAction(CloseOption option, int index); - - - /** - * 切换模板 - * - * @param templateIndex 模板索引值 - */ - void switchTpl(int templateIndex); - - - /** - * 获取打开模板的基本信息 - * - * @return - */ - List> getOpenedJTemplates(); - - - /** - * 根据指定索引关闭模板 - * @param index - */ - void closeByIndex(int index); - /** - * 关闭指定模板 - * - * @param specifiedTemplate - */ - void closeSpecifiedTemplate(JTemplate specifiedTemplate); - /** - * 删除已打开的模板 - */ - void deleteOpenedTemplate(JTemplate template); - - /** - * 获取选中模板 - * @return - */ - JTemplate getSelectedFile(); - - /** - * 刷新ui - */ - void refresh(); - - /** - * 重置下选中的Index - * @param jTemplate - */ - void resetSelectIndex(JTemplate jTemplate); - - /** - * 刷新下打开的模板list - * @param list - */ - void refreshOpenedTemplate(List> list); - - /** - * 关闭指定节点 - * @param file - */ - void closeFileTemplate(FILE file); - - /** - * 获取操作类型标识 - * @return - */ - String getOperatorType(); - - /** - * 获取当前选中模板的index - * @return - */ - int getSelectIndex(); - - /** - * 设置当前选中模板的index - * @return - */ - void setSelectIndex(int index); - - /** - * 获取指定模板在operator中的索引值 - * @param jTemplate - * @return - */ - int getJTemplateIndex(JTemplate jTemplate); - - /** - * 获取template在tab中显示的名称 - * @param jTemplate - * @return - */ - String getTemplateShowName(JTemplate jTemplate); - - - /** - * 留作兼容,在关闭模板后激活前一个模板 - */ - void activePrevTemplateAfterClose(); -} diff --git a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java deleted file mode 100644 index 6406c1d46b..0000000000 --- a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java +++ /dev/null @@ -1,376 +0,0 @@ -package com.fr.design.file.impl; - -import com.finebi.cbb.utils.CompareUtils; -import com.fr.base.vcs.DesignerMode; -import com.fr.design.actions.file.LocateAction; -import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.file.CloseOption; -import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.SaveSomeTemplatePane; -import com.fr.design.file.TemplateTabManager; -import com.fr.design.file.TemplateTabOperateProvider; -import com.fr.design.file.TemplateTreePane; -import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; -import com.fr.design.utils.TemplateUtils; -import com.fr.design.worker.WorkerManager; -import com.fr.design.worker.save.CallbackSaveWorker; -import com.fr.file.FILE; -import com.fr.file.FileNodeFILE; -import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; -import com.fr.third.javax.annotation.Nonnull; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.lock.TplOperator; - -import javax.swing.JOptionPane; -import java.util.ArrayList; -import java.util.List; - -import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; -import static javax.swing.JOptionPane.OK_CANCEL_OPTION; -import static javax.swing.JOptionPane.OK_OPTION; -import static javax.swing.JOptionPane.WARNING_MESSAGE; - -/** - * 模板tab的操作抽象类 - * @author kerry - * @since 11.0 - * created on 2023-04-14 - **/ -public abstract class AbstractTemplateTabOperate implements TemplateTabOperateProvider { - private static final String UNSAVED_SUFFIX = " *"; - //用于存放工作簿 - private java.util.List> openedTemplate = new ArrayList<>(); - //选中的Tab项 - private int selectedIndex = -1; - - public AbstractTemplateTabOperate() { - - } - - @Override - public void locateTemplateInTree(int tplIndex) { - //处于搜索模式时,先退出搜索模式,再定位 - if (TemplateTreeSearchManager.getInstance().isInSearchMode()) { - TemplateTreeSearchManager.getInstance().outOfSearchMode(); - TemplateTreePane.getInstance().refreshDockingView(); - } - JTemplate template = openedTemplate.get(tplIndex); - locateTemplate(template); - } - - private void locateTemplate(JTemplate template) { - FILE currentTemplate = template.getEditingFILE(); - //模板不属于当前环境,跟预览一样先提示保存,再定位模板 - //如果是拖拽进来的模板单单用exist不能判断,这边参考预览的判断逻辑(browserTemplate),补充一下 - boolean needSave = (!currentTemplate.exists() || !(currentTemplate instanceof FileNodeFILE)) && template.canBeSaved(); - if (needSave) { - int selVal = showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), OK_CANCEL_OPTION, WARNING_MESSAGE); - if (OK_OPTION == selVal) { - CallbackSaveWorker worker = template.saveAs(); - worker.start(template.getRuntimeId()); - worker.addSuccessCallback(new Runnable() { - @Override - public void run() { - LocateAction.gotoEditingTemplateLeaf(template.getPath()); - } - }); - } - } else { - LocateAction.gotoEditingTemplateLeaf(template.getPath()); - } - } - - @Override - public void closeAction(CloseOption option, int index) { - SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); - if (saveSomeTempaltePane.showSavePane(this.openedTemplate)) { - - JTemplate[] templates = new JTemplate[openedTemplate.size()]; - for (int i = 0; i < openedTemplate.size(); i++) { - templates[i] = openedTemplate.get(i); - } - JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - - closeTemplate(templates, currentTemplate, option, index); - - if (openedTemplate.isEmpty()) { - TemplateTabManager.getInstance().activeNewTemplate(); - selectedIndex = 0; - } else { - DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); - } - } - } - - /** - * 根据指定索引值关闭模板 - * @param index - */ - public void closeByIndex(int index) { - //关闭close图标所在的模板{ - JTemplate template = openedTemplate.get(index); - if (template.isOpening()) { - WorkerManager.getInstance().cancelWorker(template.getPath()); - } else if (template.isSaving()) { - boolean completed = WorkerManager.getInstance().isCompleted(template.getTarget().getTemplateID()); - if (!completed) { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Close_Template_Tip", template.getEditingFILE().getName())); - return; - } - } - //参考CloseCurrentTemplateAction,在closeFormat与closeSpecifiedTemplate之前要先设定isCloseCurrent,这样关闭之后才会自动切换tab - if (checkCurrentClose(template)) { - TemplateTabManager.getInstance().setCloseCurrent(true); - } - TemplateTabManager.getInstance().closeFormat(template); - closeSpecifiedTemplate(template); - DesignerContext.getDesignerFrame().getContentFrame().repaint(); - } - - private boolean checkCurrentClose(JTemplate template) { - JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - return JTemplate.isValid(currentTemplate) && ComparatorUtils.equals(template.getPath(), currentTemplate.getPath()); - } - - private void closeTemplate(JTemplate[] templates, JTemplate currentTemplate, CloseOption option, int tplIndex) { - for (int i = 0; i < templates.length; i++) { - if (option.shouldClose(tplIndex, i)) { - JTemplate jTemplate = templates[i]; - if (jTemplate == currentTemplate) { - currentTemplate = option == CloseOption.All ? null : templates[tplIndex]; - } - //判断关闭的模板是不是格式刷的被参照的模板 - openedTemplate.remove(jTemplate); - if (jTemplate != currentTemplate) { - TemplateTabManager.getInstance().closeFormat(jTemplate); - HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); - closeAndFreeLock(jTemplate); - } - } - } - } - - private void closeAndFreeLock(@Nonnull JTemplate template) { - FILE file = template.getEditingFILE(); - // 只有是环境内的文件,才执行释放锁 - if (file != null && file.isEnvFile()) { - // release lock - WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath()); - } - } - - @Override - public void switchTpl(int templateIndex) { - int tempSelectedIndex = selectedIndex; - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - boolean shouldSwitch = (selectedIndex != templateIndex || !this.accept(jTemplate.getTemplateTabOperatorType())) - && templateIndex != -1; - if (shouldSwitch) { - openedTemplate.get(selectedIndex).stopEditing(); - selectedIndex = templateIndex; - //如果在权限编辑情况下,不允许切换到表单类型的工作簿 - if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), WARNING_MESSAGE); - return; - } - JTemplate evtTemplate = openedTemplate.get(templateIndex); - evtTemplate.activeNewJTemplate(); - } - } - - @Override - public void deleteOpenedTemplate(JTemplate template) { - if (!openedTemplate.contains(template)) { - return; - } - openedTemplate.remove(template); - if (openedTemplate.size() == 0) { - TemplateTabManager.getInstance().activeNewTemplate(); - return; - } - if (openedTemplate.size() == selectedIndex) { - //如果删除的是后一个Tab,则定位到前一个 - this.selectedIndex--; - } - } - - @Override - public JTemplate getSelectedFile() { - if (openedTemplate.size() == selectedIndex) { - selectedIndex = Math.max(--selectedIndex, 0); - } - return openedTemplate.get(selectedIndex); - } - - - /** - * 关闭掉当前已打开文件列表中指定的文件 - * - * @param file 指定的文件 - */ - public void closeFileTemplate(FILE file) { - for (JTemplate temp : openedTemplate) { - if (ComparatorUtils.equals(file, temp.getEditingFILE())) { - closeSpecifiedTemplate(temp); - break; - } - } - - } - - - /** - * 关闭模板 - * - * @param specifiedTemplate 模板 - */ - public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { - if (specifiedTemplate == null && !openedTemplate.contains(specifiedTemplate)) { - return; - } - - if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { - specifiedTemplate.stopEditing(); - int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); - if (returnVal == JOptionPane.YES_OPTION) { - CallbackSaveWorker worker = specifiedTemplate.save(); - worker.addSuccessCallback(new Runnable() { - @Override - public void run() { - FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); - closeTpl(specifiedTemplate); - } - }); - worker.start(specifiedTemplate.getRuntimeId()); - } else if (returnVal == JOptionPane.NO_OPTION) { - closeTpl(specifiedTemplate); - } - } else { - closeTpl(specifiedTemplate); - } - - } - - private void closeTpl(@Nonnull JTemplate specifiedTemplate) { - JTemplate currentSelectedFile = getSelectedFile(); - HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); - closeAndFreeLock(specifiedTemplate); - activePrevTemplateAfterClose(specifiedTemplate == currentSelectedFile, currentSelectedFile); - } - - /** - * 关闭掉一个模板之后激活新的待显示模板 - */ - @Override - public void activePrevTemplateAfterClose(){ - activePrevTemplateAfterClose(TemplateTabManager.getInstance().isCloseCurrent()); - } - - - /** - * 关闭掉一个模板之后激活新的待显示模板 - */ - public void activePrevTemplateAfterClose(boolean isCurrentSelectedTpl) { - activePrevTemplateAfterClose(isCurrentSelectedTpl, HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); - } - - /** - * 关闭掉一个模板之后激活新的待显示模板 - */ - public void activePrevTemplateAfterClose(boolean isCurrentSelectedTpl, JTemplate currentSelectedJTemplate) { - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - boolean couldSwitch = template != null && this.accept(template.getTemplateTabOperatorType()); - if (openedTemplate.isEmpty()) { - if (couldSwitch){ - TemplateTabManager.getInstance().activeNewTemplate(); - } - selectedIndex = 0; - } else { - // 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板; - // selectIndex 没有变化,但是对应的模板已经变成了前一张模板 - if (isCurrentSelectedTpl || TemplateTabManager.getInstance().isCloseCurrent()) { - // 如果当前关闭的模板在最右侧,那么预览上一个,防止数组越界 - if (selectedIndex >= openedTemplate.size()) { - // selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true - selectedIndex--; - } - TemplateTabManager.getInstance().setCloseCurrent(false); - } - // 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index - else { - selectedIndex = this.openedTemplate.indexOf(currentSelectedJTemplate); - } - if ( selectedIndex < openedTemplate.size() && couldSwitch) { - //如果是已后台关闭的模板,则重新打开文件 - openedTemplate.get(selectedIndex).activeOldJTemplate(); - } - - } - TemplateTabManager.getInstance().refresh(); - } - - @Override - public void resetSelectIndex(JTemplate jTemplate) { - this.selectedIndex = openedTemplate.indexOf(jTemplate); - TemplateTabManager.getInstance().refresh(); - } - - /** - * 刷新已打开的模板 - * @param list - */ - public void refreshOpenedTemplate(List> list) { - List> result = new ArrayList<>(); - for (JTemplate jTemplate : list) { - if (this.accept(jTemplate.getTemplateTabOperatorType())) { - result.add(jTemplate); - } - } - this.openedTemplate = result; - TemplateTabManager.getInstance().refresh(); - } - - public List> getOpenedJTemplates() { - return this.openedTemplate; - } - - @Override - public void setSelectIndex(int index) { - this.selectedIndex = index; - } - - @Override - public int getSelectIndex() { - return this.selectedIndex; - } - - @Override - public int getJTemplateIndex(JTemplate jTemplate) { - return this.openedTemplate.indexOf(jTemplate); - } - - /** - * 是否支持指定操作类型 - * @param type - * @return - */ - public boolean accept(String type) { - return CompareUtils.isEqual(getOperatorType(), type); - } - - - @Override - public String getTemplateShowName(JTemplate template) { - String name = TemplateUtils.createLockeTemplatedName(template, template.getTemplateName()); - if (!template.isSaved() && !name.endsWith(UNSAVED_SUFFIX)) { - name += UNSAVED_SUFFIX; - } - return name; - } - -} diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java deleted file mode 100644 index 90853568dd..0000000000 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.fr.design.file.impl; - -import com.fr.design.file.MultiTemplateTabPane; - -/** - * 默认的模板tab的操作类 - * @author kerry - * @since 11.0 - * created on 2023-04-14 - **/ -public class DefaultTemplateTabOperate extends AbstractTemplateTabOperate { - - public static final String OPERATOR_TYPE = "DEFAULT_TEMPLATE_TAB_OPERATOR"; - - private static class Holder { - private static final DefaultTemplateTabOperate SINGLETON = new DefaultTemplateTabOperate(); - } - - private DefaultTemplateTabOperate() { - super(); - } - - /** - * 返回DefaultTemplateTabOperate 单例 - * @return - */ - public static DefaultTemplateTabOperate getInstance() { - return Holder.SINGLETON; - } - - @Override - public void refresh() { - MultiTemplateTabPane.getInstance().repaint(); - } - - @Override - public String getOperatorType() { - return OPERATOR_TYPE; - } - -} diff --git a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperate.java deleted file mode 100644 index c35a4bf655..0000000000 --- a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperate.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.fr.design.file.impl; - -import com.fr.design.file.CloseOption; -import com.fr.design.file.TemplateTabOperateProvider; -import com.fr.design.mainframe.JTemplate; -import com.fr.file.FILE; -import com.fr.stable.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * 空的模板tab的操作类 - * @author kerry - * @since 11.0 - * created on 2023-04-14 - **/ -public class EmptyTemplateTabOperate implements TemplateTabOperateProvider { - private static class Holder { - private static final EmptyTemplateTabOperate SINGLETON = new EmptyTemplateTabOperate(); - } - - - private EmptyTemplateTabOperate() { - - } - - /** - * 返回空的模板taboperator单例 - * @return - */ - public static EmptyTemplateTabOperate getInstance() { - return Holder.SINGLETON; - } - - @Override - public void locateTemplateInTree(int tplIndex) { - - } - - @Override - public void closeAction(CloseOption option, int index) { - - } - - @Override - public void closeByIndex(int index) { - - } - - @Override - public void switchTpl(int templateIndex) { - - } - - @Override - public List> getOpenedJTemplates() { - return new ArrayList<>(); - } - - @Override - public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { - - } - - @Override - public void deleteOpenedTemplate(JTemplate template) { - - } - - @Override - public JTemplate getSelectedFile() { - return null; - } - - @Override - public void refresh() { - - } - - @Override - public void resetSelectIndex(JTemplate jTemplate) { - - } - - @Override - public void refreshOpenedTemplate(List> list) { - - } - - @Override - public void closeFileTemplate(FILE file) { - - } - @Override - public String getOperatorType() { - return StringUtils.EMPTY; - } - - @Override - public int getSelectIndex() { - return 0; - } - - @Override - public void setSelectIndex(int index) { - - } - - @Override - public int getJTemplateIndex(JTemplate jTemplate) { - return 0; - } - - @Override - public String getTemplateShowName(JTemplate jTemplate) { - return StringUtils.EMPTY; - } - - @Override - public void activePrevTemplateAfterClose() { - - } -} 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 8b63b73e96..e88d0c946c 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 @@ -21,8 +21,8 @@ import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.file.SaveSomeTemplatePane; -import com.fr.design.file.TemplateTabManager; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.OemProcessor; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; @@ -1110,7 +1110,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta // 新的form不往前兼容 if (inValidDesigner(jt)) { this.addAndActivateJTemplate(); - TemplateTabManager.getInstance().setTemTemplate( + MultiTemplateTabPane.getInstance().setTemTemplate( HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); } else { this.addAndActivateJTemplate(jt); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 80fccc95cb..8cfd263421 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -21,7 +21,7 @@ import com.fr.design.file.FileOperations; import com.fr.design.file.FileToolbarStateChangeListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.file.TemplateTreePane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -275,7 +275,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt); //处理自动新建的模板 - TemplateTabManager.getInstance().doWithtemTemplate(); + MultiTemplateTabPane.getInstance().doWithtemTemplate(); if (DesignerMode.isAuthorityEditing()) { RolesAlreadyEditedPane.getInstance().refreshDockingView(); } @@ -547,10 +547,10 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) { if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) { if (isCurrentEditing) { - TemplateTabManager.getInstance().setCloseCurrent(true); + MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); } - TemplateTabManager.getInstance().closeFormat(jTemplate); - TemplateTabManager.getInstance().closeSpecifiedTemplate(jTemplate); + MultiTemplateTabPane.getInstance().closeFormat(jTemplate); + MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(jTemplate); return; } } 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 a92d59d072..229ba848d8 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 @@ -33,7 +33,6 @@ import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateResourceManager; -import com.fr.design.file.impl.DefaultTemplateTabOperate; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.PreviewProvider; @@ -618,7 +617,7 @@ public abstract class JTemplate> * @return 是则返回true */ public boolean isALLSaved() { - return this.canBeSaved() && this.saved && this.authoritySaved; + return this.saved && this.authoritySaved; } @@ -2052,10 +2051,6 @@ public abstract class JTemplate> DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode(); } - public String getTemplateTabOperatorType(){ - return DefaultTemplateTabOperate.OPERATOR_TYPE; - } - /** * 判断当前的模板是否是有效的模板 * @@ -2065,29 +2060,4 @@ public abstract class JTemplate> public static boolean isValid(JTemplate jt) { return jt != null && jt != JNullTemplate.NULL; } - - /** - * 当前模板是否可以被保存 - * @return 是/否 - */ - public boolean canBeSaved(){ - return true; - } - - /** - * 当前的模板是否支持缓存 - * - * @return 是/否 - */ - public boolean supportCache(){ - return true; - } - - /** - * 切换环境之前是否一定要保存 - * @return - */ - public boolean mustSaveBeforeSwitchEnv(){ - return false; - } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 37812c106f..3372e2ad13 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -416,7 +416,9 @@ public abstract class ToolBarMenuDock { menuDef.addShortCut(new OpenRecentReportMenuDef()); - addCloseCurrentTemplateAction(menuDef); + if (!DesignModeContext.isDuchampMode()) { + addCloseCurrentTemplateAction(menuDef); + } scs = plus.shortcut4FileMenu(); if (!ArrayUtils.isEmpty(scs)) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java index 6bfc39b78e..8cff3ffbb1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.vcs.ui; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.JTemplate; @@ -57,9 +57,9 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe jt.stopEditing(); //只有模板路径一致时关闭当前模板 if (ComparatorUtils.equals(fileOfVersion, jt.getPath())) { - TemplateTabManager.getInstance().setCloseCurrent(true); - TemplateTabManager.getInstance().closeFormat(jt); - TemplateTabManager.getInstance().closeSpecifiedTemplate(jt); + MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); + MultiTemplateTabPane.getInstance().closeFormat(jt); + MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(jt); } //再打开cache中的模板 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java index 47a95f2620..4dd14bce6d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java @@ -5,7 +5,7 @@ import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignerMode; import com.fr.design.dialog.BasicPane; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; @@ -115,9 +115,9 @@ public class FileVersionsPanel extends BasicPane { // 关闭当前打开的版本 JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - TemplateTabManager.getInstance().setCloseCurrent(true); - TemplateTabManager.getInstance().closeFormat(jt); - TemplateTabManager.getInstance().closeSpecifiedTemplate(jt); + MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); + MultiTemplateTabPane.getInstance().closeFormat(jt); + MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(jt); updateDesignerFrame(true); diff --git a/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java index baa73fc53a..d9c8568bf9 100644 --- a/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java @@ -3,7 +3,7 @@ package com.fr.design.worker.open; import com.fr.base.chart.exception.ChartNotFoundException; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.file.TemplateTreePane; import com.fr.design.i18n.Toolkit; import com.fr.design.lock.LockInfoDialog; @@ -87,7 +87,7 @@ public class OpenWorker extends SwingWorker { UIManager.getIcon("OptionPane.errorIcon")); } if (cause.getCause() instanceof TplLockedException) { - TemplateTabManager.getInstance().closeCurrentTpl(); + MultiTemplateTabPane.getInstance().closeCurrentTpl(); TemplateTreePane.getInstance().getFileNode().setLock(UUID.randomUUID().toString()); LockInfoDialog.show(null); } diff --git a/designer-base/src/main/java/com/fr/nx/app/designer/toolbar/TemplateTransformer.java b/designer-base/src/main/java/com/fr/nx/app/designer/toolbar/TemplateTransformer.java index f277320dd0..1a6e2bf1c8 100644 --- a/designer-base/src/main/java/com/fr/nx/app/designer/toolbar/TemplateTransformer.java +++ b/designer-base/src/main/java/com/fr/nx/app/designer/toolbar/TemplateTransformer.java @@ -2,7 +2,7 @@ package com.fr.nx.app.designer.toolbar; import com.fr.base.extension.FileExtension; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.file.FILE; @@ -103,9 +103,9 @@ public enum TemplateTransformer { DesignerContext.getDesignerFrame().openTemplate(file); return; } - TemplateTabManager.getInstance().setCloseCurrent(true); - TemplateTabManager.getInstance().closeFormat(jt); - TemplateTabManager.getInstance().closeSpecifiedTemplate(jt); + MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); + MultiTemplateTabPane.getInstance().closeFormat(jt); + MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(jt); DesignerContext.getDesignerFrame().openTemplate(file); } diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 50f2cd35c0..44228c2a4a 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -8,7 +8,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerStartOpenFileProcessor; import com.fr.design.fun.impl.DesignerStartWithEmptyFile; @@ -193,7 +193,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } else { df.addAndActivateJTemplate(); // 如果没有模板,则需要确认一下 - TemplateTabManager.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + MultiTemplateTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } } @@ -253,7 +253,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { private boolean createNewTemplate(DesignerFrame df) { df.addAndActivateJTemplate(); // 如果没有模板,则需要确认一下 - TemplateTabManager.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + MultiTemplateTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); return true; } diff --git a/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java b/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java index 5dcaa147ac..b42cc4ed8f 100644 --- a/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java +++ b/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java @@ -3,7 +3,7 @@ package com.fr.start.common; import com.fr.base.svg.IconUtils; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; @@ -59,7 +59,7 @@ public class DesignerOpenEmptyPanel extends JPanel { HistoryTemplateListCache.getInstance().setCurrentEditingTemplate(null); df.addAndActivateJTemplate(); // 如果没有模板,则需要确认一下 - TemplateTabManager.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + MultiTemplateTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } }); createButton.setBorder(new EmptyBorder(0, 10, 0, 10)); diff --git a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java index c362ae76d1..04633435be 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java @@ -1,7 +1,7 @@ package com.fr.design.fit.common; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.fit.NewJForm; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; @@ -86,7 +86,7 @@ public class TemplateTool { JTemplate oldJTemplate = jTemplateList.get(i); if (oldJTemplate != null && ComparatorUtils.equals(oldJTemplate.getEditingFILE(), newJTemplate.getEditingFILE())) { jTemplateList.set(i, newJTemplate); - TemplateTabManager.getInstance().refreshOpenedTemplate(jTemplateList); + MultiTemplateTabPane.getInstance().refreshOpenedTemplate(jTemplateList); return; } } diff --git a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java index 03e8e2b445..4afacee781 100644 --- a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java +++ b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java @@ -1,8 +1,7 @@ package com.fr.design.preview; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.file.TemplateTabManager; -import com.fr.design.file.TemplateTreePane; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.fun.impl.AbstractPreviewProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JForm; @@ -67,7 +66,7 @@ public class DeveloperPreview extends AbstractPreviewProvider { } private void onPreview(JTemplate jt) { - TemplateTabManager.getInstance().closeCurrentTpl(); + MultiTemplateTabPane.getInstance().closeCurrentTpl(); jt.generateForBiddenTemplate(); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 5ba4838d6e..f9c086a50b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -39,7 +39,7 @@ import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.fun.ReportSupportedFileUIProvider; @@ -1175,7 +1175,7 @@ public class JWorkBook extends JTemplate { public boolean saveShareFile() { FILE newFile = createNewEmptyFile(); //如果文件已经打开, 那么就覆盖关闭掉他 - TemplateTabManager.getInstance().closeFileTemplate(newFile); + MultiTemplateTabPane.getInstance().closeFileTemplate(newFile); final WorkBook tpl = this.getTarget(); // 弹出输入参数 java.util.Map parameterMap = inputParameters(tpl); diff --git a/designer-realize/src/main/java/com/fr/start/MainDesigner.java b/designer-realize/src/main/java/com/fr/start/MainDesigner.java index 55b6548ac5..7b974d871c 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.java @@ -17,7 +17,6 @@ import com.fr.design.deeplink.DeepLinkManager; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MultiTemplateTabPane; -import com.fr.design.file.TemplateTabManager; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.OemProcessor; import com.fr.design.gui.ibutton.UIButton; @@ -410,7 +409,8 @@ public class MainDesigner extends BaseDesigner { return; } saveButton.setEnabled(!jt.isSaved() && !DesignModeContext.isVcsMode() && jt.checkEnable()); - TemplateTabManager.getInstance().refreshOpenedTemplate(HistoryTemplateListCache.getInstance().getHistoryList()); + MultiTemplateTabPane.getInstance().refreshOpenedTemplate(HistoryTemplateListCache.getInstance().getHistoryList()); + MultiTemplateTabPane.getInstance().repaint(); if (DesignerEnvManager.getEnvManager().isSupportUndo()) { undo.setEnabled(jt.canUndo()); redo.setEnabled(jt.canRedo()); From 263fa6df3097c41a08206d2b680d422f1c98e061 Mon Sep 17 00:00:00 2001 From: obo Date: Wed, 19 Apr 2023 10:22:09 +0800 Subject: [PATCH 28/59] =?UTF-8?q?REPORT-94199=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E8=B6=85=E9=93=BE=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=84=B1=E6=95=8F=E5=B8=AE=E5=8A=A9=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E8=B7=B3=E8=BD=AC=E6=9C=AA=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/common/DesensitizationOpenPane.java | 7 +++-- .../fr/design/locale/impl/DataMaskMark.java | 30 +++++++++++++++++++ .../cell/settingpane/CellOtherSetPane.java | 6 +++- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/locale/impl/DataMaskMark.java diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/common/DesensitizationOpenPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/common/DesensitizationOpenPane.java index 949069aaa8..e04c3fed0e 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/common/DesensitizationOpenPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/common/DesensitizationOpenPane.java @@ -8,10 +8,12 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.locale.impl.DataMaskMark; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; import com.fr.log.FineLoggerFactory; import javax.swing.JPanel; -import java.awt.BorderLayout; import java.awt.Desktop; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -58,7 +60,8 @@ public class DesensitizationOpenPane extends JPanel { @Override public void mouseClicked(MouseEvent event) { try { - URL url = new URL(Toolkit.i18nText("Fine-Design_Report_Desensitization_Help_Document_Url")); + LocaleMark dataMaskMark = LocaleCenter.getMark(DataMaskMark.class); + URL url = new URL(dataMaskMark.getValue()); Desktop.getDesktop().browse(url.toURI()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e, "open browse of table data desensitization help document failed for {}", e.getMessage()); diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/DataMaskMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/DataMaskMark.java new file mode 100644 index 0000000000..11312657b9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/DataMaskMark.java @@ -0,0 +1,30 @@ +package com.fr.design.locale.impl; + +import com.fr.design.i18n.LocaleLinkProvider; +import com.fr.general.locale.LocaleMark; + + +/** + * 根据图片信息生成获取国际化服务器图标工具 + * + * @author obo + * @since 11.0 + * Created on 2023/4/19 + */ +public class DataMaskMark implements LocaleMark { + + /** + * 云中心数据脱敏帮助链接链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Data_Mask"; + + /** + * 云中心数据脱敏默认帮助链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design_Report_Desensitization_Help_Document_Url"; + + @Override + public String getValue() { + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index 9879ac53a4..5ac64d401a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -20,6 +20,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.locale.impl.DataMaskMark; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.cell.settingpane.desensitization.CellDesensitizationGroupsPane; @@ -28,6 +29,8 @@ import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellDesensitizationAttr; import com.fr.report.cell.cellattr.CellGUIAttr; @@ -156,10 +159,11 @@ public class CellOtherSetPane extends AbstractCellAttrPane { // 带超链的提示信息 UILabel label = new UILabel(); + LocaleMark dataMaskMark = LocaleCenter.getMark(DataMaskMark.class); MessageWithLink hyperlink = new MessageWithLink( Toolkit.i18nText("Fine-Design_Report_Desensitization_Tip"), Toolkit.i18nText("Fine-Design_Report_Desensitization_Hyperlink"), - Toolkit.i18nText("Fine-Design_Report_Desensitization_Help_Document_Url"), + dataMaskMark.getValue(), StringUtils.EMPTY, label.getBackground(), label.getFont(), From 894e02e41374ce4173fe9cfaa2c931374ab71958 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 19 Apr 2023 13:37:16 +0800 Subject: [PATCH 29/59] =?UTF-8?q?REPORT-75308=20FVS=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=94=AF=E6=8C=81=E5=90=8C=E6=97=B6=E6=89=93?= =?UTF-8?q?=E5=BC=80=E5=A4=9A=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/SwitchExistEnv.java | 2 +- .../design/file/HistoryTemplateListCache.java | 7 +- .../file/MultiTemplateTabMenuFactory.java | 361 ++++++++++++++++++ .../fr/design/file/MultiTemplateTabPane.java | 205 ++++++---- .../com/fr/design/file/NewTemplatePane.java | 10 +- .../fr/design/file/SaveSomeTemplatePane.java | 33 +- .../mainframe/CenterRegionContainerPane.java | 7 + .../mainframe/DefaultToolKitConfig.java | 2 +- .../com/fr/design/mainframe/JTemplate.java | 49 +++ .../mainframe/toolbar/ToolBarMenuDock.java | 4 +- 10 files changed, 598 insertions(+), 82 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java diff --git a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java index 33761a92e2..e38a39895a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java @@ -68,7 +68,7 @@ public class SwitchExistEnv extends MenuDef { EnvChangeEntrance.getInstance().chooseEnv(envName); } else { SaveSomeTemplatePane saveSomeTemplatePane = new SaveSomeTemplatePane(true); - if (saveSomeTemplatePane.showSavePane()) { + if (saveSomeTemplatePane.showSavePane(true)) { // 用户模板保存后,才进行切换目录操作 EnvChangeEntrance.getInstance().switch2Env(envName); } 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 86820aa227..f895a4f5b4 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 @@ -268,7 +268,8 @@ public class HistoryTemplateListCache implements CallbackEvent { boolean replaceWithJVirtualTemplate = overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate - && overTemplate.checkEnable(); + && overTemplate.checkEnable() + && overTemplate.supportCache(); if (replaceWithJVirtualTemplate) { closeVirtualSelectedReport(overTemplate); historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE())); @@ -297,7 +298,9 @@ public class HistoryTemplateListCache implements CallbackEvent { int index = iterator.nextIndex(); if (size == index + 1 && index > 0) { //如果删除的是后一个Tab,则定位到前一个 - MultiTemplateTabPane.getInstance().setSelectedIndex(index - 1); + MultiTemplateTabPane.getInstance().setSelectedIndex( + MultiTemplateTabPane.getInstance().calNextShowJTemplateIndex(index - 1)); + } } } diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java new file mode 100644 index 0000000000..85b30f2d5b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java @@ -0,0 +1,361 @@ +package com.fr.design.file; + +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.gui.imenu.UIScrollPopUpMenu; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.utils.TemplateUtils; +import com.fr.file.FILE; +import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.CollectionUtils; +import com.fr.third.javax.annotation.Nonnull; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 右侧下拉菜单的工厂类 + * @author Carlson + * @since 11.0 + * created on 2023-04-14 + **/ +public class MultiTemplateTabMenuFactory { + + private static final Icon CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png"); + private static final Icon MOUSE_OVER_CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/mouseoverclose icon.png"); + private static final Icon MOUSE_PRESS_CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/pressclose icon.png"); + + private static final int ITEM_SIZE = 25; + + private UIScrollPopUpMenu menu = null; + + private static MultiTemplateTabMenuFactory INSTANCE = new MultiTemplateTabMenuFactory(); + + private MultiTemplateTabMenuFactory() { + + } + + /** + * 返回右侧下拉菜单的工厂类 + * @return + */ + public static MultiTemplateTabMenuFactory getInstance() { + return INSTANCE; + } + + /** + * tab上的下拉菜单 + */ + public UIScrollPopUpMenu createMenu() { + menu = new UIScrollPopUpMenu(); + menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); + + menu.add(initCloseOther()); + menu.add(createEmptyRow()); + menu.addSeparator(); + menu.add(createEmptyRow()); + menu.add(createCategory(Toolkit.i18nText("Fine-Design_Basic_Tab_Current_Category_Templates"))); + Component[] items = createCurrentCategory(); + for (Component item : items) { + menu.add(item); + } + items = createOtherCategory(); + if (items.length > 0) { + menu.addSeparator(); + menu.add(createEmptyRow()); + menu.add(createCategory(Toolkit.i18nText("Fine-Design_Basic_Tab_Other_Category_Templates"))); + for (Component item : items) { + menu.add(item); + } + } + Dimension dimension = menu.getPreferredSize(); + dimension.width += ITEM_SIZE; + menu.setPreferredSize(dimension); + return menu; + } + + /** + * 关闭其它按钮 + */ + private UIMenuItem initCloseOther() { + UIMenuItem closeOther = new UIMenuItem(Toolkit.i18nText("Fine-Design_Basic_Tab_Close_Other_Templates_Of_Current_Category")); + closeOther.setHorizontalAlignment(SwingConstants.CENTER); + Dimension dimension = closeOther.getPreferredSize(); + dimension.height = ITEM_SIZE; + closeOther.setPreferredSize(dimension); + String currentOperator = getCurrentTabOperatorType(); + closeOther.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + MultiTemplateTabPane.getInstance().closeAllByOperatorType(currentOperator); + } + }); + if (MultiTemplateTabPane.getInstance().getOpenedJTemplatesByOperator(currentOperator).size() <= 1) { + closeOther.setEnabled(false); + } + return closeOther; + } + + + private void closeAndFreeLock(@Nonnull JTemplate template) { + FILE file = template.getEditingFILE(); + // 只有是环境内的文件,才执行释放锁 + if (file != null && file.isEnvFile()) { + // release lock + TemplateResourceManager.getResource().closeTemplate(file.getPath()); + } + } + + /** + * 美观用 + */ + private JPanel createEmptyRow() { + return new JPanel() { + @Override + public Dimension getPreferredSize() { + Dimension d = super.getPreferredSize(); + d.height = 1; + return d; + } + }; + } + + /** + * 模板分类item + */ + private UIButton createCategory(String categoryName) { + UIButton button = new UIButton(categoryName); + button.setBorderPainted(false); + button.setExtraPainted(false); + button.setPreferredSize(new Dimension(menu.getWidth(), ITEM_SIZE)); + button.setOpaque(true); + button.setBackground(UIConstants.NORMAL_BACKGROUND); + button.setHorizontalAlignment(SwingConstants.LEFT); + button.setForeground(UIConstants.FLESH_BLUE); + return button; + } + + /** + * 创建 当前分类模板 item数组 + */ + private Component[] createCurrentCategory() { + return createListDownItem(MultiTemplateTabPane.getInstance().getOpenedJTemplatesByOperator(getCurrentTabOperatorType())); + } + + private String getCurrentTabOperatorType(){ + JTemplate jTemplate= HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return jTemplate.getTemplateTabOperatorType(); + } + + /** + * 创建 其它分类模板 item数组 + */ + private Component[] createOtherCategory() { + String currentOperator = getCurrentTabOperatorType(); + List> openedTemplates = new ArrayList<>(); + Map>> map = MultiTemplateTabPane.getInstance().getOpenedJTemplatesByCategory(); + for (Map.Entry>> entry : map.entrySet()) { + if (!StringUtils.equals(currentOperator, entry.getKey())) { + openedTemplates.addAll(entry.getValue()); + } + } + return createListDownItem(openedTemplates); + } + + /** + * 根据template列表创建多个item + */ + private Component[] createListDownItem(List> openedTemplates) { + if (!CollectionUtils.isEmpty(openedTemplates)) { + Component[] templates = new Component[openedTemplates.size()]; + for (int i = 0; i < openedTemplates.size(); i++) { + templates[i] = createListDownMenuItem(openedTemplates.get(i)); + } + return templates; + } + return new Component[0]; + } + + /** + * 根据template对象创建item + */ + private Component createListDownMenuItem(JTemplate template) { + JPanel jPanel = new JPanel(); + jPanel.setPreferredSize(new Dimension(menu.getWidth(), ITEM_SIZE)); + jPanel.setLayout(new BorderLayout()); + + MenuItemButtonGroup menuItemButtonGroup = new MenuItemButtonGroup(template); + if (template == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) { + menuItemButtonGroup.templateButton.setForeground(UIConstants.FLESH_BLUE); + } + + jPanel.add(menuItemButtonGroup.iconButton, BorderLayout.WEST); + jPanel.add(menuItemButtonGroup.templateButton, BorderLayout.CENTER); + jPanel.add(menuItemButtonGroup.closeButton, BorderLayout.EAST); + + return jPanel; + } + + /** + * menu的item由模板图标、模板名、模板关闭按钮组成 + */ + private class MenuItemButtonGroup { + + private final UIButton iconButton; + private final UIButton templateButton; + private final UIButton closeButton; + + public MenuItemButtonGroup(JTemplate template) { + iconButton = createIconButton(template); + templateButton = createTemplateButton(template); + closeButton = createCloseButton(); + initListener(template); + } + + /** + * item[0] 模板图标按钮初始化 + */ + private UIButton createIconButton(JTemplate template) { + UIButton button = new UIButton(template.getIcon(), template.getIcon(), template.getIcon()); + button.setPreferredSize(new Dimension(ITEM_SIZE, ITEM_SIZE)); + button.setOpaque(true); + button.setBackground(UIConstants.NORMAL_BACKGROUND); + return button; + } + + /** + * item[1] 切换模板按钮初始化 + */ + private UIButton createTemplateButton(JTemplate template) { + UIButton button = new UIButton(TemplateUtils.createLockeTemplatedName(template, template.getTemplateName())); + button.setBorderPainted(false); + button.setExtraPainted(false); + button.setPreferredSize(new Dimension(menu.getWidth() - ITEM_SIZE * 2, ITEM_SIZE)); + button.setOpaque(true); + button.setBackground(UIConstants.NORMAL_BACKGROUND); + button.setHorizontalAlignment(SwingConstants.LEFT); + return button; + } + + /** + * item[2] 关闭模板图标按钮初始化 + */ + private UIButton createCloseButton() { + UIButton button = new UIButton(CLOSE, MOUSE_OVER_CLOSE, MOUSE_PRESS_CLOSE); + button.setPreferredSize(new Dimension(ITEM_SIZE, ITEM_SIZE)); + button.setOpaque(true); + button.setBackground(UIConstants.NORMAL_BACKGROUND); + button.setVisible(false); + return button; + } + + private void initListener(JTemplate template) { + initIconButtonListener(); + initTemplateButtonListener(template); + initCloseButtonListener(template); + } + + /** + * item[0] 模板图标按钮鼠标事件 + */ + private void initIconButtonListener() { + iconButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + fireMouseEnteredEvent(); + } + + @Override + public void mouseExited(MouseEvent e) { + fireMouseExitedEvent(); + } + }); + } + + /** + * item[1] 切换模板按钮鼠标事件 + */ + private void initTemplateButtonListener(JTemplate template) { + templateButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + menu.setVisible(false); + MultiTemplateTabPane.getInstance().switchJTemplate(template); + } + + @Override + public void mouseEntered(MouseEvent e) { + fireMouseEnteredEvent(); + } + + @Override + public void mouseExited(MouseEvent e) { + fireMouseExitedEvent(); + } + }); + } + + /** + * item[2] 关闭模板按钮鼠标事件 + */ + private void initCloseButtonListener(JTemplate template) { + closeButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + menu.setVisible(false); + MultiTemplateTabPane.getInstance().setIsCloseCurrent(template == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); + MultiTemplateTabPane.getInstance().closeFormat(template); + MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(template); + } + + @Override + public void mouseEntered(MouseEvent e) { + fireMouseEnteredEvent(); + } + + @Override + public void mouseExited(MouseEvent e) { + fireMouseExitedEvent(); + } + }); + } + + /** + * mouse移入item范围 + */ + private void fireMouseEnteredEvent() { + iconButton.setBackground(UIConstants.HOVER_BLUE); + templateButton.setBackground(UIConstants.HOVER_BLUE); + closeButton.setBackground(UIConstants.HOVER_BLUE); + closeButton.setVisible(true); + } + + /** + * mouse移出item范围 + */ + private void fireMouseExitedEvent() { + iconButton.setBackground(UIConstants.NORMAL_BACKGROUND); + templateButton.setBackground(UIConstants.NORMAL_BACKGROUND); + closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); + closeButton.setVisible(false); + } + + } + +} diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 8e302fd977..4f292ecfe7 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -1,7 +1,6 @@ package com.fr.design.file; -import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.base.svg.IconUtils; import com.fr.base.vcs.DesignerMode; @@ -19,7 +18,6 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.TemplateSavingChecker; import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; import com.fr.design.utils.DesignUtils; -import com.fr.design.utils.TemplateUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.design.worker.WorkerManager; @@ -42,7 +40,6 @@ import javax.swing.JComponent; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JOptionPane; -import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.MenuElement; import javax.swing.SwingConstants; @@ -70,6 +67,8 @@ import java.awt.geom.Line2D; import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; import static javax.swing.JOptionPane.OK_CANCEL_OPTION; @@ -333,8 +332,10 @@ public class MultiTemplateTabPane extends JComponent { JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); closeTemplate(templates, currentTemplate); - if (option == CloseOption.All) { + if (openedTemplate.size() == 0) { DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + } else if (option == CloseOption.All){ + DesignerContext.getDesignerFrame().activateJTemplate(openedTemplate.get(0)); } else { DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); } @@ -344,8 +345,9 @@ public class MultiTemplateTabPane extends JComponent { } private void closeTemplate(JTemplate[] templates, JTemplate currentTemplate) { + String operator = currentTemplate.getTemplateTabOperatorType(); for (int i = 0; i < templates.length; i++) { - if (option.shouldClose(tplIndex, i)) { + if (option.shouldClose(tplIndex, i) && ComparatorUtils.equals(operator, templates[i].getTemplateTabOperatorType())) { JTemplate jTemplate = templates[i]; if (jTemplate == currentTemplate) { currentTemplate = option == CloseOption.All ? null : templates[tplIndex]; @@ -378,6 +380,47 @@ public class MultiTemplateTabPane extends JComponent { return openedTemplate.get(selectedIndex); } + /** + * 关闭所有指定模板tab操作类型的模板 + * @param operatorType + */ + public void closeAllByOperatorType(String operatorType){ + SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); + if (saveSomeTempaltePane.showSavePane()) { + List> openedTemplate = HistoryTemplateListCache.getInstance().getHistoryList(); + + JTemplate[] templates = new JTemplate[openedTemplate.size()]; + for (int i = 0; i < openedTemplate.size(); i++) { + templates[i] = openedTemplate.get(i); + } + closeTemplate(templates, operatorType); + + if (openedTemplate.size() == 0) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + } else { + DesignerContext.getDesignerFrame().activateJTemplate(openedTemplate.get(0)); + } + MultiTemplateTabPane.getInstance().repaint(); + } + } + + /** + * 关闭指定模板 + * @param templates + * @param operatorType + */ + private static void closeTemplate(JTemplate[] templates, String operatorType) { + for (int i = 0; i < templates.length; i++) { + JTemplate jTemplate = templates[i]; + if (!ComparatorUtils.equals(operatorType, jTemplate.getTemplateTabOperatorType())){ + continue; + } + MultiTemplateTabPane.getInstance().closeFormat(jTemplate); + HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); + MultiTemplateTabPane.getInstance().closeAndFreeLock(jTemplate); + } + } + /** * 关闭掉当前已打开文件列表中指定的文件 @@ -478,11 +521,7 @@ public class MultiTemplateTabPane extends JComponent { private String tempalteShowName(JTemplate template) { - String name = TemplateUtils.createLockeTemplatedName(template, template.getTemplateName()); - if (!template.isSaved() && !name.endsWith(" *")) { - name += " *"; - } - return name; + return template.getTabShowName(template); } /** @@ -500,40 +539,7 @@ public class MultiTemplateTabPane extends JComponent { private void showListDown() { - - UIScrollPopUpMenu menu = new UIScrollPopUpMenu(); - menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); - menu.add(initCloseOther()); - JSeparator separator = new JSeparator() { - @Override - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - d.height = 1; - return d; - } - }; - menu.add(new JPanel() { - @Override - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - d.height = 1; - return d; - } - }); - separator.setForeground(UIConstants.LINE_COLOR); - menu.add(separator); - menu.add(new JPanel() { - @Override - public Dimension getPreferredSize() { - Dimension d = super.getPreferredSize(); - d.height = 1; - return d; - } - }); - UIMenuItem[] items = createListDownTemplate(); - for (int i = 0; i < items.length; i++) { - menu.add(items[i]); - } + UIScrollPopUpMenu menu = MultiTemplateTabMenuFactory.getInstance().createMenu(); GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.getInstance(), MultiTemplateTabPane.getInstance().getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); } @@ -583,6 +589,9 @@ public class MultiTemplateTabPane extends JComponent { //从可以开始展示在tab面板上的tab开始画 for (int i = minPaintIndex; i <= maxPaintIndex; i++) { JTemplate template = openedTemplate.get(i); + if (!showJTemplateTab(template)){ + continue; + } Icon icon = template.getIcon(); String name = tempalteShowName(template); //如果tab名字的长度大于最大能显示的英文字符长度,则进行省略号处理 @@ -722,8 +731,10 @@ public class MultiTemplateTabPane extends JComponent { //个数小于最多能容纳的个数的情况下,看看宽度每个要画多少 private void calculateRealAverageWidth(double maxwidth, int templateNum) { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + List> showTemplates = getOpenedJTemplatesByOperator(jTemplate.getTemplateTabOperatorType()); - int num = openedTemplate.size() > templateNum ? templateNum : openedTemplate.size(); + int num = Math.min(showTemplates.size(), templateNum); realWidth = (int) (maxwidth / (num)); if (realWidth > MAXWIDTH) { realWidth = MAXWIDTH; @@ -932,7 +943,7 @@ public class MultiTemplateTabPane extends JComponent { activePrevTemplateAfterClose(); } - private void closeAndFreeLock(@Nonnull JTemplate template) { + public void closeAndFreeLock(@Nonnull JTemplate template) { FILE file = template.getEditingFILE(); // 只有是环境内的文件,才执行释放锁 if (file != null && file.isEnvFile()) { @@ -988,7 +999,7 @@ public class MultiTemplateTabPane extends JComponent { // 如果当前关闭的模板在最右侧,那么预览上一个,防止数组越界 if (selectedIndex >= maxPaintIndex) { // selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true - selectedIndex--; + selectedIndex = calNextShowJTemplateIndex(selectedIndex - 1); } isCloseCurrent = false; } @@ -1005,6 +1016,26 @@ public class MultiTemplateTabPane extends JComponent { } } + /** + * 计算下一个可以展示的模板index + * @param currentIndex + * @return + */ + public int calNextShowJTemplateIndex(int currentIndex) { + //先看是否有可以展示的模板 + for (int i = currentIndex; i >= 0; i--) { + if (showJTemplateTab(openedTemplate.get(i))) { + return i; + } + } + for (int i = currentIndex; i >= 0; i--) { + if (!showJTemplateTab(openedTemplate.get(i))) { + return i; + } + } + return -1; + } + private boolean isOverCloseIcon(int evtX) { boolean isOverCloseIcon = false; @@ -1027,7 +1058,7 @@ public class MultiTemplateTabPane extends JComponent { private int getTemplateIndex(int evtX) { int textX = 0; for (int i = minPaintIndex; i <= maxPaintIndex; i++) { - int textWidth = realWidth; + int textWidth = showJTemplateTab(openedTemplate.get(i)) ? realWidth : 0; if (evtX >= textX && evtX < textX + textWidth) { return i; } @@ -1184,29 +1215,44 @@ public class MultiTemplateTabPane extends JComponent { //没有点击关闭和ListDown按钮,则切换到点击的模板处 closeIconIndex = -1; clodeMode = CLOSE; - int tempSelectedIndex = selectedIndex; - if (selectedIndex != getTemplateIndex(evtX) && getTemplateIndex(evtX) != -1) { - openedTemplate.get(selectedIndex).stopEditing(); - selectedIndex = getTemplateIndex(evtX); - //如果在权限编辑情况下,不允许切换到表单类型的工作簿 - if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") - + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); - MultiTemplateTabPane.this.repaint(); - return; - } - JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX)); - evtXTemplate.activeNewJTemplate(); - } + switchJTemplate(getTemplateIndex(evtX)); isShowList = false; } MultiTemplateTabPane.this.repaint(); - - } + } + /** + * 切换到指定模板 + * @param jTemplate + */ + public void switchJTemplate(JTemplate jTemplate) { + int switchIndex = this.openedTemplate.indexOf(jTemplate); + if (switchIndex >= 0) { + switchJTemplate(switchIndex); + } + } + /** + * 切换到指定index + * @param switchIndex + */ + private void switchJTemplate(int switchIndex){ + int tempSelectedIndex = selectedIndex; + if (selectedIndex != switchIndex && switchIndex != -1) { + openedTemplate.get(selectedIndex).stopEditing(); + selectedIndex = switchIndex; + //如果在权限编辑情况下,不允许切换到表单类型的工作簿 + if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); + MultiTemplateTabPane.this.repaint(); + return; + } + JTemplate evtXTemplate = openedTemplate.get(switchIndex); + evtXTemplate.activeNewJTemplate(); + } } private boolean checkCurrentClose(JTemplate template) { @@ -1251,5 +1297,34 @@ public class MultiTemplateTabPane extends JComponent { } } + /** + * 判断是否显示在tab栏上 + * @param jTemplate + * @return + */ + private boolean showJTemplateTab(JTemplate jTemplate){ + JTemplate current = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return ComparatorUtils.equals(current.getTemplateTabOperatorType(), jTemplate.getTemplateTabOperatorType()); + } + + /** + * 获取tab操作类型的模板 + * @param operator + * @return + */ + public List> getOpenedJTemplatesByOperator(String operator) { + return openedTemplate.stream().filter((jTemplate) -> ComparatorUtils.equals(jTemplate.getTemplateTabOperatorType(), operator)) + .collect(Collectors.toList()); + } + + /** + * 根据tab操作类型进行分类 + * @return + */ + public Map>> getOpenedJTemplatesByCategory() { + return openedTemplate.stream() + .collect(Collectors.groupingBy(JTemplate::getTemplateTabOperatorType)); + } + } diff --git a/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java index dae921a1c8..81f82e78c6 100644 --- a/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java @@ -81,11 +81,19 @@ public abstract class NewTemplatePane extends JComponent implements MouseListene } if (isOverNewIcon(evtX) && newWorkBookIconMode != GRAY_NEW_CPT) { newWorkBookIconMode = getMousePressNew(); - DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + createNewTemplate(); } this.repaint(); } + + /** + * 新建模板 + */ + protected void createNewTemplate() { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(); + } + /** *鼠标松开 * @param e 事件 diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index 72945b31c9..fa8e3d385d 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -47,6 +47,7 @@ public class SaveSomeTemplatePane extends BasicPane { /** * 支持自定义设置 dialog的父窗口 + * * @param isNeedTojudgeCurrent * @param parent */ @@ -79,11 +80,14 @@ public class SaveSomeTemplatePane extends BasicPane { this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; } - private void initTemplatesChoosePane() { + + private void initTemplatesChoosePane(boolean judgeJTemplateMustSave) { templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); for (int i = 0; i < unSavedTemplate.size(); i++) { templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); templateCheckBoxes[i].setSelected(true); + boolean needSave = judgeJTemplateMustSave && unSavedTemplate.get(i).needSaveBeforeSwitchEnv(); + templateCheckBoxes[i].setEnabled(!needSave); } final UIList templatesList = new UIList(templateCheckBoxes); @@ -103,7 +107,10 @@ public class SaveSomeTemplatePane extends BasicPane { boolean isSelected = chooseAllCheckBox.isSelected(); for (int i = 0; i < templatesList.getModel().getSize(); i++) { UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); - checkBox.setSelected(isSelected); + boolean mustSaveBeforeSwitchEnv = judgeJTemplateMustSave && unSavedTemplate.get(i).needSaveBeforeSwitchEnv(); + checkBox.setSelected(mustSaveBeforeSwitchEnv || isSelected); + templateCheckBoxes[i].setEnabled(!mustSaveBeforeSwitchEnv); + } templatesList.repaint(); } @@ -139,7 +146,7 @@ public class SaveSomeTemplatePane extends BasicPane { /** * 获取templateCheckBoxes中状态为选中状态的CheckBox数量 - * */ + */ private int calculateSelectedNum() { int count = 0; for (UICheckBox checkBox : templateCheckBoxes) { @@ -152,7 +159,11 @@ public class SaveSomeTemplatePane extends BasicPane { public boolean showSavePane() { - populate(); + return showSavePane(false); + } + + public boolean showSavePane(boolean judgeJTemplateMustSave) { + populate(judgeJTemplateMustSave); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); @@ -162,8 +173,12 @@ public class SaveSomeTemplatePane extends BasicPane { return isAllSaved; } - public void populate() { - java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); + protected java.util.List> getOpenedTemplatesToProcess(){ + return HistoryTemplateListPane.getInstance().getHistoryList(); + } + + public void populate(boolean judgeJTemplateMustSave) { + java.util.List> opendedTemplate = getOpenedTemplatesToProcess(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (int i = 0; i < opendedTemplate.size(); i++) { if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { @@ -171,10 +186,10 @@ public class SaveSomeTemplatePane extends BasicPane { } } templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; - initTemplatesChoosePane(); + initTemplatesChoosePane(judgeJTemplateMustSave); } - private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { + protected boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { //所有模板都判断是不是保存 if (isJudgeCurrentEditingTemplate) { return !template.isALLSaved(); @@ -194,7 +209,7 @@ public class SaveSomeTemplatePane extends BasicPane { specifiedTemplate.stopEditing(); return specifiedTemplate.saveTemplate(); } - FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); return true; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java index 63c00deaaf..3cceff5a75 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java @@ -311,4 +311,11 @@ public class CenterRegionContainerPane extends JPanel { return toolbarComponentState; } + /** + * 重置下RegionContainerpane + */ + public void resetCenterRegionContainerPane(){ + templateTabPane.add(MultiTemplateTabPane.getInstance(), BorderLayout.CENTER); + } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DefaultToolKitConfig.java b/designer-base/src/main/java/com/fr/design/mainframe/DefaultToolKitConfig.java index 581dc54cb8..73daf052f1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DefaultToolKitConfig.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DefaultToolKitConfig.java @@ -2,7 +2,6 @@ package com.fr.design.mainframe; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; - import javax.swing.JPanel; @@ -24,6 +23,7 @@ public class DefaultToolKitConfig implements ToolKitConfigStrategy { @Override public JPanel customNorthPane(JPanel toolBarPane, ToolBarMenuDockPlus plus) { + CenterRegionContainerPane.getInstance().resetCenterRegionContainerPane(); return toolBarPane; } } 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 229ba848d8..17a5afb2b6 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 @@ -58,6 +58,7 @@ import com.fr.design.module.DesignModuleFactory; import com.fr.design.preview.PagePreview; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.TemplateUtils; import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.design.worker.save.EmptyCallBackSaveWorker; import com.fr.design.worker.save.SaveFailureHandler; @@ -120,6 +121,8 @@ import java.util.concurrent.Callable; * 报表设计和表单设计的编辑区域(设计器编辑的IO文件) */ public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener, ThemedTemplate { + + private static final String DEFAULT_TAB_OPERATOR = "DefaultTabOperator"; // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null private static final int PREDEFINED_ICON_WIDTH = 27; @@ -2060,4 +2063,50 @@ public abstract class JTemplate> public static boolean isValid(JTemplate jt) { return jt != null && jt != JNullTemplate.NULL; } + + /** + * 获取此模板所使用的tab栏操作类型 + * @return + */ + public String getTemplateTabOperatorType(){ + return DEFAULT_TAB_OPERATOR; + } + + /** + * 当前模板是否可以被保存 + * @return 是/否 + */ + public boolean canBeSaved(){ + return true; + } + + /** + * 当前的模板是否支持缓存 + * + * @return 是/否 + */ + public boolean supportCache(){ + return true; + } + + /** + * 获取此模板在tab栏中显示的名称 + * @return + */ + public String getTabShowName(JTemplate jTemplate){ + String name = TemplateUtils.createLockeTemplatedName(jTemplate, jTemplate.getTemplateName()); + if (!jTemplate.isSaved() && !name.endsWith(" *")) { + name += " *"; + } + return name; + } + + /** + * 切换环境之前是否需要保存 + * @return + */ + public boolean needSaveBeforeSwitchEnv(){ + return false; + } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 3372e2ad13..37812c106f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -416,9 +416,7 @@ public abstract class ToolBarMenuDock { menuDef.addShortCut(new OpenRecentReportMenuDef()); - if (!DesignModeContext.isDuchampMode()) { - addCloseCurrentTemplateAction(menuDef); - } + addCloseCurrentTemplateAction(menuDef); scs = plus.shortcut4FileMenu(); if (!ArrayUtils.isEmpty(scs)) { From 31b455b677c7c41304554bf03f5b1706fbdef664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Wed, 19 Apr 2023 13:58:31 +0800 Subject: [PATCH 30/59] =?UTF-8?q?REPORT-93422=20=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E5=BC=80=E6=94=BE=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?-=E5=8E=BB=E6=8E=89=E5=8D=95=E5=85=83=E6=A0=BC=E7=9A=84?= =?UTF-8?q?=E2=80=9C=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=E2=80=9D=E5=B1=9E?= =?UTF-8?q?=E6=80=A7--=E5=87=8F=E5=B0=91=E5=86=97=E4=BD=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractWidgetAdvancedPaneProvider.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java b/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java index 6b60eb56a8..45316a9f66 100644 --- a/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java +++ b/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java @@ -1,5 +1,6 @@ package com.fr.design.fun.impl; + import com.fr.design.fun.WidgetAdvancedPaneProvider; import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.mark.API; @@ -23,4 +24,24 @@ public abstract class AbstractWidgetAdvancedPaneProvider extends AbstractProv return getClass().getName(); } + protected WidgetType widgetType = WidgetType.PARA; + + /** + * 按钮类型:单元格 or 参数面板 + * + * @author John.Ying + * @version 11.0 + * Created by John.Ying on 2023/4/18 + */ + protected enum WidgetType { + /** + * 参数面板 + */ + PARA, + /** + * 单元格 + */ + CELL; + } + } From 95af815cb43f19ea5b74326ae0e91389b5e29d46 Mon Sep 17 00:00:00 2001 From: obo Date: Wed, 19 Apr 2023 13:59:50 +0800 Subject: [PATCH 31/59] =?UTF-8?q?REPORT-94231=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E8=B6=85=E9=93=BE=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E5=BC=95=E6=93=8E=E9=85=8D=E7=BD=AE=E9=9D=A2=E6=9D=BF=E8=B6=85?= =?UTF-8?q?=E9=93=BE=E6=9C=AA=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/locale/impl/LineEngineMark.java | 28 +++++++++++++++++++ .../fr/design/report/ReportEnginePane.java | 8 ++++-- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/locale/impl/LineEngineMark.java diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/LineEngineMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/LineEngineMark.java new file mode 100644 index 0000000000..a13617af24 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/LineEngineMark.java @@ -0,0 +1,28 @@ +package com.fr.design.locale.impl; + +import com.fr.design.i18n.LocaleLinkProvider; +import com.fr.general.locale.LocaleMark; + +/** + * 根据国际化获取启用行式引擎执行层式报表帮助文档链接 + * + * @author obo + * @since 11.0 + * Created on 2023/4/19 + */ +public class LineEngineMark implements LocaleMark { + + /** + * 云中心数据脱敏帮助链接链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Line_Engine"; + + /** + * 云中心数据脱敏默认帮助链接在配置文件中对应的配置文件key + */ + private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Line_Engine_Default"; + @Override + public String getValue() { + return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java b/designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java index 15dd2a3ea3..380809faf0 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java @@ -11,14 +11,15 @@ 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.locale.impl.LineEngineMark; import com.fr.design.mainframe.DesignerContext; import com.fr.design.widget.FRWidgetFactory; -import com.fr.general.SiteCenter; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; import com.fr.log.FineLoggerFactory; import com.fr.report.core.ReportUtils; import com.fr.report.stable.LayerReportAttr; import com.fr.report.worksheet.WorkSheet; -import com.fr.stable.ProductConstants; import javax.swing.AbstractButton; import javax.swing.BorderFactory; @@ -203,7 +204,8 @@ public class ReportEnginePane extends BasicBeanPane { @Override public void mouseClicked(MouseEvent e) { try { - Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("standard.doc", ProductConstants.WEBSITE_URL))); + LocaleMark lineEngineMark = LocaleCenter.getMark(LineEngineMark.class); + Desktop.getDesktop().browse(new URI(lineEngineMark.getValue())); } catch (IOException | URISyntaxException ex) { FineLoggerFactory.getLogger().error("io exception or not find website", ex); } From d3ac3cca7d80d106a8d45bfe0f151f4244c81a06 Mon Sep 17 00:00:00 2001 From: obo Date: Wed, 19 Apr 2023 14:11:53 +0800 Subject: [PATCH 32/59] =?UTF-8?q?REPORT-94231=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E8=B6=85=E9=93=BE=E5=9B=BD=E9=99=85=E5=8C=96-?= =?UTF-8?q?=E5=BC=95=E6=93=8E=E9=85=8D=E7=BD=AE=E9=9D=A2=E6=9D=BF=E8=B6=85?= =?UTF-8?q?=E9=93=BE=E6=9C=AA=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/locale/impl/LineEngineMark.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/LineEngineMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/LineEngineMark.java index a13617af24..ebb5fd09a3 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/LineEngineMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/LineEngineMark.java @@ -13,12 +13,12 @@ import com.fr.general.locale.LocaleMark; public class LineEngineMark implements LocaleMark { /** - * 云中心数据脱敏帮助链接链接在配置文件中对应的配置文件key + * 云中心启用行式引擎执行层式报表帮助链接链接在配置文件中对应的配置文件key */ private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Line_Engine"; /** - * 云中心数据脱敏默认帮助链接在配置文件中对应的配置文件key + * 云中心启用行式引擎执行层式报表默认帮助链接在配置文件中对应的配置文件key */ private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Line_Engine_Default"; @Override From 4205af519888844ec276158fd791ecb5019af456 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 19 Apr 2023 15:11:12 +0800 Subject: [PATCH 33/59] =?UTF-8?q?fix=EF=BC=9A=E5=88=A0=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/file/MultiTemplateTabMenuFactory.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java index 85b30f2d5b..6b5f9e324b 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java @@ -7,11 +7,9 @@ import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.TemplateUtils; -import com.fr.file.FILE; import com.fr.general.IOUtils; import com.fr.stable.StringUtils; import com.fr.stable.collections.CollectionUtils; -import com.fr.third.javax.annotation.Nonnull; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -113,15 +111,6 @@ public class MultiTemplateTabMenuFactory { } - private void closeAndFreeLock(@Nonnull JTemplate template) { - FILE file = template.getEditingFILE(); - // 只有是环境内的文件,才执行释放锁 - if (file != null && file.isEnvFile()) { - // release lock - TemplateResourceManager.getResource().closeTemplate(file.getPath()); - } - } - /** * 美观用 */ From 3db161b224b1395eaf430f9dd442c6a30c2e5c24 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 19 Apr 2023 15:54:36 +0800 Subject: [PATCH 34/59] =?UTF-8?q?REPORT-94198=20=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E8=B4=9F=E8=BD=BD=E5=9D=87=E8=A1=A1=E8=8A=82?= =?UTF-8?q?=E7=82=B9=EF=BC=8C=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=BF=9E=E6=8E=A5=E6=96=AD=E5=BC=80=E7=9A=84?= =?UTF-8?q?=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/socketio/DesignerSocketIO.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 4b5c287ff5..922e1e4724 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -32,6 +32,7 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.base.WorkspaceConstants; import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.engine.exception.WorkspaceConnectionException; import com.fr.workspace.server.socket.CustomLogEvent; import com.fr.workspace.server.socket.LogEventConverter; import io.socket.client.IO; @@ -207,6 +208,7 @@ public class DesignerSocketIO { if (checkRPCConnect()) { showSocketDisconnectToast(); } else { + FineLoggerFactory.getLogger().info("检查不通过"); showRPCDisconnectDialog(); } } @@ -271,6 +273,11 @@ public class DesignerSocketIO { httpGet.setConfig(requestConfig); try { CloseableHttpResponse response = httpclient.execute(httpGet); + if (isErrorStatus(response.getStatusLine().getStatusCode())) { + //这边nginx做负载,服务器被kill掉,返回的是502,不会抛错,导致checkRPCConnect通过 + //针对500-600的错误码加个判断,其他类型的状态码暂不考虑,如果有遇到再处理,不然怕影响范围大 + throw new WorkspaceConnectionException("Response " + response.getStatusLine().toString()); + } } catch (Exception e) { FineLoggerFactory.getLogger().error(e, e.getMessage()); return false; @@ -278,6 +285,23 @@ public class DesignerSocketIO { return true; } + /** + * 错误状态码 + * 5xx(服务器错误)这些状态代码表示服务器在尝试处理请求时发生内部错误。 这些错误可能是服务器本身的错误,而不是请求出错。代码 说明 + * 500 (服务器内部错误) 服务器遇到错误,无法完成请求。 + * 501 (尚未实施) 服务器不具备完成请求的功能。 例如,服务器无法识别请求方法时可能会返回此代码。 + * 502 (错误网关) 服务器作为网关或代理,从上游服务器收到无效响应。 + * 503 (服务不可用) 服务器目前无法使用(由于超载或停机维护)。 通常,这只是暂时状态。 + * 504 (网关超时) 服务器作为网关或代理,但是没有及时从上游服务器收到请求。 + * 505 (HTTP 版本不受支持) 服务器不支持请求中所用的 HTTP 协议版本。 + * + * @param status 错误状态码 + * @return 是否是错误状态码 + */ + private static boolean isErrorStatus(int status) { + return status >= 500 && status <= 600; + } + //配置变更监听器 private static final Emitter.Listener modifyConfig = new Emitter.Listener() { @Override From b5bc39168f297ab1ed898106e2d6f500386a0c17 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 19 Apr 2023 15:55:48 +0800 Subject: [PATCH 35/59] =?UTF-8?q?REPORT-94198=20=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E8=B4=9F=E8=BD=BD=E5=9D=87=E8=A1=A1=E8=8A=82?= =?UTF-8?q?=E7=82=B9=EF=BC=8C=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=BF=9E=E6=8E=A5=E6=96=AD=E5=BC=80=E7=9A=84?= =?UTF-8?q?=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mainframe/socketio/DesignerSocketIO.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 922e1e4724..3ceef3ae28 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -208,7 +208,6 @@ public class DesignerSocketIO { if (checkRPCConnect()) { showSocketDisconnectToast(); } else { - FineLoggerFactory.getLogger().info("检查不通过"); showRPCDisconnectDialog(); } } From eabb150e50051e98686f0d184993d604c382cafa Mon Sep 17 00:00:00 2001 From: "Sky.Luo" Date: Wed, 19 Apr 2023 16:47:03 +0800 Subject: [PATCH 36/59] =?UTF-8?q?REPORT-94131=20&=20REPORT-94167=20&=20REP?= =?UTF-8?q?ORT-94195=20&=20REPORT-94260=20&=20REPORT-94149=20&=20REPORT-94?= =?UTF-8?q?105=20fix:=20=E5=A2=9E=E5=8A=A0=E5=AD=98=E5=82=A8=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=E6=95=B0=E6=8D=AE=E9=9B=86=E6=B7=BB=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=20&=20=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E8=8E=B7=E5=8F=96=20&=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E9=A2=84=E8=A7=88=E5=8F=96=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=90=BA=E5=B8=A6=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/data/DesignTableDataManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index 175af0653f..712dcbd33b 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -669,6 +669,7 @@ public abstract class DesignTableDataManager { if (needLoadingBar) { MultiResultTableDataWrapper.loadingBar.start(); } + parameterMap.put(SqlNoteConstants.SQL_NOTE_TEMPLATE, HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); return DataOperator.getInstance().previewMultiResultTableData(tableData, parameterMap, 0); } From 02a13b696d0935477db7412320dd91c90ee48eac Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 20 Apr 2023 13:49:50 +0800 Subject: [PATCH 37/59] =?UTF-8?q?REPORT-94324=20=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=EF=BC=8C=E6=8A=A5=E8=A1=A8=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=B8=8B=E5=8F=8C=E5=87=BB=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E6=97=B6=E6=B2=A1=E6=9C=89=E9=AB=98=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/file/FILEChooserPane.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 0561319db4..b114ef2b40 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -1466,10 +1466,17 @@ public class FILEChooserPane extends BasicPane { for (int i = 0; i < this.buttonList.size(); i++) { this.buttonList.get(i).setForeground(null); if (((SetDirectoryAction) this.buttonList.get(i).getAction()).getDir() != null - && this.buttonList.get(i).getAction() instanceof SetDirectoryAction - && (ComparatorUtils.equals(((SetDirectoryAction) this.buttonList.get(i).getAction()).getDir().getPath(), dir.getPath()))) { - - this.buttonList.get(i).setForeground(Color.BLUE); + && this.buttonList.get(i).getAction() instanceof SetDirectoryAction) { + String actionPath = ((SetDirectoryAction) this.buttonList.get(i).getAction()).getDir().getPath(); + String dirPath = dir.getPath(); + //如果是报表环境,button的Action最后会跟上"/",这个是特意处理的,但是对应代码没有说明原因,不做修改 + //FILE的getPath不会带"/",这边针对这种情况加个处理,不建议直接改FILE + if (actionPath.endsWith("/") && !dirPath.endsWith("/")) { + dirPath = dirPath + "/"; + } + if (ComparatorUtils.equals(actionPath, dirPath)) { + this.buttonList.get(i).setForeground(Color.BLUE); + } } } } From c296181cb7620260a8c2d1136baf2bd80cfc2f8d Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 20 Apr 2023 14:32:04 +0800 Subject: [PATCH 38/59] =?UTF-8?q?REPORT-93215=20=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=90=8D=E7=A7=B0=E5=8C=85=E5=90=AB=E4=BA=8E?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E6=AC=A1=E9=80=89=E7=9A=84=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=EF=BC=8C=E4=BF=9D=E5=AD=98=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E7=9A=84=E8=B7=AF=E5=BE=84=E4=B8=8D=E4=BC=9A=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/file/FILEChooserPane.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index b114ef2b40..aeccebcc71 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -1486,7 +1486,7 @@ public class FILEChooserPane extends BasicPane { } public void populate(FILE dir) { - if (popDir != null && dir != null && popDir.toString().indexOf(dir.toString()) == 0) { + if (checkOnlyHighLight(dir)) { highLightButton(dir); return; } @@ -1537,6 +1537,24 @@ public class FILEChooserPane extends BasicPane { highLightButton(dir); } + /** + * 检查是不是只需要设置高亮即可 + * + * @param dir FILE + * @return 如果还要进行别的设置就返回false,如果只需要更新下高亮(通过点击上面的路径才会只需要更新高亮),返回true + */ + private boolean checkOnlyHighLight(FILE dir) { + if (popDir == null || dir == null) { + return false; + } + String popDirStr = popDir.toString(); + String dirStr = dir.toString(); + //前缀匹配是不够的,还要看下前缀匹配的下一位是不是'/' + //否则"test"和"test副本"明明不属于同个路径逻辑,也只更新高亮,应该是"test"和"test/副本"这样才可以通过 + //如果通过了indexOf的检查,因为不会存在相同的路径,popDirStr只会比dirStr大,看一下前缀匹配的下一位是不是'/',如果不是就得更新路径文本,不能只设置高亮 + return popDirStr.indexOf(dirStr) == 0 && popDirStr.length() > dirStr.length() && popDirStr.charAt(dirStr.length()) == '/'; + } + // doLayout @Override public void doLayout() { From bc98c499b881297854c1a59391b465b1520d6390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Thu, 20 Apr 2023 16:16:02 +0800 Subject: [PATCH 39/59] =?UTF-8?q?REPORT-94359=20=E6=96=B0=E5=BB=BAfvs?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF-=E8=BD=AE=E6=92=AD=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E9=BD=BF=E8=BD=AE=E5=9B=BE=E6=95=B0=E6=8D=AE=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=AA=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/ChartPropertyPane.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java index 8e6b80c53a..297245960d 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java @@ -97,25 +97,16 @@ public class ChartPropertyPane extends BaseChartPropertyPane { * @param ePane 面板 */ public void populateChartPropertyPane(ChartCollection collection, TargetComponent ePane) { - new SwingWorker() { - @Override - protected Void doInBackground() throws Exception { - GEOJSONHelper.getInstance(); - return null; - } - @Override - protected void done() { - String chartID = collection.getSelectedChartProvider(ChartProvider.class).getID(); - updateChartEditPane(collection.getSelectedChartProvider(ChartProvider.class).getID()); - setSupportCellData(true); - container.setEPane(ePane); - if (ChartTypeManager.getInstance().chartExit(chartID)) { - chartEditPane.populate(collection); - } else { - GUICoreUtils.setEnabled(chartEditPane, false); - } - } - }.execute(); + String chartID = collection.getSelectedChartProvider(ChartProvider.class).getID(); + updateChartEditPane(collection.getSelectedChartProvider(ChartProvider.class).getID()); + setSupportCellData(true); + this.container.setEPane(ePane); + + if (ChartTypeManager.getInstance().chartExit(chartID)) { + chartEditPane.populate(collection); + } else { + GUICoreUtils.setEnabled(chartEditPane, false); + } } /** From 67da995c385a57f50a2419e42c30b47fcd3dcb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Thu, 20 Apr 2023 16:18:37 +0800 Subject: [PATCH 40/59] =?UTF-8?q?REPORT-94359=20=E6=96=B0=E5=BB=BAfvs?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF-=E8=BD=AE=E6=92=AD=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E9=BD=BF=E8=BD=AE=E5=9B=BE=E6=95=B0=E6=8D=AE=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=9C=AA=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractWidgetAdvancedPaneProvider.java | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java b/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java index 45316a9f66..eb0c1aa477 100644 --- a/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java +++ b/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java @@ -1,6 +1,4 @@ package com.fr.design.fun.impl; - - import com.fr.design.fun.WidgetAdvancedPaneProvider; import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.mark.API; @@ -24,24 +22,4 @@ public abstract class AbstractWidgetAdvancedPaneProvider extends AbstractProv return getClass().getName(); } - protected WidgetType widgetType = WidgetType.PARA; - - /** - * 按钮类型:单元格 or 参数面板 - * - * @author John.Ying - * @version 11.0 - * Created by John.Ying on 2023/4/18 - */ - protected enum WidgetType { - /** - * 参数面板 - */ - PARA, - /** - * 单元格 - */ - CELL; - } - } From 56d0d4f9969d5e4a5328e64cca445b03f188248e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Thu, 20 Apr 2023 16:19:30 +0800 Subject: [PATCH 41/59] REPORT-94359 conflict --- .../fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java b/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java index eb0c1aa477..6b60eb56a8 100644 --- a/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java +++ b/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java @@ -1,4 +1,5 @@ package com.fr.design.fun.impl; + import com.fr.design.fun.WidgetAdvancedPaneProvider; import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.mark.API; From dda0ca8794cd1e51b589728576dbfdfafd582de8 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 21 Apr 2023 10:12:41 +0800 Subject: [PATCH 42/59] =?UTF-8?q?REPORT-93215=20=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=90=8D=E7=A7=B0=E5=8C=85=E5=90=AB=E4=BA=8E?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E6=AC=A1=E9=80=89=E7=9A=84=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=EF=BC=8C=E4=BF=9D=E5=AD=98=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E7=9A=84=E8=B7=AF=E5=BE=84=E4=B8=8D=E4=BC=9A=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/file/FILEChooserPane.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index aeccebcc71..66b9d12d3d 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -129,6 +129,10 @@ public class FILEChooserPane extends BasicPane { public static final int JOPTIONPANE_CANCEL_OPTION = 3; + public static final String SEPARATOR_STRING = "/"; + + public static final char SEPARATOR_CHAR = '/'; + /** * alex:之所以在Pattern那里加个+,是因为有些路径会有两个甚至多个分隔符放在一起 @@ -1471,8 +1475,8 @@ public class FILEChooserPane extends BasicPane { String dirPath = dir.getPath(); //如果是报表环境,button的Action最后会跟上"/",这个是特意处理的,但是对应代码没有说明原因,不做修改 //FILE的getPath不会带"/",这边针对这种情况加个处理,不建议直接改FILE - if (actionPath.endsWith("/") && !dirPath.endsWith("/")) { - dirPath = dirPath + "/"; + if (actionPath.endsWith(SEPARATOR_STRING) && !dirPath.endsWith(SEPARATOR_STRING)) { + dirPath = dirPath + SEPARATOR_STRING; } if (ComparatorUtils.equals(actionPath, dirPath)) { this.buttonList.get(i).setForeground(Color.BLUE); @@ -1552,7 +1556,7 @@ public class FILEChooserPane extends BasicPane { //前缀匹配是不够的,还要看下前缀匹配的下一位是不是'/' //否则"test"和"test副本"明明不属于同个路径逻辑,也只更新高亮,应该是"test"和"test/副本"这样才可以通过 //如果通过了indexOf的检查,因为不会存在相同的路径,popDirStr只会比dirStr大,看一下前缀匹配的下一位是不是'/',如果不是就得更新路径文本,不能只设置高亮 - return popDirStr.indexOf(dirStr) == 0 && popDirStr.length() > dirStr.length() && popDirStr.charAt(dirStr.length()) == '/'; + return popDirStr.indexOf(dirStr) == 0 && popDirStr.length() > dirStr.length() && popDirStr.charAt(dirStr.length()) == SEPARATOR_CHAR; } // doLayout From 01a39012f70e14684ef0bbb17b8afe9d0349ae99 Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 21 Apr 2023 11:12:23 +0800 Subject: [PATCH 43/59] =?UTF-8?q?REPORT-94458=20JS=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=9D=A2=E6=9D=BF=E5=B8=AE=E5=8A=A9=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/javascript/JSContentWithDescriptionPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java index 3b8d04ffb3..74b1596207 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JSContentWithDescriptionPane.java @@ -391,7 +391,7 @@ public class JSContentWithDescriptionPane extends JSContentPane implements KeyLi } private void updateHelpDocuments(Object value, List helpDocuments) { - String url = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); + String url = LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT) + value.toString(); try { String result = HttpToolbox.get(url); JSONObject jsonObject = new JSONObject(result); From 9ce5a14621f7aa3d83e6ccf790a8538f59cf0439 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Fri, 21 Apr 2023 14:15:15 +0800 Subject: [PATCH 44/59] =?UTF-8?q?REPORT-94114=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E9=9D=A2=E6=9D=BF=E5=9B=BE=E8=A1=A8=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E7=BC=BA=E5=A4=B1=20=E3=80=90=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=E6=B2=A1=E6=9C=89=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=BD=93=E5=89=8D=E6=98=AF=E5=86=B3=E7=AD=96=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E5=9B=BE=E8=A1=A8=E8=BF=98=E6=98=AF=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=9B=BE=E8=A1=A8=EF=BC=8C=E4=B8=A4=E8=80=85?= =?UTF-8?q?=E7=9A=84=E8=B6=85=E9=93=BE=E9=80=89=E9=A1=B9=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E5=BD=93=E5=89=8D=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/VanChartHyperLinkPane.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java index 75ec5d3ce2..34375790f3 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java @@ -309,12 +309,19 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane { if (!JTemplate.isValid(template)) { return false; } - Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; - for (Class aClass : classes) { - if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { - // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项 - if (ComparatorUtils.equals(aClass, clazz)) { - return false; + + if (template.isJWorkBook()) { + // 如果是普通报表单元格,那么没有 FormHyperlink 选项 + FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); + return !ComparatorUtils.equals(clazz, formHyperlink.getClass()); + } else { + // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项 + Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; + for (Class aClass : classes) { + if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { + if (ComparatorUtils.equals(aClass, clazz)) { + return false; + } } } } From 059e7cfb2c482515240d2c6a6157d1e0684c726e Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Fri, 21 Apr 2023 16:30:19 +0800 Subject: [PATCH 45/59] =?UTF-8?q?REPORT-94114=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E9=9D=A2=E6=9D=BF=E5=9B=BE=E8=A1=A8=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E7=BC=BA=E5=A4=B1=20=E4=BF=AE=E6=94=B9=20frm?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=9D=97=E4=B8=AD=E7=9A=84=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E8=B6=85=E9=93=BE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../van/chart/custom/component/VanChartHyperLinkPane.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java index 34375790f3..bdd3608c9e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java @@ -315,10 +315,15 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane { FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); return !ComparatorUtils.equals(clazz, formHyperlink.getClass()); } else { - // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项 + // 如果是决策报表 + if (template.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB) { + // 编辑的是决策报表中的报表块,那么没有 ChartHyperRelateFloatLink选项 + return !ComparatorUtils.equals(clazz, ChartHyperRelateFloatLink.class); + } Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; for (Class aClass : classes) { if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { + // 编辑的是决策报表中的图表,那么没有 ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项 if (ComparatorUtils.equals(aClass, clazz)) { return false; } From cab83ef74b6bc2cb1255fdafb5a84215789dd00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Sat, 22 Apr 2023 22:08:09 +0800 Subject: [PATCH 46/59] =?UTF-8?q?REPORT-92628=20=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=BB=E9=A2=98=E5=88=87=E6=8D=A2-?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=8E=A7=E4=BB=B6=E6=9C=AA=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E6=A0=B7=E5=BC=8F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/widget/btn/ButtonConstants.java | 16 ++ .../design/widget/btn/ButtonDetailPane.java | 62 ------- .../design/widget/btn/ButtonDetailPane.java | 151 ++++++++++++++++++ .../btn/ButtonWithHotkeysDetailPane.java | 11 +- .../ui/btn/FormSubmitButtonDetailPane.java | 15 +- .../ui/btn/AppendRowButtonDefinePane.java | 20 ++- .../ui/btn/DefaultButtonDetailPane.java | 17 ++ .../ui/btn/DeleteRowButtonDefinePane.java | 17 +- .../widget/ui/btn/FreeButtonDetailPane.java | 19 ++- 9 files changed, 259 insertions(+), 69 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java create mode 100644 designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java rename {designer-base => designer-form}/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java (90%) diff --git a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonConstants.java b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonConstants.java index 9be9a8fba4..85b2cbc08e 100644 --- a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonConstants.java +++ b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonConstants.java @@ -44,4 +44,20 @@ public class ButtonConstants { StableFactory.getMarkedClass(BridgeMark.SUBMIT_BUTTON, Widget.class), StableFactory.getMarkedClass(BridgeMark.TREE_NODE_TOGGLE_BUTTON, Widget.class) }; + + public static final String[] TYPES4BUTTON4STRONGEST_CONTROL = { + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Common"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Insert_Row"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Delete_Row"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Type_Parameter_Submit"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_TreeNode") + }; + + public static final Class[] CLASSES4BUTTON4STRONGEST_CONTROL = { + Button.class, + StableFactory.getMarkedClass(BridgeMark.APPEND_ROW_BUTTON, Widget.class), + StableFactory.getMarkedClass(BridgeMark.DELETE_ROW_BUTTON, Widget.class), + StableFactory.getMarkedClass(BridgeMark.SUBMIT_BUTTON, Widget.class), + StableFactory.getMarkedClass(BridgeMark.TREE_NODE_TOGGLE_BUTTON, Widget.class) + }; } diff --git a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java deleted file mode 100644 index 63d678577a..0000000000 --- a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.fr.design.widget.btn; - -import com.fr.design.gui.icombobox.DictionaryComboBox; -import com.fr.design.dialog.BasicPane; -import com.fr.design.widget.btn.ButtonConstants; -import com.fr.form.ui.Button; - - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by IntelliJ IDEA. - * Author : Richer - * Version: 6.5.6 - * Date : 11-11-15 - * Time : 下午6:21 - */ -public abstract class ButtonDetailPane extends BasicPane { - private List ls = new ArrayList(); - - @Override - public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Button"); - } - - public void populate(T button) { - - } - - public abstract T createButton(); - - public abstract T update(); - - protected void typeChange(Object obj) { - for (int i = 0, len = ls.size(); i < len; i++) { - ls.get(i).stateChanged(new ChangeEvent(obj)); - } - } - - public void addTypeChangeListener(ChangeListener l) { - ls.add(l); - } - - public abstract Class classType(); - - protected DictionaryComboBox createButtonTypeComboBox() { - final DictionaryComboBox dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false); - dictionaryComboBox.setSelectedItem(classType()); - dictionaryComboBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - typeChange(dictionaryComboBox.getSelectedItem()); - } - }); - return dictionaryComboBox; - } -} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java b/designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java new file mode 100644 index 0000000000..81e28bf296 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/btn/ButtonDetailPane.java @@ -0,0 +1,151 @@ +package com.fr.design.widget.btn; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.WidgetAdvancedPaneProvider; +import com.fr.design.gui.icombobox.DictionaryComboBox; +import com.fr.design.dialog.BasicPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.form.ui.Button; +import com.fr.general.GeneralContext; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; + + +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * Created by IntelliJ IDEA. + * Author : Richer + * Version: 6.5.6 + * Date : 11-11-15 + * Time : 下午6:21 + */ +public abstract class ButtonDetailPane extends BasicPane { + private List ls = new ArrayList(); + protected final List> extraPaneList = new ArrayList<>(); + protected JPanel extraPane; + protected boolean containsExtraPane; + protected static double F = TableLayout.FILL; + protected static double P = TableLayout.PREFERRED; + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Button"); + } + + public void populate(T button) { + + } + + public abstract T createButton(); + + public abstract T update(); + + protected void typeChange(Object obj) { + for (int i = 0, len = ls.size(); i < len; i++) { + ls.get(i).stateChanged(new ChangeEvent(obj)); + } + } + + public void addTypeChangeListener(ChangeListener l) { + ls.add(l); + } + + public abstract Class classType(); + + protected DictionaryComboBox createButtonTypeComboBox() { +// final DictionaryComboBox dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false); +// dictionaryComboBox.setSelectedItem(classType()); +// dictionaryComboBox.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// typeChange(dictionaryComboBox.getSelectedItem()); +// } +// }); +// return dictionaryComboBox; + return createButtonTypeComboBox(false); + } + + private DictionaryComboBox initDictionaryComboBox(DictionaryComboBox dictionaryComboBox) { + dictionaryComboBox.setSelectedItem(classType()); + dictionaryComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + typeChange(dictionaryComboBox.getSelectedItem()); + } + }); + return dictionaryComboBox; +// return createButtonTypeComboBox(); + } + + protected DictionaryComboBox createButtonTypeComboBox(Boolean containsExtraPane) { + final DictionaryComboBox dictionaryComboBox; + if (!containsExtraPane) { + dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON, ButtonConstants.TYPES4BUTTON, false); + } else { + dictionaryComboBox = new DictionaryComboBox(ButtonConstants.CLASSES4BUTTON4STRONGEST_CONTROL, ButtonConstants.TYPES4BUTTON4STRONGEST_CONTROL, false); + } + return initDictionaryComboBox(dictionaryComboBox); + } + + + + protected void initExtraPane() { + initPluginListener(); + refreshExtraAdvancedPane(); + } + + protected void refreshExtraAdvancedPane() { + // do nothing + } + + protected void refreshExtraAdvancedPane(Class cls) { + extraPaneList.clear(); + boolean containsExtraPane = false; + Set> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG); + for (WidgetAdvancedPaneProvider provider : providers) { + if (!provider.accept(cls)) { + continue; + } + insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane()); + containsExtraPane = true; + } + if (containsExtraPane) { + extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); + for (BasicBeanPane pane : extraPaneList) { + extraPane.add(pane); + } + } + this.containsExtraPane = containsExtraPane; + + } + + protected void initPluginListener() { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + refreshExtraAdvancedPane(); + } + }, pluginContext -> pluginContext.getRuntime().contain(WidgetAdvancedPaneProvider.XML_TAG)); + } + + /** + * 插入配置项面板 + * + * @param index 插入的位置 + * @param pane 配置项面板 + */ + protected void insertShortCut(int index, BasicBeanPane pane) { + int size = extraPaneList.size(); + index = Math.min(index, size); + extraPaneList.add(index, pane); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java b/designer-form/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java similarity index 90% rename from designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java rename to designer-form/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java index b75aeaa81f..904126e9d0 100644 --- a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java @@ -4,6 +4,7 @@ import java.awt.*; import javax.swing.*; +import com.fr.design.beans.BasicBeanPane; import com.fr.design.designer.IntervalConstants; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ilable.UILabel; @@ -42,8 +43,9 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt JPanel labelPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); iconPane = new AccessibleIconEditor(); labelPane.add(iconPane); + Component comp = createCenterPane(); Component[][] n_components = { - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Button_Type")), createButtonTypeComboBox()}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Button_Type")), createButtonTypeComboBox(containsExtraPane)}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Name")), buttonNameTextField = new UITextField()}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Icon")), iconPane}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Hot_keys")), hotkeysTextField = new UITextField()}, @@ -52,7 +54,6 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt JPanel panel = TableLayoutHelper.createGapTableLayoutPane(n_components, rowSize, columnSize, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); advancePane.add(panel, BorderLayout.NORTH); - Component comp = createCenterPane(); if(comp != null ) { advancePane.add(comp,BorderLayout.CENTER); } @@ -71,6 +72,9 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt iconPane.setValue(button.getIconName()); buttonNameTextField.setText(button.getText()); hotkeysTextField.setText(button.getHotkeys()); + for (BasicBeanPane pane : extraPaneList) { + pane.populateBean(button); + } } @Override @@ -79,6 +83,9 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt button.setIconName((String)iconPane.getValue()); button.setText(buttonNameTextField.getText()); button.setHotkeys(hotkeysTextField.getText()); + for (BasicBeanPane pane : extraPaneList) { + pane.updateBean(button); + } return button; } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/btn/FormSubmitButtonDetailPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/btn/FormSubmitButtonDetailPane.java index acc2e76c4e..83d24e8e87 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/btn/FormSubmitButtonDetailPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/btn/FormSubmitButtonDetailPane.java @@ -1,5 +1,6 @@ package com.fr.design.widget.ui.btn; +import com.fr.design.layout.TableLayoutHelper; import com.fr.form.parameter.FormSubmitButton; import com.fr.design.widget.btn.ButtonWithHotkeysDetailPane; @@ -16,7 +17,14 @@ public class FormSubmitButtonDetailPane extends ButtonWithHotkeysDetailPane

extends Button @Override protected Component createCenterPane() { - return defineColumnRowPane = new DefineAppendColumnRowPane(); + initExtraPane(); + defineColumnRowPane = new DefineAppendColumnRowPane(); + Component[][] components = new Component[][]{ + new Component[]{defineColumnRowPane, null}, + new Component[]{extraPane, null} + }; + double[] rowSize = {P, P}; + double[] columnSize = {P, F}; + int[][] rowCount = {{1, 1},{1, 1}}; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 10, 7); } @Override @@ -55,4 +68,9 @@ public class AppendRowButtonDefinePane extends Button public Class classType() { return AppendRowButton.class; } + + @Override + protected void refreshExtraAdvancedPane() { + super.refreshExtraAdvancedPane(AppendRowButton.class); + } } diff --git a/designer-realize/src/main/java/com/fr/design/widget/ui/btn/DefaultButtonDetailPane.java b/designer-realize/src/main/java/com/fr/design/widget/ui/btn/DefaultButtonDetailPane.java index e7f621ccb4..326bcbbfcc 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/ui/btn/DefaultButtonDetailPane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/ui/btn/DefaultButtonDetailPane.java @@ -1,5 +1,6 @@ package com.fr.design.widget.ui.btn; +import com.fr.design.layout.TableLayoutHelper; import com.fr.form.ui.Button; import com.fr.form.ui.FreeButton; import com.fr.design.widget.btn.ButtonWithHotkeysDetailPane; @@ -14,6 +15,16 @@ public class DefaultButtonDetailPane extends ButtonWithHotkeysDetailPane