Browse Source

跟ju讨论,OEM这个还是StableFactory比较合适二开.另外增加接口异常捕获,规避开放接口存在的一些风险

bugfix/10.0
zack 6 years ago
parent
commit
154ef0b8ad
  1. 5
      designer-base/src/main/java/com/fr/design/fun/OemProcessor.java
  2. 13
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  3. 16
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  4. 27
      designer-base/src/main/java/com/fr/start/OemActivator.java
  5. 10
      designer-base/src/main/java/com/fr/start/OemHandler.java
  6. 10
      designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

5
designer-base/src/main/java/com/fr/design/fun/OemProcessor.java

@ -10,8 +10,11 @@ import java.util.List;
* 设计器Oem接口 * 设计器Oem接口
*/ */
public interface OemProcessor { public interface OemProcessor {
public static final String MARK_STRING = "OemProcessor";
/** /**
* 启动动画,如果不替换则返回null * 启动动画,如果不替换则返回null
*
* @return * @return
*/ */
SplashStrategy createSplashStrategy(); SplashStrategy createSplashStrategy();
@ -19,12 +22,14 @@ public interface OemProcessor {
/** /**
* 替换标题图标--DesignerFrame.initTitleIcon * 替换标题图标--DesignerFrame.initTitleIcon
* 如果不替换则返回null * 如果不替换则返回null
*
* @return * @return
*/ */
List<BufferedImage> createTitleIcon(); List<BufferedImage> createTitleIcon();
/** /**
* 处理设计器菜单增删改 * 处理设计器菜单增删改
*
* @param menuDefs 已加载的菜单 * @param menuDefs 已加载的菜单
* @return 新的菜单数组 * @return 新的菜单数组
*/ */

13
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -461,10 +461,15 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
try { try {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
OemProcessor oemProcessor = OemHandler.findOem(); OemProcessor oemProcessor = OemHandler.findOem();
List<BufferedImage> image; List<BufferedImage> image = null;
if (oemProcessor != null && oemProcessor.createTitleIcon() != null) { if (oemProcessor != null) {
image = oemProcessor.createTitleIcon(); try {
} else { image = oemProcessor.createTitleIcon();
} catch (Throwable e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
if (image == null) {
image = ICODecoder.read(DesignerFrame.class image = ICODecoder.read(DesignerFrame.class
.getResourceAsStream("/com/fr/base/images/oem/logo.ico")); .getResourceAsStream("/com/fr/base/images/oem/logo.ico"));
} }

16
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.design.utils.ThemeUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime; import com.fr.plugin.context.PluginRuntime;
import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.manage.PluginFilter;
@ -202,11 +203,18 @@ public abstract class ToolBarMenuDock {
}; };
this.menus = menus(plus); this.menus = menus(plus);
OemProcessor oemProcessor = OemHandler.findOem(); try {
if (oemProcessor != null) { OemProcessor oemProcessor = OemHandler.findOem();
this.menus = oemProcessor.dealWithMenuDef(this.menus); 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++) { for (int i = 0; i < menus.length; i++) {
menus[i].setHasRecMenu(true); menus[i].setHasRecMenu(true);
UIMenu subMenu = menus[i].createJMenu(); UIMenu subMenu = menus[i].createJMenu();

27
designer-base/src/main/java/com/fr/start/OemActivator.java

@ -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());
}
}

10
designer-base/src/main/java/com/fr/start/OemHandler.java

@ -1,18 +1,14 @@
package com.fr.start; package com.fr.start;
import com.fr.design.fun.OemProcessor; import com.fr.design.fun.OemProcessor;
import com.fr.module.Module; import com.fr.stable.bridge.StableFactory;
import com.fr.module.ModuleContext;
/** /**
* OEM处理中心 * OEM处理中心
*/ */
public class OemHandler { public class OemHandler {
public static OemProcessor findOem() { public static OemProcessor findOem() {
Module oemModule = ModuleContext.getModule(OemActivator.class); return StableFactory.getMarkedInstanceObjectFromClass(OemProcessor.MARK_STRING, OemProcessor.class);
if (oemModule != null) {
return oemModule.getSingleton(OemProcessor.class);
}
return null;
} }
} }

10
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.OperatingSystem;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.start.OemHandler;
import com.fr.start.SplashContext; import com.fr.start.SplashContext;
import com.fr.start.SplashStrategy; import com.fr.start.SplashStrategy;
import com.fr.start.fx.SplashFx; import com.fr.start.fx.SplashFx;
@ -125,9 +126,14 @@ public class PreStartActivator extends Activator {
} }
private SplashStrategy createSplash() { private SplashStrategy createSplash() {
OemProcessor oemProcessor = getSingleton(OemProcessor.class); OemProcessor oemProcessor = OemHandler.findOem();
if (oemProcessor != null) { 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) { if (splashStrategy != null) {
return splashStrategy; return splashStrategy;
} }

Loading…
Cancel
Save