forked from fanruan/design
Browse Source
Merge in DESIGN/design from ~ZHENG/c-design:feature/big-screen to feature/big-screen * commit '8487a0ce987cef0b772138d31124f40a8568f0a6': update feature: JTemplate新增 停用模板+指定模板所需设计器界面方法 refactor: north region 4 designer Frame refactor: center region 4 designer Framefeature/big-screen
zheng
4 years ago
6 changed files with 501 additions and 276 deletions
@ -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; |
||||
} |
||||
|
||||
} |
@ -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); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue