Browse Source

Pull request #13480: REPORT-111337 【设计器性能】设计器卡顿优化 打开模板动画优化

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

* commit 'a1ef183761e2191b5d9ab68d72181f5050975fb2':
  REPORT-111337 【设计器性能】设计器卡顿优化 打开模板动画优化
  REPORT-111337 【设计器性能】设计器卡顿优化 打开模板动画优化
  REPORT-111337 【设计器性能】设计器卡顿优化 打开模板动画优化
fix-lag
Destiny.Lin-林锦龙 11 months ago
parent
commit
10a7c4f187
  1. 39
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  2. 15
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  3. 8
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  4. 66
      designer-base/src/main/java/com/fr/design/worker/check/BaseCheckLockWorker.java
  5. 30
      designer-base/src/main/java/com/fr/design/worker/check/CheckLockResult.java

39
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -19,6 +19,8 @@ import com.fr.design.mainframe.JTemplate;
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.CheckLockResult;
import com.fr.design.worker.check.BaseCheckLockWorker;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
@ -65,6 +67,7 @@ import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import com.fr.workspace.server.vcs.VcsOperator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -236,21 +239,53 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (node == null) {
return;
}
String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
BaseCheckLockWorker checkLockWorker = getCheckLockWorker(node, selectedFilePath);
checkLockWorker.execute();
CheckLockResult checkLockResult = checkLockWorker.getResult();
processLockResult(checkLockResult, node ,selectedFilePath);
}
@NotNull
private BaseCheckLockWorker getCheckLockWorker(FileNode node, String selectedFilePath) {
String lock = node.getLock();
BaseCheckLockWorker checkLockWorker = new BaseCheckLockWorker(() -> {
boolean showLockInfo = needShowLockInfo(lock, selectedFilePath, node);
UserInfo userInfo = null;
if (showLockInfo) {
userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath);
}
return new CheckLockResult(showLockInfo, userInfo);
}) {
@Override
public void dealResultWhenSlowly(CheckLockResult result) {
processLockResult(result, node, selectedFilePath);
}
};
return checkLockWorker;
}
private void processLockResult(CheckLockResult checkLockResult, FileNode node, String selectedFilePath) {
if (checkLockResult != null) {
boolean showLockInfo = checkLockResult.isLock();
if (showLockInfo) {
UserInfo userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath);
node.setLock(UUID.randomUUID().toString());
// 对于开发者预览占位锁定 定位到tab中
checkDevelopForBiddenTemplate(selectedFilePath);
LockInfoDialog.show(userInfo);
LockInfoDialog.show(checkLockResult.getUserInfo());
DesignerContext.getDesignerFrame().hideCover();
return;
} else {
node.setLock(null);
}
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
} else {
if (!reportletsTree.getSelectedFileNode().isDirectory()) {
DesignerContext.getDesignerFrame().showOpenStatusLightly();
}
}
}
/**

15
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -1178,6 +1178,21 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
DesignerExiter.getInstance().execute();
}
/**
* 动作较轻的打开状态动画
*/
public void showOpenStatusLightly() {
getCenterTemplateCardPane().showOpenStatusLightly();
}
/**
* 隐藏动画
*/
public void hideCover() {
getCenterTemplateCardPane().hideCover();
}
// harry:添加程序外拖拽文件进来打开的功能
class FileDropTargetListener implements DropTargetListener {

8
designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java

@ -128,6 +128,13 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
layeredPane.moveToFront(loadingPane);
}
/**
* 动作较轻的动画展示用于展示的前置准备动作
*/
public void showOpenStatusLightly() {
layeredPane.moveToFront(loadingPane);
}
public void showOpenFailedCover(String text) {
failedPane.setFailedTip(text);
layeredPane.moveToFront(failedPane);
@ -155,6 +162,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
public void hideCover() {
recoverToolBar();
transparentPane.stop();
component.setVisible(true);
layeredPane.moveToFront(component);
EastRegionContainerPane.getInstance().updateAllPropertyPane();
JComponent downPane = WestRegionContainerPane.getInstance().getDownPane();

66
designer-base/src/main/java/com/fr/design/worker/check/BaseCheckLockWorker.java

@ -0,0 +1,66 @@
package com.fr.design.worker.check;
import com.fr.log.FineLoggerFactory;
import javax.swing.SwingWorker;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* 检查的Worker
*
* @author Destiny.Lin
* @since 11.0
* Created on 2024/1/8
*/
public abstract class BaseCheckLockWorker extends SwingWorker<CheckLockResult, Void> {
private static final int TIME_OUT = 50;
private boolean slowly = false;
private final Callable<CheckLockResult> doInBackground;
private CheckLockResult result;
public BaseCheckLockWorker(Callable<CheckLockResult> doInBackground) {
this.doInBackground = doInBackground;
}
@Override
protected CheckLockResult doInBackground() throws Exception {
return this.doInBackground.call();
}
@Override
protected void done() {
try {
result = get();
if (slowly) {
dealResultWhenSlowly(result);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 获取结果
*/
public CheckLockResult getResult() {
if (result != null) {
return result;
}
try {
return this.get(TIME_OUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
slowly = true;
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
return null;
}
/**
* 如果获取结果超过TIME_OUT则通过这个方式处理后续
*/
public abstract void dealResultWhenSlowly(CheckLockResult result);
}

30
designer-base/src/main/java/com/fr/design/worker/check/CheckLockResult.java

@ -0,0 +1,30 @@
package com.fr.design.worker.check;
import com.fr.workspace.base.UserInfo;
/**
* 信息检查结果
*
* @author Destiny.Lin
* @since 11.0
* Created on 2024/1/8
*/
public class CheckLockResult {
private boolean lock = false;
private UserInfo userInfo;
public CheckLockResult(boolean lock, UserInfo userInfo) {
this.lock = lock;
this.userInfo = userInfo;
}
public boolean isLock() {
return lock;
}
public UserInfo getUserInfo() {
return userInfo;
}
}
Loading…
Cancel
Save