|
|
|
@ -65,6 +65,9 @@ import java.util.HashSet;
|
|
|
|
|
import static javax.swing.JOptionPane.QUESTION_MESSAGE; |
|
|
|
|
|
|
|
|
|
public class EnvChangeEntrance { |
|
|
|
|
private static final String BRANCH_TAG = "#"; |
|
|
|
|
private static final String BRANCH_BEGIN = "-"; |
|
|
|
|
private static final int BRANCH_SUB_LENGTH = 13; |
|
|
|
|
|
|
|
|
|
public static EnvChangeEntrance getInstance() { |
|
|
|
|
return HOLDER.singleton; |
|
|
|
@ -116,19 +119,14 @@ public class EnvChangeEntrance {
|
|
|
|
|
if (!checkValid) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
WorkContext.switchTo(workspace, new WorkContextCallback() { |
|
|
|
|
@Override |
|
|
|
|
public void done() { |
|
|
|
|
DesignerEnvManager.getEnvManager().setCurEnvName(envName); |
|
|
|
|
DesignUtils.refreshDesignerFrame(); |
|
|
|
|
DesignTableDataManager.fireDSChanged(new HashMap<String, String>()); |
|
|
|
|
if (WorkContext.getCurrent().isLocal()) { |
|
|
|
|
//初始化一下serverTray
|
|
|
|
|
ServerTray.init(); |
|
|
|
|
} |
|
|
|
|
//如果是相同环境
|
|
|
|
|
if (isSameEnv(workspace)) { |
|
|
|
|
//目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了
|
|
|
|
|
switch2SameEnv(envName); |
|
|
|
|
} else { |
|
|
|
|
//切换到新环境,做下封装
|
|
|
|
|
switch2OtherEnv(workspace, envName); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
// REPORT-25688如果是war包部署的服务器,给与提示
|
|
|
|
|
if (WorkContext.getCurrent().isWarDeploy()) { |
|
|
|
|
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), |
|
|
|
@ -156,6 +154,47 @@ public class EnvChangeEntrance {
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 切换到其他环境 |
|
|
|
|
* |
|
|
|
|
* @param workspace 要切换的环境 |
|
|
|
|
* @param envName 要切换的环境名称 |
|
|
|
|
*/ |
|
|
|
|
private void switch2OtherEnv(Workspace workspace, String envName) { |
|
|
|
|
WorkContext.switchTo(workspace, new WorkContextCallback() { |
|
|
|
|
@Override |
|
|
|
|
public void done() { |
|
|
|
|
DesignerEnvManager.getEnvManager().setCurEnvName(envName); |
|
|
|
|
DesignUtils.refreshDesignerFrame(); |
|
|
|
|
DesignTableDataManager.fireDSChanged(new HashMap<String, String>()); |
|
|
|
|
if (WorkContext.getCurrent().isLocal()) { |
|
|
|
|
//初始化一下serverTray
|
|
|
|
|
ServerTray.init(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 切换到相同环境要做的事情 |
|
|
|
|
* |
|
|
|
|
* @param envName 当前的环境名 |
|
|
|
|
*/ |
|
|
|
|
private void switch2SameEnv(String envName) { |
|
|
|
|
//当前环境名称可能重命名更改过,需要更新一下,防止启动失败
|
|
|
|
|
DesignerEnvManager.getEnvManager().setCurEnvName(envName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 是否切换到相同环境 |
|
|
|
|
* |
|
|
|
|
* @param workspace 要切换的环境 |
|
|
|
|
* @return 是则返回true |
|
|
|
|
*/ |
|
|
|
|
private boolean isSameEnv(Workspace workspace) { |
|
|
|
|
return AssistUtils.equals(WorkContext.getCurrent(), workspace); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 这个功能留着,可能会加回来,先做注释处理 |
|
|
|
|
* 切换远程环境之前,进行版本检测,当版本不一致的时候,提示。 |
|
|
|
@ -203,6 +242,7 @@ public class EnvChangeEntrance {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 对选择的环境做服务检测 |
|
|
|
|
* |
|
|
|
|
* @param selectedEnv 选择的工作环境 |
|
|
|
|
*/ |
|
|
|
|
public void showServiceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception { |
|
|
|
@ -251,6 +291,7 @@ public class EnvChangeEntrance {
|
|
|
|
|
* 判断是否需要做版本验证,判断依据为 |
|
|
|
|
* 1、选择的环境为远程环境 |
|
|
|
|
* 2、一个月内不弹出是否勾选 |
|
|
|
|
* |
|
|
|
|
* @param selectedEnv 选择的环境 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
@ -280,6 +321,7 @@ public class EnvChangeEntrance {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取不存在的服务列表 |
|
|
|
|
* |
|
|
|
|
* @param info 环境连接信息 |
|
|
|
|
* @return 以Set形式返回不存在的服务 |
|
|
|
|
*/ |
|
|
|
@ -331,12 +373,13 @@ public class EnvChangeEntrance {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 格式化分支版本号 |
|
|
|
|
* |
|
|
|
|
* @param branch 初始的分支版本号 |
|
|
|
|
* @return 格式化后的版本号 |
|
|
|
|
*/ |
|
|
|
|
private String formatBranch(String branch) { |
|
|
|
|
if(branch.contains("#")){ |
|
|
|
|
return branch.substring(branch.lastIndexOf("-") + 1, branch.length() - 13); |
|
|
|
|
if (branch.contains(BRANCH_TAG)) { |
|
|
|
|
return branch.substring(branch.lastIndexOf(BRANCH_BEGIN) + 1, branch.length() - BRANCH_SUB_LENGTH); |
|
|
|
|
} |
|
|
|
|
return branch; |
|
|
|
|
} |
|
|
|
|