Browse Source

Pull request #7571: REPORT-64406 直接通过点击模板文件启动设计器

Merge in DESIGN/design from ~STARRYI/design:feature/x to feature/x

* commit '7b9663bcb761f55af191ed37a970a4c561a5f816':
  REPORT-64406 直接通过点击模板文件启动设计器
feature/x
starryi 3 years ago
parent
commit
307fe6c813
  1. 22
      designer-realize/src/main/java/com/fr/design/deeplink/DeepLinkManager.java
  2. 29
      designer-realize/src/main/java/com/fr/design/deeplink/FileOpen4MacDeepLink.java
  3. 1
      designer-realize/src/main/java/com/fr/start/MainDesigner.java

22
designer-realize/src/main/java/com/fr/design/deeplink/DeepLinkManager.java

@ -9,16 +9,19 @@ import com.fr.event.Listener;
import com.fr.event.Null; import com.fr.event.Null;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.third.org.apache.http.NameValuePair; import com.fr.third.org.apache.http.NameValuePair;
import com.fr.web.URLUtils; import com.fr.web.URLUtils;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.net.URLStreamHandler; import java.net.URLStreamHandler;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -49,6 +52,7 @@ public class DeepLinkManager {
} }
public void prepare() { public void prepare() {
register(new FileOpen4MacDeepLink());
register(new TemplateThemeInstallationDeepLink()); register(new TemplateThemeInstallationDeepLink());
FineStartupNotificationFactory.getNotification() FineStartupNotificationFactory.getNotification()
@ -115,7 +119,7 @@ public class DeepLinkManager {
FineLoggerFactory.getLogger().info("consume deep link: " + this.pendingURL); FineLoggerFactory.getLogger().info("consume deep link: " + this.pendingURL);
performDeepLinks(this.pendingURL, host, path, params); performDeepLinks(this.pendingURL, host, path, params);
this.pendingURL = null; markPendingURLConsumed();
} }
private void performDeepLinks(String url, String host, String path, Map<String, Object> params) { private void performDeepLinks(String url, String host, String path, Map<String, Object> params) {
@ -130,4 +134,20 @@ public class DeepLinkManager {
} }
}); });
} }
public String[] createNewArgs(String[] args) {
String filePath = this.pendingURL;
if (OperatingSystem.isMacos() && StringUtils.isNotEmpty(filePath) && new File(filePath).exists()) {
List<String> argList = Arrays.asList(args);
argList.add(filePath);
markPendingURLConsumed();
return argList.toArray(new String[]{});
} else {
return args;
}
}
private void markPendingURLConsumed() {
this.pendingURL = null;
}
} }

29
designer-realize/src/main/java/com/fr/design/deeplink/FileOpen4MacDeepLink.java

@ -0,0 +1,29 @@
package com.fr.design.deeplink;
import com.fr.design.mainframe.DesignerContext;
import com.fr.file.FileFILE;
import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem;
import java.io.File;
import java.util.Map;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2022/1/13
*/
public class FileOpen4MacDeepLink extends DeepLink {
@Override
public boolean accept(String url, String host, String path, Map<String, Object> params) {
return OperatingSystem.isMacos() && StringUtils.isEmpty(host) && StringUtils.isEmpty(path) && params.isEmpty();
}
@Override
public void run(String url, String host, String path, Map<String, Object> params) {
File file = new File(url);
if (file.exists()) {
DesignerContext.getDesignerFrame().openTemplate(new FileFILE(file));
}
}
}

1
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -122,6 +122,7 @@ public class MainDesigner extends BaseDesigner {
}); });
Module designerRoot = ModuleContext.parseRoot("designer-startup.xml"); Module designerRoot = ModuleContext.parseRoot("designer-startup.xml");
//传递启动参数 //传递启动参数
args = DeepLinkManager.getInstance().createNewArgs(args);
designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args)); designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args));
try { try {
designerRoot.start(); designerRoot.start();

Loading…
Cancel
Save