Browse Source

Merge pull request #832 in DESIGN/design from ~ZACK/design:release/10.0 to release/10.0

* commit 'fb02413bf73e6342113b49da3b2af052a5126bca':
  rt
  跟ju讨论,OEM这个还是StableFactory比较合适二开.另外增加接口异常捕获,规避开放接口存在的一些风险
  REPORT-16249 10OEM的启动页替换接口
bugfix/10.0
zack 6 years ago
parent
commit
5bddf5b246
  1. 38
      designer-base/src/main/java/com/fr/design/fun/OemProcessor.java
  2. 25
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractOemProcessor.java
  3. 15
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  4. 15
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  5. 14
      designer-base/src/main/java/com/fr/start/OemHandler.java
  6. 16
      designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

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

@ -0,0 +1,38 @@
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 {
public static final String MARK_STRING = "OemProcessor";
/**
* 启动动画,如果不替换则返回null
*
* @return
*/
SplashStrategy createSplashStrategy();
/**
* 替换标题图标--DesignerFrame.initTitleIcon
* 如果不替换则返回null
*
* @return
*/
List<BufferedImage> createTitleIcon();
/**
* 处理设计器菜单增删改
*
* @param menuDefs 已加载的菜单
* @return 新的菜单数组
*/
MenuDef[] dealWithMenuDef(MenuDef[] menuDefs);
}

25
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<BufferedImage> createTitleIcon() {
return null;
}
@Override
public SplashStrategy createSplashStrategy() {
return null;
}
}

15
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,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
try {
@SuppressWarnings("unchecked")
List<BufferedImage> image = ICODecoder.read(DesignerFrame.class
OemProcessor oemProcessor = OemHandler.findOem();
List<BufferedImage> 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"));
}
this.setIconImages(image);
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);

15
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;
@ -56,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;
@ -64,6 +66,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 +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();

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

@ -0,0 +1,14 @@
package com.fr.start;
import com.fr.design.fun.OemProcessor;
import com.fr.stable.bridge.StableFactory;
/**
* OEM处理中心
*/
public class OemHandler {
public static OemProcessor findOem() {
return StableFactory.getMarkedInstanceObjectFromClass(OemProcessor.MARK_STRING, OemProcessor.class);
}
}

16
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;
@ -14,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;
@ -123,7 +125,19 @@ public class PreStartActivator extends Activator {
service.shutdown();
}
private static SplashStrategy createSplash() {
private SplashStrategy createSplash() {
OemProcessor oemProcessor = OemHandler.findOem();
if (oemProcessor != null) {
SplashStrategy splashStrategy = null;
try {
splashStrategy = oemProcessor.createSplashStrategy();
} catch (Throwable e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (splashStrategy != null) {
return splashStrategy;
}
}
// 这里可以开接口加载自定义启动画面
if (OperatingSystem.isWindows()) {
return new SplashFx();

Loading…
Cancel
Save