Browse Source

Merge pull request #225 in DESIGN/design from ~RINOUX/design:release/10.0 to release/10.0

* commit '28298be0d6f8758495f9cafa28282486e7514c6c':
  method name
  REPORT-9668&REPORT-9656 切换环境恢复最近打开
master
rinoux 6 years ago
parent
commit
b2842c137f
  1. 99
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 2
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  3. 4
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  4. 10
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java
  5. 2
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  6. 20
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  7. 4
      designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java
  8. 4
      designer-base/src/main/java/com/fr/file/FILEFactory.java

99
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -52,6 +52,7 @@ import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -75,7 +76,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private Rectangle windowBounds = null; // window bounds. private Rectangle windowBounds = null; // window bounds.
private String DialogCurrentDirectory = null; private String DialogCurrentDirectory = null;
private String CurrentDirectoryPrefix = null; private String CurrentDirectoryPrefix = null;
private List<String> recentOpenedFilePathList = new ArrayList<String>(); private Map<String, List<String>> recentOpenedFileListMap = new HashMap<>();
private List<String> tempRecentOpenedFilePathList = new ArrayList<String>();
private boolean showPaintToolBar = true; private boolean showPaintToolBar = true;
private int maxNumberOrPreviewRow = 200; private int maxNumberOrPreviewRow = 200;
// name和Env的键值对 // name和Env的键值对
@ -193,7 +195,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
return designerEnvManager; return designerEnvManager;
} }
public ColorSelectConfigManager getColorConfigManager(){ public ColorSelectConfigManager getColorConfigManager() {
return this.configManager; return this.configManager;
} }
@ -201,7 +203,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (designerEnvManager == null || designerEnvManager.nameEnvMap.size() > 0) { if (designerEnvManager == null || designerEnvManager.nameEnvMap.size() > 0) {
return; return;
} }
String installHome = StableUtils.getInstallHome(); String installHome = StableUtils.getInstallHome();
if (installHome != null && !".".equals(installHome)) { if (installHome != null && !".".equals(installHome)) {
String name = Inter.getLocText("FR-Engine_DEFAULT"); String name = Inter.getLocText("FR-Engine_DEFAULT");
String envPath = designerEnvManager.getDefaultenvPath(installHome); String envPath = designerEnvManager.getDefaultenvPath(installHome);
@ -339,7 +341,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
// 清空前一个版本中的工作目录和最近打开 // 清空前一个版本中的工作目录和最近打开
nameEnvMap = new ListMap<String, DesignerWorkspaceInfo>(); nameEnvMap = new ListMap<String, DesignerWorkspaceInfo>();
recentOpenedFilePathList = new ArrayList<String>();
curEnvName = null; curEnvName = null;
designerEnvManager.saveXMLFile(); designerEnvManager.saveXMLFile();
} }
@ -533,10 +534,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
private String getDefaultenvPath(String installHome){ private String getDefaultenvPath(String installHome) {
//这里需要转成反斜杠和生成默认路径一致 //这里需要转成反斜杠和生成默认路径一致
return new File(StableUtils.pathJoin(installHome, WEB_NAME, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME)).getPath(); return new File(StableUtils.pathJoin(installHome, WEB_NAME, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME)).getPath();
} }
/** /**
* 设置当前环境为默认 * 设置当前环境为默认
*/ */
@ -825,7 +827,17 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* 返回最近打开的文件路径列表 * 返回最近打开的文件路径列表
*/ */
public List<String> getRecentOpenedFilePathList() { public List<String> getRecentOpenedFilePathList() {
return this.recentOpenedFilePathList;
if (StringUtils.isEmpty(getCurEnvName())) {
return tempRecentOpenedFilePathList;
} else {
if (!recentOpenedFileListMap.containsKey(getCurEnvName())) {
recentOpenedFileListMap.put(getCurEnvName(), tempRecentOpenedFilePathList);
}
}
return recentOpenedFileListMap.get(getCurEnvName());
} }
/** /**
@ -835,11 +847,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
*/ */
public void addRecentOpenedFilePath(String filePath) { public void addRecentOpenedFilePath(String filePath) {
// 先删除. // 先删除.
if (this.recentOpenedFilePathList.contains(filePath)) { if (getRecentOpenedFilePathList().contains(filePath)) {
this.recentOpenedFilePathList.remove(filePath); getRecentOpenedFilePathList().remove(filePath);
} }
this.recentOpenedFilePathList.add(0, filePath); getRecentOpenedFilePathList().add(0, filePath);
checkRecentOpenedFileNum(); checkRecentOpenedFileNum();
} }
@ -850,19 +862,21 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @param newPath 新的路径 * @param newPath 新的路径
*/ */
public void replaceRecentOpenedFilePath(String oldPath, String newPath) { public void replaceRecentOpenedFilePath(String oldPath, String newPath) {
if (this.recentOpenedFilePathList.contains(oldPath)) { List<String> list = getRecentOpenedFilePathList();
int index = recentOpenedFilePathList.indexOf(oldPath); if (list.contains(oldPath)) {
this.recentOpenedFilePathList.remove(oldPath); int index = getRecentOpenedFilePathList().indexOf(oldPath);
this.recentOpenedFilePathList.add(index, newPath); list.remove(oldPath);
list.add(index, newPath);
} }
} }
private void checkRecentOpenedFileNum() { private void checkRecentOpenedFileNum() {
if (this.recentOpenedFilePathList == null) { List<String> list = getRecentOpenedFilePathList();
if (list == null) {
return; return;
} }
while (this.recentOpenedFilePathList.size() > MAX_SHOW_NUM) { while (list.size() > MAX_SHOW_NUM) {
this.recentOpenedFilePathList.remove(this.recentOpenedFilePathList.size() - 1); list.remove(list.size() - 1);
} }
} }
@ -872,8 +886,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @param filePath 文件路径 * @param filePath 文件路径
*/ */
public void removeRecentOpenedFilePath(String filePath) { public void removeRecentOpenedFilePath(String filePath) {
if (this.recentOpenedFilePathList.contains(filePath)) { if (getRecentOpenedFilePathList().contains(filePath)) {
this.recentOpenedFilePathList.remove(filePath); getRecentOpenedFilePathList().remove(filePath);
} }
} }
@ -1311,7 +1325,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
} }
private void readRecentColor(XMLableReader reader){ private void readRecentColor(XMLableReader reader) {
reader.readXMLObject(this.configManager); reader.readXMLObject(this.configManager);
} }
@ -1332,7 +1346,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.readAttributes(reader); this.readAttributes(reader);
} else if (name.equals("ReportPaneAttributions")) { } else if (name.equals("ReportPaneAttributions")) {
this.readReportPaneAttributions(reader); this.readReportPaneAttributions(reader);
} else if ("RecentOpenedFilePathList".equals(name) || "ResentOpenedFilePathList".equals(name)) { } else if ("RecentOpenedFilePath".equals(name)) {
this.readRecentOpenFileList(reader); this.readRecentOpenFileList(reader);
} else if ("EnvConfigMap".equals(name)) { } else if ("EnvConfigMap".equals(name)) {
this.readEnvConfigMap(reader); this.readEnvConfigMap(reader);
@ -1368,8 +1382,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
readAlphaFineAttr(reader); readAlphaFineAttr(reader);
} else if (name.equals("RecentColors")) { } else if (name.equals("RecentColors")) {
readRecentColor(reader); readRecentColor(reader);
} } else {
else {
readLayout(reader, name); readLayout(reader, name);
} }
} }
@ -1518,21 +1531,32 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void readRecentOpenFileList(XMLableReader reader) { private void readRecentOpenFileList(XMLableReader reader) {
reader.readXMLObject(new XMLReadable() { reader.readXMLObject(new XMLReadable() {
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isAttr()) { if (reader.isAttr()) {
DesignerEnvManager.this.recentOpenedFilePathList.clear(); DesignerEnvManager.this.recentOpenedFileListMap.clear();
} }
if (reader.isChildNode()) { if (reader.isChildNode()) {
String tmpVal;
String name = reader.getTagName(); String name = reader.getTagName();
// alex:以前一直是写ResentOpenedFilePath if ("Env".equals(name)) {
if ("ResentOpenedFilePath".equals(name) || "Path".equals(name)) { // description. final String envName = reader.getAttrAsString("name", StringUtils.EMPTY);
if ((tmpVal = reader.getElementValue()) != null) { final List<String> recentOpenedFileList = new ArrayList<>();
DesignerEnvManager.this.recentOpenedFilePathList.add(tmpVal); reader.readXMLObject(new XMLReadable() {
} @Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
String n = reader.getTagName();
if ("Path".equals(n)) {
String path = reader.getElementValue();
if (StringUtils.isNotEmpty(path)) {
recentOpenedFileList.add(path);
}
}
}
}
});
DesignerEnvManager.this.recentOpenedFileListMap.put(envName, recentOpenedFileList);
} }
} }
} }
@ -1623,10 +1647,15 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void writeRecentOpenFileAndEnvList(XMLPrintWriter writer) { private void writeRecentOpenFileAndEnvList(XMLPrintWriter writer) {
checkRecentOpenedFileNum(); checkRecentOpenedFileNum();
writer.startTAG("RecentOpenedFilePathList"); writer.startTAG("RecentOpenedFilePath");
int resentOpenedFilePathCount = Math.min(12, this.recentOpenedFilePathList.size()); for (Entry<String, List<String>> entry : recentOpenedFileListMap.entrySet()) {
for (int i = 0; i < resentOpenedFilePathCount; i++) { writer.startTAG("Env").attr("name", entry.getKey());
writer.startTAG("Path").textNode(recentOpenedFilePathList.get(i)).end(); List<String> paths = entry.getValue();
int count = Math.min(12, paths.size());
for (int i = 0; i < count; i++) {
writer.startTAG("Path").textNode(paths.get(i)).end();
}
writer.end();
} }
writer.end(); writer.end();

2
designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java

@ -38,7 +38,7 @@ public class SwitchExistEnv extends MenuDef {
JTemplate<?, ?> t = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> t = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (t != null) { if (t != null) {
GeneralContext.addEnvWillChangedListener( GeneralContext.addEnvWillChangedListener(
t.getFullPathName(), t.getPath(),
new EnvChangedListener() { new EnvChangedListener() {
public void envChanged() { public void envChanged() {
SwitchExistEnv.this.clearShortCuts(); SwitchExistEnv.this.clearShortCuts();

4
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -105,7 +105,7 @@ public abstract class DesignTableDataManager {
public static void closeTemplate(JTemplate<?, ?> template) { public static void closeTemplate(JTemplate<?, ?> template) {
if (template != null) { if (template != null) {
dsListenersMap.remove(template.getFullPathName()); dsListenersMap.remove(template.getPath());
} }
} }
@ -164,7 +164,7 @@ public abstract class DesignTableDataManager {
JTemplate<?, ?> template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
String key = StringUtils.EMPTY; String key = StringUtils.EMPTY;
if (template != null) { if (template != null) {
key = template.getFullPathName(); key = template.getPath();
} }
List<ChangeListener> dsListeners = dsListenersMap.get(key); List<ChangeListener> dsListeners = dsListenersMap.get(key);
if (dsListeners == null) { if (dsListeners == null) {

10
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java

@ -114,7 +114,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
public void closeSelectedReport(JTemplate<?, ?> selected) { public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane(); DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected); DesignTableDataManager.closeTemplate(selected);
GeneralContext.removeEnvWillChangedListener(selected.getFullPathName()); GeneralContext.removeEnvWillChangedListener(selected.getPath());
if (contains(selected) == -1) { if (contains(selected) == -1) {
return; return;
} }
@ -139,7 +139,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
public void closeVirtualSelectedReport(JTemplate<?, ?> selected) { public void closeVirtualSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane(); DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected); DesignTableDataManager.closeTemplate(selected);
GeneralContext.removeEnvWillChangedListener(selected.getFullPathName()); GeneralContext.removeEnvWillChangedListener(selected.getPath());
if (contains(selected) == -1) { if (contains(selected) == -1) {
return; return;
} }
@ -185,7 +185,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
if (editingTemplate == null) { if (editingTemplate == null) {
return; return;
} }
DesignerEnvManager.getEnvManager().addRecentOpenedFilePath(editingTemplate.getFullPathName()); DesignerEnvManager.getEnvManager().addRecentOpenedFilePath(editingTemplate.getPath());
((HistoryListDataMode) list.getModel()).add(editingTemplate); ((HistoryListDataMode) list.getModel()).add(editingTemplate);
} }
@ -246,7 +246,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
*/ */
public int contains(String filename) { public int contains(String filename) {
for (int i = 0; i < historyList.size(); i++) { for (int i = 0; i < historyList.size(); i++) {
String historyPath = historyList.get(i).getFullPathName(); String historyPath = historyList.get(i).getPath();
if (ComparatorUtils.equals(historyPath, filename)) { if (ComparatorUtils.equals(historyPath, filename)) {
return i; return i;
} }
@ -261,7 +261,7 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations, C
* @return 是则返回TRUE * @return 是则返回TRUE
*/ */
public boolean isCurrentEditingFile(String filename) { public boolean isCurrentEditingFile(String filename) {
String editingFileName = editingTemplate.getFullPathName(); String editingFileName = editingTemplate.getPath();
return ComparatorUtils.equals(filename, editingFileName); return ComparatorUtils.equals(filename, editingFileName);
} }

2
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -218,7 +218,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1); MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1);
} }
JTemplate selectedfile = MutilTempalteTabPane.getInstance().getSelectedFile(); JTemplate selectedfile = MutilTempalteTabPane.getInstance().getSelectedFile();
if (!HistoryTemplateListPane.getInstance().isCurrentEditingFile(selectedfile.getFullPathName())) { if (!HistoryTemplateListPane.getInstance().isCurrentEditingFile(selectedfile.getPath())) {
//如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样 //如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样
DesignerContext.getDesignerFrame().activateJTemplate(selectedfile); DesignerContext.getDesignerFrame().activateJTemplate(selectedfile);
} }

20
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -40,7 +40,6 @@ import com.fr.design.write.submit.DBManipulationInWidgetEventPane;
import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.DBManipulationPane;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FILEChooserPane; import com.fr.file.FILEChooserPane;
import com.fr.file.FileNodeFILE;
import com.fr.file.MemFILE; import com.fr.file.MemFILE;
import com.fr.form.ui.NoneWidget; import com.fr.form.ui.NoneWidget;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
@ -50,17 +49,14 @@ import com.fr.log.FineLoggerFactory;
import com.fr.report.cell.Elem; import com.fr.report.cell.Elem;
import com.fr.report.cell.cellattr.CellImage; import com.fr.report.cell.cellattr.CellImage;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.UUID; import com.fr.stable.core.UUID;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*; import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.undo.UndoManager; import javax.swing.undo.UndoManager;
import java.awt.*; import java.awt.*;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Set; import java.util.Set;
@ -202,16 +198,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return -1; return -1;
} }
public String getFullPathName() { public String getPath() {
String editingFileName = getEditingFILE().getPath(); return getEditingFILE().getPath();
if (editingFileName.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFileName = ((FileNodeFILE) getEditingFILE()).getEnvPath() + File.separator + editingFileName;
}
if (OperatingSystem.isWindows()) {
return editingFileName.replaceAll("/", "\\\\");
} else {
return editingFileName.replaceAll("\\\\", "/");
}
} }
protected abstract JComponent createCenterPane(); protected abstract JComponent createCenterPane();
@ -579,7 +567,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
* @return * @return
*/ */
public boolean saveAsTemplate(boolean isShowLoc, String fileName) { public boolean saveAsTemplate(boolean isShowLoc, String fileName) {
String oldName = this.getFullPathName(); String oldName = this.getPath();
// alex:如果是SaveAs的话需要让用户来选择路径了 // alex:如果是SaveAs的话需要让用户来选择路径了
FILEChooserPane fileChooser = getFILEChooserPane(isShowLoc); FILEChooserPane fileChooser = getFILEChooserPane(isShowLoc);
fileChooser.setFileNameTextField(fileName, this.suffix()); fileChooser.setFileNameTextField(fileName, this.suffix());
@ -618,7 +606,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
collectInfo(); collectInfo();
} }
//更换最近打开 //更换最近打开
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getFullPathName()); DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath());
return result; return result;
} }

4
designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java

@ -37,7 +37,7 @@ public class JVirtualTemplate extends JTemplate {
} }
@Override @Override
public String getFullPathName() { public String getPath() {
String editingFileName = getEditingFILE().getPath(); String editingFileName = getEditingFILE().getPath();
if (editingFileName.startsWith(ProjectConstants.REPORTLETS_NAME)) { if (editingFileName.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFileName = ((FileNodeFILE) getEditingFILE()).getEnvPath() + File.separator + editingFileName; editingFileName = ((FileNodeFILE) getEditingFILE()).getEnvPath() + File.separator + editingFileName;
@ -258,7 +258,7 @@ public class JVirtualTemplate extends JTemplate {
@Override @Override
public Icon getIcon() { public Icon getIcon() {
if (getFullPathName().endsWith("cpt")) { if (getPath().endsWith("cpt")) {
return BaseUtils.readIcon("/com/fr/design/images/buttonicon/newcpts.png"); return BaseUtils.readIcon("/com/fr/design/images/buttonicon/newcpts.png");
} else { } else {
return BaseUtils.readIcon("/com/fr/web/images/form/new_form3.png"); return BaseUtils.readIcon("/com/fr/web/images/form/new_form3.png");

4
designer-base/src/main/java/com/fr/file/FILEFactory.java

@ -35,7 +35,7 @@ public class FILEFactory {
} else if (path.startsWith(FILE_PREFIX)) { } else if (path.startsWith(FILE_PREFIX)) {
return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length())));
} else { } else {
return new FileFILE(new java.io.File(path)); return new FileNodeFILE(new FileNode(path, WorkContext.getWorkResource().isDirectory(path)));
} }
} }
@ -52,7 +52,7 @@ public class FILEFactory {
} else if (path.startsWith(FILE_PREFIX)) { } else if (path.startsWith(FILE_PREFIX)) {
return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length()))); return new FileFILE(new java.io.File(path.substring(FILE_PREFIX.length())));
} else { } else {
return new FileFILE(new java.io.File(path)); return new FileNodeFILE(new FileNode(path, WorkContext.getWorkResource().isDirectory(path)));
} }
} }
} }
Loading…
Cancel
Save