Browse Source

REPORT-49986 【10.0.16】性能优化之阻塞EDT线程时优化 fix

feature/10.0
hades 4 years ago
parent
commit
bb5e2d5384
  1. 25
      designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java
  2. 12
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButton.java
  3. 9
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java
  4. 1
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  5. 10
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  6. 21
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateSave.java
  7. 8
      designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java
  8. 5
      designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java
  9. 11
      designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java
  10. 2
      designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java

25
designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java

@ -68,9 +68,21 @@ public final class WebPreviewUtils {
*
* 如果保存失败,不执行下面的WebPreview
*/
if (!jt.isSaved() && !jt.saveTemplate2Env()) {
if (!jt.isSaved()) {
CallbackSaveWorker worker = jt.save2Env();
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
browserTemplate(jt, baseRoute, map, actionType);
}
});
worker.start(jt.getTarget().getTemplateID());
return;
}
browserTemplate(jt, baseRoute, map, actionType);
}
private static void browserTemplate(JTemplate<?, ?> jt, String baseRoute, Map<String, Object> map, String actionType) {
FILE currentTemplate = jt.getEditingFILE();
// carl:是否是保存在运行环境下的模板,不是就不能被预览
if (currentTemplate instanceof FileNodeFILE) {
@ -106,11 +118,14 @@ public final class WebPreviewUtils {
WARNING_MESSAGE);
if (OK_OPTION == selVal) {
if (!jt.saveAsTemplate2Env()) {
return;
CallbackSaveWorker worker = jt.saveAs2Env();
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
browseUrl(jt.getEditingFILE(), baseRoute, map, actionType, jt);
}
currentTemplate = jt.getEditingFILE();
browseUrl(currentTemplate, baseRoute, map, actionType, jt);
});
worker.start(jt.getTarget().getTemplateID());
}
}
}

12
designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButton.java

@ -1,6 +1,8 @@
package com.fr.design.gui.ibutton;
import com.fr.base.CellBorderStyle;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.plaf.ButtonUI;
@ -45,6 +47,16 @@ public class UIForbiddenButton extends UIButton {
return super.getBorderStyle();
}
@Override
public boolean isEnabled() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean enabled = true;
if (template != null) {
enabled = super.isEnabled() && template.checkEnable();
}
return enabled;
}
@Override
public ButtonUI getUI() {
return new UIForbiddenButtonUI();

9
designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java

@ -1,7 +1,5 @@
package com.fr.design.gui.ibutton;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import java.awt.Graphics;
import javax.swing.JComponent;
@ -15,11 +13,6 @@ public class UIForbiddenButtonUI extends UIButtonUI {
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean flag = true;
if (template != null) {
flag = c.isEnabled() && template.checkEnable();
}
c.setEnabled(flag);
c.setEnabled(c.isEnabled());
}
}

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

@ -76,6 +76,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
private void showOpenStatus() {
DesignerContext.getDesignerFrame().refreshUIToolBar();
DesignerFrameFileDealerPane.getInstance().stateChange();
EastRegionContainerPane.getInstance().updateAllPropertyPane();
layeredPane.moveToFront(loadingPane);
}

10
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -1559,6 +1559,16 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
worker.start(this.template.getTemplateID());
}
@Override
public CallbackSaveWorker save2Env() {
return save(false);
}
@Override
public CallbackSaveWorker saveAs2Env() {
return saveAs(false);
}
public boolean isSaving() {
return saving;
}

21
designer-base/src/main/java/com/fr/design/mainframe/JTemplateSave.java

@ -12,7 +12,7 @@ import com.fr.design.worker.save.CallbackSaveWorker;
public interface JTemplateSave {
/**
* 直接保存后需要根据是否成功做外部回调
* 保存后需要根据是否成功做外部回调可选保存位置
*
* @return
*/
@ -20,12 +20,29 @@ public interface JTemplateSave {
/**
* 另存为后需要根据是否成功做外部回调
* 另存为后需要根据是否成功做外部回调可选保存位置
*
* @return
*/
CallbackSaveWorker saveAs();
/**
* 保存到当前工作目录(reportlets)后需要根据是否成功做外部回调
*
*
* @return
*/
CallbackSaveWorker save2Env();
/**
* 另存为到当前工作目录(reportlets)后需要根据是否成功做外部回调
*
* @return
*/
CallbackSaveWorker saveAs2Env();
/**D
* 直接保存
*/

8
designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java

@ -2,6 +2,7 @@ package com.fr.design.worker.open;
import com.fr.design.file.HistoryTemplateListCache;
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.worker.WorkerManager;
@ -69,21 +70,22 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(book);
HistoryTemplateListCache.getInstance().replaceCurrentEditingTemplate(book);
EastRegionContainerPane.getInstance().updateAllPropertyPane();
return;
}
} else {
// 当前tab页是其他模板
for (int i = 0, len = HistoryTemplateListCache.getInstance().getHistoryCount(); i < len; i++) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().get(i);
if (ComparatorUtils.equals(template.getEditingFILE(), book.getEditingFILE())) {
template.whenClose();
HistoryTemplateListCache.getInstance().getHistoryList().set(i, book);
return;
break;
}
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
DesignerFrameFileDealerPane.getInstance().stateChange();
WorkerManager.getInstance().removeWorker(taskName);
}

5
designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java

@ -35,6 +35,8 @@ public class SaveWorker extends SwingWorker<Boolean, Void> {
protected boolean success;
private boolean slowly;
public SaveWorker(Callable<Boolean> callable, JTemplate<?, ?> template) {
this.callable = callable;
this.template = template;
@ -59,7 +61,7 @@ public class SaveWorker extends SwingWorker<Boolean, Void> {
}
this.template.setSaving(false);
// 恢复界面
if (ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) {
if (slowly && ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) {
EastRegionContainerPane.getInstance().updateAllPropertyPane();
DesignerContext.getDesignerFrame().refreshUIToolBar();
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().hideCover();
@ -77,6 +79,7 @@ public class SaveWorker extends SwingWorker<Boolean, Void> {
try {
this.get(TIME_OUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException timeoutException) {
slowly = true;
// 开始禁用
EastRegionContainerPane.getInstance().updateAllPropertyPane();
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover();

11
designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.core.WidgetOption;
@ -174,4 +175,14 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio
public ButtonUI getUI() {
return new UIForbiddenButtonUI();
}
@Override
public boolean isEnabled() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean enable = true;
if (template != null) {
enable = super.isEnabled() && template.checkEnable();
}
return enable;
}
}

2
designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java

@ -83,7 +83,7 @@ class FormApp extends AbstractAppProvider {
// peter:打开新报表.
Form tpl = new Form();
// richer:打开报表通知
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("file.getName()", file.getName()) + "...");
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Report_Template_Opening_And_Waiting", file.getName()) + "...");
try {
tpl.readStream(file.asInputStream());
} catch (DecryptTemplateException e) {

Loading…
Cancel
Save