Browse Source
Merge in DESIGN/design from ~JOHN.YING/design:feature/x to feature/x * commit '5155311b6e203d96432a8db4019fd75b05b6bd9b': REPORT-83195 卡顿点优化-回退一下开发者模式部分代码,设计有点问题 REPORT-83195 卡顿点优化-根据插件提示修改了一下代码规范 REPORT-83195 卡顿点优化-根据插件提示修改了一下代码规范 REPORT-83195 卡顿点优化-根据插件提示修改了一下代码规范 REPORT-83195 卡顿点优化-开发者模式 REPORT-83195 卡顿点优化-单元格初次添加图表卡死 REPORT-83195 卡顿点优化-保存逻辑优化feature/x
John.Ying-应志浩
2 years ago
5 changed files with 282 additions and 47 deletions
@ -0,0 +1,50 @@
|
||||
package com.fr.design.worker.save.type; |
||||
|
||||
/** |
||||
* 保存的类别 |
||||
* |
||||
* @author John.Ying |
||||
* @since 11.0 |
||||
* Created on 2023/4/14 |
||||
*/ |
||||
public class SaveType { |
||||
|
||||
private TypeEnum type; |
||||
//保存时间是否慢(是否展示了保存中的UI界面)
|
||||
private boolean slowly; |
||||
|
||||
public TypeEnum getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(TypeEnum saveType) { |
||||
this.type = saveType; |
||||
} |
||||
|
||||
public boolean isSlowly() { |
||||
return slowly; |
||||
} |
||||
|
||||
public void setSlowly(boolean slowly) { |
||||
this.slowly = slowly; |
||||
} |
||||
|
||||
/** |
||||
* 保存类型:save or saveAs or empty |
||||
*/ |
||||
public enum TypeEnum { |
||||
/** |
||||
* 保存 |
||||
*/ |
||||
SAVE, |
||||
/** |
||||
* 另存 |
||||
*/ |
||||
SAVE_AS, |
||||
/** |
||||
* 空保存 |
||||
*/ |
||||
EMPTY; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,81 @@
|
||||
package com.fr.design.worker.save.type; |
||||
|
||||
|
||||
import com.fr.concurrent.FineExecutors; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.DesignerFrameFileDealerPane; |
||||
import com.fr.design.mainframe.EastRegionContainerPane; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.ui.util.UIUtil; |
||||
import com.fr.third.org.apache.commons.lang3.time.StopWatch; |
||||
|
||||
import javax.swing.SwingWorker; |
||||
import java.util.concurrent.Callable; |
||||
import java.util.concurrent.ExecutorService; |
||||
|
||||
/** |
||||
* 判断保存类别时执行的worker |
||||
* |
||||
* @author John.Ying |
||||
* @since 11.0 |
||||
* Created on 2023/4/14 |
||||
*/ |
||||
public class SaveTypeWorker extends SwingWorker<SaveType, Void> { |
||||
|
||||
public static final ExecutorService SAVE_TYPE_POOL = FineExecutors.newSingleThreadExecutor(); |
||||
|
||||
private final Callable<SaveType.TypeEnum> callable; |
||||
|
||||
private static final int TIME_OUT = 400; |
||||
|
||||
private final JTemplate<?, ?> template; |
||||
|
||||
private final SaveType saveType; |
||||
|
||||
|
||||
|
||||
public SaveTypeWorker(Callable<SaveType.TypeEnum> callable, JTemplate<?, ?> template) { |
||||
this.callable = callable; |
||||
this.template = template; |
||||
this.saveType = new SaveType(); |
||||
} |
||||
|
||||
@Override |
||||
protected SaveType doInBackground() throws Exception { |
||||
this.saveType.setType(callable.call()); |
||||
return this.saveType; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 启动saveTypeWorker |
||||
*/ |
||||
public void start() { |
||||
StopWatch stopWatch = StopWatch.createStarted(); |
||||
this.template.setSaving(true); |
||||
this.execute(); |
||||
SAVE_TYPE_POOL.execute(() -> { |
||||
while (true) { |
||||
//大于最大等待时间或者worker已经完成该线程都要结束循环
|
||||
if (stopWatch.getTime() > TIME_OUT || isDone()) { |
||||
//如果是大于最大等待时间结束的,就需要进行等待中界面的覆盖
|
||||
if (!isDone()) { |
||||
saveType.setSlowly(true); |
||||
UIUtil.invokeLaterIfNeeded(() -> { |
||||
// 开始禁用
|
||||
EastRegionContainerPane.getInstance().updateAllPropertyPane(); |
||||
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover(); |
||||
DesignerFrameFileDealerPane.getInstance().stateChange(); |
||||
}); |
||||
} |
||||
stopWatch.stop(); |
||||
break; |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
Loading…
Reference in new issue