From d07d04ed89ef7a33f83c9f15d946316ee0156ea8 Mon Sep 17 00:00:00 2001 From: lemon Date: Wed, 7 Aug 2024 11:45:11 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-127437=20feat:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=8C=89=E9=92=AE=E6=8F=92=E4=BB=B6=E9=80=82?= =?UTF-8?q?=E9=85=8D=E6=8A=BD=E8=B1=A1=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/file/MultiTemplateTabPane.java | 4 +- .../fun/impl/AbstractToolBarHandler.java | 37 +++++++++++++++++++ .../mainframe/CenterRegionContainerPane.java | 2 +- .../mainframe/toolbar/ToolBarMenuDock.java | 35 ++++++++++-------- .../mainframe/vcs/ui/FileVersionsPanel.java | 2 +- 5 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolBarHandler.java 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()) {