From 57fc08a7cdacae8328ecd093758427ad750388a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=2EYing-=E5=BA=94=E5=BF=97=E6=B5=A9?= Date: Thu, 18 May 2023 18:30:40 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-94530=20=E3=80=90=E4=BA=8C=E5=BC=80?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E3=80=91=E8=BD=AC=E6=8D=A2=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 25 +++++++++++++++- .../env/RemoteDesignerWorkspaceInfo.java | 30 +++++++++++++++++++ .../main/java/com/fr/env/RemoteEnvPane.java | 10 +++++-- 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 0a464aa6d9..1aa6008fe3 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -101,6 +101,29 @@ public class EnvChangeEntrance { } } + /** + * 插件进行用户名转换 + * + * @param workspaceInfo 环境信息 + */ + private DesignerWorkspaceInfo customUserName(DesignerWorkspaceInfo workspaceInfo) { + //本地环境直接返回 + if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { + return workspaceInfo; + } + RemoteDesignerWorkspaceInfo.RemoteDesignerWorkspaceInfoProcessor processor = ExtraDesignClassManager.getInstance().getSingle(RemoteDesignerWorkspaceInfo.RemoteDesignerWorkspaceInfoProcessor.XML_TAG); + if (processor == null) { + return workspaceInfo; + } + try { + WorkspaceConnectionInfo workspaceConnectionInfo = processor.customUserName(workspaceInfo.getConnection()); + return (RemoteDesignerWorkspaceInfo) ((RemoteDesignerWorkspaceInfo) workspaceInfo).cloneWithConnectionInfo(workspaceConnectionInfo); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return workspaceInfo; + } + } + /** * 切换到新环境 * @@ -109,7 +132,7 @@ public class EnvChangeEntrance { */ private boolean switch2Env(final String envName, PopTipStrategy strategy) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); + DesignerWorkspaceInfo selectedEnv = customUserName(envManager.getWorkspaceInfo(envName)); DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 920a13dbfb..9041b1075a 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -6,6 +6,7 @@ import com.fr.log.FineLoggerFactory; import com.fr.security.SecurityToolbox; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.fun.mark.Immutable; import com.fr.stable.project.ProjectConstants; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; @@ -166,6 +167,15 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return object; } + /** + * clone一个自定义连接信息的RemoteDesignerWorkspaceInfo + */ + public Object cloneWithConnectionInfo(WorkspaceConnectionInfo workspaceConnectionInfo) throws CloneNotSupportedException { + RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo) super.clone(); + object.connection = workspaceConnectionInfo; + return object; + } + @Override public boolean checkValid() throws Exception { @@ -181,4 +191,24 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { WorkContext.getConnector().validateVT(connection); return true; } + + /** + * 远程设计自定义用户名接口 + * + * @author John.Ying + * @version 11.0 + * Created by John.Ying on 2023/5/17 + */ + public interface RemoteDesignerWorkspaceInfoProcessor extends Immutable { + + String XML_TAG = "RemoteDesignerWorkspaceInfoProcessor"; + + int CURRENT_LEVEL = 1; + + /** + * 返回一个新的自定义连接信息 + */ + WorkspaceConnectionInfo customUserName(WorkspaceConnectionInfo workspaceInfo); + + } } diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 31bdaa979b..cc721d5e12 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -579,8 +579,14 @@ public class RemoteEnvPane extends BasicBeanPane { private void tryConnectRemoteEnv() { final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); - final WorkspaceConnectionInfo connection = remoteEnv.getConnection(); - + WorkspaceConnectionInfo originalConnection = remoteEnv.getConnection(); + final WorkspaceConnectionInfo connection; + RemoteDesignerWorkspaceInfo.RemoteDesignerWorkspaceInfoProcessor processor = ExtraDesignClassManager.getInstance().getSingle(RemoteDesignerWorkspaceInfo.RemoteDesignerWorkspaceInfoProcessor.XML_TAG); + if (processor != null) { + connection = processor.customUserName(originalConnection); + } else { + connection = remoteEnv.getConnection(); + } final SwingWorker worker = new SwingWorker() { @Override