From 97f1902490a11f5816b755c6e6968f4025da7c20 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 6 Sep 2021 10:53:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-58513=20=E8=AE=BE=E8=AE=A1=E5=99=A8-?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E4=BF=9D=E5=AD=98-=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E6=96=B0=E5=BC=95=E6=93=8E=E8=BD=AC=E5=8C=96=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=8F=98=E4=B8=BA=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/itoolbar/UIToolbar.java | 22 ++++++++++++++++++- .../mainframe/CenterRegionContainerPane.java | 8 +++++-- .../fr/design/mainframe/DesignerFrame.java | 6 ++++- .../fr/design/mainframe/DesktopCardPane.java | 2 +- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java index 347dd768f5..7d5dd1a7ea 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java +++ b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java @@ -2,13 +2,18 @@ package com.fr.design.gui.itoolbar; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.JTemplate; + import java.awt.Component; import java.awt.FlowLayout; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import javax.swing.JToolBar; public class UIToolbar extends JToolBar { + Map componentState = new HashMap<>(); + public UIToolbar() { this(FlowLayout.LEFT); } @@ -36,11 +41,26 @@ public class UIToolbar extends JToolBar { } public void refreshUIToolBar() { + refreshUIToolBar(false); + } + + public void refreshUIToolBar(boolean forbid) { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (template != null) { for (int i = 0; i < getComponentCount(); i++) { Component component = getComponents()[i]; - component.setEnabled(template.checkEnable()); + if (forbid) { + componentState.put(component, component.isEnabled()); + component.setEnabled(false); + } else { + Boolean enable = componentState.get(component); + if (enable != null) { + component.setEnabled(enable); + componentState.remove(component); + } else { + component.setEnabled(template.checkEnable()); + } + } } } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java index 36507cf37d..3ba7d38411 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java @@ -268,10 +268,14 @@ public class CenterRegionContainerPane extends JPanel { } protected void refreshUIToolBar() { + refreshUIToolBar(false); + } + + protected void refreshUIToolBar(boolean forbid) { if (toolbarComponent instanceof UIToolbar) { - ((UIToolbar ) toolbarComponent).refreshUIToolBar(); + ((UIToolbar) toolbarComponent).refreshUIToolBar(); } - combineUp.refreshUIToolBar(); + combineUp.refreshUIToolBar(forbid); getToolBarMenuDock().updateEnable(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 786deb8927..3e769b1ac7 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -366,7 +366,11 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } public void refreshUIToolBar() { - CenterRegionContainerPane.getInstance().refreshUIToolBar(); + refreshUIToolBar(false); + } + + public void refreshUIToolBar(boolean forbid) { + CenterRegionContainerPane.getInstance().refreshUIToolBar(forbid); } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java index 0e26ff3ded..47354c5406 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java @@ -122,7 +122,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener public void showCover() { transparentPane.start(); layeredPane.moveToFront(transparentPane); - DesignerContext.getDesignerFrame().refreshUIToolBar(); + DesignerContext.getDesignerFrame().refreshUIToolBar(true); EastRegionContainerPane.getInstance().updateAllPropertyPane(); JComponent downPane = WestRegionContainerPane.getInstance().getDownPane(); if (downPane instanceof BasicTableDataTreePane) { From 68a65cfee901c93de486c22f298ed00c9816e0ae Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 6 Sep 2021 15:35:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-58513=20=E8=AE=BE=E8=AE=A1=E5=99=A8-?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E4=BF=9D=E5=AD=98-=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E6=96=B0=E5=BC=95=E6=93=8E=E8=BD=AC=E5=8C=96=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=8F=98=E4=B8=BA=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/itoolbar/UIToolbar.java | 30 +++++++------------ .../mainframe/CenterRegionContainerPane.java | 19 ++++++------ .../fr/design/mainframe/DesignerFrame.java | 11 +------ .../fr/design/mainframe/DesktopCardPane.java | 27 +++++++++++++++-- .../com/fr/design/worker/save/SaveWorker.java | 1 - 5 files changed, 46 insertions(+), 42 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java index 7d5dd1a7ea..73f8adab53 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java +++ b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java @@ -40,28 +40,18 @@ public class UIToolbar extends JToolBar { } } - public void refreshUIToolBar() { - refreshUIToolBar(false); + public Map getComponentState() { + Map componentState = new HashMap<>(); + for (int i = 0; i < getComponentCount(); i++) { + Component component = getComponent(i); + componentState.put(component, component.isEnabled()); + } + return componentState; } - public void refreshUIToolBar(boolean forbid) { - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (template != null) { - for (int i = 0; i < getComponentCount(); i++) { - Component component = getComponents()[i]; - if (forbid) { - componentState.put(component, component.isEnabled()); - component.setEnabled(false); - } else { - Boolean enable = componentState.get(component); - if (enable != null) { - component.setEnabled(enable); - componentState.remove(component); - } else { - component.setEnabled(template.checkEnable()); - } - } - } + public static void resetComponentState(Map componentState) { + for (Component component : componentState.keySet()) { + component.setEnabled(componentState.get(component)); } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java index 3ba7d38411..d31b5ede09 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java @@ -19,10 +19,14 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.border.MatteBorder; import java.awt.BorderLayout; +import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Insets; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + /** * @author shine @@ -96,7 +100,7 @@ public class CenterRegionContainerPane extends JPanel { } - private ToolBarMenuDock getToolBarMenuDock() { + public ToolBarMenuDock getToolBarMenuDock() { return DesignerContext.getDesignerFrame().getToolBarMenuDock(); } @@ -267,16 +271,13 @@ public class CenterRegionContainerPane extends JPanel { return centerTemplateCardPane; } - protected void refreshUIToolBar() { - refreshUIToolBar(false); - } - - protected void refreshUIToolBar(boolean forbid) { + public Map getToolbarComponentState() { + Map toolbarComponentState = new HashMap<>(); if (toolbarComponent instanceof UIToolbar) { - ((UIToolbar) toolbarComponent).refreshUIToolBar(); + toolbarComponentState.putAll(((UIToolbar) toolbarComponent).getComponentState()); } - combineUp.refreshUIToolBar(forbid); - getToolBarMenuDock().updateEnable(); + toolbarComponentState.putAll(combineUp.getComponentState()); + return toolbarComponentState; } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 3e769b1ac7..ae67275bea 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -361,18 +361,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } public DesktopCardPane getCenterTemplateCardPane() { - return CenterRegionContainerPane.getInstance().getCenterTemplateCardPane(); } - public void refreshUIToolBar() { - refreshUIToolBar(false); - } - - public void refreshUIToolBar(boolean forbid) { - CenterRegionContainerPane.getInstance().refreshUIToolBar(forbid); - } - /** * 初始menuPane的方法 方便OEM时修改该组件 */ @@ -1044,7 +1035,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt != null) { + if (jt != null) { DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java index 47354c5406..0c10ac2e12 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java @@ -10,11 +10,14 @@ import com.fr.design.data.BasicTableDataTreePane; import com.fr.design.dialog.BasicPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; +import com.fr.design.gui.itoolbar.UIToolbar; import javax.swing.JComponent; import javax.swing.JLayeredPane; import java.awt.BorderLayout; import java.awt.Component; +import java.util.HashMap; +import java.util.Map; /** @@ -33,6 +36,9 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener private TransparentPane transparentPane = new TransparentPane(); private OpenLoadingPane loadingPane = new OpenLoadingPane(); private OpenFailedPane failedPane = new OpenFailedPane(); + + Map backUpToolbarComponentState = new HashMap<>(); + private JLayeredPane layeredPane = new JLayeredPane() { @Override public void doLayout() { @@ -103,7 +109,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener } private void showOpenStatus() { - DesignerContext.getDesignerFrame().refreshUIToolBar(); + forbidToolBar(); DesignerFrameFileDealerPane.getInstance().stateChange(); EastRegionContainerPane.getInstance().updateAllPropertyPane(); JComponent downPane = WestRegionContainerPane.getInstance().getDownPane(); @@ -120,9 +126,9 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener } public void showCover() { + forbidToolBar(); transparentPane.start(); layeredPane.moveToFront(transparentPane); - DesignerContext.getDesignerFrame().refreshUIToolBar(true); EastRegionContainerPane.getInstance().updateAllPropertyPane(); JComponent downPane = WestRegionContainerPane.getInstance().getDownPane(); if (downPane instanceof BasicTableDataTreePane) { @@ -132,6 +138,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener } public void hideCover() { + recoverToolBar(); transparentPane.stop(); layeredPane.moveToFront(component); EastRegionContainerPane.getInstance().updateAllPropertyPane(); @@ -142,6 +149,22 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener } } + private void forbidToolBar() { + CenterRegionContainerPane centerRegionContainerPane = CenterRegionContainerPane.getInstance(); + backUpToolbarComponentState = centerRegionContainerPane.getToolbarComponentState(); + for (Component component : backUpToolbarComponentState.keySet()) { + component.setEnabled(false); + } + centerRegionContainerPane.getToolBarMenuDock().updateEnable(); + } + + private void recoverToolBar() { + UIToolbar.resetComponentState(backUpToolbarComponentState); + backUpToolbarComponentState.clear(); + CenterRegionContainerPane centerRegionContainerPane = CenterRegionContainerPane.getInstance(); + centerRegionContainerPane.getToolBarMenuDock().updateEnable(); + } + protected JTemplate getSelectedJTemplate() { return component; } diff --git a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java index f47a4f88e7..51a79bbad9 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java @@ -70,7 +70,6 @@ public class SaveWorker extends SwingWorker { this.template.setSaving(false); // 恢复界面 if (slowly && ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) { - DesignerContext.getDesignerFrame().refreshUIToolBar(); DesignerContext.getDesignerFrame().getCenterTemplateCardPane().hideCover(); } DesignerFrameFileDealerPane.getInstance().stateChange(); From fcf7f54abf1c54b6fc1e00adece8a6fabccf9088 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Mon, 6 Sep 2021 15:36:26 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-58513=20=E8=AE=BE=E8=AE=A1=E5=99=A8-?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E4=BF=9D=E5=AD=98-=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E6=96=B0=E5=BC=95=E6=93=8E=E8=BD=AC=E5=8C=96=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=8F=98=E4=B8=BA=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java index 73f8adab53..709fdece73 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java +++ b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java @@ -12,8 +12,6 @@ import javax.swing.JToolBar; public class UIToolbar extends JToolBar { - Map componentState = new HashMap<>(); - public UIToolbar() { this(FlowLayout.LEFT); }