Browse Source

Merge pull request #11882 in DESIGN/design from release/11.0 to bugfix/11.0

* commit '114b84b799e94f7ad17aa505ab8dfec843089135':
  REPORT-92953 设计器修改默认工程名称后无法启动 改一下老代码魔法值
  REPORT-92953 设计器修改默认工程名称后无法启动
  REPORT-92953 设计器修改默认工程名称后无法启动
  REPORT-92953 设计器修改默认工程名称后无法启动
  REPORT-92953 设计器修改默认工程名称后无法启动
  REPORT-92953 设计器修改默认工程名称后无法启动
bugfix/11.0
superman 2 years ago
parent
commit
1bca46a32c
  1. 113
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 3
      designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java

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

@ -65,6 +65,9 @@ import java.util.HashSet;
import static javax.swing.JOptionPane.QUESTION_MESSAGE; import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance { 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() { public static EnvChangeEntrance getInstance() {
return HOLDER.singleton; return HOLDER.singleton;
@ -116,19 +119,14 @@ public class EnvChangeEntrance {
if (!checkValid) { if (!checkValid) {
return false; return false;
} }
//如果是相同环境
WorkContext.switchTo(workspace, new WorkContextCallback() { if (isSameEnv(workspace)) {
@Override //目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了
public void done() { switch2SameEnv(envName);
DesignerEnvManager.getEnvManager().setCurEnvName(envName); } else {
DesignUtils.refreshDesignerFrame(); //切换到新环境,做下封装
DesignTableDataManager.fireDSChanged(new HashMap<String, String>()); switch2OtherEnv(workspace, envName);
if (WorkContext.getCurrent().isLocal()) { }
//初始化一下serverTray
ServerTray.init();
}
}
});
// 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"),
@ -156,6 +154,47 @@ public class EnvChangeEntrance {
return true; 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);
}
/** /**
* 这个功能留着可能会加回来先做注释处理 * 这个功能留着可能会加回来先做注释处理
* 切换远程环境之前进行版本检测当版本不一致的时候提示 * 切换远程环境之前进行版本检测当版本不一致的时候提示
@ -201,13 +240,14 @@ public class EnvChangeEntrance {
return true; return true;
} }
/** /**
* 对选择的环境做服务检测 * 对选择的环境做服务检测
*
* @param selectedEnv 选择的工作环境 * @param selectedEnv 选择的工作环境
*/ */
public void showServiceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception { public void showServiceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception {
//是否需要做服务校验 //是否需要做服务校验
if(needCheckBranch(selectedEnv)) { if (needCheckBranch(selectedEnv)) {
String localBranch; String localBranch;
String remoteBranch; String remoteBranch;
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();
@ -228,18 +268,18 @@ public class EnvChangeEntrance {
StringBuilder textBuilder = new StringBuilder(); StringBuilder textBuilder = new StringBuilder();
for (Class clazz : noExistServiceSet) { for (Class clazz : noExistServiceSet) {
WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class); WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class);
if(workspaceAPI == null){ if (workspaceAPI == null) {
FineLoggerFactory.getLogger().info("workspace service {} get annotation failed", clazz); FineLoggerFactory.getLogger().info("workspace service {} get annotation failed", clazz);
continue; continue;
} }
if(workspaceAPI.ignore()){ if (workspaceAPI.ignore()) {
continue; continue;
} }
String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description()); String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description());
textBuilder.append(descriptionOfCN).append("\n"); textBuilder.append(descriptionOfCN).append("\n");
} }
String areaText = textBuilder.toString(); String areaText = textBuilder.toString();
if(StringUtils.isEmpty(areaText)){ if (StringUtils.isEmpty(areaText)) {
return; return;
} }
@ -251,24 +291,25 @@ public class EnvChangeEntrance {
* 判断是否需要做版本验证判断依据为 * 判断是否需要做版本验证判断依据为
* 1选择的环境为远程环境 * 1选择的环境为远程环境
* 2一个月内不弹出是否勾选 * 2一个月内不弹出是否勾选
*
* @param selectedEnv 选择的环境 * @param selectedEnv 选择的环境
* @return * @return
*/ */
private boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv){ private boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv) {
if(selectedEnv.getType() == DesignerWorkspaceType.Remote){ if (selectedEnv.getType() == DesignerWorkspaceType.Remote) {
try { try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
if(StringUtils.isEmpty(selectedEnv.getRemindTime())){ if (StringUtils.isEmpty(selectedEnv.getRemindTime())) {
return true; return true;
} }
//获取记录的时间 //获取记录的时间
Date remindTime = format.parse(selectedEnv.getRemindTime()); Date remindTime = format.parse(selectedEnv.getRemindTime());
calendar.setTime(remindTime); calendar.setTime(remindTime);
//获取一个月后的时间 //获取一个月后的时间
calendar.add(Calendar.MONTH,1); calendar.add(Calendar.MONTH, 1);
//与当前时间作对比,然后判断是否提示 //与当前时间作对比,然后判断是否提示
if(new Date().after(calendar.getTime())){ if (new Date().after(calendar.getTime())) {
return true; return true;
} }
} catch (ParseException e) { } catch (ParseException e) {
@ -280,21 +321,22 @@ public class EnvChangeEntrance {
/** /**
* 获取不存在的服务列表 * 获取不存在的服务列表
*
* @param info 环境连接信息 * @param info 环境连接信息
* @return 以Set形式返回不存在的服务 * @return 以Set形式返回不存在的服务
*/ */
public Set<Class> getNoExistServiceSet(WorkspaceConnectionInfo info){ public Set<Class> getNoExistServiceSet(WorkspaceConnectionInfo info) {
Set<Class> noExistServiceSet = new HashSet<Class>(); Set<Class> noExistServiceSet = new HashSet<Class>();
Set<Class> remoteServiceSet = new HashSet<Class>(); Set<Class> remoteServiceSet = new HashSet<Class>();
Set<Class> localServiceSet = FineObjectPool.getInstance().getServerPool().keySet(); Set<Class> localServiceSet = FineObjectPool.getInstance().getServerPool().keySet();
try { try {
JSONArray serviceArray = new FunctionalHttpRequest(info).getServiceList(); JSONArray serviceArray = new FunctionalHttpRequest(info).getServiceList();
for(int i = 0; i < serviceArray.size(); i++){ for (int i = 0; i < serviceArray.size(); i++) {
try{ try {
Class clazz = Class.forName((String) serviceArray.get(i)); Class clazz = Class.forName((String) serviceArray.get(i));
remoteServiceSet.add(clazz); remoteServiceSet.add(clazz);
} catch (Exception e){ } catch (Exception e) {
continue; continue;
} }
} }
@ -304,12 +346,12 @@ public class EnvChangeEntrance {
} catch (WorkspaceConnectionException e) { } catch (WorkspaceConnectionException e) {
FineLoggerFactory.getLogger().info(e.getMessage()); FineLoggerFactory.getLogger().info(e.getMessage());
//根据本地的服务列表做逐一检测 //根据本地的服务列表做逐一检测
for(Class clazz : localServiceSet) { for (Class clazz : localServiceSet) {
Method testMethod = Reflect.on(Method.class).create(clazz, "connectTest", new Class[0], String.class, new Class[0], 1025, 8, null, null, null, null).get(); Method testMethod = Reflect.on(Method.class).create(clazz, "connectTest", new Class[0], String.class, new Class[0], 1025, 8, null, null, null, null).get();
WorkspaceProxyPool proxyPool = (WorkspaceProxyPool) (((RemoteWorkspace) WorkContext.getCurrent()).getClient()).getPool(); WorkspaceProxyPool proxyPool = (WorkspaceProxyPool) (((RemoteWorkspace) WorkContext.getCurrent()).getClient()).getPool();
Result result = proxyPool.testInvoker(testMethod); Result result = proxyPool.testInvoker(testMethod);
Exception invokeException = (Exception) result.getException(); Exception invokeException = (Exception) result.getException();
if(invokeException != null){ if (invokeException != null) {
Exception cause = (Exception) invokeException.getCause(); Exception cause = (Exception) invokeException.getCause();
//获取被包装最底层的异常 //获取被包装最底层的异常
while (cause != null) { while (cause != null) {
@ -317,26 +359,27 @@ public class EnvChangeEntrance {
cause = (Exception) invokeException.getCause(); cause = (Exception) invokeException.getCause();
} }
//该异常表示服务不存在 //该异常表示服务不存在
if(invokeException instanceof ClassNotFoundException){ if (invokeException instanceof ClassNotFoundException) {
noExistServiceSet.add(clazz); noExistServiceSet.add(clazz);
} }
} }
} }
return noExistServiceSet; return noExistServiceSet;
} catch (Exception e){ } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(),e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return noExistServiceSet; return noExistServiceSet;
} }
} }
/** /**
* 格式化分支版本号 * 格式化分支版本号
*
* @param branch 初始的分支版本号 * @param branch 初始的分支版本号
* @return 格式化后的版本号 * @return 格式化后的版本号
*/ */
private String formatBranch(String branch){ private String formatBranch(String branch) {
if(branch.contains("#")){ if (branch.contains(BRANCH_TAG)) {
return branch.substring(branch.lastIndexOf("-") + 1, branch.length() - 13); return branch.substring(branch.lastIndexOf(BRANCH_BEGIN) + 1, branch.length() - BRANCH_SUB_LENGTH);
} }
return branch; return branch;
} }

3
designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java

@ -175,7 +175,8 @@ public class JNameEdList extends UIList implements CellEditorListener {
} }
public void setIllegalIndex(int index) { public void setIllegalIndex(int index) {
setNameAt(NameInspector.ILLEGAL_NAME_HOLDER, index); //环境如果重名会被命名为请重命名,这个请重命名也会重复,后面加个索引区别一下
setNameAt(NameInspector.ILLEGAL_NAME_HOLDER + index, index);
this.repaint(); this.repaint();
} }

Loading…
Cancel
Save