Browse Source

Merge pull request #1128 in BA/design from ~VITO/design:release/9.0 to release/9.0

* commit 'e28b7a8892fd7ae4b0a4eef3343cc8b0da41e04b':
  REPORT-4097 [9.0一轮回归]Mac设计器输出文件时,路径显示问题
master
superman 7 years ago
parent
commit
d8ecba8567
  1. 2
      designer/src/com/fr/design/actions/file/export/AbstractExportAction.java
  2. 116
      designer_base/src/com/fr/file/FILEChooserPane.java

2
designer/src/com/fr/design/actions/file/export/AbstractExportAction.java

@ -72,7 +72,7 @@ public abstract class AbstractExportAction extends JWorkBookAction {
} }
// Choose a file name.... // Choose a file name....
FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(false, true); FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(true, true);
fileChooserPane.setFILEFilter(this.getChooseFileFilter()); fileChooserPane.setFILEFilter(this.getChooseFileFilter());
// 打开文件后输出文件名修改,eg:w.cpt.doc / w.svg.doc,去掉中间的后缀名~~ w.doc // 打开文件后输出文件名修改,eg:w.cpt.doc / w.svg.doc,去掉中间的后缀名~~ w.doc

116
designer_base/src/com/fr/file/FILEChooserPane.java

@ -1,51 +1,5 @@
package com.fr.file; package com.fr.file;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
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.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.AbstractAction;
import javax.swing.AbstractListModel;
import javax.swing.ActionMap;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.filechooser.FileSystemView;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.plaf.basic.BasicButtonUI;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
@ -70,12 +24,23 @@ import com.fr.file.filter.FILEFilter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.CoreConstants; import com.fr.stable.*;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.filechooser.FileSystemView;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* /*
* FileChooserPane要高亮显示某Button,以显示当前路径 * FileChooserPane要高亮显示某Button,以显示当前路径
* 边距要调整 * 边距要调整
@ -306,7 +271,7 @@ public class FILEChooserPane extends BasicPane {
}); });
} }
private void doCancel(){ private void doCancel() {
this.locationBtnPane.setPopDir(null); this.locationBtnPane.setPopDir(null);
dialogExit(); dialogExit();
} }
@ -343,7 +308,7 @@ public class FILEChooserPane extends BasicPane {
} }
} }
protected String getEnvProjectName(){ protected String getEnvProjectName() {
return Inter.getLocText("Utils-Report-Env_Directory"); return Inter.getLocText("Utils-Report-Env_Directory");
} }
@ -457,6 +422,7 @@ public class FILEChooserPane extends BasicPane {
/** /**
* 打开对话框 * 打开对话框
*
* @param parent 父类 * @param parent 父类
* @return 类型 * @return 类型
*/ */
@ -466,6 +432,7 @@ public class FILEChooserPane extends BasicPane {
/** /**
* 打开对话框 * 打开对话框
*
* @param parent 父类 * @param parent 父类
* @param suffix 后缀 * @param suffix 后缀
* @return 类型 * @return 类型
@ -476,6 +443,7 @@ public class FILEChooserPane extends BasicPane {
/** /**
* 打开对话框 * 打开对话框
*
* @param parent 父类 * @param parent 父类
* @return 类型 * @return 类型
*/ */
@ -485,6 +453,7 @@ public class FILEChooserPane extends BasicPane {
/** /**
* 打开对话框 * 打开对话框
*
* @param parent 父类 * @param parent 父类
* @param suffix 后缀 * @param suffix 后缀
* @return 类型 * @return 类型
@ -506,7 +475,7 @@ public class FILEChooserPane extends BasicPane {
this.suffix = suffix; this.suffix = suffix;
dialog = showWindow((Window)parent, false); dialog = showWindow((Window) parent, false);
JPanel contentPane = (JPanel) dialog.getContentPane(); JPanel contentPane = (JPanel) dialog.getContentPane();
contentPane.setLayout(FRGUIPaneFactory.createM_BorderLayout()); contentPane.setLayout(FRGUIPaneFactory.createM_BorderLayout());
contentPane.add(this, BorderLayout.CENTER); contentPane.add(this, BorderLayout.CENTER);
@ -545,11 +514,11 @@ public class FILEChooserPane extends BasicPane {
protected void fileType() { protected void fileType() {
String appName = ProductConstants.APP_NAME; String appName = ProductConstants.APP_NAME;
JTemplate editing = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate editing = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(ComparatorUtils.equals(suffix,".crt")){ if (ComparatorUtils.equals(suffix, ".crt")) {
this.addChooseFILEFilter(new ChooseFileFilter("crt", appName + Inter.getLocText(new String[]{"Utils-The-Chart", "FR-App-All_File"}))); this.addChooseFILEFilter(new ChooseFileFilter("crt", appName + Inter.getLocText(new String[]{"Utils-The-Chart", "FR-App-All_File"})));
return; return;
} }
if(editing == null || !editing.isChartBook()){ if (editing == null || !editing.isChartBook()) {
String[] fileSuffix_local = LocalEnv.FILE_TYPE; String[] fileSuffix_local = LocalEnv.FILE_TYPE;
String[] fileSuffix = {"cpt", "frm", "form", "cht", "chart"}; String[] fileSuffix = {"cpt", "frm", "form", "cht", "chart"};
if (type == JFileChooser.OPEN_DIALOG) { if (type == JFileChooser.OPEN_DIALOG) {
@ -566,10 +535,10 @@ public class FILEChooserPane extends BasicPane {
// richer:form文件 daniel 改成三个字 // richer:form文件 daniel 改成三个字
this.addChooseFILEFilter(new ChooseFileFilter("frm", appName + Inter.getLocText(new String[]{"FR-App-Template_Form", "FR-App-All_File"}))); this.addChooseFILEFilter(new ChooseFileFilter("frm", appName + Inter.getLocText(new String[]{"FR-App-Template_Form", "FR-App-All_File"})));
this.addChooseFILEFilter(new ChooseFileFilter("form", appName + Inter.getLocText(new String[]{"FR-App-Template_Form", "FR-App-All_File"}))); this.addChooseFILEFilter(new ChooseFileFilter("form", appName + Inter.getLocText(new String[]{"FR-App-Template_Form", "FR-App-All_File"})));
}else{ } else {
String[] fileSuffix_local = {"xls","xlsx"}; String[] fileSuffix_local = {"xls", "xlsx"};
if (type == JFileChooser.OPEN_DIALOG) { if (type == JFileChooser.OPEN_DIALOG) {
this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local,Inter.getLocText("Import-Excel_Source"))); this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, Inter.getLocText("Import-Excel_Source")));
} }
} }
@ -578,8 +547,8 @@ public class FILEChooserPane extends BasicPane {
this.addChooseFILEFilter(new ChooseFileFilter("xls", Inter.getLocText("Import-Excel_Source"))); this.addChooseFILEFilter(new ChooseFileFilter("xls", Inter.getLocText("Import-Excel_Source")));
this.addChooseFILEFilter(new ChooseFileFilter("xlsx", Inter.getLocText("Import-Excel2007_Source"))); this.addChooseFILEFilter(new ChooseFileFilter("xlsx", Inter.getLocText("Import-Excel2007_Source")));
} }
if(ComparatorUtils.equals(suffix,".png")){ if (ComparatorUtils.equals(suffix, ".png")) {
this.addChooseFILEFilter(new ChooseFileFilter("png",Inter.getLocText("FR-App-Export_png"))); this.addChooseFILEFilter(new ChooseFileFilter("png", Inter.getLocText("FR-App-Export_png")));
} }
if (type == JFileChooser.SAVE_DIALOG) { if (type == JFileChooser.SAVE_DIALOG) {
this.addChooseFILEFilter(new ChooseFileFilter("pdf", Inter.getLocText("FR-Import-Export_PDF"))); this.addChooseFILEFilter(new ChooseFileFilter("pdf", Inter.getLocText("FR-Import-Export_PDF")));
@ -627,7 +596,7 @@ public class FILEChooserPane extends BasicPane {
postfixComboBox.setSelectedIndex(suffixIndex("doc")); postfixComboBox.setSelectedIndex(suffixIndex("doc"));
} else if (ComparatorUtils.equals(suffix, ".txt")) { } else if (ComparatorUtils.equals(suffix, ".txt")) {
postfixComboBox.setSelectedIndex(suffixIndex("txt")); postfixComboBox.setSelectedIndex(suffixIndex("txt"));
}else if(ComparatorUtils.equals(suffix,".png")){ } else if (ComparatorUtils.equals(suffix, ".png")) {
postfixComboBox.setSelectedIndex(suffixIndex("png")); postfixComboBox.setSelectedIndex(suffixIndex("png"));
} }
//jerry 26216 只保留.cpt .frm有用的格式,并且不可编辑 //jerry 26216 只保留.cpt .frm有用的格式,并且不可编辑
@ -643,10 +612,10 @@ public class FILEChooserPane extends BasicPane {
} }
} }
private int suffixIndex(String extension){ private int suffixIndex(String extension) {
for(int i=0 ;i<filterList.size();i++){ for (int i = 0; i < filterList.size(); i++) {
FILEFilter fileFilter = filterList.get(i); FILEFilter fileFilter = filterList.get(i);
if(fileFilter.containsExtension(extension)){ if (fileFilter.containsExtension(extension)) {
return i; return i;
} }
} }
@ -697,7 +666,7 @@ public class FILEChooserPane extends BasicPane {
FILE selectedFile = this.getSelectedFILE(); FILE selectedFile = this.getSelectedFILE();
if (!FRContext.getCurrentEnv().hasFileFolderAllow(selectedFile.getPath())) { if (!FRContext.getCurrentEnv().hasFileFolderAllow(selectedFile.getPath())) {
JOptionPane.showMessageDialog(FILEChooserPane.this, Inter.getLocText("FR-App-Privilege_No") + "!", Inter.getLocText("FR-App-File_Message"), JOptionPane.WARNING_MESSAGE); JOptionPane.showMessageDialog(FILEChooserPane.this, Inter.getLocText("FR-App-Privilege_No") + "!", Inter.getLocText("FR-App-File_Message"), JOptionPane.WARNING_MESSAGE);
return ; return;
} }
if (selectedFile.exists()) { if (selectedFile.exists()) {
int selVal = JOptionPane.showConfirmDialog(dialog, Inter.getLocText("FR-Utils-Would_you_like_to_cover_the_current_file") + " ?", int selVal = JOptionPane.showConfirmDialog(dialog, Inter.getLocText("FR-Utils-Would_you_like_to_cover_the_current_file") + " ?",
@ -781,7 +750,7 @@ public class FILEChooserPane extends BasicPane {
PlaceListModel() { PlaceListModel() {
if (FILEChooserPane.this.showEnv) { if (FILEChooserPane.this.showEnv) {
envFILE = new FileNodeFILE(new FileNode(ProjectConstants.REPORTLETS_NAME, true)){ envFILE = new FileNodeFILE(new FileNode(ProjectConstants.REPORTLETS_NAME, true)) {
public String getName() { public String getName() {
return getEnvProjectName(); return getEnvProjectName();
} }
@ -800,7 +769,9 @@ public class FILEChooserPane extends BasicPane {
} }
if (FILEChooserPane.this.showLoc) { if (FILEChooserPane.this.showLoc) {
// 桌面
if (OperatingSystem.isWindows()) {
// windows下展示桌面
File[] desktop = FileSystemView.getFileSystemView().getRoots(); File[] desktop = FileSystemView.getFileSystemView().getRoots();
if (desktop != null) { if (desktop != null) {
for (int i = 0; i < desktop.length; i++) { for (int i = 0; i < desktop.length; i++) {
@ -809,6 +780,9 @@ public class FILEChooserPane extends BasicPane {
} }
} }
} }
} else { // *nix下展示家目录
filesOfSystem.add(new FileFILE(FileSystemView.getFileSystemView().getDefaultDirectory()));
}
// C, D, E等盘符 // C, D, E等盘符
File[] roots = File.listRoots(); File[] roots = File.listRoots();
@ -1172,7 +1146,7 @@ public class FILEChooserPane extends BasicPane {
} }
} }
public void setPopDir(FILE file){ public void setPopDir(FILE file) {
popDir = file; popDir = file;
} }
@ -1182,6 +1156,7 @@ public class FILEChooserPane extends BasicPane {
return; return;
} }
boolean isWebAppNamePath;
popDir = dir; popDir = dir;
this.buttonList.clear(); this.buttonList.clear();
@ -1190,12 +1165,13 @@ public class FILEChooserPane extends BasicPane {
} }
String path = dir.getPath(); String path = dir.getPath();
isWebAppNamePath = ComparatorUtils.equals(dir.prefix(), FILEFactory.WEBREPORT_PREFIX);
// 确保最后一个字符是分隔符 // 确保最后一个字符是分隔符
if (!path.endsWith("/") && !path.endsWith("\\") && !StringUtils.isBlank(path)) { if (!path.endsWith("/") && !path.endsWith("\\") && !StringUtils.isBlank(path)) {
path = path + "/"; path = path + "/";
} }
String webAppName = GeneralContext.getCurrentAppNameOfEnv(); String webAppName = GeneralContext.getCurrentAppNameOfEnv();
if (StringUtils.isBlank(path)) { if (StringUtils.isBlank(path) && isWebAppNamePath) {
this.buttonList.add(createBlankButton(new SetDirectoryAction(webAppName + '/'))); this.buttonList.add(createBlankButton(new SetDirectoryAction(webAppName + '/')));
} }
@ -1206,7 +1182,7 @@ public class FILEChooserPane extends BasicPane {
int start = matcher.start(); int start = matcher.start();
String btn_text = path.substring(node_start, start); String btn_text = path.substring(node_start, start);
String btn_path = path.substring(0, start); String btn_path = path.substring(0, start);
if (StringUtils.isBlank(btn_text)) { if (StringUtils.isBlank(btn_text) && isWebAppNamePath) {
btn_text = webAppName; btn_text = webAppName;
} }
this.buttonList.add(createBlankButton((new SetDirectoryAction(btn_text + '/', this.buttonList.add(createBlankButton((new SetDirectoryAction(btn_text + '/',

Loading…
Cancel
Save