diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index 67fb918666..47690bba9b 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -25,7 +25,7 @@ import com.fr.stable.StringUtils; import com.fr.stable.os.OperatingSystem; import com.fr.start.ServerStarter; import com.fr.start.common.DesignerStartupContext; -import com.fr.startup.ui.StartupPageModel; +import com.fr.start.common.DesignerStartupUtil; import com.fr.value.NotNullLazyValue; import com.fr.workspace.WorkContext; import org.jetbrains.annotations.NotNull; @@ -48,7 +48,6 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.Enumeration; import java.util.Locale; -import java.util.Optional; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -216,18 +215,9 @@ public class DesignUtils { @Override public void run() { DesignerStartupContext context = DesignerStartupContext.getInstance(); + // 如果在启动页展示中 - if (context.isOnWaiting()) { - FileFILE fileFILE = new FileFILE(f); - // 设置上一次启动模板为 - DesignerEnvManager.getEnvManager().setLastOpenFile(fileFILE.getPath()); - StartupPageModel model = context.getStartupPageModel(); - Optional.ofNullable(model) - .ifPresent((e) -> { - // 执行上一次模板的启动 - Runnable openLastTemplateRunnable = e.getOpenLastTemplateRunnable(); - openLastTemplateRunnable.run(); - }); + if (DesignerStartupUtil.openTemplateIfOnWaiting(f)) { return; } // 如果是在启动中 diff --git a/designer-base/src/main/java/com/fr/start/common/DesignerStartupUtil.java b/designer-base/src/main/java/com/fr/start/common/DesignerStartupUtil.java index 5bc55e80c5..bc1d349474 100644 --- a/designer-base/src/main/java/com/fr/start/common/DesignerStartupUtil.java +++ b/designer-base/src/main/java/com/fr/start/common/DesignerStartupUtil.java @@ -6,16 +6,45 @@ import com.fr.file.FILE; import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; +import com.fr.startup.ui.StartupPageModel; import org.jetbrains.annotations.Nullable; import java.io.File; +import java.util.Optional; /** * created by Harrison on 2022/07/09 **/ public class DesignerStartupUtil { - @Nullable + /** + * 如果是在启动页中 + * + * @param file 文件 + * @return 成功/失败 + */ + public static boolean openTemplateIfOnWaiting(File file) { + + DesignerStartupContext context = DesignerStartupContext.getInstance(); + // 如果在启动页展示中 + if (context.isOnWaiting()) { + FileFILE fileFILE = new FileFILE(file); + // 设置上一次启动模板为当前模板 + // 注意这里需要设置为 envFullName + DesignerEnvManager.getEnvManager().setLastOpenFile(fileFILE.getEnvFullName()); + StartupPageModel model = context.getStartupPageModel(); + Optional.ofNullable(model) + .ifPresent((e) -> { + // 执行上一次模板的启动 + Runnable openLastTemplateRunnable = e.getOpenLastTemplateRunnable(); + openLastTemplateRunnable.run(); + }); + return true; + } + return false; + } + + @Nullable public static FILE convertArgs2FILE(String[] args) { // p:需要打开这个报表文件,这个代码不能删除.