|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.fr.file; |
|
|
|
package com.fr.file; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
|
|
|
import com.fr.base.extension.FileExtension; |
|
|
|
import com.fr.base.FRContext; |
|
|
|
import com.fr.base.FRContext; |
|
|
|
import com.fr.dav.LocalEnv; |
|
|
|
import com.fr.dav.LocalEnv; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
@ -25,19 +26,60 @@ 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.*; |
|
|
|
import com.fr.stable.CoreConstants; |
|
|
|
|
|
|
|
import com.fr.stable.OperatingSystem; |
|
|
|
|
|
|
|
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.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.ListSelectionEvent; |
|
|
|
import javax.swing.event.ListSelectionListener; |
|
|
|
import javax.swing.event.ListSelectionListener; |
|
|
|
import javax.swing.filechooser.FileSystemView; |
|
|
|
import javax.swing.filechooser.FileSystemView; |
|
|
|
import javax.swing.plaf.basic.BasicArrowButton; |
|
|
|
import javax.swing.plaf.basic.BasicArrowButton; |
|
|
|
import javax.swing.plaf.basic.BasicButtonUI; |
|
|
|
import javax.swing.plaf.basic.BasicButtonUI; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.event.*; |
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
import java.awt.Component; |
|
|
|
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
|
|
|
import java.awt.Insets; |
|
|
|
|
|
|
|
import java.awt.Window; |
|
|
|
|
|
|
|
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.io.File; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.EnumSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.regex.Pattern; |
|
|
@ -46,6 +88,7 @@ import java.util.regex.Pattern; |
|
|
|
* FileChooserPane要高亮显示某Button,以显示当前路径 |
|
|
|
* FileChooserPane要高亮显示某Button,以显示当前路径 |
|
|
|
* 边距要调整 |
|
|
|
* 边距要调整 |
|
|
|
* postfix还没有处理 |
|
|
|
* postfix还没有处理 |
|
|
|
|
|
|
|
* 该文件选择器,整理行为如下: |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class FILEChooserPane extends BasicPane { |
|
|
|
public class FILEChooserPane extends BasicPane { |
|
|
|
/** |
|
|
|
/** |
|
|
@ -180,6 +223,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
// transfer focus to CurrentEditor
|
|
|
|
// transfer focus to CurrentEditor
|
|
|
|
inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "dialogExit"); |
|
|
|
inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "dialogExit"); |
|
|
|
actionMap.put("dialogExit", new AbstractAction() { |
|
|
|
actionMap.put("dialogExit", new AbstractAction() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
returnValue = CANCEL_OPTION; |
|
|
|
returnValue = CANCEL_OPTION; |
|
|
|
dialogExit(); |
|
|
|
dialogExit(); |
|
|
@ -240,17 +284,20 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
new double[]{TableLayout.PREFERRED, TableLayout.FILL}); |
|
|
|
new double[]{TableLayout.PREFERRED, TableLayout.FILL}); |
|
|
|
this.add(contentPane, BorderLayout.CENTER); |
|
|
|
this.add(contentPane, BorderLayout.CENTER); |
|
|
|
okButton.addActionListener(new ActionListener() { |
|
|
|
okButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
doOK(); |
|
|
|
doOK(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
cancelButton.addActionListener(new ActionListener() { |
|
|
|
cancelButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
returnValue = CANCEL_OPTION; |
|
|
|
returnValue = CANCEL_OPTION; |
|
|
|
doCancel(); |
|
|
|
doCancel(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
fileNameTextField.addKeyListener(new KeyAdapter() { |
|
|
|
fileNameTextField.addKeyListener(new KeyAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
returnValue = CANCEL_OPTION; |
|
|
|
returnValue = CANCEL_OPTION; |
|
|
@ -356,6 +403,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 删除文件过滤器 |
|
|
|
* 删除文件过滤器 |
|
|
|
|
|
|
|
* 这命名太乱了,完全是误导 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param filter 过滤 |
|
|
|
* @param filter 过滤 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -392,7 +440,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setFileNameTextField(String text, String suffix) { |
|
|
|
public void setFileNameTextField(String text, String suffix) { |
|
|
|
if (StringUtils.isEmpty(suffix)) { |
|
|
|
if (StringUtils.isEmpty(suffix)) { |
|
|
|
suffix = ".cpt"; |
|
|
|
suffix = FileExtension.CPT.getSuffix(); |
|
|
|
} |
|
|
|
} |
|
|
|
this.suffix = suffix; |
|
|
|
this.suffix = suffix; |
|
|
|
|
|
|
|
|
|
|
@ -428,7 +476,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
* @return 类型 |
|
|
|
* @return 类型 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int showOpenDialog(Component parent) { |
|
|
|
public int showOpenDialog(Component parent) { |
|
|
|
return showOpenDialog(parent, ".cpt"); |
|
|
|
return showOpenDialog(parent, FileExtension.CPT.getSuffix()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -449,7 +497,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
* @return 类型 |
|
|
|
* @return 类型 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int showSaveDialog(Component parent) { |
|
|
|
public int showSaveDialog(Component parent) { |
|
|
|
return showSaveDialog(parent, ".cpt"); |
|
|
|
return showSaveDialog(parent, FileExtension.CPT.getSuffix()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -482,10 +530,12 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
okButton.setText(dialogName()); |
|
|
|
okButton.setText(dialogName()); |
|
|
|
// kel:打开界面的时候让文本域获得焦点,支持enter打开或保存。
|
|
|
|
// kel:打开界面的时候让文本域获得焦点,支持enter打开或保存。
|
|
|
|
dialog.addWindowListener(new WindowAdapter() { |
|
|
|
dialog.addWindowListener(new WindowAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void windowActivated(WindowEvent e) { |
|
|
|
public void windowActivated(WindowEvent e) { |
|
|
|
fileNameTextField.requestFocusInWindow(); |
|
|
|
fileNameTextField.requestFocusInWindow(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void windowClosing(WindowEvent e) { |
|
|
|
public void windowClosing(WindowEvent e) { |
|
|
|
returnValue = CANCEL_OPTION; |
|
|
|
returnValue = CANCEL_OPTION; |
|
|
|
dialogExit(); |
|
|
|
dialogExit(); |
|
|
@ -494,7 +544,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
// neil:默认打开pane里显示所有支持的格式
|
|
|
|
// neil:默认打开pane里显示所有支持的格式
|
|
|
|
// daniel 从templateFileTree中取
|
|
|
|
// daniel 从templateFileTree中取
|
|
|
|
if (!showWebReport) { |
|
|
|
if (!showWebReport && filterList.isEmpty()) { |
|
|
|
fileType(); |
|
|
|
fileType(); |
|
|
|
} |
|
|
|
} |
|
|
|
chooseType(); |
|
|
|
chooseType(); |
|
|
@ -514,49 +564,48 @@ 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 (FileExtension.CRT.matchExtension(suffix)) { |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter("crt", appName + Inter.getLocText(new String[]{"Utils-The-Chart", "FR-App-All_File"}))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.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", "cptx", "frm", "form", "cht", "chart"}; |
|
|
|
EnumSet<FileExtension> fileExtensions = EnumSet.of(FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, FileExtension.CHT); |
|
|
|
if (type == JFileChooser.OPEN_DIALOG) { |
|
|
|
if (type == JFileChooser.OPEN_DIALOG) { |
|
|
|
if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接
|
|
|
|
if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接
|
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix_local, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(fileSuffix, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(fileExtensions, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ben:filefilter设置初值为cpt过滤
|
|
|
|
// ben:filefilter设置初值为cpt过滤
|
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter("cpt", appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter("cptx", appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPTX, appName + Inter.getLocText(new String[]{"FR-App-Report_Template", "FR-App-All_File"}))); |
|
|
|
|
|
|
|
|
|
|
|
// 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(FileExtension.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(FileExtension.FRMX, appName + Inter.getLocText(new String[]{"FR-App-Template_Form", "FR-App-All_File"}))); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
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(EnumSet.of(FileExtension.XLS, FileExtension.XLSX), Inter.getLocText("Import-Excel_Source"))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 添加 xls 文件类型过滤 kt
|
|
|
|
// 添加 xls 文件类型过滤 kt
|
|
|
|
if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接
|
|
|
|
if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接
|
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter("xls", Inter.getLocText("Import-Excel_Source"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLS, Inter.getLocText("Import-Excel_Source"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter("xlsx", Inter.getLocText("Import-Excel2007_Source"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.XLSX, Inter.getLocText("Import-Excel2007_Source"))); |
|
|
|
} |
|
|
|
} |
|
|
|
if (ComparatorUtils.equals(suffix, ".png")) { |
|
|
|
if (FileExtension.PNG.matchExtension(suffix)) { |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter("png", Inter.getLocText("FR-App-Export_png"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.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(FileExtension.PDF, Inter.getLocText("FR-Import-Export_PDF"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter("svg", Inter.getLocText("FR-Import-Export_SVG"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.SVG, Inter.getLocText("FR-Import-Export_SVG"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter("csv", Inter.getLocText("FR-Import-Export_CSV"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CSV, Inter.getLocText("FR-Import-Export_CSV"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter("doc", Inter.getLocText("FR-Import-Export_Word"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.DOC, Inter.getLocText("FR-Import-Export_Word"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter("txt", Inter.getLocText("FR-Import-Export_Text"))); |
|
|
|
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.TXT, Inter.getLocText("FR-Import-Export_Text"))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -564,8 +613,8 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
private void chooseType() { |
|
|
|
private void chooseType() { |
|
|
|
DefaultComboBoxModel defaultComboBoxModel = (DefaultComboBoxModel) postfixComboBox.getModel(); |
|
|
|
DefaultComboBoxModel defaultComboBoxModel = (DefaultComboBoxModel) postfixComboBox.getModel(); |
|
|
|
defaultComboBoxModel.removeAllElements(); |
|
|
|
defaultComboBoxModel.removeAllElements(); |
|
|
|
for (int i = 0; i < filterList.size(); i++) { |
|
|
|
for (FILEFilter aFilterList : filterList) { |
|
|
|
defaultComboBoxModel.addElement(filterList.get(i)); |
|
|
|
defaultComboBoxModel.addElement(aFilterList); |
|
|
|
} |
|
|
|
} |
|
|
|
if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接
|
|
|
|
if (FRContext.getCurrentEnv().isSupportLocalFileOperate()) { //本地连接
|
|
|
|
if (!showWebReport) { |
|
|
|
if (!showWebReport) { |
|
|
@ -578,38 +627,22 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
defaultComboBoxModel.setSelectedItem(filterList.get(0)); |
|
|
|
defaultComboBoxModel.setSelectedItem(filterList.get(0)); |
|
|
|
} |
|
|
|
} |
|
|
|
// richer:根据不同的文件类型显示不同的后缀名
|
|
|
|
// richer:根据不同的文件类型显示不同的后缀名
|
|
|
|
if (ComparatorUtils.equals(suffix, ".cpt")) { |
|
|
|
EnumSet<FileExtension> fileExtensions = EnumSet.of( |
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("cpt")); |
|
|
|
FileExtension.CPT, FileExtension.CPTX, FileExtension.FRM, FileExtension.FRMX, |
|
|
|
} else if (ComparatorUtils.equals(suffix, ".cptx")) { |
|
|
|
FileExtension.XLS, FileExtension.XLSX, FileExtension.PDF, FileExtension.SVG, |
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("cptx")); |
|
|
|
FileExtension.CSV, FileExtension.DOC, FileExtension.TXT, FileExtension.PNG); |
|
|
|
} else if (ComparatorUtils.equals(suffix, ".frm") || ComparatorUtils.equals(suffix, ".form")) { |
|
|
|
for (FileExtension fileExtension : fileExtensions) { |
|
|
|
// postfixComboBox.setSelectedIndex(2);
|
|
|
|
if (fileExtension.matchExtension(suffix)) { |
|
|
|
// daniel 改成三个字保证兼容
|
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex(fileExtension.getExtension())); |
|
|
|
// 现在默认用的是".frm"
|
|
|
|
break; |
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("frm")); |
|
|
|
} |
|
|
|
} else if (ComparatorUtils.equals(suffix, ".xls")) { |
|
|
|
|
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("xls")); |
|
|
|
|
|
|
|
} else if (ComparatorUtils.equals(suffix, ".xlsx")) { |
|
|
|
|
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("xlsx")); |
|
|
|
|
|
|
|
} else if (ComparatorUtils.equals(suffix, ".pdf")) { |
|
|
|
|
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("pdf")); |
|
|
|
|
|
|
|
} else if (ComparatorUtils.equals(suffix, ".svg")) { |
|
|
|
|
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("svg")); |
|
|
|
|
|
|
|
} else if (ComparatorUtils.equals(suffix, ".csv")) { |
|
|
|
|
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("csv")); |
|
|
|
|
|
|
|
} else if (ComparatorUtils.equals(suffix, ".doc")) { |
|
|
|
|
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("doc")); |
|
|
|
|
|
|
|
} else if (ComparatorUtils.equals(suffix, ".txt")) { |
|
|
|
|
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("txt")); |
|
|
|
|
|
|
|
} else if (ComparatorUtils.equals(suffix, ".png")) { |
|
|
|
|
|
|
|
postfixComboBox.setSelectedIndex(suffixIndex("png")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//jerry 26216 只保留.cpt .frm有用的格式,并且不可编辑
|
|
|
|
//jerry 26216 只保留.cpt .frm有用的格式,并且不可编辑
|
|
|
|
// if (type == JFileChooser.OPEN_DIALOG) {
|
|
|
|
if (type == JFileChooser.OPEN_DIALOG) { |
|
|
|
// postfixComboBox.setEnabled(true);
|
|
|
|
postfixComboBox.setEnabled(true); |
|
|
|
// } else {
|
|
|
|
} else { |
|
|
|
// postfixComboBox.setEnabled(false);
|
|
|
|
postfixComboBox.setEnabled(false); |
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//只有一个类型时不可下拉
|
|
|
|
//只有一个类型时不可下拉
|
|
|
|
if (filterList.size() == 1) { |
|
|
|
if (filterList.size() == 1) { |
|
|
@ -749,6 +782,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
protected String title4PopupWindow() { |
|
|
|
protected String title4PopupWindow() { |
|
|
|
return dialogName(); |
|
|
|
return dialogName(); |
|
|
|
} |
|
|
|
} |
|
|
@ -761,6 +795,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)) { |
|
|
|
|
|
|
|
@Override |
|
|
|
public String getName() { |
|
|
|
public String getName() { |
|
|
|
return getEnvProjectName(); |
|
|
|
return getEnvProjectName(); |
|
|
|
} |
|
|
|
} |
|
|
@ -871,6 +906,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
private ListCellRenderer placelistRenderer = new DefaultListCellRenderer() { |
|
|
|
private ListCellRenderer placelistRenderer = new DefaultListCellRenderer() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
|
|
|
|
|
|
|
@ -898,6 +934,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private ListCellRenderer listRenderer = new DefaultListCellRenderer() { |
|
|
|
private ListCellRenderer listRenderer = new DefaultListCellRenderer() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
|
|
|
|
|
|
|
@ -920,6 +957,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
}; |
|
|
|
}; |
|
|
|
// placeList listener
|
|
|
|
// placeList listener
|
|
|
|
ListSelectionListener placeListener = new ListSelectionListener() { |
|
|
|
ListSelectionListener placeListener = new ListSelectionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void valueChanged(ListSelectionEvent e) { |
|
|
|
public void valueChanged(ListSelectionEvent e) { |
|
|
|
Object selValue = placesList.getSelectedValue(); |
|
|
|
Object selValue = placesList.getSelectedValue(); |
|
|
|
if (selValue instanceof FILE) { |
|
|
|
if (selValue instanceof FILE) { |
|
|
@ -932,6 +970,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
* placeList mouseListener |
|
|
|
* placeList mouseListener |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private MouseListener placeMouseListener = new MouseAdapter() { |
|
|
|
private MouseListener placeMouseListener = new MouseAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
Object selValue = placesList.getSelectedValue(); |
|
|
|
Object selValue = placesList.getSelectedValue(); |
|
|
|
if (selValue instanceof FILE) { |
|
|
|
if (selValue instanceof FILE) { |
|
|
@ -944,6 +983,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
* right list. |
|
|
|
* right list. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private KeyListener subFileListKeyListener = new KeyAdapter() { |
|
|
|
private KeyListener subFileListKeyListener = new KeyAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
Object source = e.getSource(); |
|
|
|
Object source = e.getSource(); |
|
|
|
if (!(source instanceof JList)) { |
|
|
|
if (!(source instanceof JList)) { |
|
|
@ -973,6 +1013,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
* 鼠标点击JList时的listener |
|
|
|
* 鼠标点击JList时的listener |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private MouseListener subFileListMouseListener = new MouseAdapter() { |
|
|
|
private MouseListener subFileListMouseListener = new MouseAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
Object source = e.getSource(); |
|
|
|
Object source = e.getSource(); |
|
|
|
if (!(source instanceof JList)) { |
|
|
|
if (!(source instanceof JList)) { |
|
|
@ -1114,11 +1155,13 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); |
|
|
|
this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); |
|
|
|
|
|
|
|
|
|
|
|
leftArrowButton = new BasicArrowButton(BasicArrowButton.WEST) { |
|
|
|
leftArrowButton = new BasicArrowButton(BasicArrowButton.WEST) { |
|
|
|
|
|
|
|
@Override |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
return new Dimension(21, 21); |
|
|
|
return new Dimension(21, 21); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
leftArrowButton.addActionListener(new ActionListener() { |
|
|
|
leftArrowButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
if (pathIndex > 0) { |
|
|
|
if (pathIndex > 0) { |
|
|
|
pathIndex--; |
|
|
|
pathIndex--; |
|
|
@ -1129,11 +1172,13 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
rightArrowButton = new BasicArrowButton(BasicArrowButton.EAST) { |
|
|
|
rightArrowButton = new BasicArrowButton(BasicArrowButton.EAST) { |
|
|
|
|
|
|
|
@Override |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
return new Dimension(21, 21); |
|
|
|
return new Dimension(21, 21); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
rightArrowButton.addActionListener(new ActionListener() { |
|
|
|
rightArrowButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
if (pathIndex < maxPathIndex) { |
|
|
|
if (pathIndex < maxPathIndex) { |
|
|
|
pathIndex++; |
|
|
|
pathIndex++; |
|
|
@ -1212,6 +1257,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// doLayout
|
|
|
|
// doLayout
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void doLayout() { |
|
|
|
public void doLayout() { |
|
|
|
this.removeAll(); |
|
|
|
this.removeAll(); |
|
|
|
|
|
|
|
|
|
|
@ -1310,6 +1356,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
this.dir = file; |
|
|
|
this.dir = file; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
if (dir != null) { |
|
|
|
if (dir != null) { |
|
|
|
setSelectedDirectory(dir); |
|
|
|
setSelectedDirectory(dir); |
|
|
@ -1338,18 +1385,21 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
blankButton.setBackground(FILEChooserPane.this.getBackground().darker()); |
|
|
|
blankButton.setBackground(FILEChooserPane.this.getBackground().darker()); |
|
|
|
blankButton.setBorderPainted(false); |
|
|
|
blankButton.setBorderPainted(false); |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
blankButton.setBackground(FILEChooserPane.this.getBackground().brighter()); |
|
|
|
blankButton.setBackground(FILEChooserPane.this.getBackground().brighter()); |
|
|
|
blankButton.setBorderPainted(false); |
|
|
|
blankButton.setBorderPainted(false); |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
blankButton.setBackground(FILEChooserPane.this.getBackground().brighter()); |
|
|
|
blankButton.setBackground(FILEChooserPane.this.getBackground().brighter()); |
|
|
|
blankButton.setBorderPainted(true); |
|
|
|
blankButton.setBorderPainted(true); |
|
|
@ -1363,6 +1413,7 @@ public class FILEChooserPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ActionListener createFolderActionListener = new ActionListener() { |
|
|
|
private ActionListener createFolderActionListener = new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
if (currentDirectory == null) { |
|
|
|
if (currentDirectory == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|