From 16b158d12797ac54427b7e19e62b00d085cfdb49 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Tue, 21 Nov 2017 15:39:21 +0800 Subject: [PATCH 001/156] =?UTF-8?q?REPORT-5033=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=89=93=E5=BC=80=E6=A8=A1=E6=9D=BF=E5=86=85=E5=AD=98?= =?UTF-8?q?=E4=BC=98=E5=8C=96.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JWorkBook.java | 5 + .../fr/design/designer/TargetComponent.java | 2 + .../design/file/HistoryTemplateListPane.java | 43 +++ .../fr/design/file/MutilTempalteTabPane.java | 22 +- .../fr/design/mainframe/DesignerFrame.java | 8 +- .../com/fr/design/mainframe/JTemplate.java | 9 + .../fr/design/mainframe/JVirtualTemplate.java | 253 ++++++++++++++++++ .../src/com/fr/design/mainframe/JForm.java | 5 + 8 files changed, 341 insertions(+), 6 deletions(-) create mode 100644 designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 2b23dabb7f..f367712773 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -849,6 +849,11 @@ public class JWorkBook extends JTemplate { return true; } + @Override + public boolean isJVirtualTemplate() { + return false; + } + @Override public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { return ReportHyperlinkGroupPane.getInstance(hyperlinkGroupPaneActionProvider); diff --git a/designer_base/src/com/fr/design/designer/TargetComponent.java b/designer_base/src/com/fr/design/designer/TargetComponent.java index 4eedfa0129..1e5cf9cf45 100644 --- a/designer_base/src/com/fr/design/designer/TargetComponent.java +++ b/designer_base/src/com/fr/design/designer/TargetComponent.java @@ -22,6 +22,8 @@ public abstract class TargetComponent extends JComponent { this.target = t; } + public TargetComponent() {} + // TODO ALEX_SEP JWorkBook不想有copy, paste, cut的操作,怎么办? public abstract void copy(); diff --git a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java index c61a39c431..de16dd2d9d 100644 --- a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -25,6 +25,7 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilist.UIList; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.module.DesignModuleFactory; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; @@ -36,6 +37,8 @@ import com.fr.stable.project.ProjectConstants; import com.fr.design.utils.gui.GUIPaintUtils; public class HistoryTemplateListPane extends JPanel implements FileOperations { + //最大保存内存中面板数,为0时关闭优化内存 + private static final int DEAD_LINE = 5; private static final int LIST_BORDER = 4; private List> historyList; private JTemplate editingTemplate; @@ -124,6 +127,26 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { } + /** + * 临时关闭选择的文件 + * @param selected 选择的 + */ + public void closeVirtualSelectedReport(JTemplate selected) { + DesignModuleFactory.clearChartPropertyPane(); + DesignTableDataManager.closeTemplate(selected); + GeneralContext.removeEnvWillChangedListener(selected.getFullPathName()); + if (contains(selected) == -1) { + return; + } + selected.fireJTemplateClosed(); + selected.stopEditing(); + try { + selected.getEditingFILE().closeTemplate(); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } + } + public JTemplate getCurrentEditingTemplate() { return this.editingTemplate; } @@ -281,10 +304,30 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { public void add(JTemplate jt) { historyList.add(jt); + closeOverLineTemplate(); refresh(); } } + /** + * 打开new模板的同时关闭old模板,优先关已保存的、先打开的 + */ + public void closeOverLineTemplate() { + int size = historyList.size(); + int vCount = size - DEAD_LINE; + if (DEAD_LINE == 0 || vCount <= 0) { + return; + } + for (int i = 0; i < vCount; i++) { + JTemplate overTemplate = historyList.get(i); + if (!overTemplate.isJVirtualTemplate() && overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) { + closeVirtualSelectedReport(overTemplate); + historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE())); + } + } + MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); + } + /** * 刷新 */ diff --git a/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java b/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java index 4fc8b0640a..2e6840728f 100644 --- a/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java @@ -219,12 +219,14 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M templates[i].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectedIndex = index; - DesignerContext.getDesignerFrame().addAndActivateJTemplate(tem); + if (!tem.isJVirtualTemplate()) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(tem); + } else { + DesignerContext.getDesignerFrame().openTemplate(tem.getEditingFILE()); + } } }); } - - return templates; } @@ -672,7 +674,12 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M this.repaint(); return; } - DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(getTemplateIndex(evtX))); + JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX)); + if (!evtXTemplate.isJVirtualTemplate()) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(getTemplateIndex(evtX))); + } else { + DesignerContext.getDesignerFrame().openTemplate(evtXTemplate.getEditingFILE()); + } } isShowList = false; } @@ -779,7 +786,12 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M //如果关闭的模板不是当前选中的模板,则激活的模板不变 selectedIndex = HistoryTemplateListPane.getInstance().contains(fileName); } - DesignerContext.getDesignerFrame().activateJTemplate(openedTemplate.get(selectedIndex)); + //如果是已后台关闭的模板,则重新打开文件 + if (!openedTemplate.get(selectedIndex).isJVirtualTemplate()) { + DesignerContext.getDesignerFrame().activateJTemplate(openedTemplate.get(selectedIndex)); + } else { + DesignerContext.getDesignerFrame().openTemplate(openedTemplate.get(selectedIndex).getEditingFILE()); + } } } diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java index f28c43de77..d51fdafc19 100644 --- a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java @@ -933,8 +933,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } fullName = fullName.replaceAll("/", "\\\\"); int index = HistoryTemplateListPane.getInstance().contains(fullName); + List> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); if (index != -1) { - this.activateJTemplate(HistoryTemplateListPane.getInstance().getHistoryList().get(index)); + if (!historyList.get(index).isJVirtualTemplate()) { + this.activateJTemplate(historyList.get(index)); + } else { + historyList.set(index, jt); + this.addAndActivateJTemplate(historyList.get(index)); + } } else { this.addAndActivateJTemplate(jt); } diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index aa42804dbb..f5269efaad 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -83,6 +83,8 @@ public abstract class JTemplate> ex private StringBuilder process = new StringBuilder(""); // 制作模板的过程 public int resolution = ScreenResolution.getScreenResolution(); + public JTemplate() {} + public JTemplate(T t, String defaultFileName) { this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true); openTime = System.currentTimeMillis(); @@ -884,6 +886,13 @@ public abstract class JTemplate> ex */ public abstract boolean isJWorkBook(); + /** + * 是否是虚拟工作薄,用于释放该template内存 + * + * @return 是则返回true + */ + public abstract boolean isJVirtualTemplate(); + /** * 返回当前支持的超链界面pane * @return 超链连接界面 diff --git a/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java b/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java new file mode 100644 index 0000000000..9f047d532d --- /dev/null +++ b/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java @@ -0,0 +1,253 @@ +package com.fr.design.mainframe; + +import com.fr.base.BaseUtils; +import com.fr.design.DesignModelAdapter; +import com.fr.design.designer.TargetComponent; +import com.fr.design.gui.frpane.HyperlinkGroupPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; +import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.mainframe.templateinfo.TemplateProcessInfo; +import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; +import com.fr.design.menu.ShortCut; +import com.fr.design.menu.ToolBarDef; +import com.fr.file.FILE; +import com.fr.file.FileNodeFILE; +import com.fr.stable.project.ProjectConstants; + +import javax.swing.*; +import java.io.File; + +/** + * Author : MoMeak + * Date: 17-11-20 + * 极简模式模板----for减少堆内存引用 + * 其他参数都去掉,只保留触发重新激活的文件路径 + */ +public class JVirtualTemplate extends JTemplate { + + private FILE editingFILE = null; + + public JVirtualTemplate(FILE editingFILE) { + setEditingFILE(editingFILE); + } + + public String getFullPathName() { + String editingFileName = getEditingFILE().getPath(); + if (editingFileName.startsWith(ProjectConstants.REPORTLETS_NAME)) { + editingFileName = ((FileNodeFILE) getEditingFILE()).getEnvPath() + File.separator + editingFileName; + } + return editingFileName.replaceAll("/", "\\\\"); + } + + /** + * 得到正在编辑的FILE + * + * @return + */ + public FILE getEditingFILE() { + return this.editingFILE; + } + + /** + * 正在编辑的FILE + * + * @return + */ + public void setEditingFILE(FILE editingFILE) { + this.editingFILE = editingFILE; + } + + @Override + public void refreshEastPropertiesPane() { + + } + + @Override + public TargetComponent getCurrentElementCasePane() { + return null; + } + + @Override + public JComponent getCurrentReportComponentPane() { + return null; + } + + @Override + public TemplateProcessInfo getProcessInfo() { + return null; + } + + @Override + public void setJTemplateResolution(int resolution) { + + } + + @Override + public int getJTemplateResolution() { + return 0; + } + + @Override + protected JComponent createCenterPane() { + return null; + } + + @Override + public void removeTemplateSelection() { + + } + + @Override + public void refreshContainer() { + + } + + @Override + public void removeParameterPaneSelection() { + + } + + @Override + public void setScale(int resolution) { + + } + + @Override + public int getScale() { + return 0; + } + + @Override + public int selfAdaptUpdate() { + return 0; + } + + @Override + protected DesignModelAdapter createDesignModel() { + return null; + } + + @Override + public UIMenuItem[] createMenuItem4Preview() { + return new UIMenuItem[0]; + } + + @Override + protected BaseUndoState createUndoState() { + return null; + } + + @Override + public String suffix() { + return null; + } + + @Override + public void copy() { + + } + + @Override + public boolean paste() { + return false; + } + + @Override + public boolean cut() { + return false; + } + + @Override + public AuthorityEditPane createAuthorityEditPane() { + return null; + } + + @Override + public ToolBarMenuDockPlus getToolBarMenuDockPlus() { + return null; + } + + @Override + public JPanel getEastUpPane() { + return null; + } + + @Override + public JPanel getEastDownPane() { + return null; + } + + @Override + public ToolBarDef[] toolbars4Target() { + return new ToolBarDef[0]; + } + + @Override + public JPanel[] toolbarPanes4Form() { + return new JPanel[0]; + } + + @Override + public ShortCut[] shortcut4TemplateMenu() { + return new ShortCut[0]; + } + + @Override + public ShortCut[] shortCuts4Authority() { + return new ShortCut[0]; + } + + @Override + public JComponent[] toolBarButton4Form() { + return new JComponent[0]; + } + + @Override + public JComponent toolBar4Authority() { + return null; + } + + @Override + public int getToolBarHeight() { + return 0; + } + + @Override + public boolean isJWorkBook() { + return false; + } + + @Override + public boolean isJVirtualTemplate() { + return true; + } + + @Override + public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return null; + } + + @Override + public HyperlinkGroupPane getHyperLinkPaneNoPop(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return null; + } + + @Override + public void setAuthorityMode(boolean isUpMode) { + + } + + @Override + public Icon getIcon() { + if (getFullPathName().endsWith("cpt")) { + return BaseUtils.readIcon("/com/fr/design/images/buttonicon/newcpts.png"); + } else { + return BaseUtils.readIcon("/com/fr/web/images/form/new_form3.png"); + } + } + + @Override + protected void applyUndoState(BaseUndoState baseUndoState) { + + } +} diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index c84f572fd3..b2656cb645 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -142,6 +142,11 @@ public class JForm extends JTemplate implements BaseJForm { return false; } + @Override + public boolean isJVirtualTemplate() { + return false; + } + /** * 返回当前支持的超链界面pane * From 5594cd8a116478cb05c88c99913ba67139aacc87 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Wed, 22 Nov 2017 09:58:09 +0800 Subject: [PATCH 002/156] PMD --- .../com/fr/design/mainframe/JWorkBook.java | 21 ++++++++++++++-- .../design/file/HistoryTemplateListPane.java | 13 +++++++--- .../fr/design/file/MutilTempalteTabPane.java | 19 ++++----------- .../fr/design/mainframe/DesignerFrame.java | 7 +----- .../com/fr/design/mainframe/JTemplate.java | 24 ++++++++++++++++--- .../fr/design/mainframe/JVirtualTemplate.java | 24 +++++++++++++++++-- .../src/com/fr/design/mainframe/JForm.java | 22 +++++++++++++++-- 7 files changed, 97 insertions(+), 33 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index f367712773..889c2163f7 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -850,8 +850,25 @@ public class JWorkBook extends JTemplate { } @Override - public boolean isJVirtualTemplate() { - return false; + public void activeJTemplate(int index, JTemplate jt) { + DesignerContext.getDesignerFrame().activateJTemplate(this); + } + + @Override + public void activeOldJTemplate() { + DesignerContext.getDesignerFrame().activateJTemplate(this); + } + + @Override + public void activeNewJTemplate() { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); + } + + @Override + public void closeOverLineTemplate(int index) { + JTemplate overTemplate = HistoryTemplateListPane.getInstance().getHistoryList().get(index); + HistoryTemplateListPane.getInstance().closeVirtualSelectedReport(overTemplate); + HistoryTemplateListPane.getInstance().getHistoryList().set(index, new JVirtualTemplate(overTemplate.getEditingFILE())); } @Override diff --git a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java index de16dd2d9d..a22c335414 100644 --- a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -147,6 +147,13 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { } } + /** + * 关闭选择的文件 + */ + public void selectedReportToVirtual(int i) { + closeOverLineTemplate(); + } + public JTemplate getCurrentEditingTemplate() { return this.editingTemplate; } @@ -320,9 +327,9 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { } for (int i = 0; i < vCount; i++) { JTemplate overTemplate = historyList.get(i); - if (!overTemplate.isJVirtualTemplate() && overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) { - closeVirtualSelectedReport(overTemplate); - historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE())); + + if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) { + historyList.get(i).closeOverLineTemplate(i); } } MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); diff --git a/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java b/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java index 2e6840728f..009a0b6ace 100644 --- a/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java @@ -8,6 +8,7 @@ import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.file.FILE; @@ -219,11 +220,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M templates[i].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectedIndex = index; - if (!tem.isJVirtualTemplate()) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(tem); - } else { - DesignerContext.getDesignerFrame().openTemplate(tem.getEditingFILE()); - } + tem.activeNewJTemplate(); } }); } @@ -675,11 +672,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M return; } JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX)); - if (!evtXTemplate.isJVirtualTemplate()) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(getTemplateIndex(evtX))); - } else { - DesignerContext.getDesignerFrame().openTemplate(evtXTemplate.getEditingFILE()); - } + evtXTemplate.activeNewJTemplate(); } isShowList = false; } @@ -787,11 +780,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M selectedIndex = HistoryTemplateListPane.getInstance().contains(fileName); } //如果是已后台关闭的模板,则重新打开文件 - if (!openedTemplate.get(selectedIndex).isJVirtualTemplate()) { - DesignerContext.getDesignerFrame().activateJTemplate(openedTemplate.get(selectedIndex)); - } else { - DesignerContext.getDesignerFrame().openTemplate(openedTemplate.get(selectedIndex).getEditingFILE()); - } + openedTemplate.get(selectedIndex).activeOldJTemplate(); } } diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java index d51fdafc19..224305940b 100644 --- a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java @@ -935,12 +935,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta int index = HistoryTemplateListPane.getInstance().contains(fullName); List> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); if (index != -1) { - if (!historyList.get(index).isJVirtualTemplate()) { - this.activateJTemplate(historyList.get(index)); - } else { - historyList.set(index, jt); - this.addAndActivateJTemplate(historyList.get(index)); - } + historyList.get(index).activeJTemplate(index, jt); } else { this.addAndActivateJTemplate(jt); } diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index f5269efaad..81fffad7c3 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -887,11 +887,29 @@ public abstract class JTemplate> ex public abstract boolean isJWorkBook(); /** - * 是否是虚拟工作薄,用于释放该template内存 + * 激活指定的template + * + */ + public abstract void activeJTemplate(int index, JTemplate jt); + + /** + * 激活已存在的模板 + * + */ + public abstract void activeOldJTemplate(); + + /** + * 激活新的模板 * - * @return 是则返回true */ - public abstract boolean isJVirtualTemplate(); + public abstract void activeNewJTemplate(); + + /** + * 后台关闭template + * + */ + public abstract void closeOverLineTemplate(int index); + /** * 返回当前支持的超链界面pane diff --git a/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java b/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java index 9f047d532d..0637a1a570 100644 --- a/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.design.DesignModelAdapter; import com.fr.design.designer.TargetComponent; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.imenu.UIMenuItem; @@ -11,11 +12,14 @@ import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.file.FILE; +import com.fr.file.FileFILE; import com.fr.file.FileNodeFILE; +import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; import javax.swing.*; import java.io.File; +import java.util.List; /** * Author : MoMeak @@ -218,8 +222,24 @@ public class JVirtualTemplate extends JTemplate { } @Override - public boolean isJVirtualTemplate() { - return true; + public void activeJTemplate(int index, JTemplate jt) { + List> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); + historyList.set(index, jt); + DesignerContext.getDesignerFrame().addAndActivateJTemplate(jt); + } + + @Override + public void activeOldJTemplate() { + DesignerContext.getDesignerFrame().openTemplate(this.getEditingFILE()); + } + + @Override + public void activeNewJTemplate() { + DesignerContext.getDesignerFrame().openTemplate(this.getEditingFILE()); + } + + @Override + public void closeOverLineTemplate(int index) { } @Override diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index b2656cb645..9672936dc1 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -17,6 +17,7 @@ import com.fr.design.designer.creator.*; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.ilable.UILabel; @@ -143,8 +144,25 @@ public class JForm extends JTemplate implements BaseJForm { } @Override - public boolean isJVirtualTemplate() { - return false; + public void activeJTemplate(int index, JTemplate jt) { + DesignerContext.getDesignerFrame().activateJTemplate(this); + } + + @Override + public void activeOldJTemplate() { + DesignerContext.getDesignerFrame().activateJTemplate(this); + } + + @Override + public void activeNewJTemplate() { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); + } + + @Override + public void closeOverLineTemplate(int index) { + JTemplate overTemplate = HistoryTemplateListPane.getInstance().getHistoryList().get(index); + HistoryTemplateListPane.getInstance().closeVirtualSelectedReport(overTemplate); + HistoryTemplateListPane.getInstance().getHistoryList().set(index, new JVirtualTemplate(overTemplate.getEditingFILE())); } /** From 1b4555722e96916c225c09f7e9c660ce5b51ef1b Mon Sep 17 00:00:00 2001 From: MoMeak Date: Wed, 22 Nov 2017 14:25:35 +0800 Subject: [PATCH 003/156] REPORT-5033 PMD --- .../com/fr/design/mainframe/JWorkBook.java | 22 ------------------- .../com/fr/design/mainframe/JTemplate.java | 18 +++++++++++---- .../fr/design/mainframe/JVirtualTemplate.java | 2 -- .../src/com/fr/design/mainframe/JForm.java | 22 ------------------- 4 files changed, 14 insertions(+), 50 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 889c2163f7..2b23dabb7f 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -849,28 +849,6 @@ public class JWorkBook extends JTemplate { return true; } - @Override - public void activeJTemplate(int index, JTemplate jt) { - DesignerContext.getDesignerFrame().activateJTemplate(this); - } - - @Override - public void activeOldJTemplate() { - DesignerContext.getDesignerFrame().activateJTemplate(this); - } - - @Override - public void activeNewJTemplate() { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); - } - - @Override - public void closeOverLineTemplate(int index) { - JTemplate overTemplate = HistoryTemplateListPane.getInstance().getHistoryList().get(index); - HistoryTemplateListPane.getInstance().closeVirtualSelectedReport(overTemplate); - HistoryTemplateListPane.getInstance().getHistoryList().set(index, new JVirtualTemplate(overTemplate.getEditingFILE())); - } - @Override public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { return ReportHyperlinkGroupPane.getInstance(hyperlinkGroupPaneActionProvider); diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index 81fffad7c3..c7ba2348cf 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -890,25 +890,35 @@ public abstract class JTemplate> ex * 激活指定的template * */ - public abstract void activeJTemplate(int index, JTemplate jt); + public void activeJTemplate(int index, JTemplate jt) { + DesignerContext.getDesignerFrame().activateJTemplate(this); + }; /** * 激活已存在的模板 * */ - public abstract void activeOldJTemplate(); + public void activeOldJTemplate() { + DesignerContext.getDesignerFrame().activateJTemplate(this); + }; /** * 激活新的模板 * */ - public abstract void activeNewJTemplate(); + public void activeNewJTemplate() { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); + }; /** * 后台关闭template * */ - public abstract void closeOverLineTemplate(int index); + public void closeOverLineTemplate(int index) { + JTemplate overTemplate = HistoryTemplateListPane.getInstance().getHistoryList().get(index); + HistoryTemplateListPane.getInstance().closeVirtualSelectedReport(overTemplate); + HistoryTemplateListPane.getInstance().getHistoryList().set(index, new JVirtualTemplate(overTemplate.getEditingFILE())); + }; /** diff --git a/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java b/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java index 0637a1a570..897991a916 100644 --- a/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java @@ -71,7 +71,6 @@ public class JVirtualTemplate extends JTemplate { return null; } - @Override public JComponent getCurrentReportComponentPane() { return null; } @@ -247,7 +246,6 @@ public class JVirtualTemplate extends JTemplate { return null; } - @Override public HyperlinkGroupPane getHyperLinkPaneNoPop(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { return null; } diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 9672936dc1..47fbd03339 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -143,28 +143,6 @@ public class JForm extends JTemplate implements BaseJForm { return false; } - @Override - public void activeJTemplate(int index, JTemplate jt) { - DesignerContext.getDesignerFrame().activateJTemplate(this); - } - - @Override - public void activeOldJTemplate() { - DesignerContext.getDesignerFrame().activateJTemplate(this); - } - - @Override - public void activeNewJTemplate() { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); - } - - @Override - public void closeOverLineTemplate(int index) { - JTemplate overTemplate = HistoryTemplateListPane.getInstance().getHistoryList().get(index); - HistoryTemplateListPane.getInstance().closeVirtualSelectedReport(overTemplate); - HistoryTemplateListPane.getInstance().getHistoryList().set(index, new JVirtualTemplate(overTemplate.getEditingFILE())); - } - /** * 返回当前支持的超链界面pane * From b86a13892eef8e548817f96f0db106b172466596 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Wed, 22 Nov 2017 16:15:01 +0800 Subject: [PATCH 004/156] 1 --- .../design/file/HistoryTemplateListPane.java | 93 ++++++++++++++----- 1 file changed, 70 insertions(+), 23 deletions(-) diff --git a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java index 87d5693241..a22c335414 100644 --- a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -1,20 +1,32 @@ package com.fr.design.file; -import com.fr.base.FRContext; -import com.fr.base.chart.chartdata.CallbackEvent; -import com.fr.dav.LocalEnv; -import com.fr.design.DesignModelAdapter; -import com.fr.design.DesignerEnvManager; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.*; +import java.util.List; +import java.util.logging.Level; + +import javax.swing.*; + import com.fr.design.constants.UIConstants; +import com.fr.design.DesignerEnvManager; import com.fr.design.data.DesignTableDataManager; +import com.fr.design.gui.ilable.UILabel; + +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import com.fr.base.FRContext; import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.dav.LocalEnv; +import com.fr.design.DesignModelAdapter; import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.UIList; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.module.DesignModuleFactory; -import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; @@ -22,19 +34,11 @@ import com.fr.general.GeneralContext; import com.fr.general.Inter; import com.fr.stable.Constants; import com.fr.stable.project.ProjectConstants; +import com.fr.design.utils.gui.GUIPaintUtils; -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.logging.Level; - -public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent{ +public class HistoryTemplateListPane extends JPanel implements FileOperations { + //最大保存内存中面板数,为0时关闭优化内存 + private static final int DEAD_LINE = 5; private static final int LIST_BORDER = 4; private List> historyList; private JTemplate editingTemplate; @@ -123,6 +127,33 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C } + /** + * 临时关闭选择的文件 + * @param selected 选择的 + */ + public void closeVirtualSelectedReport(JTemplate selected) { + DesignModuleFactory.clearChartPropertyPane(); + DesignTableDataManager.closeTemplate(selected); + GeneralContext.removeEnvWillChangedListener(selected.getFullPathName()); + if (contains(selected) == -1) { + return; + } + selected.fireJTemplateClosed(); + selected.stopEditing(); + try { + selected.getEditingFILE().closeTemplate(); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } + } + + /** + * 关闭选择的文件 + */ + public void selectedReportToVirtual(int i) { + closeOverLineTemplate(); + } + public JTemplate getCurrentEditingTemplate() { return this.editingTemplate; } @@ -227,10 +258,6 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C return ComparatorUtils.equals(filename, editingFileName); } - @Override - public void callback() { - getCurrentEditingTemplate().repaint(); - } private class HistoryListCellRender extends DefaultListCellRenderer { @@ -284,10 +311,30 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C public void add(JTemplate jt) { historyList.add(jt); + closeOverLineTemplate(); refresh(); } } + /** + * 打开new模板的同时关闭old模板,优先关已保存的、先打开的 + */ + public void closeOverLineTemplate() { + int size = historyList.size(); + int vCount = size - DEAD_LINE; + if (DEAD_LINE == 0 || vCount <= 0) { + return; + } + for (int i = 0; i < vCount; i++) { + JTemplate overTemplate = historyList.get(i); + + if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) { + historyList.get(i).closeOverLineTemplate(i); + } + } + MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); + } + /** * 刷新 */ From 89015f3eda3b1b240260cff1994ab1025bed5577 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Wed, 22 Nov 2017 16:15:27 +0800 Subject: [PATCH 005/156] 1 --- .../src/com/fr/design/file/HistoryTemplateListPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java index a22c335414..c59e1d8c05 100644 --- a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -37,7 +37,7 @@ import com.fr.stable.project.ProjectConstants; import com.fr.design.utils.gui.GUIPaintUtils; public class HistoryTemplateListPane extends JPanel implements FileOperations { - //最大保存内存中面板数,为0时关闭优化内存 + //最大保 存内存中面板数,为0时关闭优化内存 private static final int DEAD_LINE = 5; private static final int LIST_BORDER = 4; private List> historyList; From ae44a7dc72d986c783d0c64df383a7003ef5c516 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Wed, 22 Nov 2017 16:15:35 +0800 Subject: [PATCH 006/156] 1 --- .../src/com/fr/design/file/HistoryTemplateListPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java index c59e1d8c05..a22c335414 100644 --- a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -37,7 +37,7 @@ import com.fr.stable.project.ProjectConstants; import com.fr.design.utils.gui.GUIPaintUtils; public class HistoryTemplateListPane extends JPanel implements FileOperations { - //最大保 存内存中面板数,为0时关闭优化内存 + //最大保存内存中面板数,为0时关闭优化内存 private static final int DEAD_LINE = 5; private static final int LIST_BORDER = 4; private List> historyList; From 041918a62e23e9dfab0be955c03d726333b23422 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Wed, 22 Nov 2017 16:18:14 +0800 Subject: [PATCH 007/156] 1 --- .../fr/design/mainframe/DesignerFrame.java | 1854 +++++++++-------- 1 file changed, 933 insertions(+), 921 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java index b8dc09bab7..224305940b 100644 --- a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java @@ -15,17 +15,14 @@ import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; -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.file.*; import com.fr.design.fun.TitlePlaceProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.UIMenuHighLight; import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.hold.DefaultTitlePlace; import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; @@ -40,7 +37,6 @@ import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.GeneralContext; 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; @@ -58,20 +54,8 @@ import javax.swing.border.MatteBorder; import java.awt.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DropTarget; -import java.awt.dnd.DropTargetDragEvent; -import java.awt.dnd.DropTargetDropEvent; -import java.awt.dnd.DropTargetEvent; -import java.awt.dnd.DropTargetListener; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; +import java.awt.dnd.*; +import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -81,221 +65,115 @@ import java.util.List; 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> appList = new java.util.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 = null; - private Icon closeMode = UIConstants.CLOSE_OF_AUTHORITY; - private JLayeredPane layeredPane = this.getLayeredPane(); - private JPanel basePane = new JPanel(); - // 上面的虚线 - private DottedLine upDottedLine; - // 下面的虚线 - private DottedLine downDottedLine; - - // 左边的虚线 - private DottedLine leftDottedLine; - - // 右边的虚线 - 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) { - int choose = saveSomeTempaltePane.saveLastOneTemplate(); - if (choose != JOptionPane.CANCEL_OPTION) { - DesignerFrame.this.exit(); - } - } else { - if (saveSomeTempaltePane.showSavePane()) { - DesignerFrame.this.exit(); - } - } - } - - }; - - 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); - closeMode.paintIcon(this, g, 0, 0); - } - }; - 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); - WestRegionContainerPane.getInstance().replaceDownPane( - TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); - DesignerContext.getDesignerFrame().resetToolkitByPlus( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus()); - needToAddAuhtorityPaint(); - refreshDottedLine(); - fireAuthorityStateToNomal(); - } - } - - public void mouseEntered(MouseEvent e) { - closeMode = UIConstants.CLOSE_OVER_AUTHORITY; - closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); - closeButton.repaint(); - } - }; - - public DesignerFrame(ToolBarMenuDock ad) { - - setName(DESIGNER_FRAME_NAME); - this.ad = ad; - this.initTitleIcon(); - this.setTitle();// james:因为有默认的了 - // set this to context. - DesignerContext.setDesignerFrame(this); - - // the content pane - basePane.setLayout(new BorderLayout()); - toolbarPane = new JPanel() { - 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(); - eastCenterPane.add(combineUp = combineUpTooBar(null), 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(); - basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST); - basePane.setBounds(0, 0, contentWidth, contentHeight); - - // 数值越小。越在底层 - layeredPane.add(basePane); - // 调整Window大小 - modWindowBounds(); - - - // p:检查所有按钮的可见性和是否可以编辑性. - checkToolbarMenuEnable(); - - // window close listener. - this.addWindowListeners(getFrameListeners()); - - this.addComponentListener(new ComponentAdapter() { - public void componentResized(ComponentEvent e) { - reCalculateFrameSize(); - if (BaseUtils.isAuthorityEditing()) { - 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(); - } - - /** - * 注册app. - * - * @param app 注册app. - */ - public static void registApp(App app) { - if (app != null) { - appList.add(app); - } - } - + 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)); + + public static final String DESIGNER_FRAME_NAME = "designer_frame"; + public static final Dimension MIN_SIZE = new Dimension(100, 100); + + private static java.util.List> appList = new java.util.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 = null; + private Icon closeMode = UIConstants.CLOSE_OF_AUTHORITY; + private JLayeredPane layeredPane = this.getLayeredPane(); + private JPanel basePane = new JPanel(); + // 上面的虚线 + private DottedLine upDottedLine; + // 下面的虚线 + private DottedLine downDottedLine; + + // 左边的虚线 + private DottedLine leftDottedLine; + + // 右边的虚线 + 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) { + int choose = saveSomeTempaltePane.saveLastOneTemplate(); + if (choose != JOptionPane.CANCEL_OPTION) { + DesignerFrame.this.exit(); + } + } else { + if (saveSomeTempaltePane.showSavePane()) { + DesignerFrame.this.exit(); + } + } + } + + }; + + 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); + closeMode.paintIcon(this, g, 0, 0); + } + }; + + /** + * 注册app. + * + * @param app + * 注册app. + */ + public static void registApp(App app) { + if (app != null) { + appList.add(app); + } + } + public static void removeApp(App app) { - + if (app != null) { appList.remove(app); } } - protected DesktopCardPane getCenterTemplateCardPane() { - return centerTemplateCardPane; - } - - /** - * 初始menuPane的方法 方便OEM时修改该组件 - */ - 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); - this.resetToolkitByPlus(null); - } - + protected DesktopCardPane getCenterTemplateCardPane() { + return centerTemplateCardPane; + } + + /** + * 初始menuPane的方法 方便OEM时修改该组件 + */ + 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); + this.resetToolkitByPlus(null); + } + /** * @param ad * @return @@ -306,534 +184,658 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); //优先级为-1,保证最后全面刷新一次 GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { - + @Override public void on(PluginEvent event) { - + refreshNorthEastPane(northEastPane, ad); DesignUtils.refreshDesignerFrame(FRContext.getCurrentEnv()); } }, new PluginFilter() { - + @Override public boolean accept(PluginContext context) { - + return context.contain(PluginModule.ExtraDesign); } }); refreshNorthEastPane(northEastPane, ad); - return northEastPane; - } - + return northEastPane; + } + private void refreshNorthEastPane(JPanel northEastPane, 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) { - processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane()); - } - northEastPane.add(ad.createAlphaFinePane()); - if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { - ad.createAlphaFinePane().setVisible(false); - } - northEastPane.add(ad.createBBSLoginPane()); - } - - - public void initTitleIcon() { - try { - @SuppressWarnings("unchecked") - List image = ICODecoder.read(DesignerFrame.class - .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); - this.setIconImages(image); - } catch (IOException e) { - FRContext.getLogger().error(e.getMessage(), e); - this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); - } - } - - private void addWindowListeners(ArrayList listeners) { - for (WindowListener listener : listeners) { - this.addWindowListener(listener); - } - } - - protected ArrayList getFrameListeners() { - ArrayList arrayList = new ArrayList(); - arrayList.add(windowAdapter); - return arrayList; - } - - protected void laoyoutWestPane() { - basePane.add(WestRegionContainerPane.getInstance(), BorderLayout.WEST); - } - - // 调整windows大小 - private void reCalculateFrameSize() { - contentHeight = layeredPane.getHeight(); - contentWidth = layeredPane.getWidth(); - layeredPane.remove(basePane); - basePane.setBounds(0, 0, contentWidth, contentHeight); - layeredPane.add(basePane); - layeredPane.repaint(); - } - - /** - * 更新 - */ - public void populateAuthorityArea() { - int centerWidth = contentWidth - WestRegionContainerPane.getInstance().getContainerWidth() - - EastRegionContainerPane.getInstance().getContainerWidth(); - // 上面的虚线 - upDottedLine = new DottedLine(UIScrollBar.HORIZONTAL, centerWidth); - upDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), MENU_HEIGHT - 1, centerWidth, - 3); - - // 下面的虚线 - downDottedLine = new DottedLine(UIScrollBar.HORIZONTAL, centerWidth); - downDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), contentHeight - 3, - centerWidth, 3); - - // 左边的虚线 - leftDottedLine = new DottedLine(UIScrollBar.VERTICAL, contentHeight - MENU_HEIGHT); - leftDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), MENU_HEIGHT, 3, - contentHeight - MENU_HEIGHT); - - rightDottedLine = new DottedLine(UIScrollBar.VERTICAL, contentHeight - MENU_HEIGHT); - rightDottedLine.setBounds(contentWidth - EastRegionContainerPane.getInstance().getContainerWidth() - 3, - MENU_HEIGHT, 3, contentHeight - MENU_HEIGHT); - - } - - private void addDottedLine() { - layeredPane.add(upDottedLine, SECOND_LAYER); - layeredPane.add(downDottedLine, SECOND_LAYER); - layeredPane.add(leftDottedLine, SECOND_LAYER); - layeredPane.add(rightDottedLine, SECOND_LAYER); - layeredPane.add(closeButton, TOP_LAYER); - } - - private void removeDottedLine() { - layeredPane.remove(upDottedLine); - layeredPane.remove(downDottedLine); - layeredPane.remove(leftDottedLine); - layeredPane.remove(rightDottedLine); - layeredPane.remove(closeButton); - } - - public JLayeredPane getContentFrame() { - return layeredPane; - } - - /** - * 刷新 - */ - public void refreshDottedLine() { - if (BaseUtils.isAuthorityEditing()) { - populateAuthorityArea(); - populateCloseButton(); - addDottedLine(); - } else { - removeDottedLine(); - } - layeredPane.repaint(); - } - - /** - * 刷新DottedLine - */ - public void doResize() { - removeDottedLine(); - populateAuthorityArea(); - populateCloseButton(); - addDottedLine(); - } - - /** - * 刷新CloseButton - */ - public void populateCloseButton() { - - closeButton.addMouseListener(closeMouseListener); - closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); - closeButton.setBorder(null); - int x = contentWidth - EastRegionContainerPane.getInstance().getContainerWidth() - closeMode.getIconWidth() / 2; - int y = MENU_HEIGHT - closeMode.getIconHeight() / 2; - closeButton.setBounds(x, y, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH, - UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH); - } - - /** - * 退出权限编辑时,将所有的做过权限编辑的状态,作为一个状态赋给报、报表主体 - */ - private void fireAuthorityStateToNomal() { - java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); - for (int i = 0; i < opendedTemplate.size(); i++) { - // 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 - if (opendedTemplate.get(i).isDoSomethingInAuthority()) { - opendedTemplate.get(i).fireAuthorityStateToNomal(); - } - } - } - - 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)); - UIButton[] fixButtons = ad.createUp(); - for (int i = 0; i < fixButtons.length; i++) { - combineUp.add(fixButtons[i]); - } - if (!BaseUtils.isAuthorityEditing()) { - combineUp.addSeparator(new Dimension(2, 16)); - if (toolbar4Form != null) { - for (int i = 0; i < toolbar4Form.length; i++) { - combineUp.add(toolbar4Form[i]); - } - } - } - - //添加分享按钮 - addShareButton(); - - //添加插件中的按钮 - addExtraButtons(); - - return combineUp; - } - - private void addExtraButtons() { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - - - UIButton[] extraButtons = jt.createExtraButtons(); - for (int i = 0; i < extraButtons.length; i++) { - combineUp.add(extraButtons[i]); - } - if (extraButtons.length > 0) { - combineUp.addSeparator(new Dimension(2, 16)); - } - } - - private void addShareButton() { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - - combineUp.addSeparator(new Dimension(2, 16)); - UIButton[] shareButtons = jt.createShareButton(); - for (int i = 0; i < shareButtons.length; i++) { - combineUp.add(shareButtons[i]); - } - } - - /** - * 检查 - * - * @param flag 组件是否可见 - * @param al 组件名称 - */ - public void checkCombineUp(boolean flag, ArrayList al) { - combineUp.checkComponentsByNames(flag, al); - - } - - /** - * 刷新工具条. - */ - public void refreshToolbar() { - this.ad.updateToolBarDef(); - } - - /** - * 重置相关的工具条. - * - * @param plus 工具条中相关信息 - */ - public void resetToolkitByPlus(ToolBarMenuDockPlus plus) { - if (plus == null) { - plus = ToolBarMenuDock.NULLAVOID; + if (processor == null) { + processor = new DefaultTitlePlace(); } - - DesignState designState = new DesignState(plus); - MenuManager.getInstance().setMenus4Designer(designState); - if (menuBar != null) { - menuPane.remove(menuBar); - } - menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); - - if (combineUp != null) { - eastCenterPane.remove(combineUp); - combineUp = null; - } - - // 保存撤销那些按钮的面板 - eastCenterPane.add(combineUp = combineUpTooBar(ad.resetUpToolBar(plus)), BorderLayout.NORTH); - - if (toolbarComponent != null) { - toolbarPane.remove(toolbarComponent); - } - - // 颜色,字体那些按钮的工具栏 - toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); - - this.checkToolbarMenuEnable(); - this.validate(); - layeredPane.repaint(); + processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane()); + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { + northEastPane.add(ad.createAlphafinePane(), BorderLayout.CENTER); + } } - - public JComponent getToolbarComponent() { - return this.toolbarComponent; - } - - /** - * 判断是否在权限编辑状态,若是在权限编辑状态,则需要有虚线框和关闭突变 - */ - public void needToAddAuhtorityPaint() { - - newWorkBookPane.setButtonGray(BaseUtils.isAuthorityEditing()); - } - - /** - * 检查工具条. - */ - private void checkToolbarMenuEnable() { - if (this.ad != null) { - this.ad.updateMenuDef(); - this.ad.updateToolBarDef(); - } - } - - /** - * 设置标题 - */ - public void setTitle() { + + public DesignerFrame(ToolBarMenuDock ad) { + + setName(DESIGNER_FRAME_NAME); + this.ad = ad; + this.initTitleIcon(); + this.setTitle();// james:因为有默认的了 + // set this to context. + DesignerContext.setDesignerFrame(this); + + // the content pane + basePane.setLayout(new BorderLayout()); + toolbarPane = new JPanel() { + 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(); + eastCenterPane.add(combineUp = combineUpTooBar(null), 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(); +// JPanel eastRegionPane = new JPanel(new BorderLayout()); +// eastRegionPane.add(EastRegionContainerPane.getInstance(), BorderLayout.CENTER); +// eastRegionPane.add(JSliderPane.getInstance(), BorderLayout.SOUTH); +// basePane.add(eastRegionPane, BorderLayout.EAST); + + basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST); + basePane.setBounds(0, 0, contentWidth, contentHeight); + + // 数值越小。越在底层 + layeredPane.add(basePane); + // 调整Window大小 + modWindowBounds(); + + + + // p:检查所有按钮的可见性和是否可以编辑性. + checkToolbarMenuEnable(); + + // window close listener. + this.addWindowListeners(getFrameListeners()); + + this.addComponentListener(new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + reCalculateFrameSize(); + if (BaseUtils.isAuthorityEditing()) { + 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(); + } + + public void initTitleIcon() { + try { + @SuppressWarnings("unchecked") + List image = ICODecoder.read(DesignerFrame.class + .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); + this.setIconImages(image); + } catch (IOException e) { + FRContext.getLogger().error(e.getMessage(), e); + this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); + } + } + + private void addWindowListeners(ArrayList listeners){ + for(WindowListener listener : listeners){ + this.addWindowListener(listener); + } + } + + protected ArrayList getFrameListeners(){ + ArrayList arrayList = new ArrayList(); + arrayList.add(windowAdapter); + return arrayList; + } + + + protected void laoyoutWestPane(){ + basePane.add(WestRegionContainerPane.getInstance(), BorderLayout.WEST); + } + + // 调整windows大小 + private void reCalculateFrameSize() { + contentHeight = layeredPane.getHeight(); + contentWidth = layeredPane.getWidth(); + layeredPane.remove(basePane); + basePane.setBounds(0, 0, contentWidth, contentHeight); + layeredPane.add(basePane); + layeredPane.repaint(); + } + + /** + * 更新 + */ + public void populateAuthorityArea() { + int centerWidth = contentWidth - WestRegionContainerPane.getInstance().getContainerWidth() + - EastRegionContainerPane.getInstance().getContainerWidth(); + // 上面的虚线 + upDottedLine = new DottedLine(UIScrollBar.HORIZONTAL, centerWidth); + upDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), MENU_HEIGHT - 1, centerWidth, + 3); + + // 下面的虚线 + downDottedLine = new DottedLine(UIScrollBar.HORIZONTAL, centerWidth); + downDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), contentHeight - 3, + centerWidth, 3); + + // 左边的虚线 + leftDottedLine = new DottedLine(UIScrollBar.VERTICAL, contentHeight - MENU_HEIGHT); + leftDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), MENU_HEIGHT, 3, + contentHeight - MENU_HEIGHT); + + rightDottedLine = new DottedLine(UIScrollBar.VERTICAL, contentHeight - MENU_HEIGHT); + rightDottedLine.setBounds(contentWidth - EastRegionContainerPane.getInstance().getContainerWidth() - 3, + MENU_HEIGHT, 3, contentHeight - MENU_HEIGHT); + + } + + private void addDottedLine() { + layeredPane.add(upDottedLine, SECOND_LAYER); + layeredPane.add(downDottedLine, SECOND_LAYER); + layeredPane.add(leftDottedLine, SECOND_LAYER); + layeredPane.add(rightDottedLine, SECOND_LAYER); + layeredPane.add(closeButton, TOP_LAYER); + } + + private void removeDottedLine() { + layeredPane.remove(upDottedLine); + layeredPane.remove(downDottedLine); + layeredPane.remove(leftDottedLine); + layeredPane.remove(rightDottedLine); + layeredPane.remove(closeButton); + } + + public JLayeredPane getContentFrame() { + return layeredPane; + } + + /** + * 刷新 + */ + public void refreshDottedLine() { + if (BaseUtils.isAuthorityEditing()) { + populateAuthorityArea(); + populateCloseButton(); + addDottedLine(); + } else { + removeDottedLine(); + } + layeredPane.repaint(); + } + + /** + * 刷新DottedLine + */ + public void doResize() { + removeDottedLine(); + populateAuthorityArea(); + populateCloseButton(); + addDottedLine(); + } + + 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); + WestRegionContainerPane.getInstance().replaceDownPane( + TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); + DesignerContext.getDesignerFrame().resetToolkitByPlus( + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus()); + needToAddAuhtorityPaint(); + refreshDottedLine(); + fireAuthorityStateToNomal(); + } + } + + public void mouseEntered(MouseEvent e) { + closeMode = UIConstants.CLOSE_OVER_AUTHORITY; + closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); + closeButton.repaint(); + } + }; + + /** + * 刷新CloseButton + */ + public void populateCloseButton() { + + closeButton.addMouseListener(closeMouseListener); + closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); + closeButton.setBorder(null); + int x = contentWidth - EastRegionContainerPane.getInstance().getContainerWidth() - closeMode.getIconWidth() / 2; + int y = MENU_HEIGHT - closeMode.getIconHeight() / 2; + closeButton.setBounds(x, y, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH, + UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH); + } + + /** + * 退出权限编辑时,将所有的做过权限编辑的状态,作为一个状态赋给报、报表主体 + */ + private void fireAuthorityStateToNomal() { + java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); + for (int i = 0; i < opendedTemplate.size(); i++) { + // 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 + if (opendedTemplate.get(i).isDoSomethingInAuthority()) { + opendedTemplate.get(i).fireAuthorityStateToNomal(); + } + } + } + + 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)); + UIButton[] fixButtons = ad.createUp(); + for (int i = 0; i < fixButtons.length; i++) { + combineUp.add(fixButtons[i]); + } + if (!BaseUtils.isAuthorityEditing()) { + combineUp.addSeparator(new Dimension(2, 16)); + if (toolbar4Form != null) { + for (int i = 0; i < toolbar4Form.length; i++) { + combineUp.add(toolbar4Form[i]); + } + } + } + + //添加分享按钮 + addShareButton(); + + //添加插件中的按钮 + addExtraButtons(); + + return combineUp; + } + + private void addExtraButtons(){ + JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if(jt == null){ + return; + } + + + UIButton[] extraButtons = jt.createExtraButtons(); + for (int i = 0; i < extraButtons.length; i++) { + combineUp.add(extraButtons[i]); + } + if (extraButtons.length > 0) { + combineUp.addSeparator(new Dimension(2, 16)); + } + } + + private void addShareButton(){ + JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if(jt == null){ + return; + } + + combineUp.addSeparator(new Dimension(2, 16)); + UIButton[] shareButtons = jt.createShareButton(); + for (int i = 0; i < shareButtons.length; i++) { + combineUp.add(shareButtons[i]); + } + } + + /** + * 检查 + * + * @param flag + * 组件是否可见 + * @param al + * 组件名称 + */ + public void checkCombineUp(boolean flag, ArrayList al) { + combineUp.checkComponentsByNames(flag, al); + + } + + /** + * 刷新工具条. + */ + public void refreshToolbar() { + this.ad.updateToolBarDef(); + } + + /** + * 重置相关的工具条. + * + * @param plus + * 工具条中相关信息 + */ + public void resetToolkitByPlus(ToolBarMenuDockPlus plus) { + if (plus == null) { + plus = ToolBarMenuDock.NULLAVOID; + } + + DesignState designState = new DesignState(plus); + MenuManager.getInstance().setMenus4Designer(designState); + if (menuBar != null) { + menuPane.remove(menuBar); + } + menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); + + if (combineUp != null) { + eastCenterPane.remove(combineUp); + combineUp = null; + } + + // 保存撤销那些按钮的面板 + eastCenterPane.add(combineUp = combineUpTooBar(ad.resetUpToolBar(plus)), BorderLayout.NORTH); + + if (toolbarComponent != null) { + toolbarPane.remove(toolbarComponent); + } + + // 颜色,字体那些按钮的工具栏 + toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); + + this.checkToolbarMenuEnable(); + this.validate(); + layeredPane.repaint(); + } + + public JComponent getToolbarComponent() { + return this.toolbarComponent; + } + + /** + * 判断是否在权限编辑状态,若是在权限编辑状态,则需要有虚线框和关闭突变 + */ + public void needToAddAuhtorityPaint() { + + newWorkBookPane.setButtonGray(BaseUtils.isAuthorityEditing()); + } + + /** + * 检查工具条. + */ + private void checkToolbarMenuEnable() { + if (this.ad != null) { + this.ad.updateMenuDef(); + this.ad.updateToolBarDef(); + } + } + + /** + * 设置标题 + */ + public void setTitle() { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); StringBuilder defaultTitleSB = new StringBuilder(); defaultTitleSB.append(ProductConstants.PRODUCT_NAME); - defaultTitleSB.append(" "); - defaultTitleSB.append(ProductConstants.BRANCH); - // james:标识登录的用户和登录的ENV - String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); - 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 = env.getPath() + File.separator + path; - } - defaultTitleSB.append(" " + path); - } - - } - setTitle(defaultTitleSB.toString()); - } - - /** - * modify window bounds. - */ - private void modWindowBounds() { - // set the window bounds to the same as last closed - DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); - Rectangle windowBounds = designerEnvManager.getWindowBounds(); - if (windowBounds != null) { - int locX = windowBounds.x; - int locY = windowBounds.y; - - if (!OperatingSystem.isWindows()) { - locX = Math.max(1, locX); - locY = Math.max(1, locY); - } - - this.setLocation(new Point(locX, locY)); - - int width = windowBounds.width; - int height = windowBounds.height; - if (width > MIN_SIZE.width && height > MIN_SIZE.height) { - this.setSize(width, height); - } else { - GUICoreUtils.setWindowFullScreen(this); - } - } else { - GUICoreUtils.setWindowFullScreen(this); - } - } - - + defaultTitleSB.append(" "); + defaultTitleSB.append(ProductConstants.BRANCH); + // james:标识登录的用户和登录的ENV + String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); + 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 = env.getPath() + File.separator + path; + } + defaultTitleSB.append(" " + path); + } + + } + setTitle(defaultTitleSB.toString()); + } + + /** + * modify window bounds. + */ + private void modWindowBounds() { + // set the window bounds to the same as last closed + DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); + Rectangle windowBounds = designerEnvManager.getWindowBounds(); + if (windowBounds != null) { + int locX = windowBounds.x; + int locY = windowBounds.y; + + if (!OperatingSystem.isWindows()) { + locX = Math.max(1, locX); + locY = Math.max(1, locY); + } + + this.setLocation(new Point(locX, locY)); + + int width = windowBounds.width; + int height = windowBounds.height; + if (width > MIN_SIZE.width && height > MIN_SIZE.height) { + this.setSize(width, height); + } else { + GUICoreUtils.setWindowFullScreen(this); + } + } else { + GUICoreUtils.setWindowFullScreen(this); + } + } + + /** * 报表运行环境改变时,需要刷新某些面板 * * @param env 环境 */ public void refreshEnv(Env env) { - + this.setTitle(); DesignerFrameFileDealerPane.getInstance().refreshDockingView(); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TemplateTreePane.getInstance().refreshDockingView(); DesignTableDataManager.clearGlobalDs(); - EastRegionContainerPane.getInstance().refreshDownPane(); - } - - /** - * 返回选中的模板. - */ - public JTemplate getSelectedJTemplate() { - return this.centerTemplateCardPane.getSelectedJTemplate(); - } - - /** - * 保存当前编辑的模板 - */ - - public void saveCurrentEditingTemplate() { - JTemplate editingTemplate = HistoryTemplateListPane.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 = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), - 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(); - FRLogger.getLogger().log( - Level.INFO, - Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{ - editingTemplate.getEditingFILE().getName(), "."})); - } - } else { - if (editingTemplate.saveTemplate()) { - editingTemplate.saveTemplate(); - FRLogger.getLogger().log( - Level.INFO, - Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{ - editingTemplate.getEditingFILE().getName(), "."})); - } - } - } - } - - /** - * 添加新建模板, 并激活. - */ - public void addAndActivateJTemplate() { - addAndActivateJTemplate(ad.createNewTemplate()); - layeredPane.repaint(); - } - - /** - * 添加 模板, 并激活. - * - * @param jt 添加的模板. - */ - public void addAndActivateJTemplate(JTemplate jt) { - if (jt == null || jt.getEditingFILE() == null) { - return; - } - jt.addJTemplateActionListener(this); - jt.addTargetModifiedListener(this); - centerTemplateCardPane.showJTemplate(jt); - setTitle(); - layeredPane.repaint(); - } - - /** - * 激活已经存在的模板 - * - * @param jt 模板 - */ - public void activateJTemplate(JTemplate jt) { - if (jt == null || jt.getEditingFILE() == null) { - return; - } - centerTemplateCardPane.showJTemplate(jt); - setTitle(); - layeredPane.repaint(); - } - - /** - * 对象侦听 - * - * @param e 事件 - */ - public void targetModified(TargetModifiedEvent e) { - this.checkToolbarMenuEnable(); - } - - /** - * 模板关闭时 处理. - * - * @param jt 模板 - */ - public void templateClosed(JTemplate jt) { - } - - /** - * 模板打开时 处理. - * - * @param jt 模板 - */ - public void templateOpened(JTemplate jt) { - } - - /** - * 模板保存时 处理. - * - * @param jt 模板 - */ - public void templateSaved(JTemplate jt) { - this.checkToolbarMenuEnable(); - } - - /** - * 打开模板文件,如果是已经打开的就激活此模板所对应的JInternalFrame - * - * @param tplFile 文件 - */ - public void openTemplate(FILE tplFile) { - // 测试连接,如果连接失败,则提示 - 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, Inter.getLocText("Warning-Template_Do_Not_Exsit"), - ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE); - DesignerFrameFileDealerPane.getInstance().refresh(); - return; - } + EastRegionContainerPane.getInstance().refreshDownPane(); + } + + /** + * 返回选中的模板. + */ + public JTemplate getSelectedJTemplate() { + return this.centerTemplateCardPane.getSelectedJTemplate(); + } + + /** + * 保存当前编辑的模板 + */ + + public void saveCurrentEditingTemplate() { + JTemplate editingTemplate = HistoryTemplateListPane.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 = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + 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(); + FRLogger.getLogger().log( + Level.INFO, + Inter.getLocText(new String[] { "Template", "already-saved" }, new String[] { + editingTemplate.getEditingFILE().getName(), "." })); + } + } else { + if (editingTemplate.saveTemplate()) { + editingTemplate.saveTemplate(); + FRLogger.getLogger().log( + Level.INFO, + Inter.getLocText(new String[] { "Template", "already-saved" }, new String[] { + editingTemplate.getEditingFILE().getName(), "." })); + } + } + } + } + + /** + * 添加新建模板, 并激活. + */ + public void addAndActivateJTemplate() { + addAndActivateJTemplate(ad.createNewTemplate()); + layeredPane.repaint(); + } + + /** + * 添加 模板, 并激活. + * + * @param jt + * 添加的模板. + */ + public void addAndActivateJTemplate(JTemplate jt) { + if (jt == null || jt.getEditingFILE() == null) { + return; + } + jt.addJTemplateActionListener(this); + jt.addTargetModifiedListener(this); + centerTemplateCardPane.showJTemplate(jt); + setTitle(); + layeredPane.repaint(); + } + + /** + * 激活已经存在的模板 + * + * @param jt + * 模板 + */ + public void activateJTemplate(JTemplate jt) { + if (jt == null || jt.getEditingFILE() == null) { + return; + } + centerTemplateCardPane.showJTemplate(jt); + setTitle(); + layeredPane.repaint(); + } + + /** + * 对象侦听 + * + * @param e + * 事件 + */ + public void targetModified(TargetModifiedEvent e) { + this.checkToolbarMenuEnable(); + } + + /** + * 模板关闭时 处理. + * + * @param jt + * 模板 + */ + public void templateClosed(JTemplate jt) { + } + + /** + * 模板打开时 处理. + * + * @param jt + * 模板 + */ + public void templateOpened(JTemplate jt) { + } + + /** + * 模板保存时 处理. + * + * @param jt + * 模板 + */ + public void templateSaved(JTemplate jt) { + this.checkToolbarMenuEnable(); + } + + /** + * 打开模板文件,如果是已经打开的就激活此模板所对应的JInternalFrame + * + * @param tplFile + * 文件 + */ + public void openTemplate(FILE tplFile) { + // 测试连接,如果连接失败,则提示 + 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, Inter.getLocText("Warning-Template_Do_Not_Exsit"), + ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE); + DesignerFrameFileDealerPane.getInstance().refresh(); + return; + } try { openFile(tplFile); @@ -842,200 +844,210 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta addAndActivateJTemplate(); } - } - - /** - * 是否不合版本的设计器 - * - * @param jt 当前模板 - * @return 是否不合版本 - * @date 2014-10-14-下午6:30:37 - */ - private boolean inValidDesigner(JTemplate jt) { - return jt.isOldDesigner() || (!jt.isJWorkBook() && jt.isNewDesigner()); - } - - /** - * 打开指定的文件 - * - * @param tplFile 指定的文件 - * @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) { - return; - } - String fileExtention = fileName.substring(indexOfLastDot + 1); - for (int i = 0, len = appList.size(); i < len; i++) { - App app = appList.get(i); - String[] defaultAppExtentions = app.defaultExtentions(); - boolean opened = false; - for (int j = 0; j < defaultAppExtentions.length; j++) { - if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) { - JTemplate jt = null; - try { - jt = app.openTemplate(tplFile); - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage(), e); - } - if (jt == null) { - return; - } - // 新的form不往前兼容 - if (inValidDesigner(jt)) { - this.addAndActivateJTemplate(); - MutilTempalteTabPane.getInstance().setTemTemplate( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - } else { - activeTemplate(tplFile, jt); - } - opened = true; - break; - } - } - if (opened) { - break; - } - } - } - - /** - * 激活指定的模板 - * - * @param tplFile 模板文件 - * @param jt 当前报表 - * @date 2014-10-14-下午6:31:23 - */ - private void activeTemplate(FILE tplFile, JTemplate jt) { - // 如果该模板已经打开,则进行激活就可以了 - 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); - if (index != -1) { - this.activateJTemplate(HistoryTemplateListPane.getInstance().getHistoryList().get(index)); - } else { - this.addAndActivateJTemplate(jt); - } - //REPORT-5084:激活后刷新一下右側面板 - jt.refreshEastPropertiesPane(); - } - - /** - * Exit退出 - */ - public void exit() { - Thread thread = new Thread() { - @Override - public void run() { - DesignerEnvManager.doEndMapSaveWorkersIndesign(); - } - }; - thread.start(); - - try { - thread.join(); - } catch (InterruptedException e) { - FRLogger.getLogger().error("Map Thread Error"); - } - - DesignerEnvManager.getEnvManager().setLastOpenFile( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); - - DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( - WestRegionContainerPane.getInstance().getToolPaneY()); - DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth( - WestRegionContainerPane.getInstance().getContainerWidth()); - DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY( - EastRegionContainerPane.getInstance().getToolPaneY()); - DesignerEnvManager.getEnvManager().setLastEastRegionContainerWidth( - EastRegionContainerPane.getInstance().getContainerWidth()); - - DesignerEnvManager.getEnvManager().saveXMLFile(); - - 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(); - - this.ad.shutDown(); - - System.exit(0); - } - - // harry:添加程序外拖拽文件进来打开的功能 - class FileDropTargetListener implements DropTargetListener { - - @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; - } - } - - @SuppressWarnings("unchecked") - @Override - public void drop(DropTargetDropEvent event) { - if (!isDropAcceptable(event)) { - event.rejectDrop(); - return; - } - - event.acceptDrop(DnDConstants.ACTION_MOVE); - Transferable transferable = event.getTransferable(); - DataFlavor[] flavors = transferable.getTransferDataFlavors(); - for (int i = 0; i < flavors.length; i++) { - DataFlavor d = flavors[i]; - try { - if (ComparatorUtils.equals(d, DataFlavor.javaFileListFlavor)) { - List fileList = (List) transferable.getTransferData(d); - Iterator iterator = fileList.iterator(); - while (iterator.hasNext()) { - File f = iterator.next(); - DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f)); - } - } - } catch (Exception 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; - } - } + } + + /** + * 是否不合版本的设计器 + * + * @param jt + * 当前模板 + * + * @return 是否不合版本 + * + * + * @date 2014-10-14-下午6:30:37 + */ + private boolean inValidDesigner(JTemplate jt) { + return jt.isOldDesigner() || (!jt.isJWorkBook() && jt.isNewDesigner()); + } + + /** + * 打开指定的文件 + * + * @param tplFile + * 指定的文件 + * + * + * @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) { + return; + } + String fileExtention = fileName.substring(indexOfLastDot + 1); + for (int i = 0, len = appList.size(); i < len; i++) { + App app = appList.get(i); + String[] defaultAppExtentions = app.defaultExtentions(); + boolean opened = false; + for (int j = 0; j < defaultAppExtentions.length; j++) { + if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) { + JTemplate jt = null; + try { + jt = app.openTemplate(tplFile); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage(), e); + } + if (jt == null) { + return; + } + // 新的form不往前兼容 + if (inValidDesigner(jt)) { + this.addAndActivateJTemplate(); + MutilTempalteTabPane.getInstance().setTemTemplate( + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + } else { + activeTemplate(tplFile, jt); + } + opened = true; + break; + } + } + if (opened) { + break; + } + } + } + + /** + * 激活指定的模板 + * + * @param tplFile + * 模板文件 + * @param jt + * 当前报表 + * + * + * @date 2014-10-14-下午6:31:23 + */ + private void activeTemplate(FILE tplFile, JTemplate jt) { + // 如果该模板已经打开,则进行激活就可以了 + 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 = fullName.replaceAll("/", "\\\\"); + int index = HistoryTemplateListPane.getInstance().contains(fullName); + List> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); + if (index != -1) { + historyList.get(index).activeJTemplate(index, jt); + } else { + this.addAndActivateJTemplate(jt); + } + + } + + /** + * Exit退出 + */ + public void exit() { + Thread thread = new Thread() { + @Override + public void run() { + DesignerEnvManager.doEndMapSaveWorkersIndesign(); + } + }; + thread.start(); + + try { + thread.join(); + } catch (InterruptedException e) { + FRLogger.getLogger().error("Map Thread Error"); + } + + DesignerEnvManager.getEnvManager().setLastOpenFile( + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); + + DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( + WestRegionContainerPane.getInstance().getToolPaneY()); + DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth( + WestRegionContainerPane.getInstance().getContainerWidth()); + DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY( + EastRegionContainerPane.getInstance().getToolPaneY()); + DesignerEnvManager.getEnvManager().setLastEastRegionContainerWidth( + EastRegionContainerPane.getInstance().getContainerWidth()); + + DesignerEnvManager.getEnvManager().saveXMLFile(); + + Env currentEnv = FRContext.getCurrentEnv(); + try { + currentEnv.signOut(); + GeneralContext.fireEnvSignOutListener(); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } + this.setVisible(false); + this.dispose(); + + this.ad.shutDown(); + + System.exit(0); + } + + // harry:添加程序外拖拽文件进来打开的功能 + class FileDropTargetListener implements DropTargetListener { + + @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; + } + } + + @SuppressWarnings("unchecked") + @Override + public void drop(DropTargetDropEvent event) { + if (!isDropAcceptable(event)) { + event.rejectDrop(); + return; + } + + event.acceptDrop(DnDConstants.ACTION_MOVE); + Transferable transferable = event.getTransferable(); + DataFlavor[] flavors = transferable.getTransferDataFlavors(); + for (int i = 0; i < flavors.length; i++) { + DataFlavor d = flavors[i]; + try { + if (ComparatorUtils.equals(d, DataFlavor.javaFileListFlavor)) { + List fileList = (List) transferable.getTransferData(d); + Iterator iterator = fileList.iterator(); + while (iterator.hasNext()) { + File f = iterator.next(); + DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f)); + } + } + } catch (Exception 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; + } + } } \ No newline at end of file From 0db8a1483c32876921b945730867122a9bb2285c Mon Sep 17 00:00:00 2001 From: MoMeak Date: Wed, 22 Nov 2017 17:19:17 +0800 Subject: [PATCH 008/156] =?UTF-8?q?REPORT-5794=20DesignerFrame=E5=92=8CHis?= =?UTF-8?q?toryTemplateListPane=E7=9A=84=E6=94=B9=E5=8A=A8,=20release?= =?UTF-8?q?=E9=87=8C=E6=9C=89,=20feature=E9=87=8C=E6=B2=A1=E6=9C=89,=20?= =?UTF-8?q?=E5=90=88=E4=BB=A3=E7=A0=81=E5=86=B2=E7=AA=81=E4=BA=86,=20?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=89=8B=E5=8A=A8patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/file/HistoryTemplateListPane.java | 15 +- .../fr/design/mainframe/DesignerFrame.java | 1833 ++++++++--------- 2 files changed, 916 insertions(+), 932 deletions(-) diff --git a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java index a22c335414..1e9ae4e522 100644 --- a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -9,6 +9,7 @@ import java.util.logging.Level; import javax.swing.*; +import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.design.constants.UIConstants; import com.fr.design.DesignerEnvManager; import com.fr.design.data.DesignTableDataManager; @@ -25,7 +26,6 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilist.UIList; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; -import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.module.DesignModuleFactory; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; @@ -36,7 +36,7 @@ import com.fr.stable.Constants; import com.fr.stable.project.ProjectConstants; import com.fr.design.utils.gui.GUIPaintUtils; -public class HistoryTemplateListPane extends JPanel implements FileOperations { +public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent { //最大保存内存中面板数,为0时关闭优化内存 private static final int DEAD_LINE = 5; private static final int LIST_BORDER = 4; @@ -104,7 +104,8 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { } /** - *关闭选择的文件 + * 关闭选择的文件 + * * @param selected 选择的 */ public void closeSelectedReport(JTemplate selected) { @@ -129,6 +130,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { /** * 临时关闭选择的文件 + * * @param selected 选择的 */ public void closeVirtualSelectedReport(JTemplate selected) { @@ -235,6 +237,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { /** * 判断是否打开过该模板 + * * @param filename 文件名 * @return 文件位置 */ @@ -250,6 +253,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { /** * 是否是当前编辑的文件 + * * @param filename 文件名 * @return 是则返回TRUE */ @@ -258,6 +262,10 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { return ComparatorUtils.equals(filename, editingFileName); } + @Override + public void callback() { + getCurrentEditingTemplate().repaint(); + } private class HistoryListCellRender extends DefaultListCellRenderer { @@ -388,6 +396,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { /** * 路径 + * * @return 路径 */ public String getSelectedTemplatePath() { diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java index 224305940b..2f38d34c7e 100644 --- a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java @@ -37,6 +37,7 @@ import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.GeneralContext; 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; @@ -65,115 +66,222 @@ import java.util.List; import java.util.logging.Level; public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { - 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)); - - public static final String DESIGNER_FRAME_NAME = "designer_frame"; - public static final Dimension MIN_SIZE = new Dimension(100, 100); - - private static java.util.List> appList = new java.util.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 = null; - private Icon closeMode = UIConstants.CLOSE_OF_AUTHORITY; - private JLayeredPane layeredPane = this.getLayeredPane(); - private JPanel basePane = new JPanel(); - // 上面的虚线 - private DottedLine upDottedLine; - // 下面的虚线 - private DottedLine downDottedLine; - - // 左边的虚线 - private DottedLine leftDottedLine; - - // 右边的虚线 - 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) { - int choose = saveSomeTempaltePane.saveLastOneTemplate(); - if (choose != JOptionPane.CANCEL_OPTION) { - DesignerFrame.this.exit(); - } - } else { - if (saveSomeTempaltePane.showSavePane()) { - DesignerFrame.this.exit(); - } - } - } - - }; - - 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); - closeMode.paintIcon(this, g, 0, 0); - } - }; - - /** - * 注册app. - * - * @param app - * 注册app. - */ - public static void registApp(App app) { - if (app != null) { - appList.add(app); - } - } - + 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> appList = new java.util.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 = null; + private Icon closeMode = UIConstants.CLOSE_OF_AUTHORITY; + private JLayeredPane layeredPane = this.getLayeredPane(); + private JPanel basePane = new JPanel(); + // 上面的虚线 + private DottedLine upDottedLine; + // 下面的虚线 + private DottedLine downDottedLine; + + // 左边的虚线 + private DottedLine leftDottedLine; + + // 右边的虚线 + 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) { + int choose = saveSomeTempaltePane.saveLastOneTemplate(); + if (choose != JOptionPane.CANCEL_OPTION) { + DesignerFrame.this.exit(); + } + } else { + if (saveSomeTempaltePane.showSavePane()) { + DesignerFrame.this.exit(); + } + } + } + + }; + + 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); + closeMode.paintIcon(this, g, 0, 0); + } + }; + + 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); + WestRegionContainerPane.getInstance().replaceDownPane( + TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); + DesignerContext.getDesignerFrame().resetToolkitByPlus( + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus()); + needToAddAuhtorityPaint(); + refreshDottedLine(); + fireAuthorityStateToNomal(); + } + } + + public void mouseEntered(MouseEvent e) { + closeMode = UIConstants.CLOSE_OVER_AUTHORITY; + closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); + closeButton.repaint(); + } + }; + + public DesignerFrame(ToolBarMenuDock ad) { + + setName(DESIGNER_FRAME_NAME); + this.ad = ad; + this.initTitleIcon(); + this.setTitle();// james:因为有默认的了 + // set this to context. + DesignerContext.setDesignerFrame(this); + + // the content pane + basePane.setLayout(new BorderLayout()); + toolbarPane = new JPanel() { + 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(); + eastCenterPane.add(combineUp = combineUpTooBar(null), 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(); + basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST); + basePane.setBounds(0, 0, contentWidth, contentHeight); + + // 数值越小。越在底层 + layeredPane.add(basePane); + // 调整Window大小 + modWindowBounds(); + + + // p:检查所有按钮的可见性和是否可以编辑性. + checkToolbarMenuEnable(); + + // window close listener. + this.addWindowListeners(getFrameListeners()); + + this.addComponentListener(new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + reCalculateFrameSize(); + if (BaseUtils.isAuthorityEditing()) { + 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(); + } + + /** + * 注册app. + * + * @param app 注册app. + */ + public static void registApp(App app) { + if (app != null) { + appList.add(app); + } + } + public static void removeApp(App app) { - + if (app != null) { appList.remove(app); } } - protected DesktopCardPane getCenterTemplateCardPane() { - return centerTemplateCardPane; - } - - /** - * 初始menuPane的方法 方便OEM时修改该组件 - */ - 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); - this.resetToolkitByPlus(null); - } - + protected DesktopCardPane getCenterTemplateCardPane() { + return centerTemplateCardPane; + } + + /** + * 初始menuPane的方法 方便OEM时修改该组件 + */ + 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); + this.resetToolkitByPlus(null); + } + /** * @param ad * @return @@ -184,658 +292,534 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); //优先级为-1,保证最后全面刷新一次 GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { - + @Override public void on(PluginEvent event) { - + refreshNorthEastPane(northEastPane, ad); DesignUtils.refreshDesignerFrame(FRContext.getCurrentEnv()); } }, new PluginFilter() { - + @Override public boolean accept(PluginContext context) { - + return context.contain(PluginModule.ExtraDesign); } }); refreshNorthEastPane(northEastPane, ad); - return northEastPane; - } - + return northEastPane; + } + private void refreshNorthEastPane(JPanel northEastPane, 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) { - processor = new DefaultTitlePlace(); + if (processor != null) { + processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane()); + } + northEastPane.add(ad.createAlphafinePane()); + if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { + ad.createAlphafinePane().setVisible(false); } - processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane()); - if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { - northEastPane.add(ad.createAlphafinePane(), BorderLayout.CENTER); - } + northEastPane.add(ad.createBBSLoginPane()); } - - public DesignerFrame(ToolBarMenuDock ad) { - - setName(DESIGNER_FRAME_NAME); - this.ad = ad; - this.initTitleIcon(); - this.setTitle();// james:因为有默认的了 - // set this to context. - DesignerContext.setDesignerFrame(this); - - // the content pane - basePane.setLayout(new BorderLayout()); - toolbarPane = new JPanel() { - 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(); - eastCenterPane.add(combineUp = combineUpTooBar(null), 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(); -// JPanel eastRegionPane = new JPanel(new BorderLayout()); -// eastRegionPane.add(EastRegionContainerPane.getInstance(), BorderLayout.CENTER); -// eastRegionPane.add(JSliderPane.getInstance(), BorderLayout.SOUTH); -// basePane.add(eastRegionPane, BorderLayout.EAST); - - basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST); - basePane.setBounds(0, 0, contentWidth, contentHeight); - - // 数值越小。越在底层 - layeredPane.add(basePane); - // 调整Window大小 - modWindowBounds(); - - - - // p:检查所有按钮的可见性和是否可以编辑性. - checkToolbarMenuEnable(); - - // window close listener. - this.addWindowListeners(getFrameListeners()); - - this.addComponentListener(new ComponentAdapter() { - public void componentResized(ComponentEvent e) { - reCalculateFrameSize(); - if (BaseUtils.isAuthorityEditing()) { - 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(); - } - - public void initTitleIcon() { - try { - @SuppressWarnings("unchecked") - List image = ICODecoder.read(DesignerFrame.class - .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); - this.setIconImages(image); - } catch (IOException e) { - FRContext.getLogger().error(e.getMessage(), e); - this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); - } - } - - private void addWindowListeners(ArrayList listeners){ - for(WindowListener listener : listeners){ - this.addWindowListener(listener); - } - } - - protected ArrayList getFrameListeners(){ - ArrayList arrayList = new ArrayList(); - arrayList.add(windowAdapter); - return arrayList; - } - - - protected void laoyoutWestPane(){ - basePane.add(WestRegionContainerPane.getInstance(), BorderLayout.WEST); - } - - // 调整windows大小 - private void reCalculateFrameSize() { - contentHeight = layeredPane.getHeight(); - contentWidth = layeredPane.getWidth(); - layeredPane.remove(basePane); - basePane.setBounds(0, 0, contentWidth, contentHeight); - layeredPane.add(basePane); - layeredPane.repaint(); - } - - /** - * 更新 - */ - public void populateAuthorityArea() { - int centerWidth = contentWidth - WestRegionContainerPane.getInstance().getContainerWidth() - - EastRegionContainerPane.getInstance().getContainerWidth(); - // 上面的虚线 - upDottedLine = new DottedLine(UIScrollBar.HORIZONTAL, centerWidth); - upDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), MENU_HEIGHT - 1, centerWidth, - 3); - - // 下面的虚线 - downDottedLine = new DottedLine(UIScrollBar.HORIZONTAL, centerWidth); - downDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), contentHeight - 3, - centerWidth, 3); - - // 左边的虚线 - leftDottedLine = new DottedLine(UIScrollBar.VERTICAL, contentHeight - MENU_HEIGHT); - leftDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), MENU_HEIGHT, 3, - contentHeight - MENU_HEIGHT); - - rightDottedLine = new DottedLine(UIScrollBar.VERTICAL, contentHeight - MENU_HEIGHT); - rightDottedLine.setBounds(contentWidth - EastRegionContainerPane.getInstance().getContainerWidth() - 3, - MENU_HEIGHT, 3, contentHeight - MENU_HEIGHT); - - } - - private void addDottedLine() { - layeredPane.add(upDottedLine, SECOND_LAYER); - layeredPane.add(downDottedLine, SECOND_LAYER); - layeredPane.add(leftDottedLine, SECOND_LAYER); - layeredPane.add(rightDottedLine, SECOND_LAYER); - layeredPane.add(closeButton, TOP_LAYER); - } - - private void removeDottedLine() { - layeredPane.remove(upDottedLine); - layeredPane.remove(downDottedLine); - layeredPane.remove(leftDottedLine); - layeredPane.remove(rightDottedLine); - layeredPane.remove(closeButton); - } - - public JLayeredPane getContentFrame() { - return layeredPane; - } - - /** - * 刷新 - */ - public void refreshDottedLine() { - if (BaseUtils.isAuthorityEditing()) { - populateAuthorityArea(); - populateCloseButton(); - addDottedLine(); - } else { - removeDottedLine(); - } - layeredPane.repaint(); - } - - /** - * 刷新DottedLine - */ - public void doResize() { - removeDottedLine(); - populateAuthorityArea(); - populateCloseButton(); - addDottedLine(); - } - - 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); - WestRegionContainerPane.getInstance().replaceDownPane( - TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); - DesignerContext.getDesignerFrame().resetToolkitByPlus( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus()); - needToAddAuhtorityPaint(); - refreshDottedLine(); - fireAuthorityStateToNomal(); - } - } - - public void mouseEntered(MouseEvent e) { - closeMode = UIConstants.CLOSE_OVER_AUTHORITY; - closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); - closeButton.repaint(); - } - }; - - /** - * 刷新CloseButton - */ - public void populateCloseButton() { - - closeButton.addMouseListener(closeMouseListener); - closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); - closeButton.setBorder(null); - int x = contentWidth - EastRegionContainerPane.getInstance().getContainerWidth() - closeMode.getIconWidth() / 2; - int y = MENU_HEIGHT - closeMode.getIconHeight() / 2; - closeButton.setBounds(x, y, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH, - UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH); - } - - /** - * 退出权限编辑时,将所有的做过权限编辑的状态,作为一个状态赋给报、报表主体 - */ - private void fireAuthorityStateToNomal() { - java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); - for (int i = 0; i < opendedTemplate.size(); i++) { - // 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 - if (opendedTemplate.get(i).isDoSomethingInAuthority()) { - opendedTemplate.get(i).fireAuthorityStateToNomal(); - } - } - } - - 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)); - UIButton[] fixButtons = ad.createUp(); - for (int i = 0; i < fixButtons.length; i++) { - combineUp.add(fixButtons[i]); - } - if (!BaseUtils.isAuthorityEditing()) { - combineUp.addSeparator(new Dimension(2, 16)); - if (toolbar4Form != null) { - for (int i = 0; i < toolbar4Form.length; i++) { - combineUp.add(toolbar4Form[i]); - } - } - } - - //添加分享按钮 - addShareButton(); - - //添加插件中的按钮 - addExtraButtons(); - - return combineUp; - } - - private void addExtraButtons(){ - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if(jt == null){ - return; - } - - - UIButton[] extraButtons = jt.createExtraButtons(); - for (int i = 0; i < extraButtons.length; i++) { - combineUp.add(extraButtons[i]); - } - if (extraButtons.length > 0) { - combineUp.addSeparator(new Dimension(2, 16)); - } - } - - private void addShareButton(){ - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if(jt == null){ - return; - } - - combineUp.addSeparator(new Dimension(2, 16)); - UIButton[] shareButtons = jt.createShareButton(); - for (int i = 0; i < shareButtons.length; i++) { - combineUp.add(shareButtons[i]); - } - } - - /** - * 检查 - * - * @param flag - * 组件是否可见 - * @param al - * 组件名称 - */ - public void checkCombineUp(boolean flag, ArrayList al) { - combineUp.checkComponentsByNames(flag, al); - - } - - /** - * 刷新工具条. - */ - public void refreshToolbar() { - this.ad.updateToolBarDef(); - } - - /** - * 重置相关的工具条. - * - * @param plus - * 工具条中相关信息 - */ - public void resetToolkitByPlus(ToolBarMenuDockPlus plus) { - if (plus == null) { - plus = ToolBarMenuDock.NULLAVOID; - } - - DesignState designState = new DesignState(plus); - MenuManager.getInstance().setMenus4Designer(designState); - if (menuBar != null) { - menuPane.remove(menuBar); - } - menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); - - if (combineUp != null) { - eastCenterPane.remove(combineUp); - combineUp = null; - } - - // 保存撤销那些按钮的面板 - eastCenterPane.add(combineUp = combineUpTooBar(ad.resetUpToolBar(plus)), BorderLayout.NORTH); - - if (toolbarComponent != null) { - toolbarPane.remove(toolbarComponent); - } - - // 颜色,字体那些按钮的工具栏 - toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); - - this.checkToolbarMenuEnable(); - this.validate(); - layeredPane.repaint(); - } - - public JComponent getToolbarComponent() { - return this.toolbarComponent; - } - - /** - * 判断是否在权限编辑状态,若是在权限编辑状态,则需要有虚线框和关闭突变 - */ - public void needToAddAuhtorityPaint() { - - newWorkBookPane.setButtonGray(BaseUtils.isAuthorityEditing()); - } - - /** - * 检查工具条. - */ - private void checkToolbarMenuEnable() { - if (this.ad != null) { - this.ad.updateMenuDef(); - this.ad.updateToolBarDef(); - } - } - - /** - * 设置标题 - */ - public void setTitle() { + + public void initTitleIcon() { + try { + @SuppressWarnings("unchecked") + List image = ICODecoder.read(DesignerFrame.class + .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); + this.setIconImages(image); + } catch (IOException e) { + FRContext.getLogger().error(e.getMessage(), e); + this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); + } + } + + private void addWindowListeners(ArrayList listeners) { + for (WindowListener listener : listeners) { + this.addWindowListener(listener); + } + } + + protected ArrayList getFrameListeners() { + ArrayList arrayList = new ArrayList(); + arrayList.add(windowAdapter); + return arrayList; + } + + + protected void laoyoutWestPane() { + basePane.add(WestRegionContainerPane.getInstance(), BorderLayout.WEST); + } + + // 调整windows大小 + private void reCalculateFrameSize() { + contentHeight = layeredPane.getHeight(); + contentWidth = layeredPane.getWidth(); + layeredPane.remove(basePane); + basePane.setBounds(0, 0, contentWidth, contentHeight); + layeredPane.add(basePane); + layeredPane.repaint(); + } + + /** + * 更新 + */ + public void populateAuthorityArea() { + int centerWidth = contentWidth - WestRegionContainerPane.getInstance().getContainerWidth() + - EastRegionContainerPane.getInstance().getContainerWidth(); + // 上面的虚线 + upDottedLine = new DottedLine(UIScrollBar.HORIZONTAL, centerWidth); + upDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), MENU_HEIGHT - 1, centerWidth, + 3); + + // 下面的虚线 + downDottedLine = new DottedLine(UIScrollBar.HORIZONTAL, centerWidth); + downDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), contentHeight - 3, + centerWidth, 3); + + // 左边的虚线 + leftDottedLine = new DottedLine(UIScrollBar.VERTICAL, contentHeight - MENU_HEIGHT); + leftDottedLine.setBounds(WestRegionContainerPane.getInstance().getContainerWidth(), MENU_HEIGHT, 3, + contentHeight - MENU_HEIGHT); + + rightDottedLine = new DottedLine(UIScrollBar.VERTICAL, contentHeight - MENU_HEIGHT); + rightDottedLine.setBounds(contentWidth - EastRegionContainerPane.getInstance().getContainerWidth() - 3, + MENU_HEIGHT, 3, contentHeight - MENU_HEIGHT); + + } + + private void addDottedLine() { + layeredPane.add(upDottedLine, SECOND_LAYER); + layeredPane.add(downDottedLine, SECOND_LAYER); + layeredPane.add(leftDottedLine, SECOND_LAYER); + layeredPane.add(rightDottedLine, SECOND_LAYER); + layeredPane.add(closeButton, TOP_LAYER); + } + + private void removeDottedLine() { + layeredPane.remove(upDottedLine); + layeredPane.remove(downDottedLine); + layeredPane.remove(leftDottedLine); + layeredPane.remove(rightDottedLine); + layeredPane.remove(closeButton); + } + + public JLayeredPane getContentFrame() { + return layeredPane; + } + + /** + * 刷新 + */ + public void refreshDottedLine() { + if (BaseUtils.isAuthorityEditing()) { + populateAuthorityArea(); + populateCloseButton(); + addDottedLine(); + } else { + removeDottedLine(); + } + layeredPane.repaint(); + } + + /** + * 刷新DottedLine + */ + public void doResize() { + removeDottedLine(); + populateAuthorityArea(); + populateCloseButton(); + addDottedLine(); + } + + /** + * 刷新CloseButton + */ + public void populateCloseButton() { + + closeButton.addMouseListener(closeMouseListener); + closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); + closeButton.setBorder(null); + int x = contentWidth - EastRegionContainerPane.getInstance().getContainerWidth() - closeMode.getIconWidth() / 2; + int y = MENU_HEIGHT - closeMode.getIconHeight() / 2; + closeButton.setBounds(x, y, UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH, + UIConstants.CLOSE_AUTHORITY_HEIGHT_AND_WIDTH); + } + + /** + * 退出权限编辑时,将所有的做过权限编辑的状态,作为一个状态赋给报、报表主体 + */ + private void fireAuthorityStateToNomal() { + java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); + for (int i = 0; i < opendedTemplate.size(); i++) { + // 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 + if (opendedTemplate.get(i).isDoSomethingInAuthority()) { + opendedTemplate.get(i).fireAuthorityStateToNomal(); + } + } + } + + 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)); + UIButton[] fixButtons = ad.createUp(); + for (int i = 0; i < fixButtons.length; i++) { + combineUp.add(fixButtons[i]); + } + if (!BaseUtils.isAuthorityEditing()) { + combineUp.addSeparator(new Dimension(2, 16)); + if (toolbar4Form != null) { + for (int i = 0; i < toolbar4Form.length; i++) { + combineUp.add(toolbar4Form[i]); + } + } + } + + //添加分享按钮 + addShareButton(); + + //添加插件中的按钮 + addExtraButtons(); + + return combineUp; + } + + private void addExtraButtons() { + JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (jt == null) { + return; + } + + + UIButton[] extraButtons = jt.createExtraButtons(); + for (int i = 0; i < extraButtons.length; i++) { + combineUp.add(extraButtons[i]); + } + if (extraButtons.length > 0) { + combineUp.addSeparator(new Dimension(2, 16)); + } + } + + private void addShareButton() { + JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (jt == null) { + return; + } + + combineUp.addSeparator(new Dimension(2, 16)); + UIButton[] shareButtons = jt.createShareButton(); + for (int i = 0; i < shareButtons.length; i++) { + combineUp.add(shareButtons[i]); + } + } + + /** + * 检查 + * + * @param flag 组件是否可见 + * @param al 组件名称 + */ + public void checkCombineUp(boolean flag, ArrayList al) { + combineUp.checkComponentsByNames(flag, al); + + } + + /** + * 刷新工具条. + */ + public void refreshToolbar() { + this.ad.updateToolBarDef(); + } + + /** + * 重置相关的工具条. + * + * @param plus 工具条中相关信息 + */ + public void resetToolkitByPlus(ToolBarMenuDockPlus plus) { + if (plus == null) { + plus = ToolBarMenuDock.NULLAVOID; + } + + DesignState designState = new DesignState(plus); + MenuManager.getInstance().setMenus4Designer(designState); + if (menuBar != null) { + menuPane.remove(menuBar); + } + menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); + + if (combineUp != null) { + eastCenterPane.remove(combineUp); + combineUp = null; + } + + // 保存撤销那些按钮的面板 + eastCenterPane.add(combineUp = combineUpTooBar(ad.resetUpToolBar(plus)), BorderLayout.NORTH); + + if (toolbarComponent != null) { + toolbarPane.remove(toolbarComponent); + } + + // 颜色,字体那些按钮的工具栏 + toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); + + this.checkToolbarMenuEnable(); + this.validate(); + layeredPane.repaint(); + } + + public JComponent getToolbarComponent() { + return this.toolbarComponent; + } + + /** + * 判断是否在权限编辑状态,若是在权限编辑状态,则需要有虚线框和关闭突变 + */ + public void needToAddAuhtorityPaint() { + + newWorkBookPane.setButtonGray(BaseUtils.isAuthorityEditing()); + } + + /** + * 检查工具条. + */ + private void checkToolbarMenuEnable() { + if (this.ad != null) { + this.ad.updateMenuDef(); + this.ad.updateToolBarDef(); + } + } + + /** + * 设置标题 + */ + public void setTitle() { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); StringBuilder defaultTitleSB = new StringBuilder(); defaultTitleSB.append(ProductConstants.PRODUCT_NAME); - defaultTitleSB.append(" "); - defaultTitleSB.append(ProductConstants.BRANCH); - // james:标识登录的用户和登录的ENV - String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); - 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 = env.getPath() + File.separator + path; - } - defaultTitleSB.append(" " + path); - } - - } - setTitle(defaultTitleSB.toString()); - } - - /** - * modify window bounds. - */ - private void modWindowBounds() { - // set the window bounds to the same as last closed - DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); - Rectangle windowBounds = designerEnvManager.getWindowBounds(); - if (windowBounds != null) { - int locX = windowBounds.x; - int locY = windowBounds.y; - - if (!OperatingSystem.isWindows()) { - locX = Math.max(1, locX); - locY = Math.max(1, locY); - } - - this.setLocation(new Point(locX, locY)); - - int width = windowBounds.width; - int height = windowBounds.height; - if (width > MIN_SIZE.width && height > MIN_SIZE.height) { - this.setSize(width, height); - } else { - GUICoreUtils.setWindowFullScreen(this); - } - } else { - GUICoreUtils.setWindowFullScreen(this); - } - } - - + defaultTitleSB.append(" "); + defaultTitleSB.append(ProductConstants.BRANCH); + // james:标识登录的用户和登录的ENV + String envName = DesignerEnvManager.getEnvManager().getCurEnvName(); + 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 = env.getPath() + File.separator + path; + } + defaultTitleSB.append(" " + path); + } + + } + setTitle(defaultTitleSB.toString()); + } + + /** + * modify window bounds. + */ + private void modWindowBounds() { + // set the window bounds to the same as last closed + DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); + Rectangle windowBounds = designerEnvManager.getWindowBounds(); + if (windowBounds != null) { + int locX = windowBounds.x; + int locY = windowBounds.y; + + if (!OperatingSystem.isWindows()) { + locX = Math.max(1, locX); + locY = Math.max(1, locY); + } + + this.setLocation(new Point(locX, locY)); + + int width = windowBounds.width; + int height = windowBounds.height; + if (width > MIN_SIZE.width && height > MIN_SIZE.height) { + this.setSize(width, height); + } else { + GUICoreUtils.setWindowFullScreen(this); + } + } else { + GUICoreUtils.setWindowFullScreen(this); + } + } + + /** * 报表运行环境改变时,需要刷新某些面板 * * @param env 环境 */ public void refreshEnv(Env env) { - + this.setTitle(); DesignerFrameFileDealerPane.getInstance().refreshDockingView(); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); TemplateTreePane.getInstance().refreshDockingView(); DesignTableDataManager.clearGlobalDs(); - EastRegionContainerPane.getInstance().refreshDownPane(); - } - - /** - * 返回选中的模板. - */ - public JTemplate getSelectedJTemplate() { - return this.centerTemplateCardPane.getSelectedJTemplate(); - } - - /** - * 保存当前编辑的模板 - */ - - public void saveCurrentEditingTemplate() { - JTemplate editingTemplate = HistoryTemplateListPane.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 = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), - 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(); - FRLogger.getLogger().log( - Level.INFO, - Inter.getLocText(new String[] { "Template", "already-saved" }, new String[] { - editingTemplate.getEditingFILE().getName(), "." })); - } - } else { - if (editingTemplate.saveTemplate()) { - editingTemplate.saveTemplate(); - FRLogger.getLogger().log( - Level.INFO, - Inter.getLocText(new String[] { "Template", "already-saved" }, new String[] { - editingTemplate.getEditingFILE().getName(), "." })); - } - } - } - } - - /** - * 添加新建模板, 并激活. - */ - public void addAndActivateJTemplate() { - addAndActivateJTemplate(ad.createNewTemplate()); - layeredPane.repaint(); - } - - /** - * 添加 模板, 并激活. - * - * @param jt - * 添加的模板. - */ - public void addAndActivateJTemplate(JTemplate jt) { - if (jt == null || jt.getEditingFILE() == null) { - return; - } - jt.addJTemplateActionListener(this); - jt.addTargetModifiedListener(this); - centerTemplateCardPane.showJTemplate(jt); - setTitle(); - layeredPane.repaint(); - } - - /** - * 激活已经存在的模板 - * - * @param jt - * 模板 - */ - public void activateJTemplate(JTemplate jt) { - if (jt == null || jt.getEditingFILE() == null) { - return; - } - centerTemplateCardPane.showJTemplate(jt); - setTitle(); - layeredPane.repaint(); - } - - /** - * 对象侦听 - * - * @param e - * 事件 - */ - public void targetModified(TargetModifiedEvent e) { - this.checkToolbarMenuEnable(); - } - - /** - * 模板关闭时 处理. - * - * @param jt - * 模板 - */ - public void templateClosed(JTemplate jt) { - } - - /** - * 模板打开时 处理. - * - * @param jt - * 模板 - */ - public void templateOpened(JTemplate jt) { - } - - /** - * 模板保存时 处理. - * - * @param jt - * 模板 - */ - public void templateSaved(JTemplate jt) { - this.checkToolbarMenuEnable(); - } - - /** - * 打开模板文件,如果是已经打开的就激活此模板所对应的JInternalFrame - * - * @param tplFile - * 文件 - */ - public void openTemplate(FILE tplFile) { - // 测试连接,如果连接失败,则提示 - 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, Inter.getLocText("Warning-Template_Do_Not_Exsit"), - ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE); - DesignerFrameFileDealerPane.getInstance().refresh(); - return; - } + EastRegionContainerPane.getInstance().refreshDownPane(); + } + + /** + * 返回选中的模板. + */ + public JTemplate getSelectedJTemplate() { + return this.centerTemplateCardPane.getSelectedJTemplate(); + } + + /** + * 保存当前编辑的模板 + */ + + public void saveCurrentEditingTemplate() { + JTemplate editingTemplate = HistoryTemplateListPane.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 = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + 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(); + FRLogger.getLogger().log( + Level.INFO, + Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{ + editingTemplate.getEditingFILE().getName(), "."})); + } + } else { + if (editingTemplate.saveTemplate()) { + editingTemplate.saveTemplate(); + FRLogger.getLogger().log( + Level.INFO, + Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{ + editingTemplate.getEditingFILE().getName(), "."})); + } + } + } + } + + /** + * 添加新建模板, 并激活. + */ + public void addAndActivateJTemplate() { + addAndActivateJTemplate(ad.createNewTemplate()); + layeredPane.repaint(); + } + + /** + * 添加 模板, 并激活. + * + * @param jt 添加的模板. + */ + public void addAndActivateJTemplate(JTemplate jt) { + if (jt == null || jt.getEditingFILE() == null) { + return; + } + jt.addJTemplateActionListener(this); + jt.addTargetModifiedListener(this); + centerTemplateCardPane.showJTemplate(jt); + setTitle(); + layeredPane.repaint(); + } + + /** + * 激活已经存在的模板 + * + * @param jt 模板 + */ + public void activateJTemplate(JTemplate jt) { + if (jt == null || jt.getEditingFILE() == null) { + return; + } + centerTemplateCardPane.showJTemplate(jt); + setTitle(); + layeredPane.repaint(); + } + + /** + * 对象侦听 + * + * @param e 事件 + */ + public void targetModified(TargetModifiedEvent e) { + this.checkToolbarMenuEnable(); + } + + /** + * 模板关闭时 处理. + * + * @param jt 模板 + */ + public void templateClosed(JTemplate jt) { + } + + /** + * 模板打开时 处理. + * + * @param jt 模板 + */ + public void templateOpened(JTemplate jt) { + } + + /** + * 模板保存时 处理. + * + * @param jt 模板 + */ + public void templateSaved(JTemplate jt) { + this.checkToolbarMenuEnable(); + } + + /** + * 打开模板文件,如果是已经打开的就激活此模板所对应的JInternalFrame + * + * @param tplFile 文件 + */ + public void openTemplate(FILE tplFile) { + // 测试连接,如果连接失败,则提示 + 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, Inter.getLocText("Warning-Template_Do_Not_Exsit"), + ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE); + DesignerFrameFileDealerPane.getInstance().refresh(); + return; + } try { openFile(tplFile); @@ -844,210 +828,201 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta addAndActivateJTemplate(); } - } - - /** - * 是否不合版本的设计器 - * - * @param jt - * 当前模板 - * - * @return 是否不合版本 - * - * - * @date 2014-10-14-下午6:30:37 - */ - private boolean inValidDesigner(JTemplate jt) { - return jt.isOldDesigner() || (!jt.isJWorkBook() && jt.isNewDesigner()); - } - - /** - * 打开指定的文件 - * - * @param tplFile - * 指定的文件 - * - * - * @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) { - return; - } - String fileExtention = fileName.substring(indexOfLastDot + 1); - for (int i = 0, len = appList.size(); i < len; i++) { - App app = appList.get(i); - String[] defaultAppExtentions = app.defaultExtentions(); - boolean opened = false; - for (int j = 0; j < defaultAppExtentions.length; j++) { - if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) { - JTemplate jt = null; - try { - jt = app.openTemplate(tplFile); - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage(), e); - } - if (jt == null) { - return; - } - // 新的form不往前兼容 - if (inValidDesigner(jt)) { - this.addAndActivateJTemplate(); - MutilTempalteTabPane.getInstance().setTemTemplate( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - } else { - activeTemplate(tplFile, jt); - } - opened = true; - break; - } - } - if (opened) { - break; - } - } - } - - /** - * 激活指定的模板 - * - * @param tplFile - * 模板文件 - * @param jt - * 当前报表 - * - * - * @date 2014-10-14-下午6:31:23 - */ - private void activeTemplate(FILE tplFile, JTemplate jt) { - // 如果该模板已经打开,则进行激活就可以了 - 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 = fullName.replaceAll("/", "\\\\"); - int index = HistoryTemplateListPane.getInstance().contains(fullName); - List> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); - if (index != -1) { - historyList.get(index).activeJTemplate(index, jt); - } else { - this.addAndActivateJTemplate(jt); - } - - } - - /** - * Exit退出 - */ - public void exit() { - Thread thread = new Thread() { - @Override - public void run() { - DesignerEnvManager.doEndMapSaveWorkersIndesign(); - } - }; - thread.start(); - - try { - thread.join(); - } catch (InterruptedException e) { - FRLogger.getLogger().error("Map Thread Error"); - } - - DesignerEnvManager.getEnvManager().setLastOpenFile( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); - - DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( - WestRegionContainerPane.getInstance().getToolPaneY()); - DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth( - WestRegionContainerPane.getInstance().getContainerWidth()); - DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY( - EastRegionContainerPane.getInstance().getToolPaneY()); - DesignerEnvManager.getEnvManager().setLastEastRegionContainerWidth( - EastRegionContainerPane.getInstance().getContainerWidth()); - - DesignerEnvManager.getEnvManager().saveXMLFile(); - - Env currentEnv = FRContext.getCurrentEnv(); - try { - currentEnv.signOut(); - GeneralContext.fireEnvSignOutListener(); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - this.setVisible(false); - this.dispose(); - - this.ad.shutDown(); - - System.exit(0); - } - - // harry:添加程序外拖拽文件进来打开的功能 - class FileDropTargetListener implements DropTargetListener { - - @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; - } - } - - @SuppressWarnings("unchecked") - @Override - public void drop(DropTargetDropEvent event) { - if (!isDropAcceptable(event)) { - event.rejectDrop(); - return; - } - - event.acceptDrop(DnDConstants.ACTION_MOVE); - Transferable transferable = event.getTransferable(); - DataFlavor[] flavors = transferable.getTransferDataFlavors(); - for (int i = 0; i < flavors.length; i++) { - DataFlavor d = flavors[i]; - try { - if (ComparatorUtils.equals(d, DataFlavor.javaFileListFlavor)) { - List fileList = (List) transferable.getTransferData(d); - Iterator iterator = fileList.iterator(); - while (iterator.hasNext()) { - File f = iterator.next(); - DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f)); - } - } - } catch (Exception 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; - } - } + } + + /** + * 是否不合版本的设计器 + * + * @param jt 当前模板 + * @return 是否不合版本 + * @date 2014-10-14-下午6:30:37 + */ + private boolean inValidDesigner(JTemplate jt) { + return jt.isOldDesigner() || (!jt.isJWorkBook() && jt.isNewDesigner()); + } + + /** + * 打开指定的文件 + * + * @param tplFile 指定的文件 + * @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) { + return; + } + String fileExtention = fileName.substring(indexOfLastDot + 1); + for (int i = 0, len = appList.size(); i < len; i++) { + App app = appList.get(i); + String[] defaultAppExtentions = app.defaultExtentions(); + boolean opened = false; + for (int j = 0; j < defaultAppExtentions.length; j++) { + if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) { + JTemplate jt = null; + try { + jt = app.openTemplate(tplFile); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage(), e); + } + if (jt == null) { + return; + } + // 新的form不往前兼容 + if (inValidDesigner(jt)) { + this.addAndActivateJTemplate(); + MutilTempalteTabPane.getInstance().setTemTemplate( + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + } else { + activeTemplate(tplFile, jt); + } + opened = true; + break; + } + } + if (opened) { + break; + } + } + } + + /** + * 激活指定的模板 + * + * @param tplFile 模板文件 + * @param jt 当前报表 + * @date 2014-10-14-下午6:31:23 + */ + private void activeTemplate(FILE tplFile, JTemplate jt) { + // 如果该模板已经打开,则进行激活就可以了 + 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> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); + if (index != -1) { + historyList.get(index).activeJTemplate(index, jt); + } else { + this.addAndActivateJTemplate(jt); + } + //REPORT-5084:激活后刷新一下右側面板 + jt.refreshEastPropertiesPane(); + } + + /** + * Exit退出 + */ + public void exit() { + Thread thread = new Thread() { + @Override + public void run() { + DesignerEnvManager.doEndMapSaveWorkersIndesign(); + } + }; + thread.start(); + + try { + thread.join(); + } catch (InterruptedException e) { + FRLogger.getLogger().error("Map Thread Error"); + } + + DesignerEnvManager.getEnvManager().setLastOpenFile( + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); + + DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( + WestRegionContainerPane.getInstance().getToolPaneY()); + DesignerEnvManager.getEnvManager().setLastWestRegionContainerWidth( + WestRegionContainerPane.getInstance().getContainerWidth()); + DesignerEnvManager.getEnvManager().setLastEastRegionToolPaneY( + EastRegionContainerPane.getInstance().getToolPaneY()); + DesignerEnvManager.getEnvManager().setLastEastRegionContainerWidth( + EastRegionContainerPane.getInstance().getContainerWidth()); + + DesignerEnvManager.getEnvManager().saveXMLFile(); + + 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(); + + this.ad.shutDown(); + + System.exit(0); + } + + // harry:添加程序外拖拽文件进来打开的功能 + class FileDropTargetListener implements DropTargetListener { + + @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; + } + } + + @SuppressWarnings("unchecked") + @Override + public void drop(DropTargetDropEvent event) { + if (!isDropAcceptable(event)) { + event.rejectDrop(); + return; + } + + event.acceptDrop(DnDConstants.ACTION_MOVE); + Transferable transferable = event.getTransferable(); + DataFlavor[] flavors = transferable.getTransferDataFlavors(); + for (int i = 0; i < flavors.length; i++) { + DataFlavor d = flavors[i]; + try { + if (ComparatorUtils.equals(d, DataFlavor.javaFileListFlavor)) { + List fileList = (List) transferable.getTransferData(d); + Iterator iterator = fileList.iterator(); + while (iterator.hasNext()) { + File f = iterator.next(); + DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f)); + } + } + } catch (Exception 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; + } + } } \ No newline at end of file From b77d5e65a77353c96647751a6c9f5b3dd8ee4ace Mon Sep 17 00:00:00 2001 From: MoMeak Date: Wed, 22 Nov 2017 17:32:05 +0800 Subject: [PATCH 009/156] =?UTF-8?q?REPORT-5794=20DesignerFrame=E5=92=8CHis?= =?UTF-8?q?toryTemplateListPane=E7=9A=84=E6=94=B9=E5=8A=A8,=20release?= =?UTF-8?q?=E9=87=8C=E6=9C=89,=20feature=E9=87=8C=E6=B2=A1=E6=9C=89,=20?= =?UTF-8?q?=E5=90=88=E4=BB=A3=E7=A0=81=E5=86=B2=E7=AA=81=E4=BA=86,=20?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=89=8B=E5=8A=A8patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/mainframe/DesignerFrame.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java index 2f38d34c7e..e990470ee0 100644 --- a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java @@ -22,7 +22,6 @@ import com.fr.design.gui.imenu.UIMenuHighLight; import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.hold.DefaultTitlePlace; import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; @@ -319,9 +318,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta if (processor != null) { processor.hold(northEastPane, LogMessageBar.getInstance(), ad.createBBSLoginPane()); } - northEastPane.add(ad.createAlphafinePane()); + northEastPane.add(ad.createAlphaFinePane()); if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { - ad.createAlphafinePane().setVisible(false); + ad.createAlphaFinePane().setVisible(false); } northEastPane.add(ad.createBBSLoginPane()); } From 317be4b0d5839fdd549b05f350abde193d51a781 Mon Sep 17 00:00:00 2001 From: hzzz Date: Mon, 27 Nov 2017 15:48:38 +0800 Subject: [PATCH 010/156] =?UTF-8?q?REPORT-5508=20=E5=8A=A0=E5=9B=9E?= =?UTF-8?q?=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/ibutton/UIButtonGroup.java | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/ibutton/UIButtonGroup.java b/designer_base/src/com/fr/design/gui/ibutton/UIButtonGroup.java index 76828e38e7..d2e2b8d1d9 100644 --- a/designer_base/src/com/fr/design/gui/ibutton/UIButtonGroup.java +++ b/designer_base/src/com/fr/design/gui/ibutton/UIButtonGroup.java @@ -218,11 +218,11 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { } protected Border getGroupBorder() { - return BorderFactory.createEmptyBorder(0, 0, 0, 0); + return BorderFactory.createEmptyBorder(1, 1, 1, 1); } protected LayoutManager getGridLayout(int number) { - return new GridLayout(0, number, 0, 0); + return new GridLayout(0, number, 1, 0); } /** @@ -233,7 +233,7 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { public void paintComponents(Graphics g) { Graphics2D g2d = (Graphics2D) g; Shape oldClip = g2d.getClip(); - g2d.clip(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), UIConstants.ARC, UIConstants.ARC)); + g2d.clip(new RoundRectangle2D.Double(1, 1, getWidth(), getHeight(), UIConstants.ARC, UIConstants.ARC)); super.paintComponents(g); g2d.setClip(oldClip); } @@ -394,6 +394,34 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { fireStateChanged(); } + /** + * 重载Border画法 + * + * @param g + */ + @Override + protected void paintBorder(Graphics g) { + if (isToolBarComponent) { + return; + } + Graphics2D g2d = (Graphics2D) g; + g2d.setColor(UIConstants.SHADOW_GREY); + + int width = 0; + for (int i = 0; i < labelButtonList.size() - 1; i++) { + width += labelButtonList.get(i).getWidth() + 1; + int height = labelButtonList.get(i).getHeight(); + g.drawLine(width, 0, width, height); + } + + width += labelButtonList.get(labelButtonList.size() - 1).getWidth() + 1; + + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.drawRoundRect(0, 0, width, getHeight() - 1, UIConstants.BUTTON_GROUP_ARC, UIConstants.BUTTON_GROUP_ARC); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + + } + /** * main * From 87f264d412eeda21cc9b5eb2b1f3f964e1dd72a4 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 28 Nov 2017 16:43:44 +0800 Subject: [PATCH 011/156] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=A9=BA=E6=95=B0=E6=8D=AE=E6=8F=90=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E9=83=A8=E5=88=86=E5=92=8Cxml=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/start/Designer.java | 11 +- .../fr/design/actions/core/ActionFactory.java | 22 +- .../com/fr/design/images/chart/EmptyChart.png | Bin 0 -> 274 bytes .../com/fr/design/locale/designer.properties | 2 + .../design/locale/designer_en_US.properties | 2 + .../design/locale/designer_ja_JP.properties | 2 + .../design/locale/designer_ko_KR.properties | 2 + .../design/locale/designer_zh_CN.properties | 4 +- .../design/locale/designer_zh_TW.properties | 2 + .../fr/design/module/ChartDesignerModule.java | 1 + .../module/ChartEmptyDataStyleAction.java | 46 ++++ .../module/ChartEmptyDataStylePane.java | 211 ++++++++++++++++++ 12 files changed, 296 insertions(+), 9 deletions(-) create mode 100644 designer_base/src/com/fr/design/images/chart/EmptyChart.png create mode 100644 designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java create mode 100644 designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java diff --git a/designer/src/com/fr/start/Designer.java b/designer/src/com/fr/start/Designer.java index 2f484553a0..17c01527e7 100644 --- a/designer/src/com/fr/start/Designer.java +++ b/designer/src/com/fr/start/Designer.java @@ -45,13 +45,9 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLTools; -import javax.swing.JComponent; -import javax.swing.JPanel; +import javax.swing.*; import javax.swing.border.MatteBorder; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Insets; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; @@ -130,6 +126,9 @@ public class Designer extends BaseDesigner { if (ActionFactory.getChartPreStyleAction() != null) { menuDef.addShortCut(ActionFactory.getChartPreStyleAction()); } + if (ActionFactory.getChartEmptyDataStyleAction() != null) { + menuDef.addShortCut(ActionFactory.getChartEmptyDataStyleAction()); + } if (ActionFactory.getChartMapEditorAction() != null) { menuDef.addShortCut(ActionFactory.getChartMapEditorAction()); } diff --git a/designer_base/src/com/fr/design/actions/core/ActionFactory.java b/designer_base/src/com/fr/design/actions/core/ActionFactory.java index 7bc73acbb6..ecce774da7 100644 --- a/designer_base/src/com/fr/design/actions/core/ActionFactory.java +++ b/designer_base/src/com/fr/design/actions/core/ActionFactory.java @@ -9,8 +9,7 @@ import com.fr.design.menu.MenuKeySet; import com.fr.design.selection.QuickEditor; import com.fr.general.FRLogger; -import javax.swing.Action; -import javax.swing.KeyStroke; +import javax.swing.*; import java.awt.event.KeyEvent; import java.lang.reflect.Constructor; import java.util.ArrayList; @@ -50,6 +49,7 @@ public class ActionFactory { private static ConcurrentMap> cellEditorClass = new ConcurrentHashMap<>(); private static UpdateAction chartPreStyleAction = null; + private static UpdateAction chartEmptyDataStyleAction = null; private static UpdateAction chartMapEditorAction = null; private ActionFactory() { @@ -126,6 +126,15 @@ public class ActionFactory { chartPreStyleAction = action; } + /** + * 注册图表的 空数据提示样式. + * + * @param action 注册的图表空数据提示样式action + */ + public static void registerChartEmptyDataStyleAction(UpdateAction action) { + chartEmptyDataStyleAction = action; + } + /** * kunsnat: 图表注册 悬浮元素编辑器 , 因为ChartCollection和ChartQuickEditor一个在Chart,一个在Designer, 所以分开注册. * @@ -157,6 +166,15 @@ public class ActionFactory { return chartPreStyleAction; } + /** + * 图表空数据提示样式Action + * + * @return 图表空数据提示样式Action + */ + public static UpdateAction getChartEmptyDataStyleAction() { + return chartEmptyDataStyleAction; + } + /** * 图表编辑器Action diff --git a/designer_base/src/com/fr/design/images/chart/EmptyChart.png b/designer_base/src/com/fr/design/images/chart/EmptyChart.png new file mode 100644 index 0000000000000000000000000000000000000000..1613f98b2094ec2095381a19223e701506cf5b5d GIT binary patch literal 274 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GGLLkg|>2BR0px_Zt z7sn8b(@Q5G2KD7k;yrV8>Y|_pf%{XA z{_CpGIhuE-$JT;@Wg@#l$g@6A(`|A*2Tt=QeA)bDngl~s*`t6T%a{IY`mH-5WcIA- z%^kJ5iXBH3E{PV3yFA)2<|Wg(QebAo?^{Q&a!q@b>e z_r9KhOWuK{CeO{nCp2aUo%J+j4u5W!m^SD4y)!*hvx}eQ%RE20B2uj(?Y-50#>jVB VPVG}ULxKKb@O1TaS?83{1OVCAZo~ip literal 0 HcmV?d00001 diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index bbed62b646..405b7281ca 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2149,3 +2149,5 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect. FR-Designer_Format_JavaScript=Format Code +FR-Designer_Prompt_Content= +FR-Designer_Chart-EmptyData= diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index e5608bf896..9557b5314e 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -2148,3 +2148,5 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect. FR-Designer_Format_JavaScript=Format Code +FR-Designer_Prompt_Content= +FR-Designer_Chart-EmptyData= diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index bb5cfc1712..549edf34c2 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -2149,3 +2149,5 @@ FR-Designer_Decimal_Places=\u5C0F\u6570\u67A0\u6570: FR-Base-Load_Resource_File=\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u30ED\u30FC\u30C9 FR-Designer_Env_Des_Https= FR-Designer_Format_JavaScript=Format Code +FR-Designer_Prompt_Content= +FR-Designer_Chart-EmptyData= diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index d25124d98e..d248a0fa49 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -2149,3 +2149,5 @@ FR-Designer_Export_Background= FR-Designer_Print_Background= FR-Designer_Env_Des_Https= FR-Designer_Format_JavaScript=Format Code +FR-Designer_Prompt_Content= +FR-Designer_Chart-EmptyData= diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index f7b8d3a3cd..6e9e1b5d92 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2148,4 +2148,6 @@ FR-Designer_Sheet_Label_Page_Display_Position= FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=\u82E5\u542F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8BC1\u4E66\u8DEF\u5F84\u3001https\u79D8\u94A5\uFF09\uFF0C\u5FC5\u987B\u91CD\u542F\u8BBE\u8BA1\u5668\u624D\u80FD\u751F\u6548\u3002 -FR-Designer_Format_JavaScript=\u683C\u5F0F\u5316\u4EE3\u7801 \ No newline at end of file +FR-Designer_Format_JavaScript=\u683C\u5F0F\u5316\u4EE3\u7801 +FR-Designer_Prompt_Content=\u63D0\u793A\u5185\u5BB9 +FR-Designer_Chart-EmptyData=\u56FE\u8868\u7A7A\u6570\u636E\u63D0\u793A \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 42817879ea..29a2b9a55c 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -2148,3 +2148,5 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=\u82E5\u555F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8B49\u66F8\u8DEF\u5F91\u3001https\u7955\u9470\uFF09\uFF0C\u5FC5\u9808\u91CD\u555F\u8A2D\u8A08\u5668\u624D\u80FD\u751F\u6548\u3002 FR-Designer_Format_JavaScript=Format Code +FR-Designer_Prompt_Content= +FR-Designer_Chart-EmptyData= diff --git a/designer_chart/src/com/fr/design/module/ChartDesignerModule.java b/designer_chart/src/com/fr/design/module/ChartDesignerModule.java index 586910774a..85cb0bce78 100644 --- a/designer_chart/src/com/fr/design/module/ChartDesignerModule.java +++ b/designer_chart/src/com/fr/design/module/ChartDesignerModule.java @@ -53,6 +53,7 @@ public class ChartDesignerModule extends DesignModule { DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); + ActionFactory.registerChartEmptyDataStyleAction(new ChartEmptyDataStyleAction()); ActionFactory.registerChartMapEditorAction(new ChartMapEditorAction()); } diff --git a/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java b/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java new file mode 100644 index 0000000000..5f2d7753c7 --- /dev/null +++ b/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java @@ -0,0 +1,46 @@ +package com.fr.design.module; + +import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; +import com.fr.general.IOUtils; +import com.fr.general.Inter; + +import java.awt.event.ActionEvent; + +/** + * Created by mengao on 2017/11/23. + * 空数据配置action + */ +public class ChartEmptyDataStyleAction extends UpdateAction { + + public ChartEmptyDataStyleAction() { + this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/chart/EmptyChart.png")); + this.setName(Inter.getLocText("FR-Designer_Chart-EmptyData")); + } + + @Override + public void actionPerformed(ActionEvent e) { + DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + final ChartEmptyDataStylePane pane = new ChartEmptyDataStylePane(); + BasicDialog dialog = pane.showWindow(designerFrame); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + pane.updateBean(); + + } + + @Override + public void doCancel() { + + } + }); + + pane.populateBean(); + dialog.setVisible(true); + } + +} diff --git a/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java b/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java new file mode 100644 index 0000000000..b5c5911b15 --- /dev/null +++ b/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java @@ -0,0 +1,211 @@ +package com.fr.design.module; + +import com.fr.base.BaseUtils; +import com.fr.base.ChartEmptyDataStyleManagerProvider; +import com.fr.base.ChartEmptyDataStyleServerManager; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.stable.CoreGraphHelper; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +/** + * Created by mengao on 2017/11/23. + */ +public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { + + private UIButtonGroup emptyData; + private UIRadioButton defaultRadioButton; + private UIRadioButton customRadioButton; + private UIButton selectPictureButton; + + private ImagePreviewPane previewPane; + private ImageFileChooser imageFileChooser; + + private Image emptyDataImage= null; + + + @Override + protected JPanel createContentPane() { + JPanel content = new JPanel(new BorderLayout()); + content.add(creatNorthPane(), BorderLayout.NORTH); + content.add(creatCenterPane(), BorderLayout.CENTER); + return content; + } + + private JPanel creatNorthPane() { + emptyData = new UIButtonGroup(new String[]{Inter.getLocText("Plugin-ChartF_Open"), Inter.getLocText("Plugin-ChartF_Close")}); + emptyData.setSelectedIndex(0); + emptyData.setPreferredSize(new Dimension(150, 20)); + emptyData.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkEmptyDataStyle(); + } + }); + + UILabel promptContent = new UILabel(Inter.getLocText("FR-Designer_Prompt_Content")); + JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, 15, 0); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + return northPane; + } + + private JPanel creatCenterPane() { + JPanel centerPane = new JPanel(FRGUIPaneFactory.createBorderLayout()); + + // preview pane + JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + centerPane.add(previewContainerPane, BorderLayout.CENTER); + + JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Preview")); + previewOwnerPane.setLayout(new BorderLayout()); + previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER); + previewContainerPane.add(initSelectFilePane(), BorderLayout.EAST); + previewPane = new ImagePreviewPane(); + previewOwnerPane.add(new JScrollPane(previewPane)); + + + // init image file chooser. + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + return centerPane; + } + + public JPanel initSelectFilePane() { + + JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + + selectFilePane.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 30)); + + defaultRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_DEFAULT")); + customRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer-Widget-Style_Custom")); + ButtonGroup buttonGroup = new ButtonGroup(); + defaultRadioButton.setSelected(true); + buttonGroup.add(defaultRadioButton); + buttonGroup.add(customRadioButton); + + defaultRadioButton.addActionListener(getLayoutActionListener()); + customRadioButton.addActionListener(getLayoutActionListener()); + + JPanel jp = new JPanel(new GridLayout(3, 1, 0, 10)); + jp.add(defaultRadioButton); + jp.add(customRadioButton); + + selectPictureButton = new UIButton( + Inter.getLocText("FR-Designer_Background_Image_Select")); + selectPictureButton.addActionListener(getSelectPictureActionListener()); + jp.add(selectPictureButton); + + + selectFilePane.add(jp, BorderLayout.NORTH); + return selectFilePane; + } + + private ActionListener getLayoutActionListener() { + return new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + checkCustomImage(); + changeEmptyDataStyle(); + } + + private void changeEmptyDataStyle() { + previewPane.repaint(); + } + }; + } + + /** + * Select picture. + */ + private ActionListener getSelectPictureActionListener() { + return new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + int returnVal = imageFileChooser.showOpenDialog(ChartEmptyDataStylePane.this); + if (returnVal != JFileChooser.CANCEL_OPTION) { + File selectedFile = imageFileChooser.getSelectedFile(); + + if (selectedFile != null && selectedFile.isFile()) { + emptyDataImage = BaseUtils.readImage(selectedFile.getPath()); + CoreGraphHelper.waitForImage(emptyDataImage); + + previewPane.setImage(emptyDataImage); + previewPane.repaint(); + } else { + previewPane.setImage(null); + } + } + + } + }; + } + + private void checkEmptyDataStyle() { + boolean b = emptyData.getSelectedIndex() == 0; + defaultRadioButton.setEnabled(b); + customRadioButton.setEnabled(b); + selectPictureButton.setEnabled(b); + } + + private void checkCustomImage() { + selectPictureButton.setVisible(customRadioButton.isSelected()); + } + + @Override + public String getIconPath() { + return StringUtils.EMPTY; + } + + @Override + public String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Chart-EmptyData"); + } + + public void populateBean() { + ChartEmptyDataStyleManagerProvider manager = ChartEmptyDataStyleServerManager.getProviderInstance(); + emptyData.setSelectedIndex(manager.isOpenEmptyDataStyle() == true ? 0 : 1); + customRadioButton.setSelected(manager.isCustomEmptyDataStyle()); + emptyDataImage = manager.getEmptyDataImage(); + + checkEmptyDataStyle(); + checkCustomImage(); + previewPane.setImage(emptyDataImage); + previewPane.repaint(); + } + + public void updateBean() { + ChartEmptyDataStyleManagerProvider manager = ChartEmptyDataStyleServerManager.getProviderInstance(); + + manager.setOpenEmptyDataStyle(emptyData.getSelectedIndex() == 0); + manager.setCustomEmptyDataStyle(customRadioButton.isSelected()); + manager.setEmptyDataImage(emptyDataImage); + + try { + manager.writeResource(); + } catch (Exception e) { + e.printStackTrace(); + } + + // 通知报表整个刷新. + DesignerFrame frame = DesignerContext.getDesignerFrame(); + if (frame != null) { + frame.repaint(); + } + } +} From 930767eab369386c7fb7b58db1ff389565a691a4 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 28 Nov 2017 16:53:01 +0800 Subject: [PATCH 012/156] =?UTF-8?q?=E7=A9=BA=E6=95=B0=E6=8D=AE=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/locale/designer.properties | 4 ++-- .../src/com/fr/design/locale/designer_en_US.properties | 4 ++-- .../src/com/fr/design/locale/designer_ja_JP.properties | 4 ++-- .../src/com/fr/design/locale/designer_ko_KR.properties | 4 ++-- .../src/com/fr/design/locale/designer_zh_CN.properties | 4 ++-- .../src/com/fr/design/locale/designer_zh_TW.properties | 4 ++-- .../src/com/fr/design/module/ChartEmptyDataStyleAction.java | 2 +- .../src/com/fr/design/module/ChartEmptyDataStylePane.java | 6 +++--- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 405b7281ca..d66a1206ef 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2149,5 +2149,5 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect. FR-Designer_Format_JavaScript=Format Code -FR-Designer_Prompt_Content= -FR-Designer_Chart-EmptyData= +FR-Designer_Tip_Content= +FR-Designer_Chart_Empty_Data= diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 9557b5314e..4f4e40aab3 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -2148,5 +2148,5 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=If HTTPS is enabled or the HTTPS configuration (certificate path, HTTPS key) is modified, you must restart the designer to take effect. FR-Designer_Format_JavaScript=Format Code -FR-Designer_Prompt_Content= -FR-Designer_Chart-EmptyData= +FR-Designer_Tip_Content= +FR-Designer_Chart_Empty_Data= diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 549edf34c2..24ac12b1a8 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -2149,5 +2149,5 @@ FR-Designer_Decimal_Places=\u5C0F\u6570\u67A0\u6570: FR-Base-Load_Resource_File=\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u30ED\u30FC\u30C9 FR-Designer_Env_Des_Https= FR-Designer_Format_JavaScript=Format Code -FR-Designer_Prompt_Content= -FR-Designer_Chart-EmptyData= +FR-Designer_Tip_Content= +FR-Designer_Chart_Empty_Data= diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index d248a0fa49..85cadabbce 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -2149,5 +2149,5 @@ FR-Designer_Export_Background= FR-Designer_Print_Background= FR-Designer_Env_Des_Https= FR-Designer_Format_JavaScript=Format Code -FR-Designer_Prompt_Content= -FR-Designer_Chart-EmptyData= +FR-Designer_Tip_Content= +FR-Designer_Chart_Empty_Data= diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 6e9e1b5d92..c3d491d2de 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2149,5 +2149,5 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=\u82E5\u542F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8BC1\u4E66\u8DEF\u5F84\u3001https\u79D8\u94A5\uFF09\uFF0C\u5FC5\u987B\u91CD\u542F\u8BBE\u8BA1\u5668\u624D\u80FD\u751F\u6548\u3002 FR-Designer_Format_JavaScript=\u683C\u5F0F\u5316\u4EE3\u7801 -FR-Designer_Prompt_Content=\u63D0\u793A\u5185\u5BB9 -FR-Designer_Chart-EmptyData=\u56FE\u8868\u7A7A\u6570\u636E\u63D0\u793A \ No newline at end of file +FR-Designer_Tip_Content=\u63D0\u793A\u5185\u5BB9 +FR-Designer_Chart_Empty_Data=\u56FE\u8868\u7A7A\u6570\u636E\u63D0\u793A \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 29a2b9a55c..65d138d567 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -2148,5 +2148,5 @@ FR-Designer_Provide_Choose_All= FR-Designer_Decimal_Places= FR-Designer_Env_Des_Https=\u82E5\u555F\u7528https\u6216\u4FEE\u6539https\u914D\u7F6E\uFF08\u8B49\u66F8\u8DEF\u5F91\u3001https\u7955\u9470\uFF09\uFF0C\u5FC5\u9808\u91CD\u555F\u8A2D\u8A08\u5668\u624D\u80FD\u751F\u6548\u3002 FR-Designer_Format_JavaScript=Format Code -FR-Designer_Prompt_Content= -FR-Designer_Chart-EmptyData= +FR-Designer_Tip_Content= +FR-Designer_Chart_Empty_Data= diff --git a/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java b/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java index 5f2d7753c7..04213480b2 100644 --- a/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java +++ b/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java @@ -18,7 +18,7 @@ public class ChartEmptyDataStyleAction extends UpdateAction { public ChartEmptyDataStyleAction() { this.setSmallIcon(IOUtils.readIcon("com/fr/design/images/chart/EmptyChart.png")); - this.setName(Inter.getLocText("FR-Designer_Chart-EmptyData")); + this.setName(Inter.getLocText("FR-Designer_Chart_Empty_Data")); } @Override diff --git a/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java b/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java index b5c5911b15..f817558e33 100644 --- a/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java +++ b/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java @@ -37,7 +37,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { private ImagePreviewPane previewPane; private ImageFileChooser imageFileChooser; - private Image emptyDataImage= null; + private Image emptyDataImage = null; @Override @@ -59,7 +59,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { } }); - UILabel promptContent = new UILabel(Inter.getLocText("FR-Designer_Prompt_Content")); + UILabel promptContent = new UILabel(Inter.getLocText("FR-Designer_Tip_Content")); JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, 15, 0); northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); return northPane; @@ -174,7 +174,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { @Override public String title4PopupWindow() { - return Inter.getLocText("FR-Designer_Chart-EmptyData"); + return Inter.getLocText("FR-Designer_Chart_Empty_Data"); } public void populateBean() { From 24fdae75ead931847680872723698247566d1dd5 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 28 Nov 2017 20:06:44 +0800 Subject: [PATCH 013/156] =?UTF-8?q?=E4=BF=AE=E6=94=B9pmd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/ChartEmptyDataStyleAction.java | 2 +- .../module/ChartEmptyDataStylePane.java | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java b/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java index 04213480b2..7c6bdb0959 100644 --- a/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java +++ b/designer_chart/src/com/fr/design/module/ChartEmptyDataStyleAction.java @@ -35,7 +35,7 @@ public class ChartEmptyDataStyleAction extends UpdateAction { @Override public void doCancel() { - + //直接关闭弹出框 } }); diff --git a/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java b/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java index f817558e33..0c8f239277 100644 --- a/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java +++ b/designer_chart/src/com/fr/design/module/ChartEmptyDataStylePane.java @@ -14,6 +14,7 @@ import com.fr.design.mainframe.DesignerFrame; import com.fr.design.style.background.image.ImageFileChooser; import com.fr.design.style.background.image.ImagePreviewPane; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.CoreGraphHelper; import com.fr.stable.StringUtils; @@ -28,6 +29,12 @@ import java.io.File; * Created by mengao on 2017/11/23. */ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { + private static final int WIDTH =150; + private static final int HEIGHT =20; + private static final int FIVE =5; + private static final int TEN =10; + private static final int THIRTY =30; + private UIButtonGroup emptyData; private UIRadioButton defaultRadioButton; @@ -51,7 +58,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { private JPanel creatNorthPane() { emptyData = new UIButtonGroup(new String[]{Inter.getLocText("Plugin-ChartF_Open"), Inter.getLocText("Plugin-ChartF_Close")}); emptyData.setSelectedIndex(0); - emptyData.setPreferredSize(new Dimension(150, 20)); + emptyData.setPreferredSize(new Dimension(WIDTH, HEIGHT)); emptyData.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -60,8 +67,8 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { }); UILabel promptContent = new UILabel(Inter.getLocText("FR-Designer_Tip_Content")); - JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, 15, 0); - northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, TEN, 0); + northPane.setBorder(BorderFactory.createEmptyBorder(0, FIVE, 0, 0)); return northPane; } @@ -90,7 +97,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane(); - selectFilePane.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 30)); + selectFilePane.setBorder(BorderFactory.createEmptyBorder(TEN, FIVE, 0, THIRTY)); defaultRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_DEFAULT")); customRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer-Widget-Style_Custom")); @@ -102,7 +109,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { defaultRadioButton.addActionListener(getLayoutActionListener()); customRadioButton.addActionListener(getLayoutActionListener()); - JPanel jp = new JPanel(new GridLayout(3, 1, 0, 10)); + JPanel jp = new JPanel(new GridLayout(3, 1, 0, TEN)); jp.add(defaultRadioButton); jp.add(customRadioButton); @@ -199,7 +206,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane { try { manager.writeResource(); } catch (Exception e) { - e.printStackTrace(); + FRLogger.getLogger().error(e.getMessage()); } // 通知报表整个刷新. From 791cd851ba57592ced01197ea95d3b6d01715d44 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Wed, 29 Nov 2017 10:24:36 +0800 Subject: [PATCH 014/156] =?UTF-8?q?REPORT-5695=20[9.0=E4=B8=89=E8=BD=AE?= =?UTF-8?q?=E5=9B=9E=E5=BD=92][8.0]=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E5=90=8E=EF=BC=8C=E6=8A=A5=E8=A1=A8=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/gui/itoolbar/UIToolbar.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/itoolbar/UIToolbar.java b/designer_base/src/com/fr/design/gui/itoolbar/UIToolbar.java index 76be047056..758537c186 100644 --- a/designer_base/src/com/fr/design/gui/itoolbar/UIToolbar.java +++ b/designer_base/src/com/fr/design/gui/itoolbar/UIToolbar.java @@ -5,7 +5,6 @@ import java.awt.*; import java.util.ArrayList; public class UIToolbar extends JToolBar { - private static final int TOOLBAR_HEIGNT = 26; public UIToolbar() { this(FlowLayout.LEFT); @@ -24,13 +23,6 @@ public class UIToolbar extends JToolBar { this(align, new UIToolBarUI()); } - @Override - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.height = TOOLBAR_HEIGNT; - return dim; - } - public void checkComponentsByNames(boolean flag, ArrayList names) { for (int i = 0; i < getComponentCount(); i++) { Component component = getComponents()[i]; From 854ad41fd029dd07ecad84f746bd6ddddb625fc9 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Wed, 29 Nov 2017 11:17:35 +0800 Subject: [PATCH 015/156] =?UTF-8?q?REPORT-5508=20=E5=8A=A0=E5=9B=9E?= =?UTF-8?q?=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/cell/settingpane/style/CustomStylePane.java | 3 +++ .../src/com/fr/design/gui/ibutton/UIToggleButton.java | 1 + 2 files changed, 4 insertions(+) diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java index 06b8cb937b..0f6d385205 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java @@ -4,6 +4,7 @@ import com.fr.base.CellBorderStyle; import com.fr.base.NameStyle; import com.fr.base.Style; import com.fr.design.actions.utils.ReportActionUtils; +import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.MultiTabPane; import com.fr.design.gui.style.*; @@ -12,6 +13,7 @@ import com.fr.design.style.BorderUtils; import com.fr.general.Inter; import com.fr.stable.Constants; +import javax.swing.*; import javax.swing.event.ChangeListener; import java.awt.*; import java.util.ArrayList; @@ -38,6 +40,7 @@ public class CustomStylePane extends MultiTabPane