diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 13a77138ab..e71cf8e22d 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -204,8 +204,8 @@ public class MultiTemplateTabPane extends Row { leadingActionButton.addActionListener(newTemplateAction); } - public void setLeadingActionEnable(boolean enable) { - leadingActionButton.setEnabled(enable); + public void setToolBarEnable(boolean enable) { + toolBar.setEnabled(enable); } diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolBarHandler.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolBarHandler.java new file mode 100644 index 0000000000..a0e7f67b8f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolBarHandler.java @@ -0,0 +1,37 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.ToolBarHandler; +import com.fr.design.menu.ShortCut; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author lemon + * @since + * Created on + * 工具按钮插件适配抽象类 + */ +@API(level = ToolBarHandler.CURRENT_LEVEL) +public abstract class AbstractToolBarHandler extends AbstractProvider implements ToolBarHandler { + /** + * 当前接口的API等级,用于判断是否需要升级插件 + * @return API等级 + */ + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return this.getClass().getName(); + } + + /** + * 获取当前工具按钮对应的Action + * + * @return 工具按钮 Action + */ + public ShortCut shortcut() { + return null; + } +} 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 5d197201c7..f38e675b14 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 @@ -273,7 +273,7 @@ public class CenterRegionContainerPane extends JPanel { * 判断是否在权限编辑状态,若是在权限编辑状态,则需要有虚线框和关闭突变 */ protected void needToAddAuhtorityPaint() { - MultiTemplateTabPane.getInstance().setLeadingActionEnable(DesignModeContext.isAuthorityEditing()); + MultiTemplateTabPane.getInstance().setToolBarEnable(DesignModeContext.isAuthorityEditing()); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 72ab22eae1..8716de2a35 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -418,7 +418,6 @@ public abstract class ToolBarMenuDock { } private void addExtraToolBar(ToolBarDef toolBarDef, String anchor, Set set) { - List target = new ArrayList<>(); for (ToolBarHandler handler : set) { if (ComparatorUtils.equals(handler.category(), anchor)) { @@ -436,21 +435,25 @@ public abstract class ToolBarMenuDock { continue; } - if (insertPosition == MenuHandler.LAST) { - if (handler.insertSeparatorBefore()) { - toolBarDef.addShortCut(SeparatorDef.DEFAULT); - } - toolBarDef.addShortCut(shortCut); - } else { - toolBarDef.insertShortCut(insertPosition, shortCut); - if (handler.insertSeparatorBefore()) { - toolBarDef.insertShortCut(insertPosition, SeparatorDef.DEFAULT); - insertPosition++; - } - if (handler.insertSeparatorAfter()) { - insertPosition++; - toolBarDef.insertShortCut(insertPosition, SeparatorDef.DEFAULT); - } + insertSeparatorIfNeed(toolBarDef, handler, shortCut, insertPosition); + } + } + + private void insertSeparatorIfNeed(ToolBarDef toolBarDef, ToolBarHandler handler, ShortCut shortCut, int insertPosition) { + if (insertPosition == MenuHandler.LAST) { + if (handler.insertSeparatorBefore()) { + toolBarDef.addShortCut(SeparatorDef.DEFAULT); + } + toolBarDef.addShortCut(shortCut); + } else { + toolBarDef.insertShortCut(insertPosition, shortCut); + if (handler.insertSeparatorBefore()) { + toolBarDef.insertShortCut(insertPosition, SeparatorDef.DEFAULT); + insertPosition++; + } + if (handler.insertSeparatorAfter()) { + insertPosition++; + toolBarDef.insertShortCut(insertPosition, SeparatorDef.DEFAULT); } } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java index f97ec6803c..58393a3067 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java @@ -155,7 +155,7 @@ public class FileVersionsPanel extends BasicPane { DesignModeContext.switchTo(isExit ? DesignerMode.NORMAL : DesignerMode.VCS); // MutilTempalteTabPane & NewTemplatePane 是否可点 - MultiTemplateTabPane.getInstance().setLeadingActionEnable(!isExit); + MultiTemplateTabPane.getInstance().setToolBarEnable(!isExit); JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (currentEditingTemplate.isJWorkBook()) {