diff --git a/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java index f8a0f5d4fa..ed2597f1d7 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java @@ -63,6 +63,15 @@ public class CallbackSaveWorker extends SaveWorker { } } + public void addSuccessCallbackBeforeLast(Runnable successRunnable) { + if (successRunnableList == null) { + successRunnableList = new LinkedList<>(); + } + if (successRunnable != null) { + successRunnableList.add(successRunnableList.size() - 1, successRunnable); + } + } + public void addFailCallback(Runnable failRunnable) { if (failRunnableList == null) { failRunnableList = new LinkedList<>(); diff --git a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java index 782538f63a..69e514b408 100644 --- a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java +++ b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java @@ -6,10 +6,13 @@ import com.fr.design.fun.impl.AbstractPreviewProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; +import com.fr.design.worker.WorkerManager; +import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.general.web.ParameterConstants; import java.util.HashMap; import java.util.Map; +import javax.swing.SwingWorker; /** * Created by kerry on 2020-04-23 @@ -44,6 +47,22 @@ public class DeveloperPreview extends AbstractPreviewProvider { @Override public void onClick(JTemplate jt) { super.onClick(jt); + SwingWorker worker = WorkerManager.getInstance().getWorker(jt.getRuntimeId()); + if (worker instanceof CallbackSaveWorker) { + CallbackSaveWorker callbackSaveWorker = (CallbackSaveWorker) worker; + callbackSaveWorker.addSuccessCallbackBeforeLast(new Runnable() { + @Override + public void run() { + onPreview(jt); + } + }); + } else if (jt.getEditingFILE().isEnvFile()) { + // 已经保存在当前工作目录了 + onPreview(jt); + } + } + + private void onPreview(JTemplate jt) { MutilTempalteTabPane.getInstance().closeCurrentTpl(); jt.generateForBiddenTemplate(); }