|
|
|
@ -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<Component, Boolean> 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()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|