diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java b/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java index cd02bc5c5e..55dc1f00d9 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java @@ -32,7 +32,7 @@ public class DesignerPort implements XMLReadable, XMLWriter { public static final String XML_TAG = "DesignerPort"; private static final int MIN_PORT = 1024; - private static final int MAX_PORT = 65536; + private static final int MAX_PORT = 65535; public static final DesignerPort INSTANCE = new DesignerPort(); diff --git a/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java index a6576faa10..9ebbf875fe 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java @@ -12,6 +12,7 @@ import com.fr.file.FILEChooserPane; import com.fr.file.filter.ChooseFileFilter; import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; import com.fr.web.attr.ReportWebAttr; import javax.swing.BorderFactory; @@ -46,7 +47,8 @@ public class WebCssPane extends BasicPane { northPane.add(localText, FlowLayout.CENTER); northPane.add(chooseFile, FlowLayout.RIGHT); outnorth.add(northPane,BorderLayout.NORTH); - UILabel infor = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CSS_Warning")); + UILabel infor = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CSS_Warning", + ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBAPP_NAME)); infor.setForeground(new Color(207, 42, 39)); outnorth.add(infor,BorderLayout.CENTER); this.add(outnorth, BorderLayout.NORTH); diff --git a/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java index bf04e554f8..7c5c2e6b9a 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java @@ -15,6 +15,7 @@ import com.fr.file.filter.ChooseFileFilter; import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; import com.fr.web.attr.ReportWebAttr; import javax.swing.BorderFactory; @@ -97,7 +98,8 @@ public class WebJsPane extends BasicPane { northPane.add(localText); northPane.add(chooseFile); firstnorth.add(northPane,BorderLayout.NORTH); - infor1 = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING1")); + infor1 = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING1", + ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBAPP_NAME)); infor1.setForeground(new Color(207, 42, 39)); firstnorth.add(infor1,BorderLayout.CENTER); @@ -107,7 +109,7 @@ public class WebJsPane extends BasicPane { centerPane.add(urlText); centerPane.add(testConnection); secondnorth.add(centerPane,BorderLayout.NORTH); - infor2 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING2")); + infor2 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING2", ProjectConstants.WEBAPP_NAME)); infor2.setForeground(new Color(207, 42, 39)); secondnorth.add(infor2,BorderLayout.CENTER); @@ -221,13 +223,13 @@ public class WebJsPane extends BasicPane { localRadioSelectAction(); urlFileRadioButton.setForeground(new Color(143, 142, 139)); localFileRadioButton.setForeground(Color.black); - infor1.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING1")); + infor1.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING1", ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBAPP_NAME)); infor2.setText(" "); } else if (urlFileRadioButton.isSelected()) { urlRadioSelectAction(); localFileRadioButton.setForeground(new Color(143, 142, 139)); urlFileRadioButton.setForeground(Color.black); - infor2.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING2")); + infor2.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING2", ProjectConstants.WEBAPP_NAME)); infor1.setText(" "); } if (StringUtils.isEmpty(urlText.getText()) && StringUtils.isEmpty(localText.getText())) { diff --git a/designer-realize/src/main/java/com/fr/start/Designer.java b/designer-realize/src/main/java/com/fr/start/Designer.java index 57a6532250..fb974da986 100644 --- a/designer-realize/src/main/java/com/fr/start/Designer.java +++ b/designer-realize/src/main/java/com/fr/start/Designer.java @@ -1,5 +1,7 @@ package com.fr.start; +import com.fr.log.FineLoggerFactory; + /** * 设计器主进程入口(无缝更换升级jar包,若使用其他类作为入口,需要重新打包designer.exe等,升级后仍然走的原来逻辑) * @@ -11,7 +13,24 @@ package com.fr.start; public class Designer { public static void main(String[] args) { - // 创建进程 - DesignerLauncher.getInstance().start(args); + try { + if (DesignerJavaRuntime.getInstance().isInValidVmOptions()) { + runNonGuardianDesigner(args); + } else { + // 创建进程 + DesignerLauncher.getInstance().start(args); + } + } catch (Exception e) { + runNonGuardianDesigner(args); + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + /** + * 启动非守护设计器 + * @param args 参数 + */ + private static void runNonGuardianDesigner(String[] args) { + MainDesigner.main(args); } } diff --git a/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java b/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java index 351bf1e44f..c264e79cb0 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java @@ -6,6 +6,8 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.os.OperatingSystem; +import java.util.Set; + /** * 设计器Java运行环境 * @@ -16,6 +18,7 @@ import com.fr.stable.os.OperatingSystem; public class DesignerJavaRuntime extends AbstractJavaRuntime { private static final String DOT = "."; + private static final String REMOTE_DEBUG = "-agentlib:jdwp=transport=dt_socket"; private static final String INSTALL4J = ".install4j"; private static final String JAVA_EXEC = "java"; private static final String WIN_JRE_BIN = StableUtils.pathJoin("jre", "bin"); @@ -28,6 +31,20 @@ public class DesignerJavaRuntime extends AbstractJavaRuntime { return INSTANCE; } + /** + * 远程调试不走启动守护 + * @return + */ + public boolean isInValidVmOptions() { + String[] options = getJvmOptions(); + for (String op : options) { + if (op.startsWith(REMOTE_DEBUG)) { + return true; + } + } + return false; + } + @Override public String getJavaExec() { String installHome = StableUtils.getInstallHome(); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index 3dd7322f61..708cc00203 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -58,6 +58,8 @@ public class DesignerStartup extends Activator { BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); // 检查是否是-Ddebug = true 启动 并切换对应的端口以及环境配置文件 checkDebugStart(); + // 都是在启动过程中读取,这边提前初始化xml配置 + DesignerEnvManager.getEnvManager(); // 初始化look and feel DesignUtils.initLookAndFeel(); if (DesignUtils.isPortOccupied()) { diff --git a/designer-realize/src/test/java/com/fr/start/DesignerJavaRuntimeTest.java b/designer-realize/src/test/java/com/fr/start/DesignerJavaRuntimeTest.java new file mode 100644 index 0000000000..13576a6e02 --- /dev/null +++ b/designer-realize/src/test/java/com/fr/start/DesignerJavaRuntimeTest.java @@ -0,0 +1,30 @@ +package com.fr.start; + +import junit.framework.TestCase; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/10 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({DesignerJavaRuntime.class}) +public class DesignerJavaRuntimeTest extends TestCase { + + public void testIsInValidVmOptions() { + PowerMock.mockStatic(DesignerJavaRuntime.class); + DesignerJavaRuntime designerJavaRuntime = PowerMock.createPartialMock(DesignerJavaRuntime.class, "isInstallVersion", "getJvmOptions"); + String[] options = new String[]{"-Dfile.encoding=UTF-8", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"}; + EasyMock.expect(designerJavaRuntime.getJvmOptions()).andReturn(options).anyTimes(); + EasyMock.replay(designerJavaRuntime); + PowerMock.replay(DesignerJavaRuntime.class); + Assert.assertTrue(designerJavaRuntime.isInValidVmOptions()); + } +} \ No newline at end of file