Browse Source

REPORT-5208 使用文件扩展名枚举

master
vito 7 years ago
parent
commit
3cac7d1710
  1. 2
      designer-base/src/com/fr/design/mainframe/App.java
  2. 2
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  3. 2
      designer-base/src/com/fr/design/mainframe/JTemplate.java
  4. 169
      designer-base/src/com/fr/file/FILEChooserPane.java
  5. 103
      designer-base/src/com/fr/file/filter/ChooseFileFilter.java
  6. 12
      designer-chart/src/com/fr/file/FILEChooserPane4Chart.java
  7. 2
      designer-form/src/com/fr/design/module/FormDesignerModule.java
  8. 3
      designer-realize/src/com/fr/design/actions/file/export/AbstractExportAction.java
  9. 7
      designer-realize/src/com/fr/design/actions/file/export/CSVExportAction.java
  10. 7
      designer-realize/src/com/fr/design/actions/file/export/EmbeddedExportExportAction.java
  11. 5
      designer-realize/src/com/fr/design/actions/file/export/PDFExportAction.java
  12. 19
      designer-realize/src/com/fr/design/actions/file/export/PageToSheetExcelExportAction.java
  13. 17
      designer-realize/src/com/fr/design/actions/file/export/SVGExportAction.java
  14. 17
      designer-realize/src/com/fr/design/actions/file/export/TextExportAction.java
  15. 17
      designer-realize/src/com/fr/design/actions/file/export/WordExportAction.java
  16. 17
      designer-realize/src/com/fr/design/module/DesignerModule.java

2
designer-base/src/com/fr/design/mainframe/App.java

@ -18,7 +18,7 @@ public interface App<T extends BaseBook> extends Mutable, Aftermath {
* *
* @return 类型 * @return 类型
*/ */
String[] defaultExtentions(); String[] defaultExtensions();
/** /**
* 打开模板 * 打开模板

2
designer-base/src/com/fr/design/mainframe/DesignerFrame.java

@ -855,7 +855,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
String fileExtention = fileName.substring(indexOfLastDot + 1); String fileExtention = fileName.substring(indexOfLastDot + 1);
for (int i = 0, len = appList.size(); i < len; i++) { for (int i = 0, len = appList.size(); i < len; i++) {
App<?> app = appList.get(i); App<?> app = appList.get(i);
String[] defaultAppExtentions = app.defaultExtentions(); String[] defaultAppExtentions = app.defaultExtensions();
boolean opened = false; boolean opened = false;
for (int j = 0; j < defaultAppExtentions.length; j++) { for (int j = 0; j < defaultAppExtentions.length; j++) {
if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) { if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) {

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

@ -626,7 +626,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} }
protected FILEChooserPane getFILEChooserPane(boolean isShowLoc) { protected FILEChooserPane getFILEChooserPane(boolean isShowLoc) {
return new FILEChooserPane(true, isShowLoc); return FILEChooserPane.getInstance(true, isShowLoc);
} }
protected boolean saveFile() { protected boolean saveFile() {

169
designer-base/src/com/fr/file/FILEChooserPane.java

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

103
designer-base/src/com/fr/file/filter/ChooseFileFilter.java

@ -1,16 +1,17 @@
package com.fr.file.filter; package com.fr.file.filter;
import java.io.File; import com.fr.base.extension.FileExtension;
import java.util.ArrayList;
import java.util.List;
import javax.swing.filechooser.FileFilter;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io.FileFilter { import javax.swing.filechooser.FileFilter;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
public class ChooseFileFilter extends FileFilter implements FILEFilter, java.io.FileFilter {
private List<String> filters = null; private List<String> filters = null;
private String description = null; private String description = null;
private String fullDescription = null; private String fullDescription = null;
@ -19,7 +20,7 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
private boolean isExtend = false; private boolean isExtend = false;
public ChooseFileFilter() { public ChooseFileFilter() {
if (filters==null) { if (filters == null) {
this.filters = new ArrayList<String>(); this.filters = new ArrayList<String>();
} }
} }
@ -51,9 +52,51 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
public ChooseFileFilter(String[] filters, String description) { public ChooseFileFilter(String[] filters, String description) {
this(); this();
for (int i = 0; i < filters.length; i++) { for (String filter : filters) {
// add filters one by one // add filters one by one
addExtension(filters[i]); addExtension(filter);
}
if (description != null) {
setDescription(description);
}
}
public ChooseFileFilter(FileExtension extension) {
this(extension, null);
}
public ChooseFileFilter(FileExtension extension, String description) {
this();
if (extension != null) {
addExtension(extension.getExtension());
}
if (description != null) {
setDescription(description);
}
}
/**
* 使用指定枚举类集合构建文件过滤器
*
* @param filters 文件扩展名枚举类集合
*/
public ChooseFileFilter(EnumSet<FileExtension> filters) {
this(filters, null);
}
/**
* 使用指定枚举类集合构建文件过滤器
*
* @param filters 文件扩展名枚举类集合
* @param description 描述
*/
public ChooseFileFilter(EnumSet<FileExtension> filters, String description) {
this();
for (FileExtension filter : filters) {
addExtension(filter.getExtension());
} }
if (description != null) { if (description != null) {
@ -64,9 +107,11 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
/** /**
* 是否支持改文档 * 是否支持改文档
*
* @param f 文件 * @param f 文件
* @return 支持返回true * @return 支持返回true
*/ */
@Override
public boolean accept(File f) { public boolean accept(File f) {
if (f != null) { if (f != null) {
if (this.filters == null) { //all file types. if (this.filters == null) { //all file types.
@ -89,9 +134,11 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
/** /**
* 是否支持 * 是否支持
*
* @param f 文件 * @param f 文件
* @return 支持返回 true * @return 支持返回 true
*/ */
@Override
public boolean accept(FILE f) { public boolean accept(FILE f) {
if (f != null) { if (f != null) {
if (this.filters == null) { //all file types. if (this.filters == null) { //all file types.
@ -130,7 +177,7 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
if (f != null) { if (f != null) {
String filename = f.getName(); String filename = f.getName();
if (f instanceof FileFILE) { if (f instanceof FileFILE) {
filename = ((FileFILE)f).getTotalName(); filename = ((FileFILE) f).getTotalName();
} }
int i = filename.lastIndexOf('.'); int i = filename.lastIndexOf('.');
@ -144,6 +191,7 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
/** /**
* 加扩展 * 加扩展
*
* @param extension 扩展 * @param extension 扩展
*/ */
public void addExtension(String extension) { public void addExtension(String extension) {
@ -160,13 +208,16 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
/** /**
* 是否包含该扩展 * 是否包含该扩展
* @param extension 扩展 *
* @param extension 扩展
* @return 是则返回true * @return 是则返回true
*/ */
public boolean containsExtension(String extension){ @Override
return filters.contains(extension.toLowerCase()); public boolean containsExtension(String extension) {
return filters.contains(extension.toLowerCase());
} }
@Override
public String getDescription() { public String getDescription() {
if (this.filters == null) { //all file types. if (this.filters == null) { //all file types.
return fullDescription; return fullDescription;
@ -187,11 +238,11 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
// } // }
// } // }
if (!filters.isEmpty()){ if (!filters.isEmpty()) {
fullDescription += "." + filters.get(0); fullDescription += "." + filters.get(0);
for (int i=1;i<filters.size();i++){ for (int i = 1; i < filters.size(); i++) {
fullDescription += ", ." + filters.get(i); fullDescription += ", ." + filters.get(i);
} }
} }
fullDescription += ")"; fullDescription += ")";
@ -216,6 +267,7 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
/** /**
* 扩展是否列在描述之内了 * 扩展是否列在描述之内了
*
* @return 是则返回true * @return 是则返回true
*/ */
public boolean isExtensionListInDescription() { public boolean isExtensionListInDescription() {
@ -237,8 +289,8 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
// extsb.append((String) keys.nextElement()); // extsb.append((String) keys.nextElement());
// } // }
for(int i=0;i<filters.size();i++){ for (int i = 0; i < filters.size(); i++) {
extsb.append(filters.get(i)); extsb.append(filters.get(i));
} }
return extsb.toString(); return extsb.toString();
@ -246,15 +298,18 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter , java.io
/** /**
* toString方便重写 * toString方便重写
*
* @return 重写 * @return 重写
*/ */
@Override
public String toString() { public String toString() {
return getDescription(); return getDescription();
} }
@Override
public boolean equals(Object o) { public boolean equals(Object o) {
return (o instanceof ChooseFileFilter) return (o instanceof ChooseFileFilter)
&& ComparatorUtils.equals(((ChooseFileFilter)o).getDescription(),getDescription()); && ComparatorUtils.equals(((ChooseFileFilter) o).getDescription(), getDescription());
} }
} }

12
designer-chart/src/com/fr/file/FILEChooserPane4Chart.java

@ -1,7 +1,7 @@
package com.fr.file; package com.fr.file;
import com.fr.base.extension.FileExtension;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
@ -12,7 +12,7 @@ import com.fr.stable.ProductConstants;
*/ */
public class FILEChooserPane4Chart extends FILEChooserPane { public class FILEChooserPane4Chart extends FILEChooserPane {
private static final FILEChooserPane4Chart INSTANCE = new FILEChooserPane4Chart(true,true); private static final FILEChooserPane4Chart INSTANCE = new FILEChooserPane4Chart(true, true);
/** /**
* @param showEnv * @param showEnv
@ -36,15 +36,17 @@ public class FILEChooserPane4Chart extends FILEChooserPane {
super(showEnv, showLoc); super(showEnv, showLoc);
} }
@Override
protected void fileType() { protected void fileType() {
String appName = ProductConstants.APP_NAME; String appName = ProductConstants.APP_NAME;
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;
} }
} }
protected String getEnvProjectName(){ @Override
protected String getEnvProjectName() {
return Inter.getLocText("FR-Chart-Env_Directory"); return Inter.getLocText("FR-Chart-Env_Directory");
} }

2
designer-form/src/com/fr/design/module/FormDesignerModule.java

@ -57,7 +57,7 @@ public class FormDesignerModule extends DesignModule {
return new App[]{new AbstractAppProvider<Form>() { return new App[]{new AbstractAppProvider<Form>() {
@Override @Override
public String[] defaultExtentions() { public String[] defaultExtensions() {
return new String[]{"frm", "form"}; return new String[]{"frm", "form"};
} }

3
designer-realize/src/com/fr/design/actions/file/export/AbstractExportAction.java

@ -57,6 +57,7 @@ public abstract class AbstractExportAction extends JWorkBookAction {
/** /**
* 执行方法 * 执行方法
*/ */
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JWorkBook jwb = this.getEditingComponent(); JWorkBook jwb = this.getEditingComponent();
FILE editingFILE = jwb.getEditingFILE(); FILE editingFILE = jwb.getEditingFILE();
@ -80,7 +81,7 @@ public abstract class AbstractExportAction extends JWorkBookAction {
// Choose a file name.... // Choose a file name....
FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(true, true); FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(true, true);
fileChooserPane.setFILEFilter(this.getChooseFileFilter()); fileChooserPane.addChooseFILEFilter(this.getChooseFileFilter());
// 打开文件后输出文件名修改,eg:w.cpt.doc / w.svg.doc,去掉中间的后缀名~~ w.doc // 打开文件后输出文件名修改,eg:w.cpt.doc / w.svg.doc,去掉中间的后缀名~~ w.doc
String filenName = editingFILE.getName(); String filenName = editingFILE.getName();

7
designer-realize/src/com/fr/design/actions/file/export/CSVExportAction.java

@ -4,6 +4,7 @@
package com.fr.design.actions.file.export; package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.design.mainframe.JWorkBook; import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
@ -40,16 +41,16 @@ public class CSVExportAction extends AbstractExportAction {
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"csv"}, Inter.getLocText("Export-CSV")); return new ChooseFileFilter(FileExtension.CSV, Inter.getLocText("Export-CSV"));
} }
@Override @Override
protected String getDefaultExtension() { protected String getDefaultExtension() {
TemplateWorkBook tpl = this.getTemplateWorkBook(); TemplateWorkBook tpl = this.getTemplateWorkBook();
if (hasLayerReport(tpl)) { if (hasLayerReport(tpl)) {
return "zip"; return FileExtension.ZIP.getExtension();
} else { } else {
return "csv"; return FileExtension.CSV.getExtension();
} }
} }
} }

7
designer-realize/src/com/fr/design/actions/file/export/EmbeddedExportExportAction.java

@ -1,6 +1,7 @@
package com.fr.design.actions.file.export; package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.design.mainframe.JWorkBook; import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
@ -8,6 +9,8 @@ import com.fr.general.Inter;
import com.fr.io.exporter.EmbeddedTableDataExporter; import com.fr.io.exporter.EmbeddedTableDataExporter;
import com.fr.io.exporter.Exporter; import com.fr.io.exporter.Exporter;
import java.util.EnumSet;
/** /**
* Export Embedded. * Export Embedded.
*/ */
@ -30,13 +33,13 @@ public class EmbeddedExportExportAction extends AbstractExportAction {
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"cpt"}, return new ChooseFileFilter(EnumSet.of(FileExtension.CPTX, FileExtension.CPT),
Inter.getLocText("Export-Template(embedded_data)")); Inter.getLocText("Export-Template(embedded_data)"));
} }
@Override @Override
protected String getDefaultExtension() { protected String getDefaultExtension() {
return "cpt"; return getEditingComponent().suffix().substring(1);
} }
} }

5
designer-realize/src/com/fr/design/actions/file/export/PDFExportAction.java

@ -4,6 +4,7 @@
package com.fr.design.actions.file.export; package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.design.mainframe.JWorkBook; import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
@ -34,12 +35,12 @@ public class PDFExportAction extends AbstractExportAction {
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"pdf"}, Inter.getLocText("FR-Designer_Export-PDF")); return new ChooseFileFilter(FileExtension.PDF, Inter.getLocText("FR-Designer_Export-PDF"));
} }
@Override @Override
protected String getDefaultExtension() { protected String getDefaultExtension() {
return "pdf"; return FileExtension.PDF.getExtension();
} }
} }

19
designer-realize/src/com/fr/design/actions/file/export/PageToSheetExcelExportAction.java

@ -1,6 +1,7 @@
package com.fr.design.actions.file.export; package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.design.mainframe.JWorkBook; import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
@ -12,28 +13,28 @@ import com.fr.report.core.ReportUtils;
public class PageToSheetExcelExportAction extends AbstractExcelExportAction { public class PageToSheetExcelExportAction extends AbstractExcelExportAction {
public PageToSheetExcelExportAction(JWorkBook jwb) { public PageToSheetExcelExportAction(JWorkBook jwb) {
super(jwb); super(jwb);
this.setMenuKeySet(KeySetUtils.PAGETOSHEET_EXCEL_EXPORT); this.setMenuKeySet(KeySetUtils.PAGETOSHEET_EXCEL_EXPORT);
this.setName(getMenuKeySet().getMenuKeySetName()+"..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/excel.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/excel.png"));
} }
@Override @Override
protected Exporter getExporter() { protected Exporter getExporter() {
TemplateWorkBook tpl = this.getTemplateWorkBook(); TemplateWorkBook tpl = this.getTemplateWorkBook();
return new PageToSheetExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl)); return new PageToSheetExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl));
} }
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"xls"}, Inter.getLocText("Export-Excel")); return new ChooseFileFilter(FileExtension.XLS, Inter.getLocText("Export-Excel"));
} }
@Override @Override
protected String getDefaultExtension() { protected String getDefaultExtension() {
return "xls"; return FileExtension.XLS.getExtension();
} }
} }

17
designer-realize/src/com/fr/design/actions/file/export/SVGExportAction.java

@ -4,6 +4,7 @@
package com.fr.design.actions.file.export; package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.design.mainframe.JWorkBook; import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
@ -18,27 +19,27 @@ public class SVGExportAction extends AbstractExportAction {
/** /**
* Constructor * Constructor
*/ */
public SVGExportAction(JWorkBook jwb) { public SVGExportAction(JWorkBook jwb) {
super(jwb); super(jwb);
this.setMenuKeySet(KeySetUtils.SVG_EXPORT); this.setMenuKeySet(KeySetUtils.SVG_EXPORT);
this.setName(getMenuKeySet().getMenuKeySetName()+"..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/svg.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/svg.png"));
} }
@Override @Override
protected Exporter getExporter() { protected Exporter getExporter() {
return new SVGExporter(); return new SVGExporter();
} }
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"svg"}, Inter.getLocText("Export-SVG")); return new ChooseFileFilter(FileExtension.SVG, Inter.getLocText("Export-SVG"));
} }
@Override @Override
protected String getDefaultExtension() { protected String getDefaultExtension() {
return "svg"; return FileExtension.SVG.getExtension();
} }
} }

17
designer-realize/src/com/fr/design/actions/file/export/TextExportAction.java

@ -4,6 +4,7 @@
package com.fr.design.actions.file.export; package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.design.mainframe.JWorkBook; import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
@ -18,26 +19,26 @@ public class TextExportAction extends AbstractExportAction {
/** /**
* Constructor * Constructor
*/ */
public TextExportAction(JWorkBook jwb) { public TextExportAction(JWorkBook jwb) {
super(jwb); super(jwb);
this.setMenuKeySet(KeySetUtils.TEXT_EXPORT); this.setMenuKeySet(KeySetUtils.TEXT_EXPORT);
this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png"));
} }
@Override @Override
protected Exporter getExporter() { protected Exporter getExporter() {
return new TextExporter(); return new TextExporter();
} }
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"txt"}, Inter.getLocText("Export-Text")); return new ChooseFileFilter(FileExtension.TXT, Inter.getLocText("Export-Text"));
} }
@Override @Override
protected String getDefaultExtension() { protected String getDefaultExtension() {
return "txt"; return FileExtension.TXT.getExtension();
} }
} }

17
designer-realize/src/com/fr/design/actions/file/export/WordExportAction.java

@ -4,6 +4,7 @@
package com.fr.design.actions.file.export; package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.design.mainframe.JWorkBook; import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
@ -18,26 +19,26 @@ public class WordExportAction extends AbstractExportAction {
/** /**
* Constructor * Constructor
*/ */
public WordExportAction(JWorkBook jwb) { public WordExportAction(JWorkBook jwb) {
super(jwb); super(jwb);
this.setMenuKeySet(KeySetUtils.WORD_EXPORT); this.setMenuKeySet(KeySetUtils.WORD_EXPORT);
this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/word.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/word.png"));
} }
@Override @Override
protected Exporter getExporter() { protected Exporter getExporter() {
return new WordExporter(); return new WordExporter();
} }
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"doc"}, Inter.getLocText("Export-Word")); return new ChooseFileFilter(FileExtension.DOC, Inter.getLocText("Export-Word"));
} }
@Override @Override
protected String getDefaultExtension() { protected String getDefaultExtension() {
return "doc"; return FileExtension.DOC.getExtension();
} }
} }

17
designer-realize/src/com/fr/design/module/DesignerModule.java

@ -7,6 +7,7 @@ import com.fr.base.Formula;
import com.fr.base.MultiFieldParameter; import com.fr.base.MultiFieldParameter;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.TempNameStyle; import com.fr.base.TempNameStyle;
import com.fr.base.extension.FileExtension;
import com.fr.base.frpx.exception.FRPackageRunTimeException; import com.fr.base.frpx.exception.FRPackageRunTimeException;
import com.fr.base.frpx.exception.InvalidWorkBookException; import com.fr.base.frpx.exception.InvalidWorkBookException;
import com.fr.base.io.XMLEncryptUtils; import com.fr.base.io.XMLEncryptUtils;
@ -302,8 +303,8 @@ public class DesignerModule extends DesignModule {
private AbstractWorkBookApp getXlsxApp() { private AbstractWorkBookApp getXlsxApp() {
return new AbstractWorkBookApp() { return new AbstractWorkBookApp() {
@Override @Override
public String[] defaultExtentions() { public String[] defaultExtensions() {
return new String[]{"xlsx"}; return new String[]{FileExtension.XLSX.getExtension()};
} }
@Override @Override
@ -322,8 +323,8 @@ public class DesignerModule extends DesignModule {
private AbstractWorkBookApp getXlsApp() { private AbstractWorkBookApp getXlsApp() {
return new AbstractWorkBookApp() { return new AbstractWorkBookApp() {
@Override @Override
public String[] defaultExtentions() { public String[] defaultExtensions() {
return new String[]{"xls"}; return new String[]{FileExtension.XLS.getExtension()};
} }
@Override @Override
@ -342,8 +343,8 @@ public class DesignerModule extends DesignModule {
private AbstractWorkBookApp getCptApp() { private AbstractWorkBookApp getCptApp() {
return new AbstractWorkBookApp() { return new AbstractWorkBookApp() {
@Override @Override
public String[] defaultExtentions() { public String[] defaultExtensions() {
return new String[]{"cpt"}; return new String[]{FileExtension.CPT.getExtension()};
} }
@Override @Override
@ -381,8 +382,8 @@ public class DesignerModule extends DesignModule {
return new AbstractWorkBookApp() { return new AbstractWorkBookApp() {
@Override @Override
public String[] defaultExtentions() { public String[] defaultExtensions() {
return new String[]{"cptx"}; return new String[]{FileExtension.CPTX.getExtension()};
} }
@Override @Override

Loading…
Cancel
Save