Browse Source

REPORT-127437 fix:【fvs 适配】根据 mr 意见调整

newui
lemon 4 months ago
parent
commit
4d9a70c951
  1. 10
      designer-base/src/main/java/com/fine/theme/light/ui/FineTemplateTabPaneUI.java
  2. 12
      designer-base/src/main/java/com/fr/design/actions/template/NewWorkBookToolButtonAction.java
  3. 3
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  4. 110
      designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java
  5. 24
      designer-base/src/main/java/com/fr/design/fun/MultiTemplateTabPaneHandler.java
  6. 9
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractMultiTemplateTabPaneHandler.java
  7. 68
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  8. 41
      designer-base/src/test/java/com/fr/design/gui/storybook/components/TemplateTabStoryBoard.java
  9. 10
      designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java
  10. 11
      designer-realize/src/main/java/com/fr/start/MainDesigner.java

10
designer-base/src/main/java/com/fine/theme/light/ui/FineTemplateTabPaneUI.java

@ -26,7 +26,7 @@ import java.awt.geom.Rectangle2D;
import static com.fine.theme.utils.FineUIScale.scale; import static com.fine.theme.utils.FineUIScale.scale;
import static com.fine.theme.utils.FineUIUtils.paintRoundTabBorder; import static com.fine.theme.utils.FineUIUtils.paintRoundTabBorder;
import static com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import static com.formdev.flatlaf.ui.FlatStylingSupport.Styleable;
import static com.fr.design.file.MultiTemplateTabPane.LEADING_WIDTH; import static com.fr.design.file.MultiTemplateTabPane.leadingWidth;
import static com.fr.design.file.MultiTemplateTabPane.TRAILING_WIDTH; import static com.fr.design.file.MultiTemplateTabPane.TRAILING_WIDTH;
/** /**
@ -136,7 +136,7 @@ public class FineTemplateTabPaneUI extends PanelUI {
@Override @Override
public void update(Graphics g, JComponent c) { public void update(Graphics g, JComponent c) {
super.update(g, c); super.update(g, c);
double maxWidth = c.getWidth() - scale(LEADING_WIDTH) - trailingWidth; double maxWidth = c.getWidth() - scale(leadingWidth) - trailingWidth;
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
paintDefaultBackground(g2d); paintDefaultBackground(g2d);
paintPaneUnderLine(c.getWidth(), g2d); paintPaneUnderLine(c.getWidth(), g2d);
@ -168,7 +168,7 @@ public class FineTemplateTabPaneUI extends PanelUI {
if (tabPane.getSelectedIndex() < 0) { if (tabPane.getSelectedIndex() < 0) {
tabPane.setSelectedIndex(0); tabPane.setSelectedIndex(0);
} }
double templateStartX = scale(LEADING_WIDTH); double templateStartX = scale(leadingWidth);
//从可以开始展示在tab面板上的tab开始画 //从可以开始展示在tab面板上的tab开始画
@ -201,7 +201,7 @@ public class FineTemplateTabPaneUI extends PanelUI {
private void paintSeparators(Graphics2D g2d) { private void paintSeparators(Graphics2D g2d) {
g2d.setPaint(borderColor); g2d.setPaint(borderColor);
float x = scale(LEADING_WIDTH); float x = scale(leadingWidth);
Pair<Integer, Integer> viewRange = tabPane.getViewRange(); Pair<Integer, Integer> viewRange = tabPane.getViewRange();
for (int i = viewRange.getFirst(); i <= viewRange.getSecond(); i++) { for (int i = viewRange.getFirst(); i <= viewRange.getSecond(); i++) {
if (i != tabPane.getSelectedIndex() if (i != tabPane.getSelectedIndex()
@ -214,7 +214,7 @@ public class FineTemplateTabPaneUI extends PanelUI {
private void paintTrailingAction(Graphics2D g2d, double tabPaneWidth) { private void paintTrailingAction(Graphics2D g2d, double tabPaneWidth) {
int x = scale(LEADING_WIDTH) + (int) tabPaneWidth + (trailingWidth - moreAction.getIconWidth()) / 2; int x = scale(leadingWidth) + (int) tabPaneWidth + (trailingWidth - moreAction.getIconWidth()) / 2;
int y = (tabHeight - moreAction.getIconHeight()) / 2; int y = (tabHeight - moreAction.getIconHeight()) / 2;
if (tabPane.isHoverMoreAction()) { if (tabPane.isHoverMoreAction()) {
moreHoverAction.paintIcon(tabPane, g2d, x, y); moreHoverAction.paintIcon(tabPane, g2d, x, y);

12
designer-realize/src/main/java/com/fr/design/actions/toolbar/multitemplate/NewWorkBookToolBarAction.java → designer-base/src/main/java/com/fr/design/actions/template/NewWorkBookToolButtonAction.java

@ -1,21 +1,21 @@
package com.fr.design.actions.toolbar.multitemplate; package com.fr.design.actions.template;
import com.fine.theme.icon.LazyIcon; import com.fine.theme.icon.LazyIcon;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JWorkBook;
import javax.swing.Icon; import javax.swing.Icon;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
/** /**
* 工具按钮 - 新建报表文件
*
* @author lemon * @author lemon
* @since * @since
* Created on * Created on
* 新建报表文件
*/ */
public class NewWorkBookToolBarAction extends UpdateAction { public class NewWorkBookToolButtonAction extends UpdateAction {
public NewWorkBookToolBarAction() { public NewWorkBookToolButtonAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_New_WorkBook")); this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_New_WorkBook"));
this.setSmallIcon(icon()); this.setSmallIcon(icon());
} }
@ -26,6 +26,6 @@ public class NewWorkBookToolBarAction extends UpdateAction {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(new JWorkBook()); DesignerContext.getDesignerFrame().addAndActivateJTemplate();
} }
} }

3
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -4,6 +4,7 @@
package com.fr.design.data.datapane.preview; package com.fr.design.data.datapane.preview;
import com.fine.theme.icon.LazyIcon; import com.fine.theme.icon.LazyIcon;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils; import com.fine.theme.utils.FineUIUtils;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
@ -147,7 +148,7 @@ public class PreviewTablePane extends BasicPane {
} }
private PreviewTablePane() { private PreviewTablePane() {
this.setLayout(new BorderLayout(0, 10)); this.setLayout(new BorderLayout(0, FineUIScale.scale(10)));
// northPane // northPane
this.add(FineUIUtils.wrapComponentWithTitle(initNorthPane(), Toolkit.i18nText("Fine-Design_Basic_Data")), BorderLayout.NORTH); this.add(FineUIUtils.wrapComponentWithTitle(initNorthPane(), Toolkit.i18nText("Fine-Design_Basic_Data")), BorderLayout.NORTH);
// centerPane // centerPane

110
designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java

@ -8,20 +8,23 @@ import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIStyle; import com.fine.theme.utils.FineUIStyle;
import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.file.LocateAction; import com.fr.design.actions.file.LocateAction;
import com.fr.design.actions.template.NewWorkBookToolButtonAction;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.MenuHandler;
import com.fr.design.fun.MultiTemplateTabPaneHandler;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.gui.imenu.UIScrollPopUpMenu;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.worker.WorkerManager; import com.fr.design.worker.WorkerManager;
@ -51,8 +54,10 @@ import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter; import java.awt.event.MouseMotionAdapter;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set;
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON; import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON;
import static com.fine.theme.utils.FineUIScale.scale; import static com.fine.theme.utils.FineUIScale.scale;
@ -87,7 +92,8 @@ public class MultiTemplateTabPane extends Row {
* 前导动作区宽度 * 前导动作区宽度
* 最终宽度 = {@linkplain #SINGLE_BUTTON_WIDTH} * {@literal toolBar.getComponentCount()} * 最终宽度 = {@linkplain #SINGLE_BUTTON_WIDTH} * {@literal toolBar.getComponentCount()}
*/ */
public static int LEADING_WIDTH = 38; public static int leadingWidth;
// 每个按钮固定宽度大小
public static int SINGLE_BUTTON_WIDTH = 38; public static int SINGLE_BUTTON_WIDTH = 38;
//每个标签页的最大的长度和最小长度。这些长度均为均分 //每个标签页的最大的长度和最小长度。这些长度均为均分
@ -122,7 +128,7 @@ public class MultiTemplateTabPane extends Row {
private Icon clodeIcon = new LazyIcon("clear"); private Icon clodeIcon = new LazyIcon("clear");
private boolean isShowList = false; private boolean isShowList = false;
private JButton leadingActionButton; private JButton leadingActionButton;
private final UIToolbar toolBar = new UIToolbar(); private final UIToolbar leadingToolBar = new UIToolbar();
//自动新建的模板B若没有进行任何编辑,切换到其他 //自动新建的模板B若没有进行任何编辑,切换到其他
// //
@ -185,12 +191,9 @@ public class MultiTemplateTabPane extends Row {
} }
} }
}); });
ToolBarMenuDock toolBarMenuDock = getToolBarMenuDock(); preProcessMultiTemplateTabPane();
if (toolBarMenuDock != null) {
updateMultiTemplateToolBar(getToolBarMenuDock().createTemplateToolBarDef());
}
add( add(
Layouts.cell(getToolBar()).with(it -> { Layouts.cell(getLeadingToolBar()).with(it -> {
it.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON); it.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON);
it.setOpaque(false); it.setOpaque(false);
it.setBorder(new ScaledEmptyBorder(3, -7, 3, -7)); it.setBorder(new ScaledEmptyBorder(3, -7, 3, -7));
@ -199,12 +202,8 @@ public class MultiTemplateTabPane extends Row {
); );
} }
public ToolBarMenuDock getToolBarMenuDock() { private void preProcessMultiTemplateTabPane() {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); updateLeadingToolBar();
if (designerFrame == null) {
return null;
}
return designerFrame.getToolBarMenuDock();
} }
/** /**
@ -219,7 +218,7 @@ public class MultiTemplateTabPane extends Row {
} }
public void setToolBarEnable(boolean enable) { public void setToolBarEnable(boolean enable) {
toolBar.setEnabled(enable); leadingToolBar.setEnabled(enable);
} }
@ -505,7 +504,7 @@ public class MultiTemplateTabPane extends Row {
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
double maxWidth = getWidth() - scale(TRAILING_WIDTH) - scale(LEADING_WIDTH); //最大宽度 double maxWidth = getWidth() - scale(TRAILING_WIDTH) - scale(leadingWidth); //最大宽度
int maxTemplateNum = (int) (maxWidth) / scale(MINWIDTH); int maxTemplateNum = (int) (maxWidth) / scale(MINWIDTH);
calMinAndMaxIndex(maxTemplateNum); calMinAndMaxIndex(maxTemplateNum);
calculateRealAverageWidth(maxWidth, maxTemplateNum); calculateRealAverageWidth(maxWidth, maxTemplateNum);
@ -515,7 +514,7 @@ public class MultiTemplateTabPane extends Row {
private void calculateClosePosition() { private void calculateClosePosition() {
startX = new int[maxPaintIndex - minPaintIndex + 1]; startX = new int[maxPaintIndex - minPaintIndex + 1];
double templateStartX = scale(LEADING_WIDTH); double templateStartX = scale(leadingWidth);
for (int i = getViewRange().getFirst(); i <= getViewRange().getSecond(); i++) { for (int i = getViewRange().getFirst(); i <= getViewRange().getSecond(); i++) {
int closePosition = (int) templateStartX + getTabWidth() - clodeIcon.getIconWidth() - GAP; int closePosition = (int) templateStartX + getTabWidth() - clodeIcon.getIconWidth() - GAP;
startX[i - minPaintIndex] = closePosition; startX[i - minPaintIndex] = closePosition;
@ -703,7 +702,7 @@ public class MultiTemplateTabPane extends Row {
private boolean isOverListDown(int evtX) { private boolean isOverListDown(int evtX) {
int maxWidth = getWidth() - scale(LEADING_WIDTH); int maxWidth = getWidth() - scale(leadingWidth);
return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP);
} }
@ -715,13 +714,13 @@ public class MultiTemplateTabPane extends Row {
*/ */
private boolean isOverBlank(int evtX) { private boolean isOverBlank(int evtX) {
int tabWidths = (maxPaintIndex - minPaintIndex + 1) * tabWidth; int tabWidths = (maxPaintIndex - minPaintIndex + 1) * tabWidth;
int leftX = tabWidths + scale(LEADING_WIDTH); int leftX = tabWidths + scale(leadingWidth);
return evtX >= leftX && evtX <= getWidth() - scale(TRAILING_WIDTH); return evtX >= leftX && evtX <= getWidth() - scale(TRAILING_WIDTH);
} }
private int getTemplateIndex(int evtX) { private int getTemplateIndex(int evtX) {
int textX = scale(LEADING_WIDTH); int textX = scale(leadingWidth);
for (int i = minPaintIndex; i <= maxPaintIndex; i++) { for (int i = minPaintIndex; i <= maxPaintIndex; i++) {
int textWidth = tabWidth; int textWidth = tabWidth;
if (evtX >= textX && evtX < textX + textWidth) { if (evtX >= textX && evtX < textX + textWidth) {
@ -986,21 +985,72 @@ public class MultiTemplateTabPane extends Row {
} }
/** /**
* 获取多模板工具按钮 * 获取前导区多模板工具按钮
* *
* @return 工具按钮 * @return 工具按钮
*/ */
public UIToolbar getToolBar() { public UIToolbar getLeadingToolBar() {
return this.toolBar; return this.leadingToolBar;
}
/**
* 生成前导区多模板工具按钮
*/
public void updateLeadingToolBar() {
createLeadingToolBarDef().updateToolBar(getLeadingToolBar());
leadingWidth = getLeadingToolBar().getComponentCount() * SINGLE_BUTTON_WIDTH;
getLeadingToolBar().setLayout(new FlowLayout(FlowLayout.LEFT, FineUIScale.scale(14), 0));
}
/**
* 创建新建模板的前导区工具按钮
* @return
*/
private ToolBarDef createLeadingToolBarDef() {
ToolBarDef toolBarDef = ShortCut.asToolBarDef(createNewTemplateShortCuts());
insertLeadingToolButton(toolBarDef, MultiTemplateTabPaneHandler.LEADING_LOCATION);
return toolBarDef;
}
/**
* 创建新建文件的按钮数组
* @return
*/
public ShortCut[] createNewTemplateShortCuts() {
ArrayList<ShortCut> shortCuts = new ArrayList<ShortCut>();
shortCuts.add(new NewWorkBookToolButtonAction());
return shortCuts.toArray(new ShortCut[0]);
} }
/** /**
* 生成多模板工具按钮 * 插入插件中的按钮
* @param toolBarDef * @return
*/ */
public void updateMultiTemplateToolBar(ToolBarDef toolBarDef) { protected void insertLeadingToolButton(ToolBarDef toolBarDef, String anchor) {
toolBarDef.updateToolBar(getToolBar()); Set<MultiTemplateTabPaneHandler> set = ExtraDesignClassManager.getInstance().getArray(MultiTemplateTabPaneHandler.MARK_STRING);
LEADING_WIDTH = getToolBar().getComponentCount() * SINGLE_BUTTON_WIDTH; List<MultiTemplateTabPaneHandler> target = new ArrayList<>();
getToolBar().setLayout(new FlowLayout(FlowLayout.LEFT, FineUIScale.scale(14), 0)); for (MultiTemplateTabPaneHandler handler : set) {
if (ComparatorUtils.equals(handler.category(), anchor)) {
target.add(handler);
}
}
for (MultiTemplateTabPaneHandler handler : target) {
int insertPosition = handler.insertPosition(toolBarDef.getShortCutCount());
if (insertPosition == MenuHandler.HIDE) {
return;
}
ShortCut shortCut = handler.shortcut();
if (shortCut == null) {
continue;
}
if (insertPosition == MenuHandler.LAST) {
toolBarDef.addShortCut(shortCut);
} else {
toolBarDef.insertShortCut(insertPosition, shortCut);
}
}
} }
} }

24
designer-base/src/main/java/com/fr/design/fun/ToolBarHandler.java → designer-base/src/main/java/com/fr/design/fun/MultiTemplateTabPaneHandler.java

@ -4,14 +4,15 @@ import com.fr.design.menu.ShortCut;
import com.fr.stable.fun.mark.Mutable; import com.fr.stable.fun.mark.Mutable;
/** /**
* 设计器 Multi_template 按钮插件接口
*
* @author lemon * @author lemon
* @since * @since
* Created on * Created on
* 设计器工具按钮插件接口
*/ */
public interface ToolBarHandler extends Mutable { public interface MultiTemplateTabPaneHandler extends Mutable {
String MARK_STRING = "ToolBarHandler"; String MARK_STRING = "MultiTemplateToolButtonHandler";
int CURRENT_LEVEL = 1; int CURRENT_LEVEL = 1;
@ -19,7 +20,8 @@ public interface ToolBarHandler extends Mutable {
int LAST = -1; int LAST = -1;
int HIDE =-2; int HIDE =-2;
String MULTI_TEMPLATE = "multi_template"; String LEADING_LOCATION = "leading_location";
String TRAILING_LOCATION = "trailing_location";
/** /**
* 插入工具按钮的位置 * 插入工具按钮的位置
@ -29,20 +31,6 @@ public interface ToolBarHandler extends Mutable {
*/ */
int insertPosition(int total); int insertPosition(int total);
/**
* 是否在插入的工具按钮前插入一个分割符
*
* @return 是否插入分隔符
*/
boolean insertSeparatorBefore();
/**
* 是否在插入的工具按钮后插入一个分割符
*
* @return 是否插入分隔符
*/
boolean insertSeparatorAfter();
/** /**
* 所属的工具按钮分类 * 所属的工具按钮分类
* *

9
designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolBarHandler.java → designer-base/src/main/java/com/fr/design/fun/impl/AbstractMultiTemplateTabPaneHandler.java

@ -1,18 +1,19 @@
package com.fr.design.fun.impl; package com.fr.design.fun.impl;
import com.fr.design.fun.ToolBarHandler; import com.fr.design.fun.MultiTemplateTabPaneHandler;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API; import com.fr.stable.fun.mark.API;
/** /**
* 多模板工具按钮插件适配抽象类
*
* @author lemon * @author lemon
* @since * @since
* Created on * Created on
* 工具按钮插件适配抽象类
*/ */
@API(level = ToolBarHandler.CURRENT_LEVEL) @API(level = MultiTemplateTabPaneHandler.CURRENT_LEVEL)
public abstract class AbstractToolBarHandler extends AbstractProvider implements ToolBarHandler { public abstract class AbstractMultiTemplateTabPaneHandler extends AbstractProvider implements MultiTemplateTabPaneHandler {
/** /**
* 当前接口的API等级,用于判断是否需要升级插件 * 当前接口的API等级,用于判断是否需要升级插件
* @return API等级 * @return API等级

68
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -49,7 +49,6 @@ import com.fr.design.fun.MenuHandler;
import com.fr.design.fun.OemProcessor; import com.fr.design.fun.OemProcessor;
import com.fr.design.fun.PluginManagerProvider; import com.fr.design.fun.PluginManagerProvider;
import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.fun.TableDataPaneProcessor;
import com.fr.design.fun.ToolBarHandler;
import com.fr.design.gui.UILookAndFeel; import com.fr.design.gui.UILookAndFeel;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UICombinationButton; import com.fr.design.gui.ibutton.UICombinationButton;
@ -397,67 +396,6 @@ public abstract class ToolBarMenuDock {
return plus.menus4Target(); return plus.menus4Target();
} }
/**
* 创建新建模板的工具按钮
* @return
*/
public ToolBarDef createTemplateToolBarDef() {
ToolBarDef toolBarDef = ShortCut.asToolBarDef(createNewTemplateShortCuts());
insertToolBar(toolBarDef, ToolBarHandler.MULTI_TEMPLATE);
return toolBarDef;
}
/**
* 新增插件中的工具按钮
* @return
*/
protected void insertToolBar(ToolBarDef toolBarDef, String anchor) {
Set<ToolBarHandler> set = ExtraDesignClassManager.getInstance().getArray(ToolBarHandler.MARK_STRING);
addExtraToolBar(toolBarDef, anchor, set);
}
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)) {
target.add(handler);
}
}
for (ToolBarHandler handler : target) {
int insertPosition = handler.insertPosition(toolBarDef.getShortCutCount());
if (insertPosition == MenuHandler.HIDE) {
return;
}
ShortCut shortCut = handler.shortcut();
if (shortCut == null) {
continue;
}
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);
}
}
}
public MenuDef createFileMenuDef(ToolBarMenuDockPlus plus) { public MenuDef createFileMenuDef(ToolBarMenuDockPlus plus) {
if (DesignerMode.isVcsMode()) { if (DesignerMode.isVcsMode()) {
MenuDef menuDef = VcsScene.createFileMenuDef(plus); MenuDef menuDef = VcsScene.createFileMenuDef(plus);
@ -525,12 +463,6 @@ public abstract class ToolBarMenuDock {
* @return 菜单 * @return 菜单
*/ */
public abstract ShortCut[] createNewFileShortCuts(); public abstract ShortCut[] createNewFileShortCuts();
/**
* 创建新建文件的工具按钮
*
* @return 工具按钮
*/
public abstract ShortCut[] createNewTemplateShortCuts();
/** /**
* 创建论坛登录面板, chart那边不需要 * 创建论坛登录面板, chart那边不需要

41
designer-base/src/test/java/com/fr/design/gui/storybook/components/TemplateTabStoryBoard.java

@ -1,20 +1,11 @@
package com.fr.design.gui.storybook.components; package com.fr.design.gui.storybook.components;
import com.fine.theme.icon.LazyIcon;
import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.file.MultiTemplateTabPane;
import com.fr.design.gui.storybook.Story; import com.fr.design.gui.storybook.Story;
import com.fr.design.gui.storybook.StoryBoard; import com.fr.design.gui.storybook.StoryBoard;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.menu.ShortCut;
import com.fr.value.NullableLazyValue; import com.fr.value.NullableLazyValue;
import javax.swing.Icon;
import java.awt.event.ActionEvent;
/** /**
* 新建模版Tab * 新建模版Tab
* *
@ -38,37 +29,7 @@ public class TemplateTabStoryBoard extends StoryBoard {
super("新建模版Tab"); super("新建模版Tab");
init.getValue(); init.getValue();
MultiTemplateTabPane multiTemplateTabPane = MultiTemplateTabPane.getInstance(); add(MultiTemplateTabPane.getInstance());
multiTemplateTabPane.updateMultiTemplateToolBar(new ToolBarMenuDock() {
@Override
public ShortCut[] createNewFileShortCuts() {
return new ShortCut[0];
}
@Override
public ShortCut[] createNewTemplateShortCuts() {
return new ShortCut[]{new NewWorkBookToolBarAction()};
}
}.createTemplateToolBarDef());
multiTemplateTabPane.repaint();
add(multiTemplateTabPane);
} }
public class NewWorkBookToolBarAction extends UpdateAction {
public NewWorkBookToolBarAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_New_WorkBook"));
this.setSmallIcon(icon());
}
protected Icon icon() {
return new LazyIcon("add_worksheet");
}
@Override
public void actionPerformed(ActionEvent e) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(new JWorkBook());
}
}
} }

10
designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java

@ -101,11 +101,6 @@ public class ToolBarMenuDockTest {
public ShortCut[] createNewFileShortCuts() { public ShortCut[] createNewFileShortCuts() {
return new ShortCut[0]; return new ShortCut[0];
} }
@Override
public ShortCut[] createNewTemplateShortCuts() {
return new ShortCut[0];
}
}; };
ShortCut[] shortCuts = new ShortCut[] { ShortCut[] shortCuts = new ShortCut[] {
@ -159,11 +154,6 @@ public class ToolBarMenuDockTest {
public ShortCut[] createNewFileShortCuts() { public ShortCut[] createNewFileShortCuts() {
return new ShortCut[0]; return new ShortCut[0];
} }
@Override
public ShortCut[] createNewTemplateShortCuts() {
return new ShortCut[0];
}
}; };
ShortCut[] shortCuts = new ShortCut[] { ShortCut[] shortCuts = new ShortCut[] {

11
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -9,7 +9,6 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.actions.file.newReport.NewPolyReportAction; import com.fr.design.actions.file.newReport.NewPolyReportAction;
import com.fr.design.actions.file.newReport.NewWorkBookAction; import com.fr.design.actions.file.newReport.NewWorkBookAction;
import com.fr.design.actions.toolbar.multitemplate.NewWorkBookToolBarAction;
import com.fr.design.actions.server.ServerConfigManagerAction; import com.fr.design.actions.server.ServerConfigManagerAction;
import com.fr.design.actions.server.TemplateThemeManagerAction; import com.fr.design.actions.server.TemplateThemeManagerAction;
import com.fr.design.actions.server.WidgetManagerAction; import com.fr.design.actions.server.WidgetManagerAction;
@ -205,16 +204,6 @@ public class MainDesigner extends BaseDesigner {
}); });
} }
/**
* 创建新建文件的按钮数组
* @return
*/
public ShortCut[] createNewTemplateShortCuts() {
ArrayList<ShortCut> shortCuts = new ArrayList<ShortCut>();
shortCuts.add(new NewWorkBookToolBarAction());
return shortCuts.toArray(new ShortCut[0]);
}
/** /**
* 创建新建文件的快捷方式数组 * 创建新建文件的快捷方式数组
* *

Loading…
Cancel
Save