From 4c30a05784f39d44b6e9937085d7fede4cccfbc2 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 18 Mar 2020 19:31:27 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-28363=20=E7=82=B9=E5=87=BB=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E6=BC=94=E7=A4=BA=E5=90=AF=E5=8A=A8=E5=86=85=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=EF=BC=8C=E6=B2=A1=E6=9C=89=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 12 +++++-- .../fr/design/mainframe/DesignerFrame.java | 15 ++++++-- .../push/DesignerPushUpdateManager.java | 9 ++++- .../main/java/com/fr/start/ServerStarter.java | 36 ++++++++----------- 4 files changed, 45 insertions(+), 27 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index cb8634c002..81211cc579 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -82,6 +82,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private static final String VERSION_80 = "80"; private static final int CACHINGTEMPLATE_LIMIT = 5; private static final String WEB_NAME = "webapps"; + /** + * 指定默认工作空间 + */ + public static final String DEFAULT_WORKSPACE_PATH = "fr.designer.workspace.default"; private static DesignerEnvManager designerEnvManager; // gui. private String activationKey = null; @@ -555,6 +559,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private String getDefaultenvPath(String installHome) { + String defaultWorkspacePath = System.getProperty(DEFAULT_WORKSPACE_PATH); + if (defaultWorkspacePath != null) { + return defaultWorkspacePath; + } //这里需要转成反斜杠和生成默认路径一致 return new File(StableUtils.pathJoin(installHome, WEB_NAME, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME)).getPath(); } @@ -1397,6 +1405,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { /** * 对国际化进行校验 * 非简繁英日韩的默认环境 设计器全部默认为英文版本 + * * @param locale * @return */ @@ -1548,8 +1557,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { readVcsAttr(reader); } else if (DesignerPort.XML_TAG.equals(name)) { readDesignerPort(reader); - } - else { + } else { readLayout(reader, name); } } 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 237f2f9758..31798e665b 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 @@ -471,7 +471,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta OSSupportCenter.buildAction(new OSBasedAction() { @Override public void execute(Object... objects) { - bbsLoginPane[0] = ad.createBBSLoginPane(); + bbsLoginPane[0] = ad.createBBSLoginPane(); } }, SupportOSImpl.USERINFOPANE); processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); @@ -483,7 +483,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta OSSupportCenter.buildAction(new OSBasedAction() { @Override public void execute(Object... objects) { - northEastPane.add(ad.createBBSLoginPane()); + northEastPane.add(ad.createBBSLoginPane()); } }, SupportOSImpl.USERINFOPANE); @@ -508,7 +508,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } if (OperatingSystem.isMacos()) { Class clazz = Class.forName("com.apple.eawt.Application"); - BufferedImage icon = image.isEmpty() ? IOUtils.readImage("/com/fr/base/images/oem/logo.png") : image.get(image.size() - 1); + BufferedImage icon = image.isEmpty() ? IOUtils.readImage("/com/fr/base/images/oem/logo.png") : image.get(image.size() - 1); Reflect.on(Reflect.on(clazz).call("getApplication").get()).call("setDockIconImage", icon); } else { this.setIconImages(image); @@ -1284,4 +1284,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta progressDialog.dispose(); } + + /** + * 设计器是否已经打开 + * + * @return 设计器是否已经打开 + */ + public boolean isDesignerOpened() { + return designerOpened; + } } 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 12b1d74b7c..efd809e791 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 @@ -58,7 +58,14 @@ public class DesignerPushUpdateManager { private String getFullLatestVersion() { try { - String res = HttpToolbox.get(CloudCenter.getInstance().acquireUrlByKind("jar10.update")); + String url = CloudCenter.getInstance().acquireUrlByKind("jar10.update"); + if(StringUtils.isBlank(url)){ + return StringUtils.EMPTY; + } + String res = HttpToolbox.get(url); + if(StringUtils.isBlank(res)){ + return StringUtils.EMPTY; + } return new JSONObject(res).optString("buildNO"); } catch (Throwable e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-base/src/main/java/com/fr/start/ServerStarter.java b/designer-base/src/main/java/com/fr/start/ServerStarter.java index d4e1143c61..d2b8498bb9 100644 --- a/designer-base/src/main/java/com/fr/start/ServerStarter.java +++ b/designer-base/src/main/java/com/fr/start/ServerStarter.java @@ -3,10 +3,9 @@ package com.fr.start; import com.fr.base.ServerConfig; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.BrowseUtils; -import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; -import com.fr.stable.StableUtils; import com.fr.start.server.FineEmbedServer; import com.fr.start.server.FineEmbedServerMonitor; import com.fr.workspace.WorkContext; @@ -25,23 +24,11 @@ public class ServerStarter { if (!WorkContext.getCurrent().isLocal()) { //有问题,这里拿不到远程的http端口 BrowseUtils.browser(WorkContext.getCurrent().getPath()); - } else if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 - String web = GeneralContext.getCurrentAppNameOfEnv(); - browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + web + "/" + ServerConfig.getInstance().getServletName()); } else { - initDemoServerAndBrowser(); - } - - } - - - private static void initDemoServerAndBrowser() { - - try { - FineEmbedServer.start(); - } finally { - //先访问Demo, 后访问报表, 不需要重置服务器. - BrowseUtils.browser("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + GeneralContext.getCurrentAppNameOfEnv() + "/" + ServerConfig.getInstance().getServletName()); + browserURLWithLocalEnv("http://localhost:" + + DesignerEnvManager.getEnvManager().getEmbedServerPort() + + "/" + GeneralContext.getCurrentAppNameOfEnv() + + "/" + ServerConfig.getInstance().getServletName()); } } @@ -51,8 +38,8 @@ public class ServerStarter { * @param url 指定路径 */ public static void browserURLWithLocalEnv(final String url) { - - if (!FineEmbedServerMonitor.getInstance().isComplete()) { + // 内置服务器没有启动并且设计器已经打开,可以使用带进度条的启动方式 + if (!FineEmbedServer.isRunning() && DesignerContext.getDesignerFrame().isDesignerOpened()) { FineEmbedServerMonitor.getInstance().monitor(); ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("ServerStarter")); service.submit(new Runnable() { @@ -68,8 +55,15 @@ public class ServerStarter { } }); service.shutdown(); + } else if (!FineEmbedServer.isRunning()) { + // 普通方式启动内置服务器 + try { + FineEmbedServer.start(); + } finally { + BrowseUtils.browser(url); + } } else { - FineEmbedServer.start(); + // 已经启动内置服务器只需打开链接 BrowseUtils.browser(url); } }