Browse Source

REPORT-27790 && REPORT-27451

feature/big-screen
hades 5 years ago
parent
commit
22d28e0fa3
  1. 2
      designer-base/src/main/java/com/fr/design/utils/DesignerPort.java
  2. 4
      designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java
  3. 10
      designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java
  4. 19
      designer-realize/src/main/java/com/fr/start/Designer.java
  5. 19
      designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java
  6. 2
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java
  7. 30
      designer-realize/src/test/java/com/fr/start/DesignerJavaRuntimeTest.java

2
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"; public static final String XML_TAG = "DesignerPort";
private static final int MIN_PORT = 1024; 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(); public static final DesignerPort INSTANCE = new DesignerPort();

4
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.file.filter.ChooseFileFilter;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.attr.ReportWebAttr; import com.fr.web.attr.ReportWebAttr;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -46,7 +47,8 @@ public class WebCssPane extends BasicPane {
northPane.add(localText, FlowLayout.CENTER); northPane.add(localText, FlowLayout.CENTER);
northPane.add(chooseFile, FlowLayout.RIGHT); northPane.add(chooseFile, FlowLayout.RIGHT);
outnorth.add(northPane,BorderLayout.NORTH); 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)); infor.setForeground(new Color(207, 42, 39));
outnorth.add(infor,BorderLayout.CENTER); outnorth.add(infor,BorderLayout.CENTER);
this.add(outnorth, BorderLayout.NORTH); this.add(outnorth, BorderLayout.NORTH);

10
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.log.FineLoggerFactory;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.attr.ReportWebAttr; import com.fr.web.attr.ReportWebAttr;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -97,7 +98,8 @@ public class WebJsPane extends BasicPane {
northPane.add(localText); northPane.add(localText);
northPane.add(chooseFile); northPane.add(chooseFile);
firstnorth.add(northPane,BorderLayout.NORTH); 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)); infor1.setForeground(new Color(207, 42, 39));
firstnorth.add(infor1,BorderLayout.CENTER); firstnorth.add(infor1,BorderLayout.CENTER);
@ -107,7 +109,7 @@ public class WebJsPane extends BasicPane {
centerPane.add(urlText); centerPane.add(urlText);
centerPane.add(testConnection); centerPane.add(testConnection);
secondnorth.add(centerPane,BorderLayout.NORTH); 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)); infor2.setForeground(new Color(207, 42, 39));
secondnorth.add(infor2,BorderLayout.CENTER); secondnorth.add(infor2,BorderLayout.CENTER);
@ -221,13 +223,13 @@ public class WebJsPane extends BasicPane {
localRadioSelectAction(); localRadioSelectAction();
urlFileRadioButton.setForeground(new Color(143, 142, 139)); urlFileRadioButton.setForeground(new Color(143, 142, 139));
localFileRadioButton.setForeground(Color.black); 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(" "); infor2.setText(" ");
} else if (urlFileRadioButton.isSelected()) { } else if (urlFileRadioButton.isSelected()) {
urlRadioSelectAction(); urlRadioSelectAction();
localFileRadioButton.setForeground(new Color(143, 142, 139)); localFileRadioButton.setForeground(new Color(143, 142, 139));
urlFileRadioButton.setForeground(Color.black); 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(" "); infor1.setText(" ");
} }
if (StringUtils.isEmpty(urlText.getText()) && StringUtils.isEmpty(localText.getText())) { if (StringUtils.isEmpty(urlText.getText()) && StringUtils.isEmpty(localText.getText())) {

19
designer-realize/src/main/java/com/fr/start/Designer.java

@ -1,5 +1,7 @@
package com.fr.start; package com.fr.start;
import com.fr.log.FineLoggerFactory;
/** /**
* 设计器主进程入口(无缝更换升级jar包若使用其他类作为入口需要重新打包designer.exe等升级后仍然走的原来逻辑) * 设计器主进程入口(无缝更换升级jar包若使用其他类作为入口需要重新打包designer.exe等升级后仍然走的原来逻辑)
* *
@ -11,7 +13,24 @@ package com.fr.start;
public class Designer { public class Designer {
public static void main(String[] args) { public static void main(String[] args) {
try {
if (DesignerJavaRuntime.getInstance().isInValidVmOptions()) {
runNonGuardianDesigner(args);
} else {
// 创建进程 // 创建进程
DesignerLauncher.getInstance().start(args); 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);
}
} }

19
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.StringUtils;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import java.util.Set;
/** /**
* 设计器Java运行环境 * 设计器Java运行环境
* *
@ -16,11 +18,12 @@ import com.fr.stable.os.OperatingSystem;
public class DesignerJavaRuntime extends AbstractJavaRuntime { public class DesignerJavaRuntime extends AbstractJavaRuntime {
private static final String DOT = "."; 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 INSTALL4J = ".install4j";
private static final String JAVA_EXEC = "java"; private static final String JAVA_EXEC = "java";
private static final String WIN_JRE_BIN = StableUtils.pathJoin("jre", "bin"); private static final String WIN_JRE_BIN = StableUtils.pathJoin("jre", "bin");
private static final String MAC_JRE_BIN = StableUtils.pathJoin("jre.bundle", "Contents", "Home", "jre", "bin"); private static final String MAC_JRE_BIN = StableUtils.pathJoin("jre.bundle", "Contents", "Home", "jre", "bin");
private static final String[] DEBUG_OPTIONS = new String[]{"-Dfile.encoding=UTF-8", "-Xmx2048m"}; private static final String[] DEBUG_OPTIONS = new String[]{"-Dfile.encoding=UTF-8", "-Xmx2048m", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"};
private static final DesignerJavaRuntime INSTANCE = new DesignerJavaRuntime(); private static final DesignerJavaRuntime INSTANCE = new DesignerJavaRuntime();
@ -28,6 +31,20 @@ public class DesignerJavaRuntime extends AbstractJavaRuntime {
return INSTANCE; return INSTANCE;
} }
/**
* 远程调试不走启动守护
* @return
*/
public boolean isInValidVmOptions() {
String[] options = getJvmOptions();
for (String op : options) {
if (op.startsWith(REMOTE_DEBUG)) {
return true;
}
}
return false;
}
@Override @Override
public String getJavaExec() { public String getJavaExec() {
String installHome = StableUtils.getInstallHome(); String installHome = StableUtils.getInstallHome();

2
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"); BuildContext.setBuildFilePath("/com/fr/stable/build.properties");
// 检查是否是-Ddebug = true 启动 并切换对应的端口以及环境配置文件 // 检查是否是-Ddebug = true 启动 并切换对应的端口以及环境配置文件
checkDebugStart(); checkDebugStart();
// 都是在启动过程中读取,这边提前初始化xml配置
DesignerEnvManager.getEnvManager();
// 初始化look and feel // 初始化look and feel
DesignUtils.initLookAndFeel(); DesignUtils.initLookAndFeel();
if (DesignUtils.isPortOccupied()) { if (DesignUtils.isPortOccupied()) {

30
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());
}
}
Loading…
Cancel
Save