Browse Source

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

feature/10.0
hades 4 years ago
parent
commit
46bfdaf2b3
  1. 2
      designer-base/src/main/java/com/fr/design/actions/edit/RedoAction.java
  2. 2
      designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java
  3. 2
      designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java
  4. 4
      designer-base/src/main/java/com/fr/design/actions/file/ExitDesignerAction.java
  5. 3
      designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java
  6. 2
      designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java
  7. 6
      designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java
  8. 1
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  9. 4
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  10. 2
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java
  11. 18
      designer-base/src/main/java/com/fr/design/gui/imenu/UIForBiddenHeadMenu.java
  12. 25
      designer-base/src/main/java/com/fr/design/gui/imenu/UIForbiddenMenuUI.java
  13. 2
      designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java
  14. 4
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  15. 9
      designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java

2
designer-base/src/main/java/com/fr/design/actions/edit/RedoAction.java

@ -49,7 +49,7 @@ public class RedoAction extends UpdateAction implements TemplateComponentActionI
public void update() {
JTemplate<?, ?> undoComponent = getEditingComponent();
if (DesignerEnvManager.getEnvManager().isSupportUndo()) {
boolean enable = undoComponent != null && undoComponent.canRedo() && !undoComponent.isOpening() && !undoComponent.isSaving();
boolean enable = undoComponent != null && undoComponent.canRedo() && undoComponent.checkEnable();
this.setEnabled(enable);
} else {
this.setEnabled(false);

2
designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java

@ -49,7 +49,7 @@ public class UndoAction extends UpdateAction implements TemplateComponentActionI
public void update() {
JTemplate<?, ?> undoComponent = getEditingComponent();
if (DesignerEnvManager.getEnvManager().isSupportUndo()) {
boolean enable = undoComponent != null && undoComponent.canUndo() && !undoComponent.isOpening() && !undoComponent.isSaving();
boolean enable = undoComponent != null && undoComponent.canUndo() && undoComponent.checkEnable();
this.setEnabled(enable);
} else {
this.setEnabled(false);

2
designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java

@ -1 +1 @@
package com.fr.design.actions.file; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.menu.KeySetUtils; import java.awt.event.ActionEvent; /** * Author : daisy * Date: 13-8-16 * Time: 下午3:23 */ public class CloseCurrentTemplateAction extends UpdateAction { public CloseCurrentTemplateAction() { this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setAccelerator(getMenuKeySet().getKeyStroke()); } /** * 动作 * @param e 事件 */ public void actionPerformed(ActionEvent e) { MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } }
package com.fr.design.actions.file; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; import java.awt.event.ActionEvent; /** * Author : daisy * Date: 13-8-16 * Time: 下午3:23 */ public class CloseCurrentTemplateAction extends UpdateAction { public CloseCurrentTemplateAction() { this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setAccelerator(getMenuKeySet().getKeyStroke()); } /** * 动作 * @param e 事件 */ public void actionPerformed(ActionEvent e) { MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } @Override public void update() { super.update(); JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (template != null) { this.setEnabled(!template.isSaving()); } } }

4
designer-base/src/main/java/com/fr/design/actions/file/ExitDesignerAction.java

@ -3,6 +3,7 @@
*/
package com.fr.design.actions.file;
import com.fr.design.mainframe.TemplateSavingChecker;
import java.awt.event.ActionEvent;
import com.fr.design.actions.UpdateAction;
@ -27,6 +28,9 @@ public class ExitDesignerAction extends UpdateAction {
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
if (!TemplateSavingChecker.check()) {
return;
}
DesignerContext.getDesignerFrame().exit();
}
}

3
designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java

@ -40,7 +40,6 @@ public class SaveAsTemplateAction extends JTemplateAction<JTemplate<?, ?>> {
@Override
public void update() {
super.update();
boolean enable = !this.getEditingComponent().isSaving() && !this.getEditingComponent().isOpening();
this.setEnabled(enable);
this.setEnabled(this.getEditingComponent().checkEnable());
}
}

2
designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java

@ -38,7 +38,7 @@ public class SaveTemplateAction extends JTemplateAction<JTemplate<?, ?>> {
@Override
public void update() {
super.update();
boolean enable = !this.getEditingComponent().isSaved() && !this.getEditingComponent().isSaving() && !this.getEditingComponent().isOpening();
boolean enable = !this.getEditingComponent().isSaved() && this.getEditingComponent().checkEnable();
this.setEnabled(enable);
}

6
designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java

@ -226,4 +226,10 @@ public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JT
}
}
@Override
public void update() {
super.update();
this.setEnabled(this.getEditingComponent().checkEnable());
}
}

1
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -380,6 +380,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
try {
return stashWorker.get();
} catch (Exception e) {
FineLoggerFactory.getLogger().debug(e.getMessage(), e);
return false;
}
}

4
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -11,6 +11,7 @@ import com.fr.design.gui.imenu.UIScrollPopUpMenu;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.TemplateSavingChecker;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
@ -197,6 +198,9 @@ public class MutilTempalteTabPane extends JComponent {
if (openedTemplate.size() == 1) {
return;
}
if (!TemplateSavingChecker.check()) {
return;
}
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false);
//点击关闭其他模板,并且点击确定保存
if (saveSomeTempaltePane.showSavePane()) {

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

@ -18,7 +18,7 @@ public class UIForbiddenButtonUI extends UIButtonUI {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean flag = true;
if (template != null) {
flag = c.isEnabled() && !template.isSaving() && !template.isOpening();
flag = c.isEnabled() && template.checkEnable();
}
c.setEnabled(flag);
}

18
designer-base/src/main/java/com/fr/design/gui/imenu/UIForBiddenHeadMenu.java

@ -1,18 +0,0 @@
package com.fr.design.gui.imenu;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/11
*/
public class UIForBiddenHeadMenu extends UIHeadMenu {
public UIForBiddenHeadMenu(String name) {
super(name);
}
@Override
public void updateUI() {
setUI(new UIForbiddenMenuUI());
}
}

25
designer-base/src/main/java/com/fr/design/gui/imenu/UIForbiddenMenuUI.java

@ -1,25 +0,0 @@
package com.fr.design.gui.imenu;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import java.awt.Graphics;
import javax.swing.JComponent;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/11
*/
public class UIForbiddenMenuUI extends UIMenuUI {
@Override
public void paint(Graphics g, JComponent c) {
// JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
// boolean flag = true;
// if (template != null) {
// flag = !template.isSaving() && !template.isOpening();
// }
// c.setEnabled(flag);
super.paint(g, c);
}
}

2
designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java

@ -40,7 +40,7 @@ public class UIToolbar extends JToolBar {
if (template != null) {
for (int i = 0; i < getComponentCount(); i++) {
Component component = getComponents()[i];
component.setEnabled(!template.isSaving() && !template.isOpening());
component.setEnabled(template.checkEnable());
}
}
}

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

@ -185,6 +185,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
@Override
public void windowClosing(WindowEvent e) {
// 关闭前check
if (!TemplateSavingChecker.check()) {
return;
}
//关闭前当前模板 停止编辑
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().stopEditing();
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);

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

@ -1,8 +1,9 @@
package com.fr.design.worker.save;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.JTemplate;
@ -12,6 +13,7 @@ import com.fr.log.FineLoggerFactory;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
/**
@ -49,6 +51,11 @@ public class SaveWorker extends SwingWorker<Boolean, Void> {
success = get();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design-Basic_Save_Failure"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.ERROR_MESSAGE);
}
this.template.setSaving(false);
// 恢复界面

Loading…
Cancel
Save