Browse Source

REPORT-127437 feat: 增加工具按钮插件适配抽象类

newui
lemon 4 months ago
parent
commit
d07d04ed89
  1. 4
      designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java
  2. 37
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolBarHandler.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java
  4. 35
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  5. 2
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java

4
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);
}

37
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;
}
}

2
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());
}

35
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<ToolBarHandler> set) {
List<ToolBarHandler> 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);
}
}
}

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

Loading…
Cancel
Save