Browse Source

REPORT-127437 feat: fvs 适配

newui
lemon 4 months ago
parent
commit
5d045ae857
  1. 15
      designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java
  2. 59
      designer-base/src/main/java/com/fr/design/fun/ToolBarHandler.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java
  4. 2
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  5. 65
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  6. 12
      designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java
  7. 10
      designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java
  8. 31
      designer-realize/src/main/java/com/fr/design/actions/toolbar/multitemplate/NewWorkBookToolBarAction.java
  9. 12
      designer-realize/src/main/java/com/fr/start/MainDesigner.java

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

@ -10,14 +10,16 @@ import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.file.LocateAction; import com.fr.design.actions.file.LocateAction;
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.gui.ibutton.UIButton;
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.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.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.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;
import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.design.worker.save.CallbackSaveWorker;
@ -114,6 +116,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;
public UIToolbar toolBar = ToolBarDef.createJToolBar();
//自动新建的模板B若没有进行任何编辑,切换到其他 //自动新建的模板B若没有进行任何编辑,切换到其他
// //
@ -176,16 +179,20 @@ public class MultiTemplateTabPane extends Row {
} }
} }
}); });
getToolBarMenuDock().createTemplateToolBarDef().updateToolBar(toolBar);
add( add(
Layouts.cell(new UIButton(new LazyIcon("add_worksheet"))).with(it -> { Layouts.cell(toolBar).with(it -> {
it.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON); it.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON);
FineUIStyle.setStyle(it, BUTTON_TAB_ACTION); FineUIStyle.setStyle(it, BUTTON_TAB_ACTION);
it.setFocusPainted(false);
leadingActionButton = it;
}) })
); );
} }
public ToolBarMenuDock getToolBarMenuDock() {
return DesignerContext.getDesignerFrame().getToolBarMenuDock();
}
/** /**
* 为前导动作添加监听 * 为前导动作添加监听
* *

59
designer-base/src/main/java/com/fr/design/fun/ToolBarHandler.java

@ -0,0 +1,59 @@
package com.fr.design.fun;
import com.fr.design.menu.ShortCut;
import com.fr.stable.fun.mark.Mutable;
/**
* @author lemon
* @since
* Created on
* 设计器工具按钮插件接口
*/
public interface ToolBarHandler extends Mutable {
String MARK_STRING = "ToolBarHandler";
int CURRENT_LEVEL = 1;
int LAST = -1;
int HIDE =-2;
String MULTI_TEMPLATE = "multi_template";
/**
* 插入工具按钮的位置
*
* @param total 插入的位置
* @return 插入位置如果想放到最后则返回-1
*/
int insertPosition(int total);
/**
* 是否在插入的工具按钮前插入一个分割符
*
* @return 是否插入分隔符
*/
boolean insertSeparatorBefore();
/**
* 是否在插入的工具按钮后插入一个分割符
*
* @return 是否插入分隔符
*/
boolean insertSeparatorAfter();
/**
* 所属的工具按钮分类
*
* @return 分类工具按钮名
*/
String category();
/**
* 具体的工具按钮项内容
*
* @return 工具按钮项内容
*/
ShortCut shortcut();
}

2
designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java

@ -93,8 +93,6 @@ public class CenterRegionContainerPane extends JPanel {
private MultiTemplateTabPane initTemplateTabPane() { private MultiTemplateTabPane initTemplateTabPane() {
MultiTemplateTabPane templateTabPane = MultiTemplateTabPane.getInstance(); MultiTemplateTabPane templateTabPane = MultiTemplateTabPane.getInstance();
templateTabPane.addLeadingAction(e ->
DesignerContext.getDesignerFrame().addAndActivateJTemplate());
return templateTabPane; return templateTabPane;
} }

2
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -620,7 +620,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.ad.updateToolBarDef(); this.ad.updateToolBarDef();
} }
ToolBarMenuDock getToolBarMenuDock() { public ToolBarMenuDock getToolBarMenuDock() {
return this.ad; return this.ad;
} }

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

@ -49,6 +49,7 @@ 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;
@ -396,6 +397,64 @@ 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;
}
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);
@ -463,6 +522,12 @@ public abstract class ToolBarMenuDock {
* @return 菜单 * @return 菜单
*/ */
public abstract ShortCut[] createNewFileShortCuts(); public abstract ShortCut[] createNewFileShortCuts();
/**
* 创建新建文件的工具按钮
*
* @return 工具按钮
*/
public abstract ShortCut[] createNewTemplateShortCuts();
/** /**
* 创建论坛登录面板, chart那边不需要 * 创建论坛登录面板, chart那边不需要

12
designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java

@ -38,6 +38,18 @@ public class ToolBarDef {
public ToolBarDef() { public ToolBarDef() {
} }
/**
* 插入工具按钮项
*
* @param index 插入的位置
* @param shortCut 工具按钮信息
*/
public void insertShortCut(int index, ShortCut shortCut) {
int size = this.shortcutList.size();
index = Math.min(index, size);
this.shortcutList.add(index, shortCut);
}
public int getShortCutCount() { public int getShortCutCount() {
return this.shortcutList.size(); return this.shortcutList.size();
} }

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

@ -101,6 +101,11 @@ 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[] {
@ -154,6 +159,11 @@ 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[] {

31
designer-realize/src/main/java/com/fr/design/actions/toolbar/multitemplate/NewWorkBookToolBarAction.java

@ -0,0 +1,31 @@
package com.fr.design.actions.toolbar.multitemplate;
import com.fine.theme.icon.LazyIcon;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JWorkBook;
import javax.swing.Icon;
import java.awt.event.ActionEvent;
/**
* @author lemon
* @since
* Created on
* 新建报表文件
*/
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());
}
}

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

@ -1,7 +1,6 @@
package com.fr.start; package com.fr.start;
import com.fanruan.gui.UiInspector;
import com.fine.theme.icon.LazyIcon; import com.fine.theme.icon.LazyIcon;
import com.fr.base.function.UITerminator; import com.fr.base.function.UITerminator;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
@ -9,6 +8,7 @@ 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;
@ -204,6 +204,16 @@ 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