Browse Source

Merge pull request #268 in DESIGN/design from ~HZZZ/design61:release/10.0 to release/10.0

* commit '3551be07b4d3e7c1614a736d496613236534d9b0':
  .
  .
  REPORT-10066 远程设计页面,新建远程服务器默认值显示错误
research/10.0
Hzzz 7 years ago
parent
commit
640b44cf3a
  1. 47
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  2. 30
      designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java
  3. 82
      designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java

47
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -23,7 +23,6 @@ import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;
@ -115,7 +114,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
/**
* 主机位置
*/
private RemoteEnvURL remoteEnvURL = new RemoteEnvURL("");
private RemoteWorkspaceURL remoteWorkspaceURL = new RemoteWorkspaceURL("");
/**
* https 配置面板
*/
@ -189,7 +188,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
fileChooserButton.setEnabled(isHttps);
updateHttpsConfigPanel();
remoteEnvURL.setHttps(isHttps);
remoteWorkspaceURL.setHttps(isHttps);
fillRemoteEnvURLField();
fillIndividualField();
}
@ -267,9 +266,9 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
public void populateBean(RemoteDesignerWorkspaceInfo ob) {
WorkspaceConnection connection = ob.getConnection();
if (connection != null) {
this.remoteEnvURL = Strings.isNullOrEmpty(connection.getUrl())
? RemoteEnvURL.createDefaultURL()
: new RemoteEnvURL(connection.getUrl());
this.remoteWorkspaceURL = Strings.isNullOrEmpty(connection.getUrl())
? RemoteWorkspaceURL.createDefaultURL()
: new RemoteWorkspaceURL(connection.getUrl());
String username = fromNullable(connection.getUserName()).or(StringUtils.EMPTY);
String pwd = fromNullable(connection.getPassword()).or(StringUtils.EMPTY);
String certPath = fromNullable(connection.getCertPath()).or(StringUtils.EMPTY);
@ -280,17 +279,17 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
this.certSecretKeyInput.setText(certSecretKey);
} else {
this.remoteEnvURL = RemoteEnvURL.createDefaultURL();
this.remoteWorkspaceURL = RemoteWorkspaceURL.createDefaultURL();
this.usernameInput.setText(StringUtils.EMPTY);
this.passwordInput.setText(StringUtils.EMPTY);
}
fillRemoteEnvURLField();
fillIndividualField();
httpsCheckbox.setSelected(this.remoteEnvURL.getHttps());
httpsCheckbox.setSelected(this.remoteWorkspaceURL.getHttps());
DesignerEnvManager.getEnvManager().setHttps(this.remoteEnvURL.getHttps());
fileChooserButton.setEnabled(this.remoteEnvURL.getHttps());
DesignerEnvManager.getEnvManager().setHttps(this.remoteWorkspaceURL.getHttps());
fileChooserButton.setEnabled(this.remoteWorkspaceURL.getHttps());
updateHttpsConfigPanel();
@ -299,7 +298,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
@Override
public RemoteDesignerWorkspaceInfo updateBean() {
WorkspaceConnection connection = new WorkspaceConnection(
this.remoteEnvURL.getURL(),
this.remoteWorkspaceURL.getURL(),
this.usernameInput.getText(),
new String(this.passwordInput.getPassword()),
this.certPathInput.getText(),
@ -576,7 +575,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
*/
private void fillRemoteEnvURLField() {
remoteEnvURLInput.getDocument().removeDocumentListener(overallDocListener);
remoteEnvURLInput.setText(remoteEnvURL.getURL());
remoteEnvURLInput.setText(remoteWorkspaceURL.getURL());
remoteEnvURLInput.getDocument().addDocumentListener(overallDocListener);
}
@ -584,14 +583,14 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
* 自动填充子条目输入框
*/
private void fillIndividualField() {
if (remoteEnvURL == null) {
if (remoteWorkspaceURL == null) {
return;
}
disableSubDocListener();
hostNameInput.setText(remoteEnvURL.hasDefaultHostName() ? StringUtils.EMPTY : remoteEnvURL.getHost());
portInput.setText(remoteEnvURL.getPort());
webAppNameInput.setText(remoteEnvURL.getWeb());
servletNameInput.setText(remoteEnvURL.getServlet());
hostNameInput.setText(remoteWorkspaceURL.hasDefaultHostName() ? StringUtils.EMPTY : remoteWorkspaceURL.getHost());
portInput.setText(remoteWorkspaceURL.getPort());
webAppNameInput.setText(remoteWorkspaceURL.getWeb());
servletNameInput.setText(remoteWorkspaceURL.getServlet());
enableSubDocListener();
}
@ -601,11 +600,11 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
String port = portInput.getText();
String web = webAppNameInput.getText();
String servlet = servletNameInput.getText();
remoteEnvURL.setHttps(isHttps);
remoteEnvURL.setHost(host);
remoteEnvURL.setPort(port);
remoteEnvURL.setWeb(web);
remoteEnvURL.setServlet(servlet);
remoteWorkspaceURL.setHttps(isHttps);
remoteWorkspaceURL.setHost(host);
remoteWorkspaceURL.setPort(port);
remoteWorkspaceURL.setWeb(web);
remoteWorkspaceURL.setServlet(servlet);
}
@ -617,10 +616,10 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
}
private void actionURLInputChange() {
remoteEnvURL = new RemoteEnvURL(remoteEnvURLInput.getText());
remoteWorkspaceURL = new RemoteWorkspaceURL(remoteEnvURLInput.getText());
fillIndividualField();
httpsCheckbox.setSelected(remoteEnvURL.getHttps());
httpsCheckbox.setSelected(remoteWorkspaceURL.getHttps());
boolean isHttps = httpsCheckbox.isSelected();
DesignerEnvManager.getEnvManager().setHttps(isHttps);
fileChooserButton.setEnabled(isHttps);

30
designer-base/src/main/java/com/fr/env/RemoteEnvURL.java → designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java vendored

@ -8,7 +8,7 @@ import java.util.Objects;
/**
* @author yaohwu
*/
public class RemoteEnvURL implements FCloneable {
public class RemoteWorkspaceURL implements FCloneable {
/**
* 默认 hostname
@ -17,20 +17,20 @@ public class RemoteEnvURL implements FCloneable {
/**
* 默认 web app name
*/
private static final String DEFAULT_WEB_APP_NAME = "WebReport";
private static final String DEFAULT_WEB_APP_NAME = "webroot";
/**
* 默认 servlet name
*/
private static final String DEFAULT_SERVLET_NAME = "ReportServer";
private static final String DEFAULT_SERVLET_NAME = "decision";
/**
* 默认端口
*/
private static final String DEFAULT_PORT = "8080";
private static final String DEFAULT_PORT = "8075";
private static final String HTTPS = "https://";
private static final String HTTP = "http://";
public static final RemoteEnvURL DEFAULT_URL =
new RemoteEnvURL(
public static final RemoteWorkspaceURL DEFAULT_URL =
new RemoteWorkspaceURL(
false,
DEFAULT_HOST_NAME,
DEFAULT_PORT,
@ -45,12 +45,12 @@ public class RemoteEnvURL implements FCloneable {
/**
* 解析 url 字符串 生成 RemoteEnvURL 对象
* 解析 url 字符串 生成 RemoteWorkspaceURL 对象
* url 字符串格式 (http(s)://)host(:port)/+web/+servlet/+(others)
*
* @param url x:x/x/x/x
*/
public RemoteEnvURL(String url) {
public RemoteWorkspaceURL(String url) {
// 没有写协议名称 默认 使用 http 协议
if (!url.startsWith(HTTPS) && !url.startsWith(HTTP)) {
@ -102,12 +102,12 @@ public class RemoteEnvURL implements FCloneable {
return DEFAULT_HOST_NAME.equals(host);
}
public static RemoteEnvURL createDefaultURL() {
public static RemoteWorkspaceURL createDefaultURL() {
return DEFAULT_URL.clone();
}
public RemoteEnvURL(boolean isHttps, String host, String port, String web, String servlet) {
public RemoteWorkspaceURL(boolean isHttps, String host, String port, String web, String servlet) {
this.isHttps = isHttps;
this.host = host != null ? host.trim() : StringUtils.EMPTY;
this.port = port != null ? port.trim() : StringUtils.EMPTY;
@ -172,7 +172,7 @@ public class RemoteEnvURL implements FCloneable {
if (o == null || getClass() != o.getClass()) {
return false;
}
RemoteEnvURL that = (RemoteEnvURL) o;
RemoteWorkspaceURL that = (RemoteWorkspaceURL) o;
return isHttps == that.isHttps &&
Objects.equals(host, that.host) &&
Objects.equals(port, that.port) &&
@ -188,7 +188,7 @@ public class RemoteEnvURL implements FCloneable {
@Override
public String toString() {
return "RemoteEnvURL{" +
return "RemoteWorkspaceURL{" +
"isHttps=" + isHttps +
", host='" + host + '\'' +
", port='" + port + '\'' +
@ -198,10 +198,10 @@ public class RemoteEnvURL implements FCloneable {
}
@Override
public RemoteEnvURL clone() {
RemoteEnvURL cloned;
public RemoteWorkspaceURL clone() {
RemoteWorkspaceURL cloned;
try {
cloned = (RemoteEnvURL) super.clone();
cloned = (RemoteWorkspaceURL) super.clone();
return cloned;
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable

82
designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java vendored

@ -14,71 +14,71 @@ public class RemoteEnvURLTest {
public void testURLParser() {
String a;
RemoteEnvURL b;
RemoteWorkspaceURL b;
// https or http begin
a = "www.baidu.com:9090/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
Assert.assertFalse(b.getHttps());
a = "http://www.baidu.com:9090/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
Assert.assertFalse(b.getHttps());
a = "https://www.baidu.com:9090/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
Assert.assertTrue(b.getHttps());
// https or http end
// host begin
a = "https://www.baidu.com/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("www.baidu.com", b.getHost());
a = "https://baidu.com/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("baidu.com", b.getHost());
a = "https://192.168.1/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("192.168.1", b.getHost());
a = "https://中文·o((⊙﹏⊙))o囖/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getHost());
a = "https://a.b.c.d.e.f/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a.b.c.d.e.f", b.getHost());
// host end
//port begin
a = "https://www.baidu.com:9090/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("9090", b.getPort());
a = "https://www.baidu.com:/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getPort());
a = "https://www.baidu.com/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getPort());
a = "https://www.baidu.com:kk/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("kk", b.getPort());
a = "https://www.baidu.com:中文·o((⊙﹏⊙))o囖/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getPort());
a = "https://www.baidu.com:中文·o((⊙﹏⊙))o囖";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getPort());
a = "https://www.baidu.com:中文·o((⊙﹏⊙))o囖///////";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getPort());
//port end
@ -86,109 +86,109 @@ public class RemoteEnvURLTest {
//web begin
a = "https://www.baidu.com:9090///";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getWeb());
a = "https://www.baidu.com:9090";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getWeb());
a = "https://www.baidu.com:9090/";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getWeb());
a = "https://www.baidu.com:9090///web///servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("web", b.getWeb());
a = "https://www.baidu.com:9090/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("web", b.getWeb());
a = "https://www.baidu.com:9090/中文·o((⊙﹏⊙))o囖/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getWeb());
a = "https://www.baidu.com:9090/web///servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("web", b.getWeb());
a = "https://www.baidu.com:9090///web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("web", b.getWeb());
//web end
//servlet begin
a = "https://www.baidu.com:9090///web////servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("servlet", b.getServlet());
a = "https://www.baidu.com:9090";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090/";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//web";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//web//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//web/";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//web//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com:9090//web/a/";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
a = "https://www.baidu.com:9090//web/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
a = "https://www.baidu.com:9090//web/a//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
a = "https://www.baidu.com:9090//web/中文·o((⊙﹏⊙))o囖//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("中文·o((⊙﹏⊙))o囖", b.getServlet());
a = "https://www.baidu.com//web//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("", b.getServlet());
a = "https://www.baidu.com//web/a/";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
a = "https://www.baidu.com//web/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
a = "https://www.baidu.com//web/a//";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
assertEquals("a", b.getServlet());
// servlet end
//others begin
a = "https://www.baidu.com/web/servlet/ahttps://www.baidu.com/web/servlet/a";
b = new RemoteEnvURL(a);
b = new RemoteWorkspaceURL(a);
Assert.assertTrue(b.getHttps());
assertEquals("www.baidu.com", b.getHost());
assertEquals("", b.getPort());

Loading…
Cancel
Save