Browse Source

refactor: center region 4 designer Frame

feature/big-screen
shine 4 years ago
parent
commit
f6078b1742
  1. 230
      designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java
  2. 163
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

230
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<String> 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;
}
}

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

@ -21,17 +21,14 @@ import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.file.SaveSomeTemplatePane;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.OemProcessor; import com.fr.design.fun.OemProcessor;
import com.fr.design.fun.TitlePlaceProcessor; import com.fr.design.fun.TitlePlaceProcessor;
import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; 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.imenu.UIMenuHighLight;
import com.fr.design.gui.iprogressbar.ProgressDialog; import com.fr.design.gui.iprogressbar.ProgressDialog;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.loghandler.LogMessageBar;
@ -70,7 +67,6 @@ import com.fr.start.OemHandler;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import org.jetbrains.annotations.Nullable;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -82,15 +78,13 @@ import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import javax.swing.border.MatteBorder;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Component;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants; import java.awt.dnd.DnDConstants;
@ -123,8 +117,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private static final long serialVersionUID = -8732559571067484460L; private static final long serialVersionUID = -8732559571067484460L;
private static final int LEFT_ALIGN_GAP = -5;
private static final int MENU_HEIGHT = 26; private static final int MENU_HEIGHT = 26;
private static final Integer SECOND_LAYER = 100; private static final Integer SECOND_LAYER = 100;
@ -135,22 +127,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private ToolBarMenuDock ad; private ToolBarMenuDock ad;
private DesktopCardPane centerTemplateCardPane;
private JPanel toolbarPane;
private JComponent toolbarComponent;
private JPanel menuPane; private JPanel menuPane;
private JMenuBar menuBar; private JMenuBar menuBar;
private JPanel eastCenterPane;
private UIToolbar combineUp;
private NewTemplatePane newWorkBookPane;
private Icon closeMode; private Icon closeMode;
private JLayeredPane layeredPane = this.getLayeredPane(); private JLayeredPane layeredPane = this.getLayeredPane();
@ -268,37 +248,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// the content pane // the content pane
basePane.setLayout(new BorderLayout()); basePane.setLayout(new BorderLayout());
toolbarPane = new JPanel() {
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize(); basePane.add(CenterRegionContainerPane.getInstance(), BorderLayout.CENTER);
// 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);
laoyoutWestPane(); laoyoutWestPane();
basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST); basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST);
basePane.setBounds(0, 0, contentWidth, contentHeight); basePane.setBounds(0, 0, contentWidth, contentHeight);
@ -406,7 +357,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
protected DesktopCardPane getCenterTemplateCardPane() { protected DesktopCardPane getCenterTemplateCardPane() {
return centerTemplateCardPane; return CenterRegionContainerPane.getInstance().getCenterTemplateCardPane();
} }
/** /**
@ -664,80 +615,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.closeMode = closeMode; 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 +622,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param al 组件名称 * @param al 组件名称
*/ */
public void checkCombineUp(boolean flag, ArrayList<String> al) { public void checkCombineUp(boolean flag, ArrayList<String> al) {
//Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的 CenterRegionContainerPane.getInstance().checkCombineUp(flag, al);
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate != null) {
// 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return
if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) {
return;
}
combineUp.checkComponentsByNames(flag, al);
}
} }
/** /**
* 刷新工具条. * 刷新工具条.
*/ */
@ -764,6 +634,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.ad.updateToolBarDef(); this.ad.updateToolBarDef();
} }
public ToolBarMenuDock getToolBarMenuDock() {
return this.ad;
}
/** /**
* 重置相关的工具条. * 重置相关的工具条.
* *
@ -783,14 +657,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
ad.resetJMenuBar(menuBar, plus); ad.resetJMenuBar(menuBar, plus);
} }
resetCombineUpTooBar(ad.resetUpToolBar(plus)); CenterRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad);
if (toolbarComponent != null) {
toolbarPane.remove(toolbarComponent);
}
// 颜色,字体那些按钮的工具栏
toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER);
this.checkToolbarMenuEnable(); this.checkToolbarMenuEnable();
this.validate(); this.validate();
@ -799,7 +666,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public JComponent getToolbarComponent() { public JComponent getToolbarComponent() {
return this.toolbarComponent; return CenterRegionContainerPane.getInstance().getToolbarComponent();
} }
/** /**
@ -807,7 +674,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void needToAddAuhtorityPaint() { public void needToAddAuhtorityPaint() {
newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); CenterRegionContainerPane.getInstance().needToAddAuhtorityPaint();
// 进入或退出权限编辑模式,通知插件 // 进入或退出权限编辑模式,通知插件
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
@ -923,7 +790,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public JTemplate<?, ?> getSelectedJTemplate() { public JTemplate<?, ?> getSelectedJTemplate() {
return this.centerTemplateCardPane.getSelectedJTemplate(); return getCenterTemplateCardPane().getSelectedJTemplate();
} }
/** /**
@ -991,7 +858,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
jt.addJTemplateActionListener(this); jt.addJTemplateActionListener(this);
jt.addTargetModifiedListener(this); jt.addTargetModifiedListener(this);
jt.addJTemplateActionListener(VcsHelper.getInstance()); jt.addJTemplateActionListener(VcsHelper.getInstance());
centerTemplateCardPane.showJTemplate(jt); getCenterTemplateCardPane().showJTemplate(jt);
setTitle(); setTitle();
layeredPane.repaint(); layeredPane.repaint();
} }
@ -1009,7 +876,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
if (jt == null || jt.getEditingFILE() == null) { if (jt == null || jt.getEditingFILE() == null) {
return; return;
} }
centerTemplateCardPane.showJTemplate(jt); getCenterTemplateCardPane().showJTemplate(jt);
setTitle(); setTitle();
layeredPane.repaint(); layeredPane.repaint();
} }

Loading…
Cancel
Save