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) {