From f959f4102c419caaaea66a5eb132d532aa8a2690 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 11 Jan 2024 14:06:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-113059=20=E7=BC=96=E8=BE=91=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=EF=BC=8C=E5=8D=A1=E9=A1=BF=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=8D=E6=98=8E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/TableDataTreePane.java | 40 ++++++++++++++++--- .../com/fr/design/file/TemplateTreePane.java | 8 ++-- ...aseCheckWorker.java => DefaultWorker.java} | 20 +++++----- .../design/worker/data/TableDataResult.java | 32 +++++++++++++++ 4 files changed, 82 insertions(+), 18 deletions(-) rename designer-base/src/main/java/com/fr/design/worker/{check/BaseCheckWorker.java => DefaultWorker.java} (70%) create mode 100644 designer-base/src/main/java/com/fr/design/worker/data/TableDataResult.java 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 Date: Thu, 11 Jan 2024 14:41:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-113059=20=E7=BC=96=E8=BE=91=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=EF=BC=8C=E5=8D=A1=E9=A1=BF=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=8D=E6=98=8E=E6=98=BE=20=E4=BF=AE=E5=A4=8DdsName=E4=B8=8D?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/worker/data/TableDataResult.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/worker/data/TableDataResult.java b/designer-base/src/main/java/com/fr/design/worker/data/TableDataResult.java index b8261bea23..753259dbe5 100644 --- a/designer-base/src/main/java/com/fr/design/worker/data/TableDataResult.java +++ b/designer-base/src/main/java/com/fr/design/worker/data/TableDataResult.java @@ -1,6 +1,8 @@ package com.fr.design.worker.data; +import com.fr.base.AbstractTableData; import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; +import com.fr.stable.StringUtils; /** * 数据集的worker结果 @@ -17,7 +19,10 @@ public class TableDataResult { public TableDataResult(TemplateTableDataWrapper wrapper) { this.wrapper = wrapper; - this.name = wrapper.getTableDataName(); + // getTableDataInstance中就已经初始化了名字,但是没直接连到wrapper上来,如果直接wrapper.getTableDataName()获取不到 + // 跟rinoux确认了一下【没直接连到wrapper上来】可能是存在额外考虑 + // 因此在这里通过额外判断来复用,如果不符合预期就重新再拿一次name吧 + this.name = wrapper.getTableData() instanceof AbstractTableData ? ((AbstractTableData) wrapper.getTableData()).getDsName() : StringUtils.EMPTY; }