Browse Source

Pull request #12121: REPORT-94530 【二开接口】转换用户名接口

Merge in DESIGN/design from ~JOHN.YING/design:feature/x to feature/x

* commit 'f04b2e44f06d000cbcb97256e61d338bdcfec8ac':
  REPORT-94530 【二开接口】转换用户名接口--调整一下接口位置
  REPORT-94530 【二开接口】转换用户名接口--格式调整
  REPORT-94530 【二开接口】转换用户名接口--注释
  REPORT-94530 【二开接口】转换用户名接口--注释
  REPORT-94530 【二开接口】转换用户名接口
  REPORT-94530 【二开接口】转换用户名接口
  REPORT-94530 【二开接口】转换用户名接口
feature/x
John.Ying-应志浩 2 years ago
parent
commit
c78de7a96f
  1. 26
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 10
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  3. 24
      designer-base/src/main/java/com/fr/design/env/processor/AbstractRemoteDesignerWorkspaceInfoProcessor.java
  4. 25
      designer-base/src/main/java/com/fr/design/env/processor/RemoteDesignerWorkspaceInfoProcessor.java
  5. 11
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java

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

@ -1,6 +1,7 @@
package com.fr.design;
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;
@ -101,6 +102,29 @@ public class EnvChangeEntrance {
}
}
/**
* 插件进行用户名转换
*
* @param workspaceInfo 环境信息
*/
private DesignerWorkspaceInfo customUserName(DesignerWorkspaceInfo workspaceInfo) {
//本地环境直接返回
if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) {
return workspaceInfo;
}
RemoteDesignerWorkspaceInfoProcessor processor = ExtraDesignClassManager.getInstance().getSingle(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 +133,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();

10
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.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 {

24
designer-base/src/main/java/com/fr/design/env/processor/AbstractRemoteDesignerWorkspaceInfoProcessor.java vendored

@ -0,0 +1,24 @@
package com.fr.design.env.processor;
import com.fr.stable.fun.mark.API;
/**
* 远程设计自定义用户名接口实现抽象类
*
* @author John.Ying
* @since 11.0
* Created on 2023/5/17
*/
@API(level = RemoteDesignerWorkspaceInfoProcessor.CURRENT_LEVEL)
public abstract class AbstractRemoteDesignerWorkspaceInfoProcessor implements RemoteDesignerWorkspaceInfoProcessor {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
}

25
designer-base/src/main/java/com/fr/design/env/processor/RemoteDesignerWorkspaceInfoProcessor.java vendored

@ -0,0 +1,25 @@
package com.fr.design.env.processor;
import com.fr.stable.fun.mark.Immutable;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
/**
* 远程设计自定义用户名接口
* px:为了二开插件开的接口不建议实现后面可能会变动
*
* @author John.Ying
* @since 11.0
* Created on 2023/5/17
*/
public interface RemoteDesignerWorkspaceInfoProcessor extends Immutable {
String XML_TAG = "RemoteDesignerWorkspaceInfoProcessor";
int CURRENT_LEVEL = 1;
/**
* 根据链接信息自定义用户名
*/
WorkspaceConnectionInfo customUserName(WorkspaceConnectionInfo workspaceInfo);
}

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

@ -5,6 +5,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.env.processor.RemoteDesignerWorkspaceInfoProcessor;
import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
@ -579,8 +580,14 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
private void tryConnectRemoteEnv() {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
final WorkspaceConnectionInfo connection = remoteEnv.getConnection();
WorkspaceConnectionInfo originalConnection = remoteEnv.getConnection();
final WorkspaceConnectionInfo connection;
RemoteDesignerWorkspaceInfoProcessor processor = ExtraDesignClassManager.getInstance().getSingle(RemoteDesignerWorkspaceInfoProcessor.XML_TAG);
if (processor != null) {
connection = processor.customUserName(originalConnection);
} else {
connection = originalConnection;
}
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override

Loading…
Cancel
Save