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 * 如果保存失败,不执行下面的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; return;
} }
browserTemplate(jt, baseRoute, map, actionType);
}
private static void browserTemplate(JTemplate<?, ?> jt, String baseRoute, Map<String, Object> map, String actionType) {
FILE currentTemplate = jt.getEditingFILE(); FILE currentTemplate = jt.getEditingFILE();
// carl:是否是保存在运行环境下的模板,不是就不能被预览 // carl:是否是保存在运行环境下的模板,不是就不能被预览
if (currentTemplate instanceof FileNodeFILE) { if (currentTemplate instanceof FileNodeFILE) {
@ -106,11 +118,14 @@ public final class WebPreviewUtils {
WARNING_MESSAGE); WARNING_MESSAGE);
if (OK_OPTION == selVal) { if (OK_OPTION == selVal) {
if (!jt.saveAsTemplate2Env()) { CallbackSaveWorker worker = jt.saveAs2Env();
return; 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; package com.fr.design.gui.ibutton;
import com.fr.base.CellBorderStyle; import com.fr.base.CellBorderStyle;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.plaf.ButtonUI; import javax.swing.plaf.ButtonUI;
@ -45,6 +47,16 @@ public class UIForbiddenButton extends UIButton {
return super.getBorderStyle(); 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 @Override
public ButtonUI getUI() { public ButtonUI getUI() {
return new UIForbiddenButtonUI(); 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; package com.fr.design.gui.ibutton;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import java.awt.Graphics; import java.awt.Graphics;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -15,11 +13,6 @@ public class UIForbiddenButtonUI extends UIButtonUI {
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
super.paint(g, c); super.paint(g, c);
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); c.setEnabled(c.isEnabled());
boolean flag = true;
if (template != null) {
flag = c.isEnabled() && template.checkEnable();
}
c.setEnabled(flag);
} }
} }

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() { private void showOpenStatus() {
DesignerContext.getDesignerFrame().refreshUIToolBar(); DesignerContext.getDesignerFrame().refreshUIToolBar();
DesignerFrameFileDealerPane.getInstance().stateChange();
EastRegionContainerPane.getInstance().updateAllPropertyPane(); EastRegionContainerPane.getInstance().updateAllPropertyPane();
layeredPane.moveToFront(loadingPane); 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()); worker.start(this.template.getTemplateID());
} }
@Override
public CallbackSaveWorker save2Env() {
return save(false);
}
@Override
public CallbackSaveWorker saveAs2Env() {
return saveAs(false);
}
public boolean isSaving() { public boolean isSaving() {
return saving; 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 { public interface JTemplateSave {
/** /**
* 直接保存后需要根据是否成功做外部回调 * 保存后需要根据是否成功做外部回调可选保存位置
* *
* @return * @return
*/ */
@ -20,12 +20,29 @@ public interface JTemplateSave {
/** /**
* 另存为后需要根据是否成功做外部回调 * 另存为后需要根据是否成功做外部回调可选保存位置
* *
* @return * @return
*/ */
CallbackSaveWorker saveAs(); CallbackSaveWorker saveAs();
/**
* 保存到当前工作目录(reportlets)后需要根据是否成功做外部回调
*
*
* @return
*/
CallbackSaveWorker save2Env();
/**
* 另存为到当前工作目录(reportlets)后需要根据是否成功做外部回调
*
* @return
*/
CallbackSaveWorker saveAs2Env();
/**D /**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.file.HistoryTemplateListCache;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.worker.WorkerManager; import com.fr.design.worker.WorkerManager;
@ -69,21 +70,22 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(book); DesignerContext.getDesignerFrame().addAndActivateJTemplate(book);
HistoryTemplateListCache.getInstance().replaceCurrentEditingTemplate(book); HistoryTemplateListCache.getInstance().replaceCurrentEditingTemplate(book);
EastRegionContainerPane.getInstance().updateAllPropertyPane(); EastRegionContainerPane.getInstance().updateAllPropertyPane();
return; } else {
}
// 当前tab页是其他模板 // 当前tab页是其他模板
for (int i = 0, len = HistoryTemplateListCache.getInstance().getHistoryCount(); i < len; i++) { for (int i = 0, len = HistoryTemplateListCache.getInstance().getHistoryCount(); i < len; i++) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().get(i); JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().get(i);
if (ComparatorUtils.equals(template.getEditingFILE(), book.getEditingFILE())) { if (ComparatorUtils.equals(template.getEditingFILE(), book.getEditingFILE())) {
template.whenClose(); template.whenClose();
HistoryTemplateListCache.getInstance().getHistoryList().set(i, book); HistoryTemplateListCache.getInstance().getHistoryList().set(i, book);
return; break;
}
} }
} }
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
DesignerFrameFileDealerPane.getInstance().stateChange();
WorkerManager.getInstance().removeWorker(taskName); 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; protected boolean success;
private boolean slowly;
public SaveWorker(Callable<Boolean> callable, JTemplate<?, ?> template) { public SaveWorker(Callable<Boolean> callable, JTemplate<?, ?> template) {
this.callable = callable; this.callable = callable;
this.template = template; this.template = template;
@ -59,7 +61,7 @@ public class SaveWorker extends SwingWorker<Boolean, Void> {
} }
this.template.setSaving(false); 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(); EastRegionContainerPane.getInstance().updateAllPropertyPane();
DesignerContext.getDesignerFrame().refreshUIToolBar(); DesignerContext.getDesignerFrame().refreshUIToolBar();
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().hideCover(); DesignerContext.getDesignerFrame().getCenterTemplateCardPane().hideCover();
@ -77,6 +79,7 @@ public class SaveWorker extends SwingWorker<Boolean, Void> {
try { try {
this.get(TIME_OUT, TimeUnit.MILLISECONDS); this.get(TIME_OUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException timeoutException) { } catch (TimeoutException timeoutException) {
slowly = true;
// 开始禁用 // 开始禁用
EastRegionContainerPane.getInstance().updateAllPropertyPane(); EastRegionContainerPane.getInstance().updateAllPropertyPane();
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover(); 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.base.vcs.DesignerMode;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
@ -174,4 +175,14 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio
public ButtonUI getUI() { public ButtonUI getUI() {
return new UIForbiddenButtonUI(); 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:打开新报表. // peter:打开新报表.
Form tpl = new Form(); Form tpl = new Form();
// richer:打开报表通知 // 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 { try {
tpl.readStream(file.asInputStream()); tpl.readStream(file.asInputStream());
} catch (DecryptTemplateException e) { } catch (DecryptTemplateException e) {

Loading…
Cancel
Save