Browse Source

远程导出

research/10.0
yaoh.wu 6 years ago
parent
commit
a57c7c4b81
  1. 20
      designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java
  2. 1
      designer-base/src/main/java/com/fr/file/FILE.java
  3. 12
      designer-base/src/main/java/com/fr/file/MemFILE.java
  4. 2
      designer-form/src/main/java/com/fr/design/actions/FormMobileAttrAction.java
  5. 2
      designer-form/src/main/java/com/fr/design/actions/NewFormAction.java
  6. 2
      designer-form/src/main/java/com/fr/design/actions/TemplateParameterAction.java
  7. 185
      designer-form/src/main/java/com/fr/design/actions/file/export/EmbeddedFormExportExportAction.java
  8. 8
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  9. 155
      designer-form/src/main/java/com/fr/design/mainframe/actions/EmbeddedFormExportExportAction.java
  10. 2
      designer-realize/src/main/java/com/fr/design/actions/file/export/AbstractExcelExportAction.java
  11. 196
      designer-realize/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java
  12. 197
      designer-realize/src/main/java/com/fr/design/actions/file/export/AbstractJWorkBookExportAction.java
  13. 25
      designer-realize/src/main/java/com/fr/design/actions/file/export/CSVExportAction.java
  14. 18
      designer-realize/src/main/java/com/fr/design/actions/file/export/EmbeddedExportExportAction.java
  15. 15
      designer-realize/src/main/java/com/fr/design/actions/file/export/ExcelExportAction.java
  16. 19
      designer-realize/src/main/java/com/fr/design/actions/file/export/PDFExportAction.java
  17. 15
      designer-realize/src/main/java/com/fr/design/actions/file/export/PageExcelExportAction.java
  18. 19
      designer-realize/src/main/java/com/fr/design/actions/file/export/PageToSheetExcelExportAction.java
  19. 19
      designer-realize/src/main/java/com/fr/design/actions/file/export/SVGExportAction.java
  20. 17
      designer-realize/src/main/java/com/fr/design/actions/file/export/TextExportAction.java
  21. 13
      designer-realize/src/main/java/com/fr/design/actions/file/export/WordExportAction.java
  22. 4
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  23. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java
  24. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java
  25. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java
  26. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java
  27. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java
  28. 2
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

20
designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java

@ -0,0 +1,20 @@
package com.fr.design.actions.file.export;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.DesignExportType;
public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JTemplateAction<E> {
public AbstractExportAction(E t) {
super(t);
}
public abstract String exportScopeName();
public abstract DesignExportType exportType();
protected abstract ChooseFileFilter getChooseFileFilter();
}

1
designer-base/src/main/java/com/fr/file/FILE.java

@ -55,6 +55,7 @@ public interface FILE {
* @return 是否新建成功 * @return 是否新建成功
* @throws Exception 异常 * @throws Exception 异常
*/ */
@SuppressWarnings({"UnusedReturnValue"})
boolean mkfile() throws Exception; boolean mkfile() throws Exception;
/** /**

12
designer-base/src/main/java/com/fr/file/MemFILE.java

@ -18,6 +18,7 @@ public class MemFILE implements FILE {
* @param name 名字 * @param name 名字
* @return 新建目录 * @return 新建目录
*/ */
@Override
public boolean createFolder(String name) { public boolean createFolder(String name) {
return false; return false;
} }
@ -27,6 +28,7 @@ public class MemFILE implements FILE {
* *
* @return 是否存在 * @return 是否存在
*/ */
@Override
public boolean exists() { public boolean exists() {
return false; return false;
} }
@ -37,6 +39,7 @@ public class MemFILE implements FILE {
* @return 是否新建成功 * @return 是否新建成功
* @throws Exception 异常 * @throws Exception 异常
*/ */
@Override
public boolean mkfile() throws Exception { public boolean mkfile() throws Exception {
return false; return false;
} }
@ -56,6 +59,7 @@ public class MemFILE implements FILE {
return name; return name;
} }
@Override
public String getEnvFullName() { public String getEnvFullName() {
return name; return name;
} }
@ -65,6 +69,7 @@ public class MemFILE implements FILE {
* *
* @return 是则返回true * @return 是则返回true
*/ */
@Override
public boolean isMemFile() { public boolean isMemFile() {
return true; return true;
} }
@ -74,6 +79,7 @@ public class MemFILE implements FILE {
* *
* @return 是则返回true * @return 是则返回true
*/ */
@Override
public boolean isEnvFile() { public boolean isEnvFile() {
return false; return false;
} }
@ -88,6 +94,7 @@ public class MemFILE implements FILE {
* *
* @return 是则返回true * @return 是则返回true
*/ */
@Override
public boolean isDirectory() { public boolean isDirectory() {
return false; return false;
} }
@ -97,6 +104,7 @@ public class MemFILE implements FILE {
* *
* @return 文件 * @return 文件
*/ */
@Override
public FILE[] listFiles() { public FILE[] listFiles() {
return new FILE[0]; return new FILE[0];
} }
@ -106,6 +114,7 @@ public class MemFILE implements FILE {
* *
* @return 前缀 * @return 前缀
*/ */
@Override
public String prefix() { public String prefix() {
return FILEFactory.MEM_PREFIX; return FILEFactory.MEM_PREFIX;
} }
@ -129,6 +138,7 @@ public class MemFILE implements FILE {
* *
* @throws Exception 异常 * @throws Exception 异常
*/ */
@Override
public void closeTemplate() throws Exception { public void closeTemplate() throws Exception {
} }
@ -138,6 +148,7 @@ public class MemFILE implements FILE {
* @return 输入流 * @return 输入流
* @throws Exception 异常 * @throws Exception 异常
*/ */
@Override
public InputStream asInputStream() throws Exception { public InputStream asInputStream() throws Exception {
return null; return null;
} }
@ -148,6 +159,7 @@ public class MemFILE implements FILE {
* @return 输出流 * @return 输出流
* @throws Exception 异常 * @throws Exception 异常
*/ */
@Override
public OutputStream asOutputStream() throws Exception { public OutputStream asOutputStream() throws Exception {
return null; return null;
} }

2
designer-form/src/main/java/com/fr/design/mainframe/actions/FormMobileAttrAction.java → designer-form/src/main/java/com/fr/design/actions/FormMobileAttrAction.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.actions; package com.fr.design.actions;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.iofile.attr.MobileOnlyTemplateAttrMark; import com.fr.base.iofile.attr.MobileOnlyTemplateAttrMark;

2
designer-form/src/main/java/com/fr/design/mainframe/actions/NewFormAction.java → designer-form/src/main/java/com/fr/design/actions/NewFormAction.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.actions; package com.fr.design.actions;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;

2
designer-form/src/main/java/com/fr/design/mainframe/actions/TemplateParameterAction.java → designer-form/src/main/java/com/fr/design/actions/TemplateParameterAction.java

@ -1,4 +1,4 @@
package com.fr.design.mainframe.actions; package com.fr.design.actions;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Parameter; import com.fr.base.Parameter;

185
designer-form/src/main/java/com/fr/design/actions/file/export/EmbeddedFormExportExportAction.java

@ -0,0 +1,185 @@
package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.iprogressbar.FRProgressBar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.form.main.Form;
import com.fr.io.exporter.DesignExportType;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.exporter.TemplateExportOperator;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import java.awt.event.ActionEvent;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
/**
* Export Embedded.
*/
public class EmbeddedFormExportExportAction extends AbstractExportAction<JForm> {
private FRProgressBar progressbar;
public EmbeddedFormExportExportAction(JForm jwb) {
super(jwb);
this.setMenuKeySet(KeySetUtils.EMBEDDED_EXPORT);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/oem/logo.png"));
}
@Override
public String exportScopeName() {
return "FINE_FORM";
}
@Override
public DesignExportType exportType() {
return DesignExportType.EMBEDDED_FORM;
}
/**
* Action触发事件
*
* @param e 触发事件
*/
@Override
public void actionPerformed(ActionEvent e) {
// todo 提示保存
JTemplate jwb = this.getEditingComponent();
FILE source = jwb.getEditingFILE();
// 输入参数
final Map<String, Object> parameterMap = new HashMap<String, Object>();
final Form tpl = this.getEditingComponent().getTarget();
inputParameter(parameterMap, tpl, DesignerContext.getDesignerFrame());
FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(false, true);
fileChooserPane.setFILEFilter(this.getChooseFileFilter());
String fileName = source.getName();
fileChooserPane.setFileNameTextField(fileName, ProjectConstants.FRM_SUFFIX);
int saveValue = fileChooserPane.showSaveDialog(DesignerContext.getDesignerFrame(), ProjectConstants.FRM_SUFFIX);
if (isOk(saveValue)) {
startExport(source, parameterMap, fileChooserPane);
}
}
private void startExport(FILE source, Map<String, Object> parameterMap,
FILEChooserPane fileChooserPane) {
FILE target = fileChooserPane.getSelectedFILE();
try {
target.mkfile();
} catch (Exception e1) {
FineLoggerFactory.getLogger().error("Error In Make New File");
}
FineLoggerFactory.getLogger().info("\"" + target.getName() + "\"" + Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!");
(progressbar =
new FRProgressBar(
createExportWork(source, target, parameterMap),
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Report_Exporting"),
StringUtils.EMPTY,
0,
100)
).start();
}
private boolean isOk(int saveValue) {
return saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION;
}
private void inputParameter(final Map<String, Object> parameterMap, final Form tpl, DesignerFrame designerFrame) {
Parameter[] parameters = tpl.getParameters();
// 检查Parameter.
if (ArrayUtils.isNotEmpty(parameters)) {
final ParameterInputPane pPane = new ParameterInputPane(parameters);
pPane.showSmallWindow(designerFrame, new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
}
}
@Override
protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"frm"}, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EmbeddedTD"));
}
private SwingWorker createExportWork(FILE source, final FILE target, final Map<String, Object> parameterMap) {
final String path = source.getPath();
final String name = target.getName();
return new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
Thread.sleep(100);
try {
final OutputStream fileOutputStream = target.asOutputStream();
this.setProgress(10);
dealExporter(fileOutputStream, path, parameterMap);
this.setProgress(80);
fileOutputStream.flush();
fileOutputStream.close();
this.setProgress(100);
FineLoggerFactory.getLogger().info("\"" + name + "\"" + Toolkit.i18nText("Fine-Design_Report_Finish_Export") + "!");
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Report_Exported_Successfully") + "\n" + name);
} catch (Exception exp) {
this.setProgress(100);
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Report_Export_Failed") + "\n" + path);
}
return null;
}
@Override
public void done() {
progressbar.close();
}
};
}
private void dealExporter(OutputStream outputStream, String path, final Map<String, Object> para) throws Exception {
// 没有办法处理这个 isLocal 判断,因为一个是修改参数传递结果,一个是返回值做结果
// todo 后续想想办法
if (WorkContext.getCurrent().isLocal()) {
WorkContext.getCurrent().get(TemplateExportOperator.class)
.export(exportScopeName(), exportType(), outputStream, path, para);
} else {
byte[] contents =
WorkContext.getCurrent().get(TemplateExportOperator.class)
.export(exportScopeName(), exportType(), null, path, para);
outputStream.write(contents);
}
}
}

8
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -5,6 +5,8 @@ import com.fr.base.PaperSize;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.actions.file.export.EmbeddedFormExportExportAction;
import com.fr.design.actions.TemplateParameterAction;
import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.cell.FloatElementsProvider; import com.fr.design.cell.FloatElementsProvider;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
@ -31,11 +33,8 @@ import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.xpane.FormHyperlinkGroupPane; import com.fr.design.gui.xpane.FormHyperlinkGroupPane;
import com.fr.design.gui.xpane.FormHyperlinkGroupPaneNoPop; import com.fr.design.gui.xpane.FormHyperlinkGroupPaneNoPop;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.actions.EmbeddedFormExportExportAction;
import com.fr.design.mainframe.actions.TemplateParameterAction;
import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider; import com.fr.design.mainframe.form.FormECDesignerProvider;
import com.fr.design.report.fit.menupane.ReportFitAttrAction;
import com.fr.design.mainframe.templateinfo.JFormProcessInfo; import com.fr.design.mainframe.templateinfo.JFormProcessInfo;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo; import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
@ -47,6 +46,7 @@ import com.fr.design.menu.ToolBarDef;
import com.fr.design.parameter.ParameterPropertyPane; import com.fr.design.parameter.ParameterPropertyPane;
import com.fr.design.preview.FormPreview; import com.fr.design.preview.FormPreview;
import com.fr.design.preview.MobilePreview; import com.fr.design.preview.MobilePreview;
import com.fr.design.report.fit.menupane.ReportFitAttrAction;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.file.FILE; import com.fr.file.FILE;
@ -469,6 +469,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
public void setPictureElem(Elem elem, CellImage cellImage) { public void setPictureElem(Elem elem, CellImage cellImage) {
elem.setValue(cellImage.getImage()); elem.setValue(cellImage.getImage());
} }
/** /**
* 目标菜单 * 目标菜单
* *
@ -932,6 +933,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
/** /**
* 支持的预览模式 * 支持的预览模式
*
* @return 预览模式 * @return 预览模式
*/ */
@Override @Override

155
designer-form/src/main/java/com/fr/design/mainframe/actions/EmbeddedFormExportExportAction.java

@ -1,155 +0,0 @@
package com.fr.design.mainframe.actions;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.iprogressbar.FRProgressBar;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.form.main.Form;
import com.fr.form.main.FormEmbeddedTableDataExporter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Map;
/**
* Export Embedded.
*/
public class EmbeddedFormExportExportAction extends JTemplateAction<JForm>{
private FRProgressBar progressbar;
/**
* Constructor
*/
public EmbeddedFormExportExportAction(JForm jwb) {
super(jwb);
this.setMenuKeySet(KeySetUtils.EMBEDDED_EXPORT);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/oem/logo.png"));
}
/**
* Action触发事件
*
* @param e 触发事件
*
*/
public void actionPerformed(ActionEvent e) {
JTemplate jwb = this.getEditingComponent();
FILE editingFILE = jwb.getEditingFILE();
DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final Map<String, Object> parameterMap = new HashMap<String, Object>();
final Form tpl = this.getEditingComponent().getTarget();
inputParameter(parameterMap, tpl, designerFrame);
FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(false, true);
fileChooserPane.setFILEFilter(this.getChooseFileFilter());
String filenName = editingFILE.getName();
fileChooserPane.setFileNameTextField(filenName, ProjectConstants.FRM_SUFFIX);
int saveValue = fileChooserPane.showSaveDialog(designerFrame, ProjectConstants.FRM_SUFFIX);
if (isCancel(saveValue)) {
fileChooserPane = null;
return;
}
if (isOk(saveValue)) {
startExport(parameterMap, tpl, designerFrame, fileChooserPane);
}
}
private void startExport(Map<String, Object> parameterMap, Form tpl, DesignerFrame designerFrame,
FILEChooserPane fileChooserPane){
FILE file = fileChooserPane.getSelectedFILE();
try {
file.mkfile();
} catch (Exception e1) {
FineLoggerFactory.getLogger().error("Error In Make New File");
}
fileChooserPane = null;
FRContext.getLogger().info("\"" + file.getName() + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!");
(progressbar = new FRProgressBar(createExportWork(file, tpl, parameterMap), designerFrame,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Exporting"), "", 0, 100)).start();
}
private boolean isOk(int saveValue){
return saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION;
}
private boolean isCancel(int saveValue){
return saveValue == FILEChooserPane.CANCEL_OPTION || saveValue == FILEChooserPane.JOPTIONPANE_CANCEL_OPTION;
}
private void inputParameter(final Map<String, Object> parameterMap, final Form tpl, DesignerFrame designerFrame){
Parameter[] parameters = tpl.getParameters();
if (ArrayUtils.isNotEmpty(parameters)) {// 检查Parameter.
final ParameterInputPane pPane = new ParameterInputPane(parameters);
pPane.showSmallWindow(designerFrame, new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
}
}
protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"frm"}, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EmbeddedTD"));
}
private SwingWorker createExportWork(FILE file, final Form tpl, final Map parameterMap) {
final String filePath = file.getPath();
final String fileGetName = file.getName();
SwingWorker exportWorker = new SwingWorker<Void, Void>() {
protected Void doInBackground() throws Exception {
Thread.sleep(100);
try {
final FileOutputStream fileOutputStream = new FileOutputStream(filePath);
this.setProgress(10);
FormEmbeddedTableDataExporter exporter = new FormEmbeddedTableDataExporter();
exporter.export(fileOutputStream, tpl, parameterMap);
this.setProgress(80);
fileOutputStream.close();
this.setProgress(100);
FRContext.getLogger().info("\"" + fileGetName + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Finish_Export") + "!");
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Exported_Successfully") + "\n" + fileGetName);
} catch (Exception exp) {
this.setProgress(100);
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_Failed") + "\n" + filePath);
}
return null;
}
public void done() {
progressbar.close();
}
};
return exportWorker;
}
}

2
designer-realize/src/main/java/com/fr/design/actions/file/export/AbstractExcelExportAction.java

@ -12,7 +12,7 @@ import com.fr.main.TemplateWorkBook;
/** /**
* Export excel. * Export excel.
*/ */
public abstract class AbstractExcelExportAction extends AbstractExportAction { public abstract class AbstractExcelExportAction extends AbstractJWorkBookExportAction {
/** /**
* Constructor * Constructor
*/ */

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

@ -1,196 +0,0 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.file.export;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.design.actions.JWorkBookAction;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.iprogressbar.FRProgressBar;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.log.FineLoggerFactory;
import com.fr.io.exporter.AppExporter;
import com.fr.io.exporter.CSVExporter;
import com.fr.io.exporter.EmbeddedTableDataExporter;
import com.fr.io.exporter.ExcelExporter;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.PDFExporterProcessor;
import com.fr.io.exporter.WordExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
import com.fr.page.PageSetProvider;
import com.fr.report.ReportHelper;
import com.fr.report.core.ReportUtils;
import com.fr.report.report.Report;
import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.ActorConstants;
import com.fr.stable.ActorFactory;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.OutputStream;
import java.util.Map;
/**
* Abstract export action.
*/
public abstract class AbstractExportAction extends JWorkBookAction {
protected AbstractExportAction(JWorkBook jwb) {
super(jwb);
}
private FRProgressBar progressbar;
protected WorkBook getTemplateWorkBook() {
return this.getEditingComponent().getTarget();
}
/**
* 执行方法
*/
@Override
public void actionPerformed(ActionEvent e) {
JWorkBook jwb = this.getEditingComponent();
FILE editingFILE = jwb.getEditingFILE();
DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
// 弹出参数
final java.util.Map parameterMap = new java.util.HashMap();
final TemplateWorkBook tpl = getTemplateWorkBook();
Parameter[] parameters = tpl.getParameters();
if (parameters != null && parameters.length > 0) {// 检查Parameter.
final ParameterInputPane pPane = new ParameterInputPane(
parameters);
pPane.showSmallWindow(designerFrame, new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
}
// Choose a file name....
FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(true, true);
fileChooserPane.addChooseFILEFilter(this.getChooseFileFilter());
// 打开文件后输出文件名修改,eg:w.cpt.doc / w.svg.doc,去掉中间的后缀名~~ w.doc
String filenName = editingFILE.getName();
if (filenName.indexOf('.') != -1) {
filenName = filenName.substring(0, editingFILE.getName().lastIndexOf('.'));
}
fileChooserPane.setFileNameTextField(filenName, "." + this.getDefaultExtension());
int saveValue = fileChooserPane.showSaveDialog(designerFrame, "." + this.getDefaultExtension());
if (saveValue == FILEChooserPane.CANCEL_OPTION || saveValue == FILEChooserPane.JOPTIONPANE_CANCEL_OPTION) {
fileChooserPane = null;
return;
} else if (saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION) {
FILE file = fileChooserPane.getSelectedFILE();
try {
file.mkfile();
} catch (Exception e1) {
FineLoggerFactory.getLogger().error("Error In Make New File");
}
fileChooserPane = null;
FRContext.getLogger().info("\"" + file.getName() + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!");
(progressbar = new FRProgressBar(createExportWork(file, tpl, parameterMap), designerFrame,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Exporting"), "", 0, 100)).start();
}
}
private SwingWorker createExportWork(final FILE file, final TemplateWorkBook tpl, final Map parameterMap) {
final String filePath = file.getPath();
final String fileGetName = file.getName();
SwingWorker exportWorker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
Thread.sleep(100); //bug 10516
try {
OutputStream outputStream = file.asOutputStream();
this.setProgress(10);
dealExporter(outputStream, tpl, parameterMap);
this.setProgress(80);
outputStream.flush();
outputStream.close();
this.setProgress(100);
FRContext.getLogger().info("\"" + fileGetName + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Finish_Export") + "!");
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Exported_Successfully") + "\n" + fileGetName);
} catch (Exception exp) {
this.setProgress(100);
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_Failed") + "\n" + filePath,
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
}
return null;
}
@Override
public void done() {
progressbar.close();
}
};
return exportWorker;
}
private void dealExporter(OutputStream outputStream, final TemplateWorkBook tpl, final Map parameterMap) throws Exception {
final Exporter exporter = AbstractExportAction.this.getExporter();
if (exporter instanceof AppExporter) {
AppExporter appExporter = (AppExporter) exporter;
if (exporter instanceof ExcelExporter || exporter instanceof CSVExporter
|| exporter instanceof PDFExporterProcessor || exporter instanceof WordExporter) {
ReportHelper.clearFormulaResult(tpl);// 清空rpt中的公式计算结果
appExporter.export(outputStream, tpl.execute(parameterMap, ActorFactory.getActor(ActorConstants.TYPE_PAGE)
));
} else {
ReportHelper.clearFormulaResult(tpl);// 清空currentReport中的公式计算结果
PageSetProvider pageSet = tpl.execute(parameterMap, ActorFactory.getActor(ActorConstants.TYPE_PAGE)).generateReportPageSet(
ReportUtils.getPaperSettingListFromWorkBook(tpl)).traverse4Export();
appExporter.export(outputStream, pageSet);
pageSet.release();
}
} else if (exporter instanceof EmbeddedTableDataExporter) {
((EmbeddedTableDataExporter) exporter).export(outputStream, (WorkBook) tpl, parameterMap);
}
}
/*
* 这边判断是否有层式报表有层式需要使用大数据量导出
*/
protected boolean hasLayerReport(TemplateWorkBook tpl) {
if (tpl == null) {
return false;
}
for (int i = 0; i < tpl.getReportCount(); i++) {
Report r = tpl.getReport(i);
if (r instanceof WorkSheet) {
if (((WorkSheet) r).getLayerReportAttr() != null) {
return true;
}
}
}
return false;
}
protected abstract ChooseFileFilter getChooseFileFilter();
protected abstract String getDefaultExtension();
protected abstract Exporter getExporter();
}

197
designer-realize/src/main/java/com/fr/design/actions/file/export/AbstractJWorkBookExportAction.java

@ -0,0 +1,197 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.actions.file.export;
import com.fr.base.Parameter;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.iprogressbar.FRProgressBar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.log.FineLoggerFactory;
import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
import com.fr.report.report.Report;
import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.exporter.TemplateExportOperator;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import java.awt.event.ActionEvent;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
/**
* Abstract export action.
*/
public abstract class AbstractJWorkBookExportAction extends AbstractExportAction<JWorkBook> {
private FRProgressBar progressbar;
protected AbstractJWorkBookExportAction(JWorkBook jwb) {
super(jwb);
}
protected WorkBook getTemplateWorkBook() {
return this.getEditingComponent().getTarget();
}
/**
* 执行方法
*/
@Override
public void actionPerformed(ActionEvent e) {
// todo 弹出提醒保存,如果没保存
JWorkBook jwb = this.getEditingComponent();
FILE source = jwb.getEditingFILE();
// 弹出参数
final Map<String, Object> parameterMap = new HashMap<>();
final TemplateWorkBook tpl = getTemplateWorkBook();
Parameter[] parameters = tpl.getParameters();
if (parameters != null && parameters.length > 0) {// 检查Parameter.
final ParameterInputPane pPane = new ParameterInputPane(
parameters);
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
}
// file choose
FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(true, true);
fileChooserPane.addChooseFILEFilter(this.getChooseFileFilter());
// 打开文件后输出文件名修改,eg:w.cpt.doc / w.svg.doc,去掉中间的后缀名~~ w.doc
String fileName = source.getName();
if (fileName.indexOf('.') != -1) {
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
}
fileChooserPane.setFileNameTextField(fileName, "." + this.getDefaultExtension());
int saveValue = fileChooserPane.showSaveDialog(DesignerContext.getDesignerFrame(), "." + this.getDefaultExtension());
if (saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION) {
FILE target = fileChooserPane.getSelectedFILE();
try {
target.mkfile();
} catch (Exception exp) {
FineLoggerFactory.getLogger().error("Error In Make New File", exp);
}
FineLoggerFactory.getLogger().info("\"" + target.getName() + "\"" + Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!");
(progressbar = new FRProgressBar(
createExportWork(source, target, parameterMap),
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Report_Exporting"),
StringUtils.EMPTY,
0,
100)
).start();
}
}
private SwingWorker createExportWork(final FILE source, final FILE target, final Map<String, Object> parameterMap) {
final String path = source.getPath();
final String name = target.getName();
return new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
//bug 10516
Thread.sleep(100);
OutputStream outputStream = null;
try {
outputStream = target.asOutputStream();
this.setProgress(10);
dealExporter(outputStream, path, parameterMap);
this.setProgress(80);
outputStream.flush();
outputStream.close();
this.setProgress(100);
FineLoggerFactory.getLogger().info("\"" + name + "\"" + Toolkit.i18nText("Fine-Design_Report_Finish_Export") + "!");
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Report_Exported_Successfully") + "\n" + name);
} catch (Exception exp) {
this.setProgress(100);
target.closeTemplate();
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Report_Export_Failed") + "\n" + path,
null,
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
} finally {
if (outputStream != null) {
outputStream.close();
}
}
return null;
}
@Override
public void done() {
progressbar.close();
}
};
}
private void dealExporter(OutputStream outputStream, String path, final Map<String, Object> para) throws Exception {
// 没有办法处理这个 isLocal 判断,因为一个是修改参数传递结果,一个是返回值做结果
// todo 后续想想办法
if (WorkContext.getCurrent().isLocal()) {
WorkContext.getCurrent().get(TemplateExportOperator.class)
.export(exportScopeName(), exportType(), outputStream, path, para);
} else {
byte[] contents =
WorkContext.getCurrent().get(TemplateExportOperator.class)
.export(exportScopeName(), exportType(), null, path, para);
outputStream.write(contents);
}
}
/*
* 这边判断是否有层式报表有层式需要使用大数据量导出
*/
protected boolean hasLayerReport(TemplateWorkBook tpl) {
if (tpl == null) {
return false;
}
for (int i = 0; i < tpl.getReportCount(); i++) {
Report r = tpl.getReport(i);
if (r instanceof WorkSheet) {
if (((WorkSheet) r).getLayerReportAttr() != null) {
return true;
}
}
}
return false;
}
protected abstract String getDefaultExtension();
public String exportScopeName() {
return "FINE_BOOK";
}
}

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

@ -5,19 +5,17 @@ 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.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
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;
import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.CSVExporter;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.LargeDataPageCSVExporter;
import com.fr.main.TemplateWorkBook; import com.fr.main.TemplateWorkBook;
/** /**
* Export CSV. * Export CSV.
*/ */
public class CSVExportAction extends AbstractExportAction { public class CSVExportAction extends AbstractJWorkBookExportAction {
/** /**
* Constructor * Constructor
*/ */
@ -29,19 +27,9 @@ public class CSVExportAction extends AbstractExportAction {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/csv.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/csv.png"));
} }
@Override
protected Exporter getExporter() {
TemplateWorkBook tpl = this.getTemplateWorkBook();
if (hasLayerReport(tpl)) {
return new LargeDataPageCSVExporter();
} else {
return new CSVExporter();
}
}
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.CSV, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_CSV")); return new ChooseFileFilter(FileExtension.CSV, Toolkit.i18nText("Fine-Design_Report_Export_CSV"));
} }
@Override @Override
@ -53,4 +41,9 @@ public class CSVExportAction extends AbstractExportAction {
return FileExtension.CSV.getExtension(); return FileExtension.CSV.getExtension();
} }
} }
@Override
public DesignExportType exportType() {
return DesignExportType.CSV;
}
} }

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

@ -2,19 +2,18 @@ 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.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
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;
import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.EmbeddedTableDataExporter;
import com.fr.io.exporter.Exporter;
import java.util.EnumSet; import java.util.EnumSet;
/** /**
* Export Embedded. * Export Embedded.
*/ */
public class EmbeddedExportExportAction extends AbstractExportAction { public class EmbeddedExportExportAction extends AbstractJWorkBookExportAction {
/** /**
* Constructor * Constructor
*/ */
@ -26,15 +25,10 @@ public class EmbeddedExportExportAction extends AbstractExportAction {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/oem/logo.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/oem/logo.png"));
} }
@Override
protected Exporter getExporter() {
return new EmbeddedTableDataExporter();
}
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(EnumSet.of(FileExtension.CPTX, FileExtension.CPT), return new ChooseFileFilter(EnumSet.of(FileExtension.CPTX, FileExtension.CPT),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_Template(Embedded_Data)")); Toolkit.i18nText("Fine-Design_Report_Export_Template(Embedded_Data)"));
} }
@Override @Override
@ -42,4 +36,8 @@ public class EmbeddedExportExportAction extends AbstractExportAction {
return getEditingComponent().suffix().substring(1); return getEditingComponent().suffix().substring(1);
} }
@Override
public DesignExportType exportType() {
return DesignExportType.EMBEDDED_WORKBOOK;
}
} }

15
designer-realize/src/main/java/com/fr/design/actions/file/export/ExcelExportAction.java

@ -3,11 +3,7 @@ package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
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.io.exporter.ExcelExporter; import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.LargeDataPageExcelExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.report.core.ReportUtils;
public class ExcelExportAction extends AbstractExcelExportAction { public class ExcelExportAction extends AbstractExcelExportAction {
/** /**
@ -22,12 +18,7 @@ public class ExcelExportAction extends AbstractExcelExportAction {
} }
@Override @Override
protected Exporter getExporter() { public DesignExportType exportType() {
TemplateWorkBook tpl = this.getTemplateWorkBook(); return DesignExportType.EXCEL;
if (hasLayerReport(tpl)) {
return new LargeDataPageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl), false);
} else {
return new ExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl));
}
} }
} }

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

@ -5,17 +5,16 @@ 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.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
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;
import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.Exporter;
import com.fr.web.core.reserve.PDFExporterFactory;
/** /**
* Export pdf * Export pdf
*/ */
public class PDFExportAction extends AbstractExportAction { public class PDFExportAction extends AbstractJWorkBookExportAction {
/** /**
* Constructor * Constructor
*/ */
@ -27,15 +26,9 @@ public class PDFExportAction extends AbstractExportAction {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/pdf.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/pdf.png"));
} }
@Override
protected Exporter getExporter() {
return PDFExporterFactory.getPDFExporter();
}
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.PDF, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_PDF")); return new ChooseFileFilter(FileExtension.PDF, Toolkit.i18nText("Fine-Design_Report_Export_PDF"));
} }
@Override @Override
@ -43,4 +36,8 @@ public class PDFExportAction extends AbstractExportAction {
return FileExtension.PDF.getExtension(); return FileExtension.PDF.getExtension();
} }
@Override
public DesignExportType exportType() {
return DesignExportType.PDF;
}
} }

15
designer-realize/src/main/java/com/fr/design/actions/file/export/PageExcelExportAction.java

@ -3,11 +3,7 @@ package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
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.io.exporter.Exporter; import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.LargeDataPageExcelExporter;
import com.fr.io.exporter.PageExcelExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.report.core.ReportUtils;
public class PageExcelExportAction extends AbstractExcelExportAction { public class PageExcelExportAction extends AbstractExcelExportAction {
@ -20,12 +16,7 @@ public class PageExcelExportAction extends AbstractExcelExportAction {
} }
@Override @Override
protected Exporter getExporter() { public DesignExportType exportType() {
TemplateWorkBook tpl = this.getTemplateWorkBook(); return DesignExportType.PAGE_EXCEL;
if (hasLayerReport(tpl)) {
return new LargeDataPageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl), true);
} else {
return new PageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl));
}
} }
} }

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

@ -2,14 +2,11 @@ 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.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
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;
import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.PageToSheetExcelExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.report.core.ReportUtils;
public class PageToSheetExcelExportAction extends AbstractExcelExportAction { public class PageToSheetExcelExportAction extends AbstractExcelExportAction {
@ -22,19 +19,19 @@ public class PageToSheetExcelExportAction extends AbstractExcelExportAction {
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
protected Exporter getExporter() {
TemplateWorkBook tpl = this.getTemplateWorkBook();
return new PageToSheetExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl));
}
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.XLS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_Excel")); return new ChooseFileFilter(FileExtension.XLS, Toolkit.i18nText("Fine-Design_Report_Export_Excel"));
} }
@Override @Override
protected String getDefaultExtension() { protected String getDefaultExtension() {
return FileExtension.XLS.getExtension(); return FileExtension.XLS.getExtension();
} }
@Override
public DesignExportType exportType() {
return DesignExportType.PAGE_TO_SHEET_EXCEL;
}
} }

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

@ -5,17 +5,16 @@ 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.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
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;
import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.SVGExporter;
/** /**
* Export SVG * Export SVG
*/ */
public class SVGExportAction extends AbstractExportAction { public class SVGExportAction extends AbstractJWorkBookExportAction {
/** /**
* Constructor * Constructor
*/ */
@ -28,18 +27,18 @@ public class SVGExportAction extends AbstractExportAction {
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
protected Exporter getExporter() {
return new SVGExporter();
}
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.SVG, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_SVG")); return new ChooseFileFilter(FileExtension.SVG, Toolkit.i18nText("Fine-Design_Report_Export_SVG"));
} }
@Override @Override
protected String getDefaultExtension() { protected String getDefaultExtension() {
return FileExtension.SVG.getExtension(); return FileExtension.SVG.getExtension();
} }
@Override
public DesignExportType exportType() {
return DesignExportType.SVG;
}
} }

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

@ -5,20 +5,17 @@ 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.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
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;
import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.TextExporter;
/** /**
* Export Text. * Export Text.
*/ */
public class TextExportAction extends AbstractExportAction { public class TextExportAction extends AbstractJWorkBookExportAction {
/**
* Constructor
*/
public TextExportAction(JWorkBook jwb) { public TextExportAction(JWorkBook jwb) {
super(jwb); super(jwb);
this.setMenuKeySet(KeySetUtils.TEXT_EXPORT); this.setMenuKeySet(KeySetUtils.TEXT_EXPORT);
@ -28,13 +25,13 @@ public class TextExportAction extends AbstractExportAction {
} }
@Override @Override
protected Exporter getExporter() { public DesignExportType exportType() {
return new TextExporter(); return DesignExportType.TEXT;
} }
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.TXT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_Text")); return new ChooseFileFilter(FileExtension.TXT, Toolkit.i18nText("Fine-Design_Report_Export_Text"));
} }
@Override @Override

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

@ -5,17 +5,16 @@ 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.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
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;
import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.WordExporter;
/** /**
* Export excel. * Export excel.
*/ */
public class WordExportAction extends AbstractExportAction { public class WordExportAction extends AbstractJWorkBookExportAction {
/** /**
* Constructor * Constructor
*/ */
@ -28,13 +27,13 @@ public class WordExportAction extends AbstractExportAction {
} }
@Override @Override
protected Exporter getExporter() { public DesignExportType exportType() {
return new WordExporter(); return DesignExportType.WORD;
} }
@Override @Override
protected ChooseFileFilter getChooseFileFilter() { protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.DOC, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_Word")); return new ChooseFileFilter(FileExtension.DOC, Toolkit.i18nText("Fine-Design_Report_Export_Word"));
} }
@Override @Override

4
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -635,8 +635,8 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
@Override @Override
public ShortCut[] shortcut4FileMenu() { public ShortCut[] shortcut4FileMenu() {
boolean showWorkBookExportMenu = DesignerMode.isVcsMode() boolean showWorkBookExportMenu = DesignerMode.isVcsMode()
|| DesignerMode.isAuthorityEditing() || DesignerMode.isAuthorityEditing();
|| !WorkContext.getCurrent().isLocal(); // || !WorkContext.getCurrent().isLocal();
return (ShortCut[]) ArrayUtils.addAll(super.shortcut4FileMenu(), return (ShortCut[]) ArrayUtils.addAll(super.shortcut4FileMenu(),
showWorkBookExportMenu ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()} showWorkBookExportMenu ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()}
); );

4
designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java

@ -14,7 +14,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DecodeDialog; import com.fr.design.mainframe.DecodeDialog;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.exception.PermissionDeniedException; import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.exception.TplLockedException; import com.fr.exception.TplLockedException;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -58,7 +58,7 @@ class CptApp extends AbstractWorkBookApp {
namestyle.clear(); namestyle.clear();
try { try {
tpl.readStream(file.asInputStream()); tpl.readStream(file.asInputStream());
} catch (PermissionDeniedException exp) { } catch (RemoteDesignPermissionDeniedException exp) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp); FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp);
} catch (TplLockedException exp) { } catch (TplLockedException exp) {
FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp);

4
designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java

@ -4,7 +4,7 @@ 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.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.exception.PermissionDeniedException; import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.exception.TplLockedException; import com.fr.exception.TplLockedException;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -38,7 +38,7 @@ class CptxApp extends AbstractWorkBookApp {
FineLoggerFactory.getLogger().error("cost: " + (System.currentTimeMillis() - time) + " ms"); FineLoggerFactory.getLogger().error("cost: " + (System.currentTimeMillis() - time) + " ms");
} catch (PermissionDeniedException exp) { } catch (RemoteDesignPermissionDeniedException exp) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp); FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp);
} catch (TplLockedException exp) { } catch (TplLockedException exp) {
FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp);

4
designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java

@ -7,7 +7,7 @@ import com.fr.design.mainframe.AbstractAppProvider;
import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DecodeDialog; import com.fr.design.mainframe.DecodeDialog;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.exception.PermissionDeniedException; import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.exception.TplLockedException; import com.fr.exception.TplLockedException;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.form.main.Form; import com.fr.form.main.Form;
@ -57,7 +57,7 @@ class FormApp extends AbstractAppProvider {
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("file.getName()", file.getName()) + "..."); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("file.getName()", file.getName()) + "...");
try { try {
tpl.readStream(file.asInputStream()); tpl.readStream(file.asInputStream());
} catch (PermissionDeniedException exp) { } catch (RemoteDesignPermissionDeniedException exp) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp); FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp);
} catch (TplLockedException exp) { } catch (TplLockedException exp) {
FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); FineLoggerFactory.getLogger().error(file + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp);

4
designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java

@ -2,7 +2,7 @@ package com.fr.design.mainframe.app;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.exception.PermissionDeniedException; import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.exception.TplLockedException; import com.fr.exception.TplLockedException;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.io.importer.ExcelReportImporter; import com.fr.io.importer.ExcelReportImporter;
@ -26,7 +26,7 @@ class XlsApp extends AbstractWorkBookApp {
WorkBook workbook = null; WorkBook workbook = null;
try { try {
workbook = new ExcelReportImporter().generateWorkBookByStream(tplFile.asInputStream()); workbook = new ExcelReportImporter().generateWorkBookByStream(tplFile.asInputStream());
} catch (PermissionDeniedException exp) { } catch (RemoteDesignPermissionDeniedException exp) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + tplFile, exp); FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + tplFile, exp);
} catch (TplLockedException exp) { } catch (TplLockedException exp) {
FineLoggerFactory.getLogger().error(tplFile + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); FineLoggerFactory.getLogger().error(tplFile + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp);

4
designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java

@ -2,7 +2,7 @@ package com.fr.design.mainframe.app;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.exception.PermissionDeniedException; import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.exception.TplLockedException; import com.fr.exception.TplLockedException;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.io.importer.Excel2007ReportImporter; import com.fr.io.importer.Excel2007ReportImporter;
@ -27,7 +27,7 @@ class XlsxApp extends AbstractWorkBookApp {
try { try {
workbook = new Excel2007ReportImporter().generateWorkBookByStream(tplFile.asInputStream()); workbook = new Excel2007ReportImporter().generateWorkBookByStream(tplFile.asInputStream());
} catch (PermissionDeniedException exp) { } catch (RemoteDesignPermissionDeniedException exp) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + tplFile, exp); FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + tplFile, exp);
} catch (TplLockedException exp) { } catch (TplLockedException exp) {
FineLoggerFactory.getLogger().error(tplFile + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp); FineLoggerFactory.getLogger().error(tplFile + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp);

2
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -42,7 +42,7 @@ import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.WidgetToolBarPane; import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.actions.NewFormAction; import com.fr.design.actions.NewFormAction;
import com.fr.design.mainframe.bbs.BBSGuestPane; import com.fr.design.mainframe.bbs.BBSGuestPane;
import com.fr.design.mainframe.bbs.UserInfoPane; import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECCompositeProvider;

Loading…
Cancel
Save