Browse Source

Pull request #1743: REPORT-33369 在A目录的修改没有点确定。在B目录确定,A的修改也会保存

Merge in DESIGN/design from ~LUCIAN.CHEN/design:release/10.0 to release/10.0

* commit '9a9f48eadc6771100fdf8f57bc5107fb64635d11':
  REPORT-33369 在A目录的修改没有点确定。在B目录确定,A的修改也会保存
feature/big-screen
Lucian.Chen 5 years ago
parent
commit
b2ff3f3aa1
  1. 25
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 25
      designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java

25
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -53,6 +53,7 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
@ -385,7 +386,7 @@ public class EnvChangeEntrance {
public void doOk() { public void doOk() {
envListOkAction(envListPane, PopTipStrategy.LATER); envListOkAction(envListPane, PopTipStrategy.LATER);
// 切换完成后清理密码 // 切换完成后清理密码
updateSelectEnv(DesignerEnvManager.getEnvManager().getCurEnvName()); updateNotRememberPwdEnv();
} }
@Override @Override
@ -416,7 +417,7 @@ public class EnvChangeEntrance {
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
DesignerExiter.getInstance().execute(); DesignerExiter.getInstance().execute();
} else { } else {
updateSelectEnv(DesignerEnvManager.getEnvManager().getCurEnvName()); updateNotRememberPwdEnv();
} }
} }
@ -430,15 +431,17 @@ public class EnvChangeEntrance {
/** /**
* 切换环境后 刷新远程目录需要忘记密码的情况 * 切换环境后 刷新远程目录需要忘记密码的情况
* @param envName 环境名
*/ */
private void updateSelectEnv(String envName) { private void updateNotRememberPwdEnv() {
DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); DesignerEnvManager mgr = DesignerEnvManager.getEnvManager();
Iterator<String> iterator = mgr.getEnvNameIterator();
while (iterator.hasNext()) {
String envName = iterator.next();
DesignerWorkspaceInfo info = mgr.getWorkspaceInfo(envName); DesignerWorkspaceInfo info = mgr.getWorkspaceInfo(envName);
if (info != null) {
WorkspaceConnectionInfo connection = info.getConnection();
if (connection != null && !connection.isRememberPwd()) {
if (isNotRememberPwd(info)) {
WorkspaceConnectionInfo connection = info.getConnection();
DesignerWorkspaceInfo workspaceInfo = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo( DesignerWorkspaceInfo workspaceInfo = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo(
connection.getUrl(), connection.getUserName(), StringUtils.EMPTY, connection.getCertPath(), connection.getCertSecretKey(), false)); connection.getUrl(), connection.getUserName(), StringUtils.EMPTY, connection.getCertPath(), connection.getCertSecretKey(), false));
mgr.putEnv(envName, workspaceInfo); mgr.putEnv(envName, workspaceInfo);
@ -446,6 +449,14 @@ public class EnvChangeEntrance {
} }
} }
private boolean isNotRememberPwd(DesignerWorkspaceInfo info) {
if (info != null && info.getType() == DesignerWorkspaceType.Remote) {
WorkspaceConnectionInfo connection = info.getConnection();
return connection != null && !connection.isRememberPwd();
}
return false;
}
/** /**
* 提示显示策略 * 提示显示策略

25
designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java

@ -2,6 +2,7 @@ package com.fr.design;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.env.CheckServiceDialog; import com.fr.env.CheckServiceDialog;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
@ -58,7 +59,7 @@ public class EnvChangeEntranceTest {
} }
@Test @Test
public void testUpdateSelectEnv() { public void testUpdateNotRememberPwdEnv() {
DesignerEnvManager manager = new DesignerEnvManager(); DesignerEnvManager manager = new DesignerEnvManager();
@ -71,16 +72,32 @@ public class EnvChangeEntranceTest {
manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true))); manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)));
manager.putEnv("test2", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", false))); manager.putEnv("test2", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", false)));
manager.putEnv("test3", LocalDesignerWorkspaceInfo.create("name", "path"));
Reflect.on(entrance).call("updateSelectEnv", "test1"); Reflect.on(entrance).call("updateNotRememberPwdEnv");
Reflect.on(entrance).call("updateSelectEnv", "test2");
Assert.assertEquals(manager.getWorkspaceInfo("test1").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)).getConnection()); Assert.assertEquals(manager.getWorkspaceInfo("test1").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)).getConnection());
Assert.assertEquals(manager.getWorkspaceInfo("test2").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "", "", "", false)).getConnection()); Assert.assertEquals(manager.getWorkspaceInfo("test2").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "", "", "", false)).getConnection());
Assert.assertEquals(manager.getWorkspaceInfo("test3").getName(), "name");
Assert.assertEquals(manager.getWorkspaceInfo("test3").getPath(), "path");
PowerMock.verifyAll(); PowerMock.verifyAll();
} }
@Test
public void testIsNotRememberPwd() {
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
DesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true));
DesignerWorkspaceInfo info2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "111", "", "", false));
DesignerWorkspaceInfo info3 = LocalDesignerWorkspaceInfo.create("name", "path");
DesignerWorkspaceInfo info4 = null;
Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info1).get());
Assert.assertTrue((boolean) Reflect.on(entrance).call("isNotRememberPwd", info2).get());
Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info3).get());
Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info4).get());
}
} }
Loading…
Cancel
Save