|
|
@ -1,9 +1,6 @@ |
|
|
|
package com.fr.design; |
|
|
|
package com.fr.design; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.common.report.ReportState; |
|
|
|
import com.fr.common.report.ReportState; |
|
|
|
import com.fr.design.env.processor.RemoteDesignerWorkspaceInfoProcessor; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard; |
|
|
|
|
|
|
|
import com.fr.design.plugin.remind.PluginErrorDesignReminder; |
|
|
|
|
|
|
|
import com.fr.design.data.DesignTableDataManager; |
|
|
|
import com.fr.design.data.DesignTableDataManager; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
@ -14,13 +11,16 @@ import com.fr.design.env.DesignerWorkspaceInfoContext; |
|
|
|
import com.fr.design.env.DesignerWorkspaceType; |
|
|
|
import com.fr.design.env.DesignerWorkspaceType; |
|
|
|
import com.fr.design.env.RemoteDesignerWorkspaceInfo; |
|
|
|
import com.fr.design.env.RemoteDesignerWorkspaceInfo; |
|
|
|
import com.fr.design.env.RemoteWorkspace; |
|
|
|
import com.fr.design.env.RemoteWorkspace; |
|
|
|
|
|
|
|
import com.fr.design.env.processor.RemoteDesignerWorkspaceInfoProcessor; |
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
import com.fr.design.file.SaveSomeTemplatePane; |
|
|
|
import com.fr.design.file.SaveSomeTemplatePane; |
|
|
|
import com.fr.design.file.TemplateTreePane; |
|
|
|
import com.fr.design.file.TemplateTreePane; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard; |
|
|
|
import com.fr.design.notification.NotificationCenter; |
|
|
|
import com.fr.design.notification.NotificationCenter; |
|
|
|
|
|
|
|
import com.fr.design.plugin.remind.PluginErrorDesignReminder; |
|
|
|
import com.fr.design.utils.DesignUtils; |
|
|
|
import com.fr.design.utils.DesignUtils; |
|
|
|
import com.fr.design.versioncheck.VersionCheckUtils; |
|
|
|
import com.fr.design.versioncheck.VersionCheckUtils; |
|
|
|
import com.fr.env.EnvListPane; |
|
|
|
import com.fr.env.EnvListPane; |
|
|
@ -31,6 +31,7 @@ import com.fr.invoke.Reflect; |
|
|
|
import com.fr.json.JSONArray; |
|
|
|
import com.fr.json.JSONArray; |
|
|
|
import com.fr.locale.InterProviderFactory; |
|
|
|
import com.fr.locale.InterProviderFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
import com.fr.performance.profile.PerformancePoint; |
|
|
|
import com.fr.process.ProcessEventPipe; |
|
|
|
import com.fr.process.ProcessEventPipe; |
|
|
|
import com.fr.process.engine.core.CarryMessageEvent; |
|
|
|
import com.fr.process.engine.core.CarryMessageEvent; |
|
|
|
import com.fr.process.engine.core.FineProcessContext; |
|
|
|
import com.fr.process.engine.core.FineProcessContext; |
|
|
@ -41,12 +42,14 @@ import com.fr.start.server.ServerTray; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
import com.fr.workspace.WorkContextCallback; |
|
|
|
import com.fr.workspace.WorkContextCallback; |
|
|
|
import com.fr.workspace.Workspace; |
|
|
|
import com.fr.workspace.Workspace; |
|
|
|
|
|
|
|
import com.fr.workspace.WorkspaceSwitchProcess; |
|
|
|
import com.fr.workspace.base.WorkspaceAPI; |
|
|
|
import com.fr.workspace.base.WorkspaceAPI; |
|
|
|
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
|
|
|
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
|
|
|
import com.fr.workspace.engine.base.FineObjectPool; |
|
|
|
import com.fr.workspace.engine.base.FineObjectPool; |
|
|
|
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; |
|
|
|
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; |
|
|
|
import com.fr.workspace.engine.exception.WorkspaceConnectionException; |
|
|
|
import com.fr.workspace.engine.exception.WorkspaceConnectionException; |
|
|
|
import com.fr.workspace.engine.rpc.WorkspaceProxyPool; |
|
|
|
import com.fr.workspace.engine.rpc.WorkspaceProxyPool; |
|
|
|
|
|
|
|
import static javax.swing.JOptionPane.QUESTION_MESSAGE; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JOptionPane; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
@ -58,12 +61,11 @@ 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.HashSet; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.HashSet; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static javax.swing.JOptionPane.QUESTION_MESSAGE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class EnvChangeEntrance { |
|
|
|
public class EnvChangeEntrance { |
|
|
|
private static final String BRANCH_TAG = "#"; |
|
|
|
private static final String BRANCH_TAG = "#"; |
|
|
@ -125,48 +127,111 @@ 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) { |
|
|
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
|
|
|
|
|
|
|
DesignerWorkspaceInfo selectedEnv = customUserName(envManager.getWorkspaceInfo(envName)); |
|
|
|
|
|
|
|
DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); |
|
|
|
|
|
|
|
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WorkspaceSwitchProcess lastProcess = WorkContext.getSwitcher().getProcess(); |
|
|
|
|
|
|
|
PerformancePoint performancePoint = PerformancePoint.create(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean switchStatus = doSwitch2Env(envName, strategy); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WorkspaceSwitchProcess currentProcess = WorkContext.getSwitcher().getProcess(); |
|
|
|
|
|
|
|
// 如果相同,代表根本没切换 ==
|
|
|
|
|
|
|
|
if (lastProcess != currentProcess) { |
|
|
|
|
|
|
|
// 记录切换耗时
|
|
|
|
|
|
|
|
recordSwitchInfos(performancePoint, switchStatus); |
|
|
|
|
|
|
|
// 触发切换埋点
|
|
|
|
|
|
|
|
triggerSwitchMetric(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return switchStatus; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 由云端运维,触发切换埋点 |
|
|
|
|
|
|
|
* 内部空实现 |
|
|
|
|
|
|
|
* 见 <a href="https://kms.fineres.com/pages/viewpage.action?pageId=945327503">实现</a> |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void triggerSwitchMetric() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 切换到新环境 |
|
|
|
|
|
|
|
* 1. 先获取选中的环境 |
|
|
|
|
|
|
|
* 2. 生成工作目录 |
|
|
|
|
|
|
|
* 3. 验证工作目录 |
|
|
|
|
|
|
|
* 4. 触发切换操作 |
|
|
|
|
|
|
|
* 5. 触发可能存在异常的切换后动作 |
|
|
|
|
|
|
|
* 6. 触发切换后动作 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param envName 新工作环境名称 |
|
|
|
|
|
|
|
* @return 是否成功 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean doSwitch2Env(final String envName, PopTipStrategy strategy) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DesignerWorkspaceInfo selectedEnv = getSelectedEnv(envName); |
|
|
|
try { |
|
|
|
try { |
|
|
|
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); |
|
|
|
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); |
|
|
|
boolean checkValid = workspace != null && selectedEnv.checkValid(); |
|
|
|
if (notValid(workspace, selectedEnv)) { |
|
|
|
if (!checkValid) { |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
//如果是相同环境
|
|
|
|
doSwitchAction(envName, workspace); |
|
|
|
if (isSameEnv(workspace)) { |
|
|
|
afterSwitchWithEx(); |
|
|
|
//目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了
|
|
|
|
|
|
|
|
switch2SameEnv(envName); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//切换到新环境,做下封装
|
|
|
|
|
|
|
|
switch2OtherEnv(workspace, envName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// REPORT-25688如果是war包部署的服务器,给与提示
|
|
|
|
|
|
|
|
if (WorkContext.getCurrent().isWarDeploy()) { |
|
|
|
|
|
|
|
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
|
|
|
|
|
|
|
|
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
|
|
|
if (JTemplate.isValid(template)) { |
|
|
|
|
|
|
|
template.refreshToolArea(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); |
|
|
|
|
|
|
|
} catch (Exception exception) { |
|
|
|
} catch (Exception exception) { |
|
|
|
// 失败的处理
|
|
|
|
// 失败的处理
|
|
|
|
WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); |
|
|
|
WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
afterSwitch(); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private DesignerWorkspaceInfo getSelectedEnv(String envName) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
|
|
|
|
|
|
|
DesignerWorkspaceInfo selectedEnv = customUserName(envManager.getWorkspaceInfo(envName)); |
|
|
|
|
|
|
|
DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); |
|
|
|
|
|
|
|
return selectedEnv; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean notValid(Workspace workspace, DesignerWorkspaceInfo selectedEnv) throws Exception { |
|
|
|
|
|
|
|
boolean checkValid = workspace != null && selectedEnv.checkValid(); |
|
|
|
|
|
|
|
return !checkValid; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void doSwitchAction(String envName, Workspace workspace) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果是相同环境
|
|
|
|
|
|
|
|
if (isSameEnv(workspace)) { |
|
|
|
|
|
|
|
//目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了
|
|
|
|
|
|
|
|
switch2SameEnv(envName); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//切换到新环境,做下封装
|
|
|
|
|
|
|
|
switch2OtherEnv(workspace, envName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void afterSwitchWithEx() { |
|
|
|
|
|
|
|
// REPORT-25688如果是war包部署的服务器,给与提示
|
|
|
|
|
|
|
|
if (WorkContext.getCurrent().isWarDeploy()) { |
|
|
|
|
|
|
|
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
|
|
|
|
|
|
|
|
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
|
|
|
if (JTemplate.isValid(template)) { |
|
|
|
|
|
|
|
template.refreshToolArea(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void afterSwitch() { |
|
|
|
TemplateTreePane.getInstance().refreshDockingView(); |
|
|
|
TemplateTreePane.getInstance().refreshDockingView(); |
|
|
|
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter(); |
|
|
|
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter(); |
|
|
|
if (model != null) { |
|
|
|
if (model != null) { |
|
|
@ -175,7 +240,18 @@ public class EnvChangeEntrance { |
|
|
|
NotificationCenter.getInstance().clearAllNotifications(); |
|
|
|
NotificationCenter.getInstance().clearAllNotifications(); |
|
|
|
//切换环境后,清空粘贴板里面的内容
|
|
|
|
//切换环境后,清空粘贴板里面的内容
|
|
|
|
TemplateTreeClipboard.getInstance().reset(); |
|
|
|
TemplateTreeClipboard.getInstance().reset(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void recordSwitchInfos(PerformancePoint performancePoint, boolean switchSuccess) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
performancePoint.end(elapsed -> { |
|
|
|
|
|
|
|
WorkspaceSwitchProcess process = WorkContext.getSwitcher().getProcess(); |
|
|
|
|
|
|
|
Optional.ofNullable(process) |
|
|
|
|
|
|
|
.ifPresent((e) -> { |
|
|
|
|
|
|
|
e.recordSwitchElapsed(elapsed); |
|
|
|
|
|
|
|
e.setSwitchSuccess(switchSuccess); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|