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. 11
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  3. 10
      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接口
*/
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<BufferedImage> createTitleIcon();
/**
* 处理设计器菜单增删改
*
* @param menuDefs 已加载的菜单
* @return 新的菜单数组
*/

11
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<BufferedImage> image;
if (oemProcessor != null && oemProcessor.createTitleIcon() != null) {
List<BufferedImage> image = null;
if (oemProcessor != null) {
try {
image = oemProcessor.createTitleIcon();
} else {
} 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"));
}

10
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);
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();

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

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.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;
}

Loading…
Cancel
Save