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 new file mode 100644 index 0000000000..cb04a942eb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java @@ -0,0 +1,230 @@ +package com.fr.design.mainframe; + +import com.fr.design.DesignState; +import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.constants.UIConstants; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.MutilTempalteTabPane; +import com.fr.design.file.NewTemplatePane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.imenu.UIMenuHighLight; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.toolbar.ToolBarMenuDock; +import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; +import org.jetbrains.annotations.Nullable; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.border.MatteBorder; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.util.ArrayList; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/4/6 + */ +public class CenterRegionContainerPane extends JPanel { + + private static volatile CenterRegionContainerPane THIS; + + private static final int LEFT_ALIGN_GAP = -5; + + private DesktopCardPane centerTemplateCardPane; + + private JPanel toolbarPane;//撤销重做 等工具栏 + 模板tab标签 + maybe have cpt 字体 + + private JComponent toolbarComponent;//cpt 字体 等工具栏 + + private JPanel eastCenterPane; + + private UIToolbar combineUp;//撤销重做 等工具栏 + + private NewTemplatePane newWorkBookPane;//模板tab标签 + + + public static CenterRegionContainerPane getInstance() { + if (THIS == null) { + synchronized (CenterRegionContainerPane.class) { + if (THIS == null) { + THIS = new CenterRegionContainerPane(); + } + } + } + return THIS; + } + + public CenterRegionContainerPane() { + + toolbarPane = new JPanel() { + + @Override + public Dimension getPreferredSize() { + + Dimension dim = super.getPreferredSize(); + // dim.height = TOOLBAR_HEIGHT; + return dim; + } + }; + toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + eastPane.add(getToolBarMenuDock().createLargeToolbar(), BorderLayout.WEST); + eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + combineUpTooBar(); + eastCenterPane.add(combineUp, BorderLayout.NORTH); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.add(newWorkBookPane = getToolBarMenuDock().getNewTemplatePane(), BorderLayout.WEST); + panel.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER); + eastCenterPane.add(panel, BorderLayout.CENTER); + + eastPane.add(eastCenterPane, BorderLayout.CENTER); + toolbarPane.add(eastPane, BorderLayout.NORTH); + toolbarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); + + this.setLayout(new BorderLayout()); + this.add(centerTemplateCardPane = new DesktopCardPane(), BorderLayout.CENTER); + this.add(toolbarPane, BorderLayout.NORTH); + + } + + private ToolBarMenuDock getToolBarMenuDock() { + return DesignerContext.getDesignerFrame().getToolBarMenuDock(); + } + + /** + * 创建上工具栏 + */ + private void combineUpTooBar() { + combineUp = new UIToolbar(FlowLayout.LEFT); + combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); + combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2)); + setUpUpToolBar(null); + + } + + + /** + * 重置上工具栏 + */ + private void resetCombineUpTooBar(JComponent[] toolbar4Form) { + combineUp.removeAll(); + setUpUpToolBar(toolbar4Form); + } + + + /** + * 填充上工具栏的中的工具 + * + * @param toolbar4Form 目标组件 + */ + private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) { + UIButton[] fixButtons = getToolBarMenuDock().createUp(); + for (UIButton fixButton : fixButtons) { + combineUp.add(fixButton); + } + if (!DesignModeContext.isAuthorityEditing()) { + combineUp.addSeparator(new Dimension(2, 16)); + if (toolbar4Form != null) { + for (JComponent jComponent : toolbar4Form) { + combineUp.add(jComponent); + } + } + } + //添加分享按钮 + addShareButton(); + //添加插件中的按钮 + addExtraButtons(); + } + + + private void addExtraButtons() { + + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt == null) { + return; + } + + + UIButton[] extraButtons = jt.createExtraButtons(); + for (UIButton extraButton : extraButtons) { + combineUp.add(extraButton); + } + if (extraButtons.length > 0) { + combineUp.addSeparator(new Dimension(2, 16)); + } + } + + private void addShareButton() { + + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt == null) { + return; + } + + combineUp.addSeparator(new Dimension(2, 16)); + UIButton[] shareButtons = jt.createShareButton(); + for (UIButton shareButton : shareButtons) { + combineUp.add(shareButton); + } + } + + /** + * 检查 + * + * @param flag 组件是否可见 + * @param al 组件名称 + */ + protected void checkCombineUp(boolean flag, ArrayList al) { + //Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的 + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jTemplate != null) { + // 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return + if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) { + return; + } + combineUp.checkComponentsByNames(flag, al); + } + } + + + /** + * 重置相关的工具条. + * + * @param plus 工具条中相关信息 + */ + protected void resetToolkitByPlus(ToolBarMenuDockPlus plus, ToolBarMenuDock ad) { + + resetCombineUpTooBar(ad.resetUpToolBar(plus)); + + if (toolbarComponent != null) { + toolbarPane.remove(toolbarComponent); + } + + // 颜色,字体那些按钮的工具栏 + toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); + } + + JComponent getToolbarComponent() { + + return this.toolbarComponent; + } + + /** + * 判断是否在权限编辑状态,若是在权限编辑状态,则需要有虚线框和关闭突变 + */ + protected void needToAddAuhtorityPaint() { + newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); + + } + + + protected DesktopCardPane getCenterTemplateCardPane() { + + return centerTemplateCardPane; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index b826931b61..76a0e3ad3d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -5,7 +5,6 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.design.DesignModelAdapter; -import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.core.ActionFactory; @@ -21,24 +20,16 @@ import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; -import com.fr.design.file.NewTemplatePane; import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.OemProcessor; -import com.fr.design.fun.TitlePlaceProcessor; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.imenu.UIMenuHighLight; import com.fr.design.gui.iprogressbar.ProgressDialog; import com.fr.design.gui.iscrollbar.UIScrollBar; -import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.design.menu.MenuManager; import com.fr.design.menu.ShortCut; import com.fr.design.os.impl.MacOsAddListenerAction; import com.fr.design.os.impl.SupportOSImpl; @@ -50,47 +41,33 @@ import com.fr.file.FILE; import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; -import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.invoke.Reflect; import com.fr.log.FineLoggerFactory; -import com.fr.plugin.context.PluginContext; -import com.fr.plugin.injectable.PluginModule; -import com.fr.plugin.manage.PluginFilter; -import com.fr.plugin.observer.PluginEvent; -import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.os.OperatingSystem; -import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.project.ProjectConstants; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceConnectionInfo; -import org.jetbrains.annotations.Nullable; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLayeredPane; -import javax.swing.JMenuBar; import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.WindowConstants; -import javax.swing.border.MatteBorder; import java.awt.BorderLayout; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.Graphics; -import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; -import java.awt.Component; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.dnd.DnDConstants; @@ -123,8 +100,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private static final long serialVersionUID = -8732559571067484460L; - private static final int LEFT_ALIGN_GAP = -5; - private static final int MENU_HEIGHT = 26; private static final Integer SECOND_LAYER = 100; @@ -135,22 +110,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private ToolBarMenuDock ad; - private DesktopCardPane centerTemplateCardPane; - - private JPanel toolbarPane; - - private JComponent toolbarComponent; - - private JPanel menuPane; - - private JMenuBar menuBar; - - private JPanel eastCenterPane; - - private UIToolbar combineUp; - - private NewTemplatePane newWorkBookPane; - private Icon closeMode; private JLayeredPane layeredPane = this.getLayeredPane(); @@ -268,37 +227,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta // the content pane basePane.setLayout(new BorderLayout()); - toolbarPane = new JPanel() { - - @Override - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - // dim.height = TOOLBAR_HEIGHT; - return dim; - } - }; - toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - eastPane.add(ad.createLargeToolbar(), BorderLayout.WEST); - eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - combineUpTooBar(); - eastCenterPane.add(combineUp, BorderLayout.NORTH); - JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - panel.add(newWorkBookPane = ad.getNewTemplatePane(), BorderLayout.WEST); - panel.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER); - eastCenterPane.add(panel, BorderLayout.CENTER); - - eastPane.add(eastCenterPane, BorderLayout.CENTER); - toolbarPane.add(eastPane, BorderLayout.NORTH); - toolbarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); - - JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - centerPane.add(centerTemplateCardPane = new DesktopCardPane(), BorderLayout.CENTER); - centerPane.add(toolbarPane, BorderLayout.NORTH); - - - basePane.add(centerPane, BorderLayout.CENTER); + basePane.add(CenterRegionContainerPane.getInstance(), BorderLayout.CENTER); laoyoutWestPane(); basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST); basePane.setBounds(0, 0, contentWidth, contentHeight); @@ -406,7 +336,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta protected DesktopCardPane getCenterTemplateCardPane() { - return centerTemplateCardPane; + return CenterRegionContainerPane.getInstance().getCenterTemplateCardPane(); } /** @@ -414,80 +344,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ protected void initMenuPane() { - menuPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - menuPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); - menuPane.add(initNorthEastPane(ad), BorderLayout.EAST); - basePane.add(menuPane, BorderLayout.NORTH); + basePane.add(NorthRegionContainerPane.getInstance(), BorderLayout.NORTH); this.resetToolkitByPlus(null); } - /** - * @param ad 菜单栏 - * @return panel - */ - protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { - //hugh: private修改为protected方便oem的时候修改右上的组件构成 - //顶部日志+登陆按钮 - final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - //优先级为-1,保证最后全面刷新一次 - GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { - - @Override - public void on(PluginEvent event) { - - refreshNorthEastPane(northEastPane, ad); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - if (DesignerContext.getDesignerFrame() == null) { - return; - } - DesignerContext.getDesignerFrame().refresh(); - DesignerContext.getDesignerFrame().repaint(); - } - }); - } - }, new PluginFilter() { - - @Override - public boolean accept(PluginContext context) { - - return context.contain(PluginModule.ExtraDesign); - } - }); - refreshNorthEastPane(northEastPane, ad); - return northEastPane; - } - - private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) { - - northEastPane.removeAll(); - northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); - northEastPane.add(LogMessageBar.getInstance()); - TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); - if (processor != null) { - final Component[] bbsLoginPane = {null}; - OSSupportCenter.buildAction(new OSBasedAction() { - @Override - public void execute(Object... objects) { - bbsLoginPane[0] = ad.createBBSLoginPane(); - } - }, SupportOSImpl.USERINFOPANE); - processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); - } - northEastPane.add(ad.createAlphaFinePane()); - if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { - ad.createAlphaFinePane().setVisible(false); - } - OSSupportCenter.buildAction(new OSBasedAction() { - @Override - public void execute(Object... objects) { - northEastPane.add(ad.createBBSLoginPane()); - } - }, SupportOSImpl.USERINFOPANE); - - } - public void initTitleIcon() { try { @@ -664,80 +524,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.closeMode = closeMode; } - /** - * 创建上工具栏 - */ - private void combineUpTooBar() { - combineUp = new UIToolbar(FlowLayout.LEFT); - combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); - combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2)); - setUpUpToolBar(null); - - } - - /** - * 重置上工具栏 - */ - private void resetCombineUpTooBar(JComponent[] toolbar4Form) { - combineUp.removeAll(); - setUpUpToolBar(toolbar4Form); - } - - /** - * 填充上工具栏的中的工具 - * - * @param toolbar4Form 目标组件 - */ - private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) { - UIButton[] fixButtons = ad.createUp(); - for (UIButton fixButton : fixButtons) { - combineUp.add(fixButton); - } - if (!DesignModeContext.isAuthorityEditing()) { - combineUp.addSeparator(new Dimension(2, 16)); - if (toolbar4Form != null) { - for (JComponent jComponent : toolbar4Form) { - combineUp.add(jComponent); - } - } - } - //添加分享按钮 - addShareButton(); - //添加插件中的按钮 - addExtraButtons(); - } - - private void addExtraButtons() { - - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - - - UIButton[] extraButtons = jt.createExtraButtons(); - for (UIButton extraButton : extraButtons) { - combineUp.add(extraButton); - } - if (extraButtons.length > 0) { - combineUp.addSeparator(new Dimension(2, 16)); - } - } - - private void addShareButton() { - - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - - combineUp.addSeparator(new Dimension(2, 16)); - UIButton[] shareButtons = jt.createShareButton(); - for (UIButton shareButton : shareButtons) { - combineUp.add(shareButton); - } - } - /** * 检查 * @@ -745,17 +531,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * @param al 组件名称 */ public void checkCombineUp(boolean flag, ArrayList al) { - //Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的 - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jTemplate != null) { - // 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return - if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) { - return; - } - combineUp.checkComponentsByNames(flag, al); - } + CenterRegionContainerPane.getInstance().checkCombineUp(flag, al); } + /** * 刷新工具条. */ @@ -764,6 +543,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.ad.updateToolBarDef(); } + ToolBarMenuDock getToolBarMenuDock() { + return this.ad; + } + /** * 重置相关的工具条. * @@ -775,22 +558,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta plus = ToolBarMenuDock.NULLAVOID; } - DesignState designState = new DesignState(plus); - MenuManager.getInstance().setMenus4Designer(designState); - if (menuBar == null) { - menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); - } else { - ad.resetJMenuBar(menuBar, plus); - } - - resetCombineUpTooBar(ad.resetUpToolBar(plus)); - - if (toolbarComponent != null) { - toolbarPane.remove(toolbarComponent); - } + NorthRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad); - // 颜色,字体那些按钮的工具栏 - toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); + CenterRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad); this.checkToolbarMenuEnable(); this.validate(); @@ -799,7 +569,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public JComponent getToolbarComponent() { - return this.toolbarComponent; + return CenterRegionContainerPane.getInstance().getToolbarComponent(); } /** @@ -807,7 +577,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void needToAddAuhtorityPaint() { - newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); + CenterRegionContainerPane.getInstance().needToAddAuhtorityPaint(); // 进入或退出权限编辑模式,通知插件 Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); @@ -923,7 +693,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public JTemplate getSelectedJTemplate() { - return this.centerTemplateCardPane.getSelectedJTemplate(); + return getCenterTemplateCardPane().getSelectedJTemplate(); } /** @@ -988,10 +758,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta if (jt == null || jt.getEditingFILE() == null) { return; } + if (currentTemplateDeactivateFail()) { + return; + } jt.addJTemplateActionListener(this); jt.addTargetModifiedListener(this); jt.addJTemplateActionListener(VcsHelper.getInstance()); - centerTemplateCardPane.showJTemplate(jt); + getCenterTemplateCardPane().showJTemplate(jt); + refreshBaseContentPane(jt); setTitle(); layeredPane.repaint(); } @@ -1009,11 +783,54 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta if (jt == null || jt.getEditingFILE() == null) { return; } - centerTemplateCardPane.showJTemplate(jt); + if (currentTemplateDeactivateFail()) { + return; + } + getCenterTemplateCardPane().showJTemplate(jt); + refreshBaseContentPane(jt); setTitle(); layeredPane.repaint(); } + /** + * 当前模板 停用失败 + * + * @return 是否停用失败 + */ + private boolean currentTemplateDeactivateFail() { + JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return currentEditingTemplate != null && !currentEditingTemplate.deactivateTemplate(); + } + + + /** + * 根据模板刷新 设计器整个界面 + * + * @param jTemplate 当前模板 + */ + private void refreshBaseContentPane(JTemplate jTemplate) { + + JComponent north = jTemplate.north4DesignerFrame(), + center = jTemplate.center4DesignerFrame(), + west = jTemplate.west4DesignerFrame(), + east = jTemplate.east4DesignerFrame(); + + basePane.removeAll(); + + if (north != null) { + basePane.add(north, BorderLayout.NORTH); + } + if (center != null) { + basePane.add(center, BorderLayout.CENTER); + } + if (west != null) { + basePane.add(west, BorderLayout.WEST); + } + if (east != null) { + basePane.add(east, BorderLayout.EAST); + } + } + /** * 对象侦听 * diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 483e74d9d7..5ecf4ae82b 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -82,11 +82,11 @@ import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.undo.UndoManager; +import java.awt.BorderLayout; import java.util.ArrayList; import java.util.Arrays; import java.util.Set; import java.util.regex.Pattern; -import java.awt.BorderLayout; /** * 报表设计和表单设计的编辑区域(设计器编辑的IO文件) @@ -1125,6 +1125,16 @@ public abstract class JTemplate> DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); } + /** + * 将要激活打开其他模板,使当前模板灭活 + * 默认 do nothing 返回true + * + * @return true:成功停用当前模板 + */ + public boolean deactivateTemplate() { + return true; + } + /** * 返回当前支持的超链界面pane @@ -1237,15 +1247,6 @@ public abstract class JTemplate> */ public abstract Icon getIcon(); - /** - * 导出菜单项 - * - * @return 菜单项 - */ - @Override - public ShortCut[] shortcut4ExportMenu() { - return new ShortCut[0]; - } /** * 复制JS代码 @@ -1359,4 +1360,44 @@ public abstract class JTemplate> return StringUtils.EMPTY; } + /** + * 指定 设计器界面 NORTH组件 + * 默认是 菜单区域 + * + * @return NORTH组件 + */ + public JComponent north4DesignerFrame() { + return NorthRegionContainerPane.getInstance(); + } + + /** + * 指定 设计器界面 CENTER组件 + * 默认是 模板对应的工具栏区域+模板设计区域 + * + * @return CENTER组件 + */ + public JComponent center4DesignerFrame() { + return CenterRegionContainerPane.getInstance(); + } + + /** + * 指定 设计器界面 WEST组件 + * 默认是 模板目录树+数据集编辑区域 + * + * @return WEST组件 + */ + public JComponent west4DesignerFrame() { + return WestRegionContainerPane.getInstance(); + } + + /** + * 指定 设计器界面 EAST组件 + * 默认是 属性配置界面 + * + * @return EAST组件 + */ + public JComponent east4DesignerFrame() { + return EastRegionContainerPane.getInstance(); + } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java new file mode 100644 index 0000000000..dcc274eed1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java @@ -0,0 +1,142 @@ +package com.fr.design.mainframe; + +import com.fr.design.DesignState; +import com.fr.design.DesignerEnvManager; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.TitlePlaceProcessor; +import com.fr.design.gui.imenu.UIMenuHighLight; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.loghandler.LogMessageBar; +import com.fr.design.mainframe.toolbar.ToolBarMenuDock; +import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; +import com.fr.design.menu.MenuManager; +import com.fr.design.os.impl.SupportOSImpl; +import com.fr.general.GeneralContext; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; + +import javax.swing.JMenuBar; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/4/6 + */ +public class NorthRegionContainerPane extends JPanel { + + private static volatile NorthRegionContainerPane THIS; + + private JMenuBar menuBar; + + public static NorthRegionContainerPane getInstance() { + if (THIS == null) { + synchronized (NorthRegionContainerPane.class) { + if (THIS == null) { + THIS = new NorthRegionContainerPane(); + } + } + } + return THIS; + } + + public NorthRegionContainerPane() { + + ToolBarMenuDock ad = DesignerContext.getDesignerFrame().getToolBarMenuDock(); + + this.setLayout(new BorderLayout()); + this.add(new UIMenuHighLight(), BorderLayout.SOUTH); + this.add(initNorthEastPane(ad), BorderLayout.EAST); + } + + /** + * @param ad 菜单栏 + * @return panel + */ + protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { + //hugh: private修改为protected方便oem的时候修改右上的组件构成 + //顶部日志+登陆按钮 + final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + //优先级为-1,保证最后全面刷新一次 + GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { + + @Override + public void on(PluginEvent event) { + + refreshNorthEastPane(northEastPane, ad); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (DesignerContext.getDesignerFrame() == null) { + return; + } + DesignerContext.getDesignerFrame().refresh(); + DesignerContext.getDesignerFrame().repaint(); + } + }); + } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign); + } + }); + refreshNorthEastPane(northEastPane, ad); + return northEastPane; + } + + private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) { + + northEastPane.removeAll(); + northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + northEastPane.add(LogMessageBar.getInstance()); + TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); + if (processor != null) { + final Component[] bbsLoginPane = {null}; + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + bbsLoginPane[0] = ad.createBBSLoginPane(); + } + }, SupportOSImpl.USERINFOPANE); + processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); + } + northEastPane.add(ad.createAlphaFinePane()); + if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { + ad.createAlphaFinePane().setVisible(false); + } + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + northEastPane.add(ad.createBBSLoginPane()); + } + }, SupportOSImpl.USERINFOPANE); + + } + + /** + * 重置相关的工具条. + * + * @param plus 工具条中相关信息 + */ + void resetToolkitByPlus(ToolBarMenuDockPlus plus, ToolBarMenuDock ad) { + DesignState designState = new DesignState(plus); + MenuManager.getInstance().setMenus4Designer(designState); + if (menuBar == null) { + this.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); + } else { + ad.resetJMenuBar(menuBar, plus); + } + } +} 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 aca9bcc362..fa9835492e 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 @@ -9,7 +9,18 @@ import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; -import com.fr.design.actions.community.*; +import com.fr.design.actions.community.BBSAction; +import com.fr.design.actions.community.BugAction; +import com.fr.design.actions.community.BugNeedAction; +import com.fr.design.actions.community.CenterAction; +import com.fr.design.actions.community.FacebookFansAction; +import com.fr.design.actions.community.NeedAction; +import com.fr.design.actions.community.QuestionAction; +import com.fr.design.actions.community.SignAction; +import com.fr.design.actions.community.TechSolutionAction; +import com.fr.design.actions.community.TechSupportAction; +import com.fr.design.actions.community.VideoAction; +import com.fr.design.actions.community.WorkOrderCenterAction; import com.fr.design.actions.file.CloseCurrentTemplateAction; import com.fr.design.actions.file.ExitDesignerAction; import com.fr.design.actions.file.OpenRecentReportMenuDef; @@ -64,7 +75,6 @@ import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import com.fr.stable.bridge.ObjectHolder; -import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; @@ -141,16 +151,6 @@ public abstract class ToolBarMenuDock { return PANLE_HEIGNT; } - /** - * 导出菜单的子菜单 ,目前用于图表设计器 - * - * @return 子菜单 - */ - @Override - public ShortCut[] shortcut4ExportMenu() { - return new ShortCut[0]; - } - }; private static final int MENUBAR_HEIGHT = 22; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java index ada075aeb6..ed9b9d7871 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java @@ -1,11 +1,12 @@ package com.fr.design.mainframe.toolbar; -import javax.swing.*; - import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; +import javax.swing.JComponent; +import javax.swing.JPanel; + public interface ToolBarMenuDockPlus { /** * 模板的工具 @@ -53,11 +54,5 @@ public interface ToolBarMenuDockPlus { int getToolBarHeight(); - /** - * 导出菜单的子菜单 ,目前用于图表设计器 - * - * @return 子菜单 - */ - ShortCut[] shortcut4ExportMenu(); } \ No newline at end of file