From c89f013405bcfe5242cb7499f3f1070c9b6c2d04 Mon Sep 17 00:00:00 2001 From: zack Date: Fri, 19 Apr 2019 17:38:01 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-16249=2010OEM=E7=9A=84=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E9=A1=B5=E6=9B=BF=E6=8D=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/fun/OemProcessor.java | 33 +++++++++++++++++++ .../design/fun/impl/AbstractOemProcessor.java | 25 ++++++++++++++ .../fr/design/mainframe/DesignerFrame.java | 12 +++++-- .../mainframe/toolbar/ToolBarMenuDock.java | 7 ++++ .../main/java/com/fr/start/OemActivator.java | 27 +++++++++++++++ .../main/java/com/fr/start/OemHandler.java | 18 ++++++++++ .../src/main/java/com/fr/start/OemImpl.java | 7 ++++ .../fr/start/module/PreStartActivator.java | 10 +++++- 8 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/fun/OemProcessor.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractOemProcessor.java create mode 100644 designer-base/src/main/java/com/fr/start/OemActivator.java create mode 100644 designer-base/src/main/java/com/fr/start/OemHandler.java create mode 100644 designer-base/src/main/java/com/fr/start/OemImpl.java diff --git a/designer-base/src/main/java/com/fr/design/fun/OemProcessor.java b/designer-base/src/main/java/com/fr/design/fun/OemProcessor.java new file mode 100644 index 0000000000..01e53c9c56 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/OemProcessor.java @@ -0,0 +1,33 @@ +package com.fr.design.fun; + +import com.fr.design.menu.MenuDef; +import com.fr.start.SplashStrategy; + +import java.awt.image.BufferedImage; +import java.util.List; + +/** + * 设计器Oem接口 + */ +public interface OemProcessor { + /** + * 启动动画,如果不替换则返回null + * @return + */ + SplashStrategy createSplashStrategy(); + + /** + * 替换标题图标--DesignerFrame.initTitleIcon + * 如果不替换则返回null + * @return + */ + List createTitleIcon(); + + /** + * 处理设计器菜单(增删改) + * @param menuDefs 已加载的菜单 + * @return 新的菜单数组 + */ + MenuDef[] dealWithMenuDef(MenuDef[] menuDefs); + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractOemProcessor.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractOemProcessor.java new file mode 100644 index 0000000000..d49bfdf246 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractOemProcessor.java @@ -0,0 +1,25 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.OemProcessor; +import com.fr.design.menu.MenuDef; +import com.fr.start.SplashStrategy; + +import java.awt.image.BufferedImage; +import java.util.List; + +public abstract class AbstractOemProcessor implements OemProcessor{ + @Override + public MenuDef[] dealWithMenuDef(MenuDef[] menuDefs) { + return menuDefs; + } + + @Override + public List createTitleIcon() { + return null; + } + + @Override + public SplashStrategy createSplashStrategy() { + return null; + } +} \ No newline at end of file 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 55e07cc1ce..397fd312a8 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 @@ -24,6 +24,7 @@ import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.NewTemplatePane; import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.file.TemplateTreePane; +import com.fr.design.fun.OemProcessor; import com.fr.design.fun.TitlePlaceProcessor; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; import com.fr.design.gui.ibutton.UIButton; @@ -57,6 +58,7 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.project.ProjectConstants; +import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceConnectionInfo; @@ -458,8 +460,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta try { @SuppressWarnings("unchecked") - List image = ICODecoder.read(DesignerFrame.class - .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); + OemProcessor oemProcessor = OemHandler.findOem(); + List image; + if (oemProcessor != null && oemProcessor.createTitleIcon() != null) { + image = oemProcessor.createTitleIcon(); + } else { + image = ICODecoder.read(DesignerFrame.class + .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); + } this.setIconImages(image); } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); 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 ff31f01564..4459bd554d 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 @@ -38,6 +38,7 @@ import com.fr.design.actions.server.PlatformManagerAction; import com.fr.design.actions.server.PluginManagerAction; import com.fr.design.file.NewTemplatePane; import com.fr.design.fun.MenuHandler; +import com.fr.design.fun.OemProcessor; import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -64,6 +65,7 @@ import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; +import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import javax.swing.JComponent; @@ -200,6 +202,11 @@ public abstract class ToolBarMenuDock { }; this.menus = menus(plus); + OemProcessor oemProcessor = OemHandler.findOem(); + if (oemProcessor != null) { + this.menus = oemProcessor.dealWithMenuDef(this.menus); + } + for (int i = 0; i < menus.length; i++) { menus[i].setHasRecMenu(true); UIMenu subMenu = menus[i].createJMenu(); diff --git a/designer-base/src/main/java/com/fr/start/OemActivator.java b/designer-base/src/main/java/com/fr/start/OemActivator.java new file mode 100644 index 0000000000..6e3bba6036 --- /dev/null +++ b/designer-base/src/main/java/com/fr/start/OemActivator.java @@ -0,0 +1,27 @@ +package com.fr.start; + +import com.fr.design.fun.OemProcessor; +import com.fr.module.Activator; +import com.fr.module.extension.Prepare; + +/** + * 设计器OEM注册 + */ +public class OemActivator extends Activator implements Prepare { + + @Override + public void start() { + } + + @Override + public void stop() { + + } + + @Override + public void prepare() { + // 加入Oem + setSingleton(OemProcessor.class, new OemImpl()); + } + +} diff --git a/designer-base/src/main/java/com/fr/start/OemHandler.java b/designer-base/src/main/java/com/fr/start/OemHandler.java new file mode 100644 index 0000000000..ff56bc1735 --- /dev/null +++ b/designer-base/src/main/java/com/fr/start/OemHandler.java @@ -0,0 +1,18 @@ +package com.fr.start; + +import com.fr.design.fun.OemProcessor; +import com.fr.module.Module; +import com.fr.module.ModuleContext; + +/** + * OEM处理中心 + */ +public class OemHandler { + public static OemProcessor findOem() { + Module oemModule = ModuleContext.getModule(OemActivator.class); + if (oemModule != null) { + return oemModule.getSingleton(OemProcessor.class); + } + return null; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/start/OemImpl.java b/designer-base/src/main/java/com/fr/start/OemImpl.java new file mode 100644 index 0000000000..68bf767c80 --- /dev/null +++ b/designer-base/src/main/java/com/fr/start/OemImpl.java @@ -0,0 +1,7 @@ +package com.fr.start; + +import com.fr.design.fun.impl.AbstractOemProcessor; + +public class OemImpl extends AbstractOemProcessor{ + +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java index 1dd95cf6ad..9f6f751229 100644 --- a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java @@ -2,6 +2,7 @@ package com.fr.start.module; import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; +import com.fr.design.fun.OemProcessor; import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignerPort; @@ -123,7 +124,14 @@ public class PreStartActivator extends Activator { service.shutdown(); } - private static SplashStrategy createSplash() { + private SplashStrategy createSplash() { + OemProcessor oemProcessor = getSingleton(OemProcessor.class); + if (oemProcessor != null) { + SplashStrategy splashStrategy = oemProcessor.createSplashStrategy(); + if (splashStrategy != null) { + return splashStrategy; + } + } // 这里可以开接口加载自定义启动画面 if (OperatingSystem.isWindows()) { return new SplashFx(); From 154ef0b8ad75dd5b97418dcc1f4043b6cbf2e07a Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 23 Apr 2019 09:39:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B7=9Fju=E8=AE=A8=E8=AE=BA=EF=BC=8COEM?= =?UTF-8?q?=E8=BF=99=E4=B8=AA=E8=BF=98=E6=98=AFStableFactory=E6=AF=94?= =?UTF-8?q?=E8=BE=83=E5=90=88=E9=80=82=E4=BA=8C=E5=BC=80.=E5=8F=A6?= =?UTF-8?q?=E5=A4=96=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=8D=95=E8=8E=B7=EF=BC=8C=E8=A7=84=E9=81=BF=E5=BC=80=E6=94=BE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AD=98=E5=9C=A8=E7=9A=84=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E9=A3=8E=E9=99=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/fun/OemProcessor.java | 5 ++++ .../fr/design/mainframe/DesignerFrame.java | 13 ++++++--- .../mainframe/toolbar/ToolBarMenuDock.java | 16 ++++++++--- .../main/java/com/fr/start/OemActivator.java | 27 ------------------- .../main/java/com/fr/start/OemHandler.java | 10 +++---- .../fr/start/module/PreStartActivator.java | 10 +++++-- 6 files changed, 37 insertions(+), 44 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/start/OemActivator.java diff --git a/designer-base/src/main/java/com/fr/design/fun/OemProcessor.java b/designer-base/src/main/java/com/fr/design/fun/OemProcessor.java index 01e53c9c56..44acc11902 100644 --- a/designer-base/src/main/java/com/fr/design/fun/OemProcessor.java +++ b/designer-base/src/main/java/com/fr/design/fun/OemProcessor.java @@ -10,8 +10,11 @@ import java.util.List; * 设计器Oem接口 */ public interface OemProcessor { + public static final String MARK_STRING = "OemProcessor"; + /** * 启动动画,如果不替换则返回null + * * @return */ SplashStrategy createSplashStrategy(); @@ -19,12 +22,14 @@ public interface OemProcessor { /** * 替换标题图标--DesignerFrame.initTitleIcon * 如果不替换则返回null + * * @return */ List createTitleIcon(); /** * 处理设计器菜单(增删改) + * * @param menuDefs 已加载的菜单 * @return 新的菜单数组 */ 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 397fd312a8..04dab52b50 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 @@ -461,10 +461,15 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta try { @SuppressWarnings("unchecked") OemProcessor oemProcessor = OemHandler.findOem(); - List image; - if (oemProcessor != null && oemProcessor.createTitleIcon() != null) { - image = oemProcessor.createTitleIcon(); - } else { + List image = null; + if (oemProcessor != null) { + try { + image = oemProcessor.createTitleIcon(); + } catch (Throwable e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + if (image == null) { image = ICODecoder.read(DesignerFrame.class .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); } 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 4459bd554d..2577b6bd02 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 @@ -57,6 +57,7 @@ import com.fr.design.remote.action.RemoteDesignAuthManagerAction; import com.fr.design.utils.ThemeUtils; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; import com.fr.plugin.manage.PluginFilter; @@ -202,11 +203,18 @@ public abstract class ToolBarMenuDock { }; this.menus = menus(plus); - OemProcessor oemProcessor = OemHandler.findOem(); - if (oemProcessor != null) { - this.menus = oemProcessor.dealWithMenuDef(this.menus); + try { + OemProcessor oemProcessor = OemHandler.findOem(); + if (oemProcessor != null) { + this.menus = oemProcessor.dealWithMenuDef(this.menus); + if (this.menus == null) { + this.menus = menus(plus); + } + } + } catch (Throwable e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + this.menus = menus(plus); } - for (int i = 0; i < menus.length; i++) { menus[i].setHasRecMenu(true); UIMenu subMenu = menus[i].createJMenu(); diff --git a/designer-base/src/main/java/com/fr/start/OemActivator.java b/designer-base/src/main/java/com/fr/start/OemActivator.java deleted file mode 100644 index 6e3bba6036..0000000000 --- a/designer-base/src/main/java/com/fr/start/OemActivator.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.fr.start; - -import com.fr.design.fun.OemProcessor; -import com.fr.module.Activator; -import com.fr.module.extension.Prepare; - -/** - * 设计器OEM注册 - */ -public class OemActivator extends Activator implements Prepare { - - @Override - public void start() { - } - - @Override - public void stop() { - - } - - @Override - public void prepare() { - // 加入Oem - setSingleton(OemProcessor.class, new OemImpl()); - } - -} diff --git a/designer-base/src/main/java/com/fr/start/OemHandler.java b/designer-base/src/main/java/com/fr/start/OemHandler.java index ff56bc1735..b127e07f43 100644 --- a/designer-base/src/main/java/com/fr/start/OemHandler.java +++ b/designer-base/src/main/java/com/fr/start/OemHandler.java @@ -1,18 +1,14 @@ package com.fr.start; import com.fr.design.fun.OemProcessor; -import com.fr.module.Module; -import com.fr.module.ModuleContext; +import com.fr.stable.bridge.StableFactory; /** * OEM处理中心 */ public class OemHandler { + public static OemProcessor findOem() { - Module oemModule = ModuleContext.getModule(OemActivator.class); - if (oemModule != null) { - return oemModule.getSingleton(OemProcessor.class); - } - return null; + return StableFactory.getMarkedInstanceObjectFromClass(OemProcessor.MARK_STRING, OemProcessor.class); } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java index 9f6f751229..3c255c936d 100644 --- a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java @@ -15,6 +15,7 @@ import com.fr.stable.BuildContext; import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; +import com.fr.start.OemHandler; import com.fr.start.SplashContext; import com.fr.start.SplashStrategy; import com.fr.start.fx.SplashFx; @@ -125,9 +126,14 @@ public class PreStartActivator extends Activator { } private SplashStrategy createSplash() { - OemProcessor oemProcessor = getSingleton(OemProcessor.class); + OemProcessor oemProcessor = OemHandler.findOem(); if (oemProcessor != null) { - SplashStrategy splashStrategy = oemProcessor.createSplashStrategy(); + SplashStrategy splashStrategy = null; + try { + splashStrategy = oemProcessor.createSplashStrategy(); + } catch (Throwable e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } if (splashStrategy != null) { return splashStrategy; } From fb02413bf73e6342113b49da3b2af052a5126bca Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 23 Apr 2019 09:50:02 +0800 Subject: [PATCH 3/3] rt --- designer-base/src/main/java/com/fr/start/OemImpl.java | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/start/OemImpl.java diff --git a/designer-base/src/main/java/com/fr/start/OemImpl.java b/designer-base/src/main/java/com/fr/start/OemImpl.java deleted file mode 100644 index 68bf767c80..0000000000 --- a/designer-base/src/main/java/com/fr/start/OemImpl.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fr.start; - -import com.fr.design.fun.impl.AbstractOemProcessor; - -public class OemImpl extends AbstractOemProcessor{ - -} \ No newline at end of file