Browse Source

merge:先把我自己的改回去

feature/big-screen
shine 3 years ago
parent
commit
6a225d293d
  1. 399
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

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

@ -4,9 +4,7 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.chart.exception.ChartNotFoundException;
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;
@ -22,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;
@ -51,47 +41,31 @@ 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.GeneralUtils;
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 java.util.concurrent.CopyOnWriteArrayList;
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.Component;
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.datatransfer.DataFlavor;
@ -126,34 +100,16 @@ 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;
private static final Integer TOP_LAYER = 200;
private List<DesignerOpenedListener> designerOpenedListenerList = new CopyOnWriteArrayList<>();
private List<DesignerOpenedListener> designerOpenedListenerList = new ArrayList<>();
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();
@ -188,10 +144,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
@Override
public void windowClosing(WindowEvent e) {
// 关闭前check
if (!TemplateSavingChecker.check()) {
return;
}
//关闭前当前模板 停止编辑
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().stopEditing();
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
@ -275,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);
@ -411,9 +334,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
designerOpenedListenerList.clear();
}
public DesktopCardPane getCenterTemplateCardPane() {
protected DesktopCardPane getCenterTemplateCardPane() {
return centerTemplateCardPane;
return CenterRegionContainerPane.getInstance().getCenterTemplateCardPane();
}
/**
@ -421,82 +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);
}
northEastPane.add(ad.createNotificationCenterPane());
OSSupportCenter.buildAction(new OSBasedAction() {
@Override
public void execute(Object... objects) {
northEastPane.add(ad.createBBSLoginPane());
}
}, SupportOSImpl.USERINFOPANE);
}
public void initTitleIcon() {
try {
@ -673,94 +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);
}
}
//添加检测按钮
addCheckButton();
}
//添加分享按钮
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 addCheckButton() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
combineUp.addSeparator(new Dimension(2, 16));
UIButton[] checkButtons = jt.createCheckButton();
for (UIButton checkButton : checkButtons) {
combineUp.add(checkButton);
}
}
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);
}
}
/**
* 检查
*
@ -768,17 +531,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param al 组件名称
*/
public 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);
}
CenterRegionContainerPane.getInstance().checkCombineUp(flag, al);
}
/**
* 刷新工具条.
*/
@ -787,6 +543,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.ad.updateToolBarDef();
}
ToolBarMenuDock getToolBarMenuDock() {
return this.ad;
}
/**
* 重置相关的工具条.
*
@ -798,39 +558,18 @@ 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));
NorthRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad);
if (toolbarComponent != null) {
toolbarPane.remove(toolbarComponent);
}
// 颜色,字体那些按钮的工具栏
toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER);
CenterRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad);
this.checkToolbarMenuEnable();
this.validate();
layeredPane.repaint();
}
public void refreshUIToolBar() {
if (toolbarComponent instanceof UIToolbar) {
((UIToolbar ) toolbarComponent).refreshUIToolBar();
}
combineUp.refreshUIToolBar();
this.ad.updateEnable();
}
public JComponent getToolbarComponent() {
return this.toolbarComponent;
return CenterRegionContainerPane.getInstance().getToolbarComponent();
}
/**
@ -838,7 +577,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/
public void needToAddAuhtorityPaint() {
newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing());
CenterRegionContainerPane.getInstance().needToAddAuhtorityPaint();
// 进入或退出权限编辑模式,通知插件
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
@ -867,9 +606,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
JTemplate<?, ?> editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
StringBuilder defaultTitleSB = new StringBuilder();
defaultTitleSB.append(ProductConstants.APP_NAME);
defaultTitleSB.append(" ");
defaultTitleSB.append(GeneralUtils.getVersion());
defaultTitleSB.append(ProductConstants.PRODUCT_NAME);
defaultTitleSB.append(" ");
defaultTitleSB.append(ProductConstants.BRANCH);
defaultTitleSB.append(" ");
@ -956,7 +693,43 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/
public JTemplate<?, ?> getSelectedJTemplate() {
return this.centerTemplateCardPane.getSelectedJTemplate();
return getCenterTemplateCardPane().getSelectedJTemplate();
}
/**
* 保存当前编辑的模板
*/
public void saveCurrentEditingTemplate() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (editingTemplate == null) {
return;
}
if (editingTemplate.isSaved()) {// isSaved == true表示已经保存过,或者新建的一张模板
if (editingTemplate.getEditingFILE().exists()) {// 表示磁盘上的某一张已经保存过的模板,要添加到历史中
// HistoryTemplateListPane.getInstance().addHistory();
}
} else {
editingTemplate.stopEditing();
if (!editingTemplate.getEditingFILE().exists()) {
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE()
+ "\" ?", Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName()));
}
} else {
if (editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName()));
}
}
}
}
/**
@ -985,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();
}
@ -1006,11 +783,57 @@ 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);
}
layeredPane.repaint();
layeredPane.revalidate();
}
/**
* 对象侦听
*
@ -1082,16 +905,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
JOptionPane.WARNING_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
if (this.getSelectedJTemplate() == null) {
addAndActivateJTemplate();
}
} catch (ChartNotFoundException e) {
FineJOptionPane.showMessageDialog(this,
Toolkit.i18nText("Fine-Design_Chart_Not_Found_Exception"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
if (this.getSelectedJTemplate() == null) {
addAndActivateJTemplate();
}
@ -1314,4 +1127,4 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
return designerOpened;
}
}
}
Loading…
Cancel
Save