diff --git a/designer-base/src/main/java/com/fr/design/RestartHelper.java b/designer-base/src/main/java/com/fr/design/RestartHelper.java index 7f2aeeb781..4a0813f320 100644 --- a/designer-base/src/main/java/com/fr/design/RestartHelper.java +++ b/designer-base/src/main/java/com/fr/design/RestartHelper.java @@ -1,13 +1,16 @@ package com.fr.design; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.os.impl.RestartAction; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; -import com.fr.stable.OperatingSystem; +import com.fr.stable.os.OperatingSystem; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import java.io.File; import java.io.FileInputStream; @@ -168,11 +171,8 @@ public class RestartHelper { }catch (Exception e){ FineLoggerFactory.getLogger().error(e.getMessage(), e); } - if (OperatingSystem.isMacOS()) { - restartInMacOS(installHome, filesToBeDelete); - } else { - restartInWindows(installHome, filesToBeDelete); - } + OSBasedAction osBasedAction = OSSupportCenter.getAction(RestartAction.class); + osBasedAction.execute(filesToBeDelete); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } finally { @@ -187,7 +187,7 @@ public class RestartHelper { } } - private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { + /* private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { ProcessBuilder builder = new ProcessBuilder(); List commands = new ArrayList(); commands.add("open"); @@ -210,4 +210,16 @@ public class RestartHelper { builder.command(commands); builder.start(); } + + private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception { + ProcessBuilder builder = new ProcessBuilder(); + List commands = new ArrayList(); + //现在先写的是restart.sh + commands.add(installHome + File.separator + "bin" + File.separator + "restart.sh"); + if (ArrayUtils.isNotEmpty(filesToBeDelete)) { + commands.add(StableUtils.join(filesToBeDelete, "+")); + } + builder.command(commands); + builder.start(); + }*/ } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 6a8132a609..20d2af94fc 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -28,7 +28,7 @@ import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.design.update.push.DesignerPushUpdateManager; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.general.ComparatorUtils; @@ -213,10 +213,15 @@ public class PreferencePane extends BasicPane { joinProductImproveCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Join_Product_Improve")); improvePane.add(joinProductImproveCheckBox); - if (DesignerPushUpdateManager.getInstance().isAutoPushUpdateSupported()) { + if(SupportOSImpl.AUTOPUSHUPDATE.support()){ autoPushUpdateCheckBox = new UICheckBox(i18nText("Fine-Design_Automatic_Push_Update")); improvePane.add(autoPushUpdateCheckBox); } + /* + if (DesignerPushUpdateManager.getInstance().isAutoPushUpdateSupported()) { + autoPushUpdateCheckBox = new UICheckBox(i18nText("Fine-Design_Automatic_Push_Update")); + improvePane.add(autoPushUpdateCheckBox); + }*/ JPanel spaceUpPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); spaceUpPane.add(oraclePane, BorderLayout.NORTH); diff --git a/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java b/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java index 76b11b2ff9..15c6cb705c 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java @@ -1,24 +1,17 @@ package com.fr.design.actions.server; - -import com.fr.config.ServerPreferenceConfig; import com.fr.data.impl.Connection; import com.fr.design.actions.UpdateAction; -import com.fr.design.data.datapane.connect.ConnectionManagerPane; import com.fr.design.data.datapane.connect.ConnectionShowPane; import com.fr.design.data.datapane.connect.DatabaseConnectionPane; import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.NameInspector; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; -import com.fr.design.dcm.UniversalDatabaseOpener; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; +import com.fr.design.os.impl.DatabaseDialogAction; import com.fr.file.ConnectionConfig; import com.fr.general.IOUtils; -import com.fr.transaction.CallBackAdaptor; -import com.fr.transaction.Configurations; -import com.fr.transaction.WorkerFacade; import javax.swing.*; import java.awt.event.ActionEvent; @@ -60,14 +53,11 @@ public class ConnectionListAction extends UpdateAction { * @param evt 事件 */ public void actionPerformed(ActionEvent evt) { - if (ServerPreferenceConfig.getInstance().isUseUniverseDBM()) { - UniversalDatabaseOpener.showUniverseDatabaseDialog(); - } else { - openDesignDatabaseManager(); - } + OSBasedAction osBasedAction = OSSupportCenter.getAction(DatabaseDialogAction.class); + osBasedAction.execute(); } - private void openDesignDatabaseManager() { + /* private void openDesignDatabaseManager() { DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); final ConnectionConfig datasourceManager = ConnectionConfig.getInstance(); final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() { @@ -108,7 +98,7 @@ public class ConnectionListAction extends UpdateAction { }); databaseListDialog.setVisible(true); } - +*/ /** * 更新datasourceManager diff --git a/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java b/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java index 1b7d7bbc47..7b41f6fd81 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java @@ -1,11 +1,11 @@ package com.fr.design.actions.server; -import com.fr.config.ServerPreferenceConfig; import com.fr.design.actions.UpdateAction; -import com.fr.design.extra.WebViewDlgHelper; import com.fr.design.menu.MenuKeySet; -import com.fr.design.upm.UpmFinder; +import com.fr.design.os.impl.PMDialogAction; import com.fr.general.IOUtils; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import javax.swing.*; import java.awt.event.ActionEvent; @@ -16,22 +16,18 @@ import java.awt.event.ActionEvent; * @since 8.0 */ public class PluginManagerAction extends UpdateAction { - + private static String PLUGIN_MANAGER_ROUTE = "#management/plugin"; public PluginManagerAction() { this.setMenuKeySet(PLUGIN_MANAGER); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/server/plugin.png")); } - @Override public void actionPerformed(ActionEvent e) { // 可以启用新版本的插件商店(使用JxBrowser作为容器) - if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM()) { - UpmFinder.showUPMDialog(); - } else { - WebViewDlgHelper.createPluginDialog(); - } + OSBasedAction osBasedAction = OSSupportCenter.getAction(PMDialogAction.class); + osBasedAction.execute(); } public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java index a9b470a58d..e416083f73 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java @@ -3,6 +3,9 @@ package com.fr.design.gui.iprogressbar; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ilable.UILabel; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; @@ -28,7 +31,12 @@ public class ProgressDialog extends UIDialog { setUndecorated(true); setSize(parent.getSize()); setLocationRelativeTo(null); - setOpacity(0.5f); + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + setOpacity(0.5f); + } + }, SupportOSImpl.OPACITY); initComponent(); } 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 b422be44e8..56e119d6a7 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 @@ -40,6 +40,7 @@ import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.menu.MenuManager; import com.fr.design.menu.ShortCut; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.event.EventDispatcher; import com.fr.exception.DecryptTemplateException; @@ -58,6 +59,8 @@ import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.project.ProjectConstants; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; @@ -83,6 +86,7 @@ import java.awt.Graphics; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; +import java.awt.Component; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.dnd.DnDConstants; @@ -449,20 +453,33 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta return northEastPane; } - private void refreshNorthEastPane(JPanel northEastPane, ToolBarMenuDock ad) { + private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) { northEastPane.removeAll(); northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); northEastPane.add(LogMessageBar.getInstance()); TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); if (processor != null) { - processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane()); + final Component[] bbsLoginPane = {null}; + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + bbsLoginPane[0] = ad.createBBSLoginPane(); + } + }, SupportOSImpl.USERINFOPANE); + processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); } northEastPane.add(ad.createAlphaFinePane()); if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { ad.createAlphaFinePane().setVisible(false); } - northEastPane.add(ad.createBBSLoginPane()); + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + northEastPane.add(ad.createBBSLoginPane()); + } + }, SupportOSImpl.USERINFOPANE); + } public void initTitleIcon() { 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 262dbe6d57..d916d967fc 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 @@ -54,6 +54,7 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.remote.action.RemoteDesignAuthManagerAction; import com.fr.design.update.actions.SoftwareUpdateAction; import com.fr.design.utils.ThemeUtils; @@ -70,6 +71,8 @@ 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.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import org.jetbrains.annotations.Nullable; @@ -524,7 +527,7 @@ public abstract class ToolBarMenuDock { * @return 帮组菜单的子菜单 */ public ShortCut[] createHelpShortCuts() { - java.util.List shortCuts = new ArrayList(); + final java.util.List shortCuts = new ArrayList(); shortCuts.add(new WebDemoAction()); // 英文,把 video 和帮助文档放到 Help 下面 if (GeneralContext.getLocale().equals(Locale.US)) { @@ -541,7 +544,13 @@ public abstract class ToolBarMenuDock { shortCuts.add(SeparatorDef.DEFAULT); if (DesignerEnvManager.getEnvManager().isOpenDebug()) { - shortCuts.add(new FineUIAction()); + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + shortCuts.add(new FineUIAction()); + } + }, SupportOSImpl.FINEUI); + } shortCuts.add(new AboutAction()); diff --git a/designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java b/designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java new file mode 100644 index 0000000000..7db0004937 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java @@ -0,0 +1,77 @@ +package com.fr.design.os.impl; + +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.data.datapane.connect.ConnectionManagerPane; +import com.fr.design.dcm.UniversalDatabaseOpener; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; +import com.fr.file.ConnectionConfig; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.transaction.CallBackAdaptor; +import com.fr.transaction.Configurations; +import com.fr.transaction.WorkerFacade; +import static com.fr.design.actions.server.ConnectionListAction.doWithDatasourceManager; + +/** + * 数据连接窗口 + * @author pengda + * @date 2019/10/9 + */ +public class DatabaseDialogAction implements OSBasedAction { + + @Override + public void execute(Object... objects) { + if (ServerPreferenceConfig.getInstance().isUseUniverseDBM() && !OperatingSystem.isLinux()) { + UniversalDatabaseOpener.showUniverseDatabaseDialog(); + } else { + openDesignDatabaseManager(); + } + } + + private void openDesignDatabaseManager() { + DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + final ConnectionConfig datasourceManager = ConnectionConfig.getInstance(); + final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() { + public void complete() { + ConnectionConfig connectionConfig = datasourceManager.mirror(); + populate(connectionConfig); + } + + protected void renameConnection(String oldName, String newName) { + datasourceManager.renameConnection(oldName, newName); + } + }; + final BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null); + databaseListDialog.addDialogActionListener(new DialogActionAdapter() { + public void doOk() { + if (!databaseManagerPane.isNamePermitted()) { + databaseListDialog.setDoOKSucceed(false); + return; + } + Configurations.modify(new WorkerFacade(ConnectionConfig.class) { + @Override + public void run() { + databaseManagerPane.update(datasourceManager); + } + }.addCallBack(new CallBackAdaptor() { + @Override + public boolean beforeCommit() { + //如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面 + return doWithDatasourceManager(datasourceManager, databaseManagerPane, databaseListDialog); + } + + @Override + public void afterCommit() { + DesignerContext.getDesignerBean("databasename").refreshBeanElement(); + } + })); + } + }); + databaseListDialog.setVisible(true); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/DemoAction.java b/designer-base/src/main/java/com/fr/design/os/impl/DemoAction.java new file mode 100644 index 0000000000..8feb02952a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/DemoAction.java @@ -0,0 +1,59 @@ +package com.fr.design.os.impl; + +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StableUtils; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; + +import java.io.IOException; +/** + * @author pengda + * @date 2019/10/9 + */ +public class DemoAction implements OSBasedAction { + + @Override + public void execute(Object... objects) { + String installHome = StableUtils.getInstallHome(); + if (installHome == null) { + FineLoggerFactory.getLogger().error("Can not find the install home, please check it."); + return; + } + + String executorPath; + + if (OperatingSystem.isMacos()) { + executorPath = StableUtils.pathJoin(installHome, "bin", "designer.app"); + } else if(OperatingSystem.isWindows()){ + executorPath = StableUtils.pathJoin(installHome, "bin", "designer.exe demo"); + }else{ + executorPath = StableUtils.pathJoin(installHome, "bin", "designer.sh demo"); + } + + if (OperatingSystem.isMacos()) { + ProcessBuilder builder = new ProcessBuilder(); + builder.command("open", "-a", executorPath, "--args", "demo"); + try { + builder.start(); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } else if(OperatingSystem.isWindows()){ + // ProcessBuilder这种方式在window下报错:系统找不到指定文件 + Runtime rt = Runtime.getRuntime(); + try { + rt.exec(executorPath); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + }else{ + //先用和win一样的方式 + Runtime rt = Runtime.getRuntime(); + try { + rt.exec(executorPath); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java b/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java new file mode 100644 index 0000000000..3f2f097283 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java @@ -0,0 +1,30 @@ +package com.fr.design.os.impl; + +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.extra.WebViewDlgHelper; +import com.fr.design.upm.UpmFinder; +import com.fr.design.utils.DesignUtils; +import com.fr.stable.os.Arch; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; + +/** + * 插件管理窗口 + * @author pengda + * @date 2019/10/9 + */ +public class PMDialogAction implements OSBasedAction { + private static String PLUGIN_MANAGER_ROUTE = "#management/plugin"; + @Override + public void execute(Object... objects) { + if(Arch.getArch() == Arch.ARM){ + DesignUtils.visitEnvServerByParameters( PLUGIN_MANAGER_ROUTE,null,null); + return; + } + if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM() && !OperatingSystem.isLinux()) { + UpmFinder.showUPMDialog(); + } else { + WebViewDlgHelper.createPluginDialog(); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java b/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java new file mode 100644 index 0000000000..b18254c113 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java @@ -0,0 +1,74 @@ +package com.fr.design.os.impl; + +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StableUtils; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class RestartAction implements OSBasedAction { + @Override + public void execute(Object... objects) { + String[] filesToBeDelete = (String[])objects; + String installHome = StableUtils.getInstallHome(); + try{ + if (OperatingSystem.isMacos()) { + restartInMacOS(installHome, filesToBeDelete); + } else if(OperatingSystem.isWindows()){ + restartInWindows(installHome, filesToBeDelete); + }else{ + //增加一个Linux系统 + restartInLinux(installHome,filesToBeDelete); + } + }catch(Exception e){ + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + + } + + private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { + ProcessBuilder builder = new ProcessBuilder(); + List commands = new ArrayList(); + commands.add("open"); + commands.add(installHome + File.separator + "bin" + File.separator + "restart.app"); + if (ArrayUtils.isNotEmpty(filesToBeDelete)) { + commands.add("--args"); + commands.add(StableUtils.join(filesToBeDelete, "+")); + } + builder.command(commands); + builder.start(); + } + + private static void restartInWindows(String installHome, String[] filesToBeDelete) throws Exception { + ProcessBuilder builder = new ProcessBuilder(); + List commands = new ArrayList(); + commands.add(installHome + File.separator + "bin" + File.separator + "restart.exe"); + if (ArrayUtils.isNotEmpty(filesToBeDelete)) { + commands.add(StableUtils.join(filesToBeDelete, "+")); + } + builder.command(commands); + builder.start(); + } + + private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception { + ProcessBuilder builder = new ProcessBuilder(); + List commands = new ArrayList(); + //现在先写的是restart.sh + commands.add(installHome + File.separator + "bin" + File.separator + "restart.sh"); + if (ArrayUtils.isNotEmpty(filesToBeDelete)) { + commands.add(StableUtils.join(filesToBeDelete, "+")); + } + builder.command(commands); + builder.start(); + } + + + + + + + +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java b/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java new file mode 100644 index 0000000000..31aac9aa11 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java @@ -0,0 +1,63 @@ +package com.fr.design.os.impl; + +import com.fr.base.FRContext; +import com.fr.general.GeneralContext; +import com.fr.stable.os.Arch; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.SupportOS; +import com.fr.workspace.WorkContext; + +/** + * @author pengda + * @date 2019/10/9 + */ +public enum SupportOSImpl implements SupportOS { + + /** + * ARM下屏蔽登录 + */ + USERINFOPANE{ + public boolean support(){ + return Arch.getArch() != Arch.ARM; + } + }, + /** + * Linux系统屏蔽透明度 + */ + OPACITY{ + public boolean support(){ + return !OperatingSystem.isLinux(); + } + }, + /** + * Linux系统屏蔽FineUI选项 + */ + FINEUI{ + public boolean support(){ + return !OperatingSystem.isLinux(); + } + }, + /** + * 自动更新推送 + */ + AUTOPUSHUPDATE{ + @Override + public boolean support() { + boolean isLocalEnv = WorkContext.getCurrent().isLocal(); + boolean isChineseEnv = GeneralContext.isChineseEnv(); + boolean isLinux = OperatingSystem.isLinux(); + // 远程设计和非中文环境以及Linux环境,都不生效 + return isLocalEnv && isChineseEnv && !isLinux; + } + }, + /** + * BBS窗口 + */ + BBSDIALOG{ + @Override + public boolean support() { + return FRContext.isChineseEnv() && !OperatingSystem.isMacos() && Arch.getArch() != Arch.ARM; + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/UpdateDialogAction.java b/designer-base/src/main/java/com/fr/design/os/impl/UpdateDialogAction.java new file mode 100644 index 0000000000..64f8f21120 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/UpdateDialogAction.java @@ -0,0 +1,25 @@ +package com.fr.design.os.impl; + +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.update.ui.dialog.UpdateMainDialog; +import com.fr.design.utils.DesignUtils; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; + +/** + * 更新升级窗口 + * @author pengda + * @date 2019/10/9 + */ +public class UpdateDialogAction implements OSBasedAction { + private static String UPDATE_ROUTE = "#management/backup"; + @Override + public void execute(Object... objects) { + if(!OperatingSystem.isLinux()) { + UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); + dialog.showDialog(); + }else{ + DesignUtils.visitEnvServerByParameters( UPDATE_ROUTE,null,null); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/update/actions/SoftwareUpdateAction.java b/designer-base/src/main/java/com/fr/design/update/actions/SoftwareUpdateAction.java index cb412dcb1f..d65d8fec58 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/SoftwareUpdateAction.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/SoftwareUpdateAction.java @@ -2,8 +2,9 @@ package com.fr.design.update.actions; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.update.ui.dialog.UpdateMainDialog; +import com.fr.design.os.impl.UpdateDialogAction; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import java.awt.event.ActionEvent; @@ -12,7 +13,6 @@ import java.awt.event.ActionEvent; */ public class SoftwareUpdateAction extends UpdateAction { - public SoftwareUpdateAction() { setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_UpdateAndUpgrade")); setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/update/update_new.png")); @@ -26,8 +26,9 @@ public class SoftwareUpdateAction extends UpdateAction { */ @Override public void actionPerformed(ActionEvent e) { - UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); - dialog.showDialog(); + //说之后更新升级要用jxbrowser,Linux下进平台 + OSBasedAction osBasedAction = OSSupportCenter.getAction(UpdateDialogAction.class); + osBasedAction.execute(); } } diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java index 44cfb146b1..dcc282c53f 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java @@ -4,6 +4,7 @@ import com.fr.concurrent.NamedThreadFactory; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; @@ -12,6 +13,9 @@ import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import com.fr.workspace.WorkContext; import java.util.concurrent.ExecutorService; @@ -81,21 +85,6 @@ public class DesignerPushUpdateManager { return StringUtils.EMPTY; } - /** - * "自动更新推送"选项是否生效 - */ - public boolean isAutoPushUpdateSupported() { - boolean isLocalEnv = WorkContext.getCurrent().isLocal(); - boolean isChineseEnv = GeneralContext.isChineseEnv(); - - return isAutoPushUpdateSupported(isLocalEnv, isChineseEnv); - } - - private boolean isAutoPushUpdateSupported(boolean isLocalEnv, boolean isChineseEnv) { - // 远程设计和非中文环境,都不生效 - return isLocalEnv && isChineseEnv; - } - /** * 检查更新,如果有合适的更新版本,则弹窗 */ @@ -129,8 +118,7 @@ public class DesignerPushUpdateManager { initUpdateInfo(currentVersion, latestVersion); } } - - return isAutoPushUpdateSupported() && updateInfo.hasNewPushVersion(); + return SupportOSImpl.AUTOPUSHUPDATE.support() && updateInfo.hasNewPushVersion(); } private boolean isValidJarVersion(String fullCurrentVersion, String fullLatestVersion) { diff --git a/designer-base/src/main/java/com/fr/start/Demo.java b/designer-base/src/main/java/com/fr/start/Demo.java index bac5a9b0f0..58f4050fd0 100644 --- a/designer-base/src/main/java/com/fr/start/Demo.java +++ b/designer-base/src/main/java/com/fr/start/Demo.java @@ -1,46 +1,13 @@ package com.fr.start; - -import com.fr.log.FineLoggerFactory; -import com.fr.stable.OperatingSystem; -import com.fr.stable.StableUtils; - -import java.io.IOException; +import com.fr.design.os.impl.DemoAction; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; public class Demo { public static void main(String[] args) { - String installHome = StableUtils.getInstallHome(); - if (installHome == null) { - FineLoggerFactory.getLogger().error("Can not find the install home, please check it."); - return; - } - - String executorPath; - - if (OperatingSystem.isMacOS()) { - executorPath = StableUtils.pathJoin(installHome, "bin", "designer.app"); - } else { - executorPath = StableUtils.pathJoin(installHome, "bin", "designer.exe demo"); - } - - if (OperatingSystem.isMacOS()) { - ProcessBuilder builder = new ProcessBuilder(); - builder.command("open", "-a", executorPath, "--args", "demo"); - try { - builder.start(); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } else { - // ProcessBuilder这种方式在window下报错:系统找不到指定文件 - Runtime rt = Runtime.getRuntime(); - try { - rt.exec(executorPath); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - + OSBasedAction osBasedAction = OSSupportCenter.getAction(DemoAction.class); + osBasedAction.execute(); System.exit(0); } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java index 7fe8b8ff87..6e423e1729 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -16,6 +16,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.upm.event.CertificateEvent; import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.gui.GUICoreUtils; @@ -28,10 +29,8 @@ import com.fr.general.DateUtils; import com.fr.general.http.HttpClient; import com.fr.log.FineLoggerFactory; import com.fr.stable.EncodeConstants; -import com.fr.stable.OperatingSystem; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; - import javax.swing.SwingConstants; import java.awt.Cursor; import java.awt.Desktop; @@ -142,7 +141,8 @@ public class UserInfoLabel extends UILabel { @Override public void run() { // vito:最新mac10.12和javafx弹出框初始化时会有大几率卡死在native方法,这里先屏蔽一下。 - if (!FRContext.isChineseEnv() || OperatingSystem.isMacOS()) { + //ARM下暂时也不能用javafx + if (!SupportOSImpl.BBSDIALOG.support()) { return; } String lastBBSNewsTime = DesignerEnvManager.getEnvManager().getLastShowBBSNewsTime(); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 4cee65f25f..1727906fb0 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -55,6 +55,7 @@ import com.fr.design.mainframe.form.FormReportComponentComposite; import com.fr.design.mainframe.loghandler.DesignerLogAppender; import com.fr.design.mainframe.socketio.DesignerSocketIO; import com.fr.design.module.DesignModuleFactory; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.parameter.FormParameterReader; import com.fr.design.parameter.ParameterPropertyPane; import com.fr.design.parameter.WorkBookParameterReader; @@ -93,6 +94,8 @@ import com.fr.report.cell.painter.CellImagePainter; import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.bridge.StableFactory; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.plugin.ExtraDesignClassManagerProvider; import com.fr.stable.script.CalculatorProviderContext; import com.fr.stable.script.ValueConverter; @@ -127,7 +130,12 @@ public class DesignerActivator extends Activator { designerModuleStart(); loadLogAppender(); DesignerSocketIO.update(); - UserInfoPane.getInstance().updateBBSUserInfo(); + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + UserInfoPane.getInstance().updateBBSUserInfo(); + } + }, SupportOSImpl.USERINFOPANE); storePassport(); AlphaFineHelper.switchConfig4Locale(); RecoverManager.register(new RecoverForDesigner());