Browse Source

REPORT-9221

10.0插件兼容-版本管理
research/10.0
hzzz 6 years ago
parent
commit
ba7b696fe2
  1. 292
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

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

@ -4,15 +4,18 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode;
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;
import com.fr.design.actions.file.SwitchExistEnv;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
@ -22,9 +25,9 @@ import com.fr.design.file.NewTemplatePane;
import com.fr.design.file.SaveSomeTemplatePane;
import com.fr.design.file.TemplateTreePane;
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.layout.FRGUIPaneFactory;
@ -32,6 +35,7 @@ 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.menu.ShortCut;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FILE;
@ -39,9 +43,10 @@ import com.fr.file.FILEFactory;
import com.fr.file.FileFILE;
import com.fr.file.FileNodeFILE;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.general.Inter;
import com.fr.general.env.EnvContext;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
@ -51,30 +56,12 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.image4j.codec.ico.ICODecoder;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceConnection;
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.WindowConstants;
import javax.swing.*;
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.Toolkit;
import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
@ -97,54 +84,41 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener {
public static final String DESIGNER_FRAME_NAME = "designer_frame";
public static final Dimension MIN_SIZE = new Dimension(100, 100);
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 = new Integer(100);
private static final Integer TOP_LAYER = new Integer((200));
private static java.util.List<App<?>> appList = new java.util.ArrayList<App<?>>();
private List<DesignerOpenedListener> designerOpenedListenerList = new ArrayList<>();
private ToolBarMenuDock ad;
//顶部日志+登陆按钮
private static final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
private static 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 = null;
private Icon closeMode = UIConstants.CLOSE_OF_AUTHORITY;
private JLayeredPane layeredPane = this.getLayeredPane();
private JPanel basePane = new JPanel();
// 上面的虚线
private DottedLine upDottedLine;
// 下面的虚线
private DottedLine downDottedLine;
@ -155,18 +129,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private DottedLine rightDottedLine;
private int contentWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth());
private int contentHeight = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight());
private WindowAdapter windowAdapter = new WindowAdapter() {
public void windowOpened(WindowEvent e) {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize();
}
@Override
public void windowClosing(WindowEvent e) {
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
// 只有一个文件未保存时
if (HistoryTemplateListPane.getInstance().getHistoryCount() == 1) {
@ -184,9 +158,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
};
private JComponent closeButton = new JComponent() {
protected void paintComponent(Graphics g) {
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillArc(0, 0, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH,
0, 360);
@ -195,32 +167,27 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
};
private MouseListener closeMouseListener = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
closeMode = UIConstants.CLOSE_PRESS_AUTHORITY;
closeButton.setBackground(UIConstants.NORMAL_BACKGROUND);
closeButton.repaint();
}
public void mouseExited(MouseEvent e) {
closeMode = UIConstants.CLOSE_OF_AUTHORITY;
closeButton.setBackground(UIConstants.NORMAL_BACKGROUND);
closeButton.repaint();
}
public void mouseMoved(MouseEvent e) {
closeMode = UIConstants.CLOSE_OVER_AUTHORITY;
closeButton.setBackground(UIConstants.NORMAL_BACKGROUND);
closeButton.repaint();
}
public void mouseReleased(MouseEvent e) {
if (BaseUtils.isAuthorityEditing()) {
BaseUtils.setAuthorityEditing(false);
if (DesignerMode.isAuthorityEditing()) {
DesignerMode.setMode(DesignerMode.NORMARL);
WestRegionContainerPane.getInstance().replaceDownPane(
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane();
@ -233,15 +200,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
public void mouseEntered(MouseEvent e) {
closeMode = UIConstants.CLOSE_OVER_AUTHORITY;
closeButton.setBackground(UIConstants.NORMAL_BACKGROUND);
closeButton.repaint();
}
};
private ProgressDialog progressDialog;
public DesignerFrame(ToolBarMenuDock ad) {
setName(DESIGNER_FRAME_NAME);
@ -254,9 +218,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// the content pane
basePane.setLayout(new BorderLayout());
toolbarPane = new JPanel() {
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
// dim.height = TOOLBAR_HEIGHT;
return dim;
@ -299,32 +261,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.addWindowListeners(getFrameListeners());
this.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
reCalculateFrameSize();
if (BaseUtils.isAuthorityEditing()) {
if (DesignerMode.isAuthorityEditing()) {
doResize();
}
}
});
this.addDesignerOpenedListener(new DesignerOpenedListener() {
@Override
public void designerOpened() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize();
}
});
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setVisible(false);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.setDropTarget(new DropTarget(this, DnDConstants.ACTION_MOVE, new FileDropTargetListener(), true));
closeMode = UIConstants.CLOSE_OF_AUTHORITY;
initMenuPane();
this.progressDialog = new ProgressDialog(this);
}
/**
@ -333,7 +282,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param app 注册app.
*/
public static void registApp(App<?> app) {
if (app != null) {
appList.add(app);
}
@ -350,7 +298,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 注册"设计器初始化完成"的监听
*/
public void addDesignerOpenedListener(DesignerOpenedListener listener) {
designerOpenedListenerList.add(listener);
}
@ -358,14 +305,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 触发"设计器初始化完成"事件
*/
public void fireDesignerOpened() {
for (DesignerOpenedListener listener : designerOpenedListenerList) {
listener.designerOpened();
}
}
protected DesktopCardPane getCenterTemplateCardPane() {
return centerTemplateCardPane;
}
@ -373,45 +318,41 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 初始menuPane的方法 方便OEM时修改该组件
*/
protected void initMenuPane() {
menuPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
menuPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
menuPane.add(initNorthEastPane(ad), BorderLayout.EAST);
menuPane.add(initNorthEastPane(), BorderLayout.EAST);
basePane.add(menuPane, BorderLayout.NORTH);
this.resetToolkitByPlus(null);
}
/**
* @param ad
* @return
*/
protected JPanel initNorthEastPane(final ToolBarMenuDock ad) {
protected JPanel initNorthEastPane() {
//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);
DesignUtils.refreshDesignerFrame();
refreshNorthEastPane();
DesignUtils.refreshDesignerFrame(FRContext.getCurrentEnv());
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign);
return !SwitchExistEnv.isSwitching()
&& context.contain(PluginModule.ExtraDesign);
}
});
refreshNorthEastPane(northEastPane, ad);
refreshNorthEastPane();
return northEastPane;
}
private void refreshNorthEastPane(JPanel northEastPane, ToolBarMenuDock ad) {
public static void refreshNorthEastPane() {
northEastPane.removeAll();
northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
northEastPane.add(LogMessageBar.getInstance());
@ -427,27 +368,24 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
public void initTitleIcon() {
try {
@SuppressWarnings("unchecked")
List<BufferedImage> image = ICODecoder.read(DesignerFrame.class
.getResourceAsStream("/com/fr/base/images/oem/logo.ico"));
this.setIconImages(image);
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FRContext.getLogger().error(e.getMessage(), e);
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
}
}
private void addWindowListeners(ArrayList<WindowListener> listeners) {
for (WindowListener listener : listeners) {
this.addWindowListener(listener);
}
}
protected ArrayList<WindowListener> getFrameListeners() {
ArrayList<WindowListener> arrayList = new ArrayList<WindowListener>();
arrayList.add(windowAdapter);
return arrayList;
@ -455,13 +393,11 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
protected void laoyoutWestPane() {
basePane.add(WestRegionContainerPane.getInstance(), BorderLayout.WEST);
}
// 调整windows大小
private void reCalculateFrameSize() {
contentHeight = layeredPane.getHeight();
contentWidth = layeredPane.getWidth();
layeredPane.remove(basePane);
@ -474,7 +410,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 更新
*/
public void populateAuthorityArea() {
int centerWidth = contentWidth - WestRegionContainerPane.getInstance().getContainerWidth()
- EastRegionContainerPane.getInstance().getContainerWidth();
// 上面的虚线
@ -499,7 +434,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
private void addDottedLine() {
layeredPane.add(upDottedLine, SECOND_LAYER);
layeredPane.add(downDottedLine, SECOND_LAYER);
layeredPane.add(leftDottedLine, SECOND_LAYER);
@ -508,7 +442,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
private void removeDottedLine() {
layeredPane.remove(upDottedLine);
layeredPane.remove(downDottedLine);
layeredPane.remove(leftDottedLine);
@ -517,7 +450,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
public JLayeredPane getContentFrame() {
return layeredPane;
}
@ -525,8 +457,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 刷新
*/
public void refreshDottedLine() {
if (BaseUtils.isAuthorityEditing()) {
if (DesignerMode.isAuthorityEditing()) {
populateAuthorityArea();
populateCloseButton();
addDottedLine();
@ -540,7 +471,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 刷新DottedLine
*/
public void doResize() {
removeDottedLine();
populateAuthorityArea();
populateCloseButton();
@ -565,7 +495,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 退出权限编辑时将所有的做过权限编辑的状态作为一个状态赋给报报表主体
*/
private void fireAuthorityStateToNomal() {
java.util.List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList();
for (int i = 0; i < opendedTemplate.size(); i++) {
// 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表
@ -576,12 +505,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
public void setCloseMode(Icon closeMode) {
this.closeMode = closeMode;
}
private UIToolbar combineUpTooBar(JComponent[] toolbar4Form) {
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));
@ -589,7 +516,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
for (int i = 0; i < fixButtons.length; i++) {
combineUp.add(fixButtons[i]);
}
if (!BaseUtils.isAuthorityEditing()) {
if (!DesignerMode.isAuthorityEditing()) {
combineUp.addSeparator(new Dimension(2, 16));
if (toolbar4Form != null) {
for (int i = 0; i < toolbar4Form.length; i++) {
@ -608,7 +535,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
private void addExtraButtons() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
@ -625,7 +551,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
private void addShareButton() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
@ -645,7 +570,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param al 组件名称
*/
public void checkCombineUp(boolean flag, ArrayList<String> al) {
combineUp.checkComponentsByNames(flag, al);
}
@ -654,7 +578,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 刷新工具条.
*/
public void refreshToolbar() {
this.ad.updateToolBarDef();
}
@ -664,7 +587,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param plus 工具条中相关信息
*/
public void resetToolkitByPlus(ToolBarMenuDockPlus plus) {
if (plus == null) {
plus = ToolBarMenuDock.NULLAVOID;
}
@ -697,7 +619,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
public JComponent getToolbarComponent() {
return this.toolbarComponent;
}
@ -706,14 +627,22 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/
public void needToAddAuhtorityPaint() {
newWorkBookPane.setButtonGray(BaseUtils.isAuthorityEditing());
newWorkBookPane.setButtonGray(DesignerMode.isAuthorityEditing());
// 进入或退出权限编辑模式,通知插件
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) {
if (shortCut instanceof AbstractTemplateTreeShortCutProvider) {
((AbstractTemplateTreeShortCutProvider) shortCut).notifyFromAuhtorityChange(DesignerMode.isAuthorityEditing());
}
}
}
/**
* 检查工具条.
*/
private void checkToolbarMenuEnable() {
if (this.ad != null) {
this.ad.updateMenuDef();
this.ad.updateToolBarDef();
@ -724,34 +653,29 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 设置标题
*/
public void setTitle() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
StringBuilder defaultTitleSB = new StringBuilder();
defaultTitleSB.append(ProductConstants.PRODUCT_NAME);
defaultTitleSB.append(" ");
defaultTitleSB.append(ProductConstants.BRANCH);
defaultTitleSB.append(" ");
// james:标识登录的用户和登录的ENV
String envName = DesignerEnvManager.getEnvManager().getCurEnvName();
Workspace workspace = WorkContext.getCurrent();
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
String username = null;
if (info != null) {
WorkspaceConnection connection = info.getConnection();
username = connection == null ? StringUtils.EMPTY : connection.getUserName();
}
defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]");
Env env = DesignerEnvManager.getEnvManager().getEnv(envName);
if (env != null) {
defaultTitleSB.append(env.getUser()).append('@').append(envName).append('[');
defaultTitleSB.append(env.getEnvDescription());
defaultTitleSB.append(']');
if (editingTemplate != null) {
String path = editingTemplate.getEditingFILE().getPath();
if (!editingTemplate.getEditingFILE().exists()) {
path = FILEFactory.MEM_PREFIX + path;
} else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) {
path = workspace.getPath() + File.separator + path;
path = env.getPath() + File.separator + path;
}
defaultTitleSB.append(" " + path);
}
}
setTitle(defaultTitleSB.toString());
}
@ -788,22 +712,26 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/**
* 报表运行环境改变时,需要刷新某些面板
*
* @param env 环境
*/
public void refreshEnv() {
public void refreshEnv(Env env) {
this.setTitle();
DesignerFrameFileDealerPane.getInstance().refreshDockingView();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
TemplateTreePane.getInstance().refreshDockingView();
DesignTableDataManager.clearGlobalDs();
EastRegionContainerPane.getInstance().refreshDownPane();
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
}
/**
* 返回选中的模板.
*/
public JTemplate<?, ?> getSelectedJTemplate() {
return this.centerTemplateCardPane.getSelectedJTemplate();
}
@ -812,7 +740,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/
public void saveCurrentEditingTemplate() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (editingTemplate == null) {
return;
@ -825,19 +752,23 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
editingTemplate.stopEditing();
if (!editingTemplate.getEditingFILE().exists()) {
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
com.fr.design.i18n.Toolkit.i18nText("Utils-Would_you_like_to_save") + " \"" + editingTemplate.getEditingFILE()
Inter.getLocText("Utils-Would_you_like_to_save") + " \"" + editingTemplate.getEditingFILE()
+ "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Already_Saved",
editingTemplate.getEditingFILE().getName()));
FRLogger.getLogger().log(
Level.INFO,
Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{
editingTemplate.getEditingFILE().getName(), "."}));
}
} else {
if (editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Already_Saved",
editingTemplate.getEditingFILE().getName()));
FRLogger.getLogger().log(
Level.INFO,
Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{
editingTemplate.getEditingFILE().getName(), "."}));
}
}
}
@ -847,7 +778,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* 添加新建模板, 并激活.
*/
public void addAndActivateJTemplate() {
addAndActivateJTemplate(ad.createNewTemplate());
layeredPane.repaint();
}
@ -892,7 +822,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param e 事件
*/
public void targetModified(TargetModifiedEvent e) {
this.checkToolbarMenuEnable();
}
@ -902,7 +831,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param jt 模板
*/
public void templateClosed(JTemplate<?, ?> jt) {
}
/**
@ -911,7 +839,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param jt 模板
*/
public void templateOpened(JTemplate<?, ?> jt) {
}
/**
@ -920,7 +847,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @param jt 模板
*/
public void templateSaved(JTemplate<?, ?> jt) {
this.checkToolbarMenuEnable();
}
@ -931,22 +857,22 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/
public void openTemplate(FILE tplFile) {
// 测试连接,如果连接失败,则提示
// try {
// if (FRContext.getCommonOperator() != null
// && !FRContext.getCommonOperator().testServerConnectionWithOutShowMessagePane()) {
// JOptionPane.showMessageDialog(
// DesignerContext.getDesignerFrame(),
// com.fr.design.i18n.Toolkit.i18nText(new String[]{"FR-Chart-Server_disconnected", "FR-Server-Design_template_unopened"}, new String[]{
// ",", "!"}), com.fr.design.i18n.Toolkit.i18nText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE);
// return;
// }
// } catch (Exception e) {
// FineLoggerFactory.getLogger().error(e.getMessage());
// }
try {
if (FRContext.getCurrentEnv() != null
&& !FRContext.getCurrentEnv().testServerConnectionWithOutShowMessagePane()) {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"FR-Chart-Server_disconnected", "FR-Server-Design_template_unopened"}, new String[]{
",", "!"}), Inter.getLocText("FR-Server-All_Error"), JOptionPane.ERROR_MESSAGE);
return;
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
// p:判断一下,如何文件为空或者文件不存在,直接返回.
if (tplFile == null || !tplFile.exists()) {
JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Warning-Template_Do_Not_Exsit"),
JOptionPane.showMessageDialog(this, Inter.getLocText("Warning-Template_Do_Not_Exsit"),
ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE);
DesignerFrameFileDealerPane.getInstance().refresh();
return;
@ -955,7 +881,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
try {
openFile(tplFile);
} catch (Throwable t) {
FineLoggerFactory.getLogger().error(t.getMessage(), t);
FRLogger.getLogger().error(t.getMessage(), t);
addAndActivateJTemplate();
}
@ -969,7 +895,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @date 2014-10-14-下午6:30:37
*/
private boolean inValidDesigner(JTemplate jt) {
return jt.isOldDesigner() || (!jt.isJWorkBook() && jt.isNewDesigner());
}
@ -980,7 +905,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* @date 2014-10-14-下午6:31:05
*/
private void openFile(FILE tplFile) {
String fileName = tplFile.getName();
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT);
if (indexOfLastDot < 0) {
@ -989,13 +913,16 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
String fileExtention = fileName.substring(indexOfLastDot + 1);
for (int i = 0, len = appList.size(); i < len; i++) {
App<?> app = appList.get(i);
String[] defaultAppExtentions = app.defaultExtensions();
String[] defaultAppExtentions = app.defaultExtentions();
boolean opened = false;
for (int j = 0; j < defaultAppExtentions.length; j++) {
if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) {
// 不要catch
JTemplate jt = app.openTemplate(tplFile);
JTemplate jt = null;
try {
jt = app.openTemplate(tplFile);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
if (jt == null) {
return;
}
@ -1026,7 +953,16 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/
private void activeTemplate(FILE tplFile, JTemplate jt) {
// 如果该模板已经打开,则进行激活就可以了
int index = HistoryTemplateListPane.getInstance().contains(tplFile.getPath());
String fullName = StableUtils.pathJoin(new String[]{ProjectConstants.REPORTLETS_NAME, tplFile.getName()});
if (tplFile instanceof FileNodeFILE) {
fullName = ((FileNodeFILE) tplFile).getEnvPath() + "/" + tplFile.getPath();
}
// 如果是从文件夹打开的文件,不是从设计器文件树打开的文件,则直接取path就行
if (tplFile instanceof FileFILE) {
fullName = tplFile.getPath();
}
fullName = OperatingSystem.isWindows() ? fullName.replaceAll("/", "\\\\") : fullName.replaceAll("\\\\", "/");
int index = HistoryTemplateListPane.getInstance().contains(fullName);
List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList();
if (index != -1) {
historyList.get(index).activeJTemplate(index, jt);
@ -1039,12 +975,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* Exit退出
*/
public void exit() {
Thread thread = new Thread() {
@Override
public void run() {
DesignerEnvManager.doEndMapSaveWorkersIndesign();
}
};
@ -1053,7 +986,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
try {
thread.join();
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error("Map Thread Error");
FRLogger.getLogger().error("Map Thread Error");
}
DesignerEnvManager.getEnvManager().setLastOpenFile(
@ -1070,8 +1003,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
DesignerEnvManager.getEnvManager().saveXMLFile();
WorkContext.switchTo(null);
Env currentEnv = FRContext.getCurrentEnv();
try {
EnvContext.fireBeforeSignOut();
currentEnv.signOut();
EnvContext.fireAfterSignOut();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
this.setVisible(false);
this.dispose();
@ -1085,22 +1024,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
@Override
public void dragEnter(DropTargetDragEvent event) {
}
@Override
public void dragExit(DropTargetEvent event) {
}
@Override
public void dragOver(DropTargetDragEvent event) {
}
@Override
public void dropActionChanged(DropTargetDragEvent event) {
if (!isDragAcceptable(event)) {
event.rejectDrag();
return;
@ -1110,7 +1045,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
@SuppressWarnings("unchecked")
@Override
public void drop(DropTargetDropEvent event) {
if (!isDropAcceptable(event)) {
event.rejectDrop();
return;
@ -1131,25 +1065,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FRContext.getLogger().error(e.getMessage(), e);
}
}
event.dropComplete(true);
}
public boolean isDragAcceptable(DropTargetDragEvent event) {
return (event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0;
}
public boolean isDropAcceptable(DropTargetDropEvent event) {
return (event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0;
}
}
public ProgressDialog getProgressDialog() {
return progressDialog;
}
}
Loading…
Cancel
Save