Browse Source

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

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

* commit 'f959f4102c419caaaea66a5eb132d532aa8a2690':
  REPORT-113059 编辑数据集,卡顿修复不明显
fix-lag
Destiny.Lin-林锦龙 11 months ago
parent
commit
9a8fe63e0c
  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. 32
      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.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<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.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<TemplateCheckResult> checkLockWorker = getCheckLockWorker(node, selectedFilePath);
checkLockWorker.execute();
TemplateCheckResult checkLockResult = checkLockWorker.getResult();
processLockResult(checkLockResult, node ,selectedFilePath);
}
@NotNull
private BaseCheckWorker getCheckLockWorker(FileNode node, String selectedFilePath) {
private DefaultWorker<TemplateCheckResult> getCheckLockWorker(FileNode node, String selectedFilePath) {
String lock = node.getLock();
return new BaseCheckWorker(() -> {
return new DefaultWorker<TemplateCheckResult>(() -> {
boolean showLockInfo = needShowLockInfo(lock, selectedFilePath, node);
UserInfo userInfo = 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;
@ -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<TemplateCheckResult, Void> {
public class DefaultWorker<T> extends SwingWorker<T, Void> {
private static final int TIME_OUT = 50;
private boolean slowly = false;
private final Callable<TemplateCheckResult> doInBackground;
private TemplateCheckResult result;
private final Callable<T> doInBackground;
private T result;
public BaseCheckWorker(Callable<TemplateCheckResult> doInBackground) {
public DefaultWorker(Callable<T> 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<TemplateCheckResult, V
/**
* 获取结果
*/
public TemplateCheckResult getResult() {
public T getResult() {
if (result != null) {
return result;
}
@ -62,5 +62,7 @@ public abstract class BaseCheckWorker extends SwingWorker<TemplateCheckResult, V
/**
* 如果获取结果超过TIME_OUT则通过这个方式处理后续
*/
public abstract void dealResultWhenSlowly(TemplateCheckResult result);
public void dealResultWhenSlowly(T result) {
}
}

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

@ -0,0 +1,32 @@
package com.fr.design.worker.data;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
/**
* 数据集的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;
this.name = wrapper.getTableDataName();
}
public TemplateTableDataWrapper getWrapper() {
return wrapper;
}
public String getName() {
return name;
}
}
Loading…
Cancel
Save