|
|
@ -127,27 +127,80 @@ public class EnvChangeEntrance { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 切换到新环境 |
|
|
|
* 切换到新环境 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param envName 新工作环境名称 |
|
|
|
* @param envName 新工作环境名称 |
|
|
|
|
|
|
|
* @param strategy 提示策略 |
|
|
|
* @return 是否成功 |
|
|
|
* @return 是否成功 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private boolean switch2Env(final String envName, PopTipStrategy strategy) { |
|
|
|
private boolean switch2Env(final String envName, PopTipStrategy strategy) { |
|
|
|
|
|
|
|
|
|
|
|
PerformancePoint performancePoint = PerformancePoint.create(); |
|
|
|
PerformancePoint performancePoint = PerformancePoint.create(); |
|
|
|
|
|
|
|
boolean switchStatus = doSwitch2Env(envName, strategy); |
|
|
|
|
|
|
|
// 记录切换耗时
|
|
|
|
|
|
|
|
recordSwitchElapsed(performancePoint); |
|
|
|
|
|
|
|
// 触发切换埋点
|
|
|
|
|
|
|
|
triggerSwitchMetric(switchStatus); |
|
|
|
|
|
|
|
return switchStatus; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 由云端运维,触发切换埋点 |
|
|
|
|
|
|
|
* 内部空实现 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param switchStatus 切换状态 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void triggerSwitchMetric(boolean switchStatus) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 切换到新环境 |
|
|
|
|
|
|
|
* 1. 先获取选中的环境 |
|
|
|
|
|
|
|
* 2. 生成工作目录 |
|
|
|
|
|
|
|
* 3. 验证工作目录 |
|
|
|
|
|
|
|
* 4. 触发切换操作 |
|
|
|
|
|
|
|
* 5. 触发可能存在异常的切换后动作 |
|
|
|
|
|
|
|
* 6. 触发切换后动作 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param envName 新工作环境名称 |
|
|
|
|
|
|
|
* @return 是否成功 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean doSwitch2Env(final String envName, PopTipStrategy strategy) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DesignerWorkspaceInfo selectedEnv = getSelectedEnv(envName); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); |
|
|
|
|
|
|
|
if (notValid(workspace, selectedEnv)) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
doSwitchAction(envName, workspace); |
|
|
|
|
|
|
|
afterSwitchWithEx(); |
|
|
|
|
|
|
|
} catch (Exception exception) { |
|
|
|
|
|
|
|
// 失败的处理
|
|
|
|
|
|
|
|
WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
afterSwitch(); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private DesignerWorkspaceInfo getSelectedEnv(String envName) { |
|
|
|
|
|
|
|
|
|
|
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
|
|
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
|
|
|
DesignerWorkspaceInfo selectedEnv = customUserName(envManager.getWorkspaceInfo(envName)); |
|
|
|
DesignerWorkspaceInfo selectedEnv = customUserName(envManager.getWorkspaceInfo(envName)); |
|
|
|
DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); |
|
|
|
DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); |
|
|
|
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); |
|
|
|
return selectedEnv; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
private static boolean notValid(Workspace workspace, DesignerWorkspaceInfo selectedEnv) throws Exception { |
|
|
|
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); |
|
|
|
|
|
|
|
boolean checkValid = workspace != null && selectedEnv.checkValid(); |
|
|
|
boolean checkValid = workspace != null && selectedEnv.checkValid(); |
|
|
|
if (!checkValid) { |
|
|
|
return !checkValid; |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void doSwitchAction(String envName, Workspace workspace) { |
|
|
|
|
|
|
|
|
|
|
|
//如果是相同环境
|
|
|
|
//如果是相同环境
|
|
|
|
if (isSameEnv(workspace)) { |
|
|
|
if (isSameEnv(workspace)) { |
|
|
|
//目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了
|
|
|
|
//目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了
|
|
|
@ -156,6 +209,9 @@ public class EnvChangeEntrance { |
|
|
|
//切换到新环境,做下封装
|
|
|
|
//切换到新环境,做下封装
|
|
|
|
switch2OtherEnv(workspace, envName); |
|
|
|
switch2OtherEnv(workspace, envName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void afterSwitchWithEx() { |
|
|
|
// REPORT-25688如果是war包部署的服务器,给与提示
|
|
|
|
// REPORT-25688如果是war包部署的服务器,给与提示
|
|
|
|
if (WorkContext.getCurrent().isWarDeploy()) { |
|
|
|
if (WorkContext.getCurrent().isWarDeploy()) { |
|
|
|
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), |
|
|
|
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), |
|
|
@ -167,13 +223,9 @@ public class EnvChangeEntrance { |
|
|
|
template.refreshToolArea(); |
|
|
|
template.refreshToolArea(); |
|
|
|
} |
|
|
|
} |
|
|
|
PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); |
|
|
|
PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); |
|
|
|
} catch (Exception exception) { |
|
|
|
|
|
|
|
// 失败的处理
|
|
|
|
|
|
|
|
WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); |
|
|
|
|
|
|
|
// 记录切换耗时
|
|
|
|
|
|
|
|
recordSwitchElapsed(performancePoint); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void afterSwitch() { |
|
|
|
TemplateTreePane.getInstance().refreshDockingView(); |
|
|
|
TemplateTreePane.getInstance().refreshDockingView(); |
|
|
|
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter(); |
|
|
|
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter(); |
|
|
|
if (model != null) { |
|
|
|
if (model != null) { |
|
|
@ -182,9 +234,6 @@ public class EnvChangeEntrance { |
|
|
|
NotificationCenter.getInstance().clearAllNotifications(); |
|
|
|
NotificationCenter.getInstance().clearAllNotifications(); |
|
|
|
//切换环境后,清空粘贴板里面的内容
|
|
|
|
//切换环境后,清空粘贴板里面的内容
|
|
|
|
TemplateTreeClipboard.getInstance().reset(); |
|
|
|
TemplateTreeClipboard.getInstance().reset(); |
|
|
|
// 记录切换耗时
|
|
|
|
|
|
|
|
recordSwitchElapsed(performancePoint); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void recordSwitchElapsed(PerformancePoint performancePoint) { |
|
|
|
private static void recordSwitchElapsed(PerformancePoint performancePoint) { |
|
|
|