Browse Source

Pull request #13524: REPORT-113059 编辑数据集,卡顿修复不明显

Merge in DESIGN/design from ~DESTINY.LIN/design:fix-lag to fix-lag

* commit '802d33ef45ab000a02934362c9a7ea350b9108dc':
  REPORT-113059 编辑数据集,卡顿修复不明显 修复dsName不复用问题
  REPORT-113059 编辑数据集,卡顿修复不明显
fix-lag
Destiny.Lin-林锦龙 11 months ago
parent
commit
23f8617003
  1. 40
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  2. 8
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  3. 20
      designer-base/src/main/java/com/fr/design/worker/DefaultWorker.java
  4. 37
      designer-base/src/main/java/com/fr/design/worker/data/TableDataResult.java

40
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.SeparatorDef;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils; 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.StrategyConfig;
import com.fr.esd.core.strategy.config.StrategyConfigHelper; import com.fr.esd.core.strategy.config.StrategyConfigHelper;
import com.fr.esd.event.DSMapping; import com.fr.esd.event.DSMapping;
@ -77,10 +79,7 @@ import javax.swing.SwingUtilities;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import javax.swing.ToolTipManager; import javax.swing.ToolTipManager;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.dnd.DnDConstants; import java.awt.dnd.DnDConstants;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
@ -95,6 +94,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
public class TableDataTreePane extends BasicTableDataTreePane { public class TableDataTreePane extends BasicTableDataTreePane {
@ -150,6 +150,8 @@ public class TableDataTreePane extends BasicTableDataTreePane {
private TableDataSearchRemindPane remindPane; private TableDataSearchRemindPane remindPane;
private TreeSearchToolbarPane toolbarPane; private TreeSearchToolbarPane toolbarPane;
private BasicDialog loadingDialog;
private TableDataTreePane() { private TableDataTreePane() {
initPane(); initPane();
} }
@ -1027,7 +1029,35 @@ public class TableDataTreePane extends BasicTableDataTreePane {
@Override @Override
public void actionPerformed(ActionEvent e) { 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<TableDataResult> worker = new DefaultWorker<TableDataResult>(() -> 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);
} }
} }

8
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.manager.search.searcher.control.pane.TemplateSearchRemindPane;
import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.worker.check.TemplateCheckResult; 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.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
@ -242,16 +242,16 @@ public class TemplateTreePane extends JPanel implements FileOperations {
String reportPath = reportletsTree.getSelectedTemplatePath(); String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
BaseCheckWorker checkLockWorker = getCheckLockWorker(node, selectedFilePath); DefaultWorker<TemplateCheckResult> checkLockWorker = getCheckLockWorker(node, selectedFilePath);
checkLockWorker.execute(); checkLockWorker.execute();
TemplateCheckResult checkLockResult = checkLockWorker.getResult(); TemplateCheckResult checkLockResult = checkLockWorker.getResult();
processLockResult(checkLockResult, node ,selectedFilePath); processLockResult(checkLockResult, node ,selectedFilePath);
} }
@NotNull @NotNull
private BaseCheckWorker getCheckLockWorker(FileNode node, String selectedFilePath) { private DefaultWorker<TemplateCheckResult> getCheckLockWorker(FileNode node, String selectedFilePath) {
String lock = node.getLock(); String lock = node.getLock();
return new BaseCheckWorker(() -> { return new DefaultWorker<TemplateCheckResult>(() -> {
boolean showLockInfo = needShowLockInfo(lock, selectedFilePath, node); boolean showLockInfo = needShowLockInfo(lock, selectedFilePath, node);
UserInfo userInfo = null; UserInfo userInfo = null;
FileNodeFILE file = null; FileNodeFILE file = null;

20
designer-base/src/main/java/com/fr/design/worker/check/BaseCheckWorker.java → 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; import com.fr.log.FineLoggerFactory;
@ -8,24 +8,24 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/** /**
* 检查的Worker * 通用的Worker
* *
* @author Destiny.Lin * @author Destiny.Lin
* @since 11.0 * @since 11.0
* Created on 2024/1/8 * Created on 2024/1/8
*/ */
public abstract class BaseCheckWorker extends SwingWorker<TemplateCheckResult, Void> { public class DefaultWorker<T> extends SwingWorker<T, Void> {
private static final int TIME_OUT = 50; private static final int TIME_OUT = 50;
private boolean slowly = false; private boolean slowly = false;
private final Callable<TemplateCheckResult> doInBackground; private final Callable<T> doInBackground;
private TemplateCheckResult result; private T result;
public BaseCheckWorker(Callable<TemplateCheckResult> doInBackground) { public DefaultWorker(Callable<T> doInBackground) {
this.doInBackground = doInBackground; this.doInBackground = doInBackground;
} }
@Override @Override
protected TemplateCheckResult doInBackground() throws Exception { protected T doInBackground() throws Exception {
return this.doInBackground.call(); return this.doInBackground.call();
} }
@ -44,7 +44,7 @@ public abstract class BaseCheckWorker extends SwingWorker<TemplateCheckResult, V
/** /**
* 获取结果 * 获取结果
*/ */
public TemplateCheckResult getResult() { public T getResult() {
if (result != null) { if (result != null) {
return result; return result;
} }
@ -62,5 +62,7 @@ public abstract class BaseCheckWorker extends SwingWorker<TemplateCheckResult, V
/** /**
* 如果获取结果超过TIME_OUT则通过这个方式处理后续 * 如果获取结果超过TIME_OUT则通过这个方式处理后续
*/ */
public abstract void dealResultWhenSlowly(TemplateCheckResult result); public void dealResultWhenSlowly(T result) {
}
} }

37
designer-base/src/main/java/com/fr/design/worker/data/TableDataResult.java

@ -0,0 +1,37 @@
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结果
*
* @author Destiny.Lin
* @since 11.0
* Created on 2024/1/11
*/
public class TableDataResult {
private TemplateTableDataWrapper wrapper;
private String name;
public TableDataResult(TemplateTableDataWrapper wrapper) {
this.wrapper = wrapper;
// getTableDataInstance中就已经初始化了名字,但是没直接连到wrapper上来,如果直接wrapper.getTableDataName()获取不到
// 跟rinoux确认了一下【没直接连到wrapper上来】可能是存在额外考虑
// 因此在这里通过额外判断来复用,如果不符合预期就重新再拿一次name吧
this.name = wrapper.getTableData() instanceof AbstractTableData ? ((AbstractTableData) wrapper.getTableData()).getDsName() : StringUtils.EMPTY;
}
public TemplateTableDataWrapper getWrapper() {
return wrapper;
}
public String getName() {
return name;
}
}
Loading…
Cancel
Save