neil 7 years ago
parent
commit
b86a13892e
  1. 93
      designer_base/src/com/fr/design/file/HistoryTemplateListPane.java

93
designer_base/src/com/fr/design/file/HistoryTemplateListPane.java

@ -1,20 +1,32 @@
package com.fr.design.file; package com.fr.design.file;
import com.fr.base.FRContext; import java.awt.*;
import com.fr.base.chart.chartdata.CallbackEvent; import java.awt.event.MouseAdapter;
import com.fr.dav.LocalEnv; import java.awt.event.MouseEvent;
import com.fr.design.DesignModelAdapter; import java.util.*;
import com.fr.design.DesignerEnvManager; import java.util.List;
import java.util.logging.Level;
import javax.swing.*;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager; 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.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.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ilist.UIList; import com.fr.design.gui.ilist.UIList;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
@ -22,19 +34,11 @@ import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.design.utils.gui.GUIPaintUtils;
import javax.swing.*; public class HistoryTemplateListPane extends JPanel implements FileOperations {
import javax.swing.event.ListSelectionEvent; //最大保存内存中面板数,为0时关闭优化内存
import javax.swing.event.ListSelectionListener; private static final int DEAD_LINE = 5;
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{
private static final int LIST_BORDER = 4; private static final int LIST_BORDER = 4;
private List<JTemplate<?, ?>> historyList; private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate; 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() { public JTemplate<?, ?> getCurrentEditingTemplate() {
return this.editingTemplate; return this.editingTemplate;
} }
@ -227,10 +258,6 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
return ComparatorUtils.equals(filename, editingFileName); return ComparatorUtils.equals(filename, editingFileName);
} }
@Override
public void callback() {
getCurrentEditingTemplate().repaint();
}
private class HistoryListCellRender extends DefaultListCellRenderer { private class HistoryListCellRender extends DefaultListCellRenderer {
@ -284,10 +311,30 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
public void add(JTemplate<?, ?> jt) { public void add(JTemplate<?, ?> jt) {
historyList.add(jt); historyList.add(jt);
closeOverLineTemplate();
refresh(); 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);
}
/** /**
* 刷新 * 刷新
*/ */

Loading…
Cancel
Save