From 5594cd8a116478cb05c88c99913ba67139aacc87 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Wed, 22 Nov 2017 09:58:09 +0800 Subject: [PATCH] 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())); } /**