Browse Source

Merge pull request #1477 in BA/design from ~MOMEAK/design9.0:feature/9.0 to feature/9.0

* commit '1b4555722e96916c225c09f7e9c660ce5b51ef1b':
  REPORT-5033 PMD
  PMD
  REPORT-5033 设计器打开模板内存优化.
master
superman 7 years ago
parent
commit
44c8b9d4c2
  1. 2
      designer_base/src/com/fr/design/designer/TargetComponent.java
  2. 50
      designer_base/src/com/fr/design/file/HistoryTemplateListPane.java
  3. 11
      designer_base/src/com/fr/design/file/MutilTempalteTabPane.java
  4. 3
      designer_base/src/com/fr/design/mainframe/DesignerFrame.java
  5. 37
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  6. 271
      designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java
  7. 1
      designer_form/src/com/fr/design/mainframe/JForm.java

2
designer_base/src/com/fr/design/designer/TargetComponent.java

@ -22,6 +22,8 @@ public abstract class TargetComponent<T> extends JComponent {
this.target = t;
}
public TargetComponent() {}
// TODO ALEX_SEP JWorkBook不想有copy, paste, cut的操作,怎么办?
public abstract void copy();

50
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<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;
@ -124,6 +127,33 @@ 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 void selectedReportToVirtual(int i) {
closeOverLineTemplate();
}
public JTemplate<?, ?> getCurrentEditingTemplate() {
return this.editingTemplate;
}
@ -281,10 +311,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.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) {
historyList.get(i).closeOverLineTemplate(i);
}
}
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
}
/**
* 刷新
*/

11
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,12 +220,10 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
templates[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
selectedIndex = index;
DesignerContext.getDesignerFrame().addAndActivateJTemplate(tem);
tem.activeNewJTemplate();
}
});
}
return templates;
}
@ -672,7 +671,8 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
this.repaint();
return;
}
DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(getTemplateIndex(evtX)));
JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX));
evtXTemplate.activeNewJTemplate();
}
isShowList = false;
}
@ -779,7 +779,8 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
//如果关闭的模板不是当前选中的模板,则激活的模板不变
selectedIndex = HistoryTemplateListPane.getInstance().contains(fileName);
}
DesignerContext.getDesignerFrame().activateJTemplate(openedTemplate.get(selectedIndex));
//如果是已后台关闭的模板,则重新打开文件
openedTemplate.get(selectedIndex).activeOldJTemplate();
}
}

3
designer_base/src/com/fr/design/mainframe/DesignerFrame.java

@ -933,8 +933,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
fullName = fullName.replaceAll("/", "\\\\");
int index = HistoryTemplateListPane.getInstance().contains(fullName);
List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList();
if (index != -1) {
this.activateJTemplate(HistoryTemplateListPane.getInstance().getHistoryList().get(index));
historyList.get(index).activeJTemplate(index, jt);
} else {
this.addAndActivateJTemplate(jt);
}

37
designer_base/src/com/fr/design/mainframe/JTemplate.java

@ -83,6 +83,8 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> 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,41 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
*/
public abstract boolean isJWorkBook();
/**
* 激活指定的template
*
*/
public void activeJTemplate(int index, JTemplate jt) {
DesignerContext.getDesignerFrame().activateJTemplate(this);
};
/**
* 激活已存在的模板
*
*/
public void activeOldJTemplate() {
DesignerContext.getDesignerFrame().activateJTemplate(this);
};
/**
* 激活新的模板
*
*/
public void activeNewJTemplate() {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(this);
};
/**
* 后台关闭template
*
*/
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
* @return 超链连接界面

271
designer_base/src/com/fr/design/mainframe/JVirtualTemplate.java

@ -0,0 +1,271 @@
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;
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.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
* 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;
}
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 void activeJTemplate(int index, JTemplate jt) {
List<JTemplate<?, ?>> 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
public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) {
return null;
}
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) {
}
}

1
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;

Loading…
Cancel
Save