Browse Source

REPORT-94530 【二开接口】转换用户名接口

feature/x
John.Ying-应志浩 2 years ago
parent
commit
57fc08a7cd
  1. 25
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 30
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  3. 10
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java

25
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) { private boolean switch2Env(final String envName, PopTipStrategy strategy) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); DesignerWorkspaceInfo selectedEnv = customUserName(envManager.getWorkspaceInfo(envName));
DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv);
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();

30
designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -6,6 +6,7 @@ import com.fr.log.FineLoggerFactory;
import com.fr.security.SecurityToolbox; import com.fr.security.SecurityToolbox;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.fun.mark.Immutable;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -166,6 +167,15 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
return object; return object;
} }
/**
* clone一个自定义连接信息的RemoteDesignerWorkspaceInfo
*/
public Object cloneWithConnectionInfo(WorkspaceConnectionInfo workspaceConnectionInfo) throws CloneNotSupportedException {
RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo) super.clone();
object.connection = workspaceConnectionInfo;
return object;
}
@Override @Override
public boolean checkValid() throws Exception { public boolean checkValid() throws Exception {
@ -181,4 +191,24 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
WorkContext.getConnector().validateVT(connection); WorkContext.getConnector().validateVT(connection);
return true; 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);
}
} }

10
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -579,8 +579,14 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
private void tryConnectRemoteEnv() { private void tryConnectRemoteEnv() {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); 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<Boolean, Void> worker = new SwingWorker<Boolean, Void>() { final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override @Override

Loading…
Cancel
Save