Browse Source

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

feature/big-screen
lucian 4 years ago
parent
commit
bf8da8edde
  1. 29
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 25
      designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java

29
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.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
@ -385,7 +386,7 @@ public class EnvChangeEntrance {
public void doOk() {
envListOkAction(envListPane, PopTipStrategy.LATER);
// 切换完成后清理密码
updateSelectEnv(DesignerEnvManager.getEnvManager().getCurEnvName());
updateNotRememberPwdEnv();
}
@Override
@ -416,7 +417,7 @@ public class EnvChangeEntrance {
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
DesignerExiter.getInstance().execute();
} else {
updateSelectEnv(DesignerEnvManager.getEnvManager().getCurEnvName());
updateNotRememberPwdEnv();
}
}
@ -428,17 +429,19 @@ public class EnvChangeEntrance {
envListDialog.setVisible(true);
}
/**
/**
* 切换环境后 刷新远程目录需要忘记密码的情况
* @param envName 环境名
*/
private void updateSelectEnv(String envName) {
private void updateNotRememberPwdEnv() {
DesignerEnvManager mgr = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo info = mgr.getWorkspaceInfo(envName);
if (info != null) {
WorkspaceConnectionInfo connection = info.getConnection();
if (connection != null && !connection.isRememberPwd()) {
Iterator<String> iterator = mgr.getEnvNameIterator();
while (iterator.hasNext()) {
String envName = iterator.next();
DesignerWorkspaceInfo info = mgr.getWorkspaceInfo(envName);
if (isNotRememberPwd(info)) {
WorkspaceConnectionInfo connection = info.getConnection();
DesignerWorkspaceInfo workspaceInfo = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo(
connection.getUrl(), connection.getUserName(), StringUtils.EMPTY, connection.getCertPath(), connection.getCertSecretKey(), false));
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.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.env.CheckServiceDialog;
import com.fr.invoke.Reflect;
@ -58,7 +59,7 @@ public class EnvChangeEntranceTest {
}
@Test
public void testUpdateSelectEnv() {
public void testUpdateNotRememberPwdEnv() {
DesignerEnvManager manager = new DesignerEnvManager();
@ -71,16 +72,32 @@ public class EnvChangeEntranceTest {
manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)));
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("updateSelectEnv", "test2");
Reflect.on(entrance).call("updateNotRememberPwdEnv");
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("test3").getName(), "name");
Assert.assertEquals(manager.getWorkspaceInfo("test3").getPath(), "path");
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