diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java index 149fa87dc2..321663ce5e 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java @@ -49,6 +49,8 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ToolBarDef; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.design.worker.DefaultWorker; +import com.fr.design.worker.data.TableDataResult; import com.fr.esd.core.strategy.config.StrategyConfig; import com.fr.esd.core.strategy.config.StrategyConfigHelper; import com.fr.esd.event.DSMapping; @@ -77,10 +79,7 @@ import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.ToolTipManager; import javax.swing.tree.TreePath; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.GridLayout; +import java.awt.*; import java.awt.dnd.DnDConstants; import java.awt.event.ActionEvent; import java.awt.event.KeyAdapter; @@ -95,6 +94,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; public class TableDataTreePane extends BasicTableDataTreePane { @@ -150,6 +150,8 @@ public class TableDataTreePane extends BasicTableDataTreePane { private TableDataSearchRemindPane remindPane; private TreeSearchToolbarPane toolbarPane; + private BasicDialog loadingDialog; + private TableDataTreePane() { initPane(); } @@ -1027,7 +1029,35 @@ public class TableDataTreePane extends BasicTableDataTreePane { @Override public void actionPerformed(ActionEvent e) { - dgEdit(getTableDataInstance().creatTableDataPane(), createDsName(getNamePrefix()), false); + TableDataResult result = getTableDataResult(); + if (result != null) { + dgEditByResult(result); + } else { + if (loadingDialog == null) { + TableDataLoadingPane loadingPane = new TableDataLoadingPane(); + loadingDialog = loadingPane.showLargeWindow(SwingUtilities.getWindowAncestor(TableDataTreePane.this), null); + } + loadingDialog.setVisible(true); + } + + } + + private TableDataResult getTableDataResult() { + DefaultWorker worker = new DefaultWorker(() -> new TableDataResult(getTableDataInstance())) { + @Override + public void dealResultWhenSlowly(TableDataResult result) { + if (loadingDialog != null) { + loadingDialog.setVisible(false); + } + dgEditByResult(result); + } + }; + worker.execute(); + return worker.getResult(); + } + + private void dgEditByResult(TableDataResult result) { + dgEdit(result.getWrapper().creatTableDataPane(), StringUtils.isEmpty(result.getName()) ? createDsName(getNamePrefix()) : result.getName(), false); } } diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index 58c73d24a8..ee00ad10b0 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -20,7 +20,7 @@ import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; import com.fr.design.mainframe.manager.search.searcher.control.pane.TemplateSearchRemindPane; import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.worker.check.TemplateCheckResult; -import com.fr.design.worker.check.BaseCheckWorker; +import com.fr.design.worker.DefaultWorker; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; @@ -242,16 +242,16 @@ public class TemplateTreePane extends JPanel implements FileOperations { String reportPath = reportletsTree.getSelectedTemplatePath(); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); - BaseCheckWorker checkLockWorker = getCheckLockWorker(node, selectedFilePath); + DefaultWorker checkLockWorker = getCheckLockWorker(node, selectedFilePath); checkLockWorker.execute(); TemplateCheckResult checkLockResult = checkLockWorker.getResult(); processLockResult(checkLockResult, node ,selectedFilePath); } @NotNull - private BaseCheckWorker getCheckLockWorker(FileNode node, String selectedFilePath) { + private DefaultWorker getCheckLockWorker(FileNode node, String selectedFilePath) { String lock = node.getLock(); - return new BaseCheckWorker(() -> { + return new DefaultWorker(() -> { boolean showLockInfo = needShowLockInfo(lock, selectedFilePath, node); UserInfo userInfo = null; FileNodeFILE file = null; diff --git a/designer-base/src/main/java/com/fr/design/worker/check/BaseCheckWorker.java b/designer-base/src/main/java/com/fr/design/worker/DefaultWorker.java similarity index 70% rename from designer-base/src/main/java/com/fr/design/worker/check/BaseCheckWorker.java rename to designer-base/src/main/java/com/fr/design/worker/DefaultWorker.java index 425a1e3124..f84bc0c006 100644 --- a/designer-base/src/main/java/com/fr/design/worker/check/BaseCheckWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/DefaultWorker.java @@ -1,4 +1,4 @@ -package com.fr.design.worker.check; +package com.fr.design.worker; import com.fr.log.FineLoggerFactory; @@ -8,24 +8,24 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /** - * 检查的Worker + * 通用的Worker * * @author Destiny.Lin * @since 11.0 * Created on 2024/1/8 */ -public abstract class BaseCheckWorker extends SwingWorker { +public class DefaultWorker extends SwingWorker { private static final int TIME_OUT = 50; private boolean slowly = false; - private final Callable doInBackground; - private TemplateCheckResult result; + private final Callable doInBackground; + private T result; - public BaseCheckWorker(Callable doInBackground) { + public DefaultWorker(Callable doInBackground) { this.doInBackground = doInBackground; } @Override - protected TemplateCheckResult doInBackground() throws Exception { + protected T doInBackground() throws Exception { return this.doInBackground.call(); } @@ -44,7 +44,7 @@ public abstract class BaseCheckWorker extends SwingWorker