Browse Source

Merge branch 'feature/10.0' of http://cloud.finedevelop.com:2015/scm/~hades/design into feature/10.0

research/10.0
Hades 6 years ago
parent
commit
7febd3ca5f
  1. 223
      designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java
  2. 23
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  3. 144
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java
  4. 14
      designer-base/src/main/java/com/fr/design/fun/ConnectionProvider.java
  5. 107
      designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java
  6. 27
      designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java
  7. 4
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptImplPane.java
  8. 11
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  9. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  10. 29
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  11. 33
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java
  12. 2
      designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java
  13. 1
      designer-base/src/main/java/com/fr/file/FILE.java
  14. 306
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  15. 12
      designer-base/src/main/java/com/fr/file/MemFILE.java
  16. 18
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/axis/ChartValuePane.java
  17. 2
      designer-form/src/main/java/com/fr/design/actions/FormMobileAttrAction.java
  18. 2
      designer-form/src/main/java/com/fr/design/actions/NewFormAction.java
  19. 2
      designer-form/src/main/java/com/fr/design/actions/TemplateParameterAction.java
  20. 77
      designer-form/src/main/java/com/fr/design/actions/file/export/EmbeddedFormExportExportAction.java
  21. 27
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  22. 19
      designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java
  23. 155
      designer-form/src/main/java/com/fr/design/mainframe/actions/EmbeddedFormExportExportAction.java
  24. 43
      designer-realize/src/main/java/com/fr/design/actions/file/export/AbstractExcelExportAction.java
  25. 196
      designer-realize/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java
  26. 57
      designer-realize/src/main/java/com/fr/design/actions/file/export/AbstractWorkBookExportAction.java
  27. 38
      designer-realize/src/main/java/com/fr/design/actions/file/export/CSVExportAction.java
  28. 20
      designer-realize/src/main/java/com/fr/design/actions/file/export/EmbeddedExportExportAction.java
  29. 21
      designer-realize/src/main/java/com/fr/design/actions/file/export/ExcelExportAction.java
  30. 27
      designer-realize/src/main/java/com/fr/design/actions/file/export/PDFExportAction.java
  31. 21
      designer-realize/src/main/java/com/fr/design/actions/file/export/PageExcelExportAction.java
  32. 19
      designer-realize/src/main/java/com/fr/design/actions/file/export/PageToSheetExcelExportAction.java
  33. 19
      designer-realize/src/main/java/com/fr/design/actions/file/export/SVGExportAction.java
  34. 17
      designer-realize/src/main/java/com/fr/design/actions/file/export/TextExportAction.java
  35. 13
      designer-realize/src/main/java/com/fr/design/actions/file/export/WordExportAction.java
  36. 2
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  37. 26
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  38. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java
  39. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java
  40. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java
  41. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/XlsApp.java
  42. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/XlsxApp.java
  43. 34
      designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSConstants.java
  44. 41
      designer-realize/src/main/java/com/fr/start/SplashContext.java
  45. 17
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java
  46. BIN
      designer-realize/src/main/resources/com/fr/start/jni/splash.dylib

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

@ -0,0 +1,223 @@
package com.fr.design.actions.file.export;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.gui.iprogressbar.FRProgressBar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.io.exporter.ExporterKey;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.DesignExportType;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.third.jodd.io.FileNameUtil;
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.Map;
public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JTemplateAction<E> {
private FRProgressBar progressbar;
public AbstractExportAction(E t) {
super(t);
}
/**
* 导出接口名
*
* @return String scopeName
*/
public abstract ExporterKey exportKey();
/**
* 导出类型
*
* @return DesignExportType tyoe
*/
public abstract DesignExportType exportType();
/**
* 目标文件过滤器
*
* @return ChooseFileFilter filter
*/
protected abstract ChooseFileFilter getChooseFileFilter();
/**
* 目标文件扩展名
*
* @return String extensionName
*/
protected abstract String getDefaultExtension();
/**
* 处理参数
*
* @return Map para
*/
protected abstract Map<String, Object> processParameter();
/**
* 执行方法
*/
@Override
public void actionPerformed(ActionEvent e) {
if (!processNotSaved()) {
return;
}
Map<String, Object> para = processParameter();
// 选择输入的文件
FILEChooserPane fileChooserPane = FILEChooserPane.getMultiEnvInstance(true, false);
fileChooserPane.addChooseFILEFilter(this.getChooseFileFilter());
String fileName = getTargetFileName();
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(getSource(), target, para),
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Report_Exporting"),
StringUtils.EMPTY,
0,
100);
progressbar.start();
}
}
private FILE getSource() {
return this.getEditingComponent().getEditingFILE();
}
private String getTargetFileName() {
FILE source = getSource();
String fileName = source.getName();
return FileNameUtil.removeExtension(fileName);
}
private boolean processNotSaved() {
//当前编辑的模板
E e = getEditingComponent();
if (!e.isALLSaved() && !DesignerMode.isVcsMode()) {
e.stopEditing();
int returnVal = JOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + e.getEditingFILE() + "\" ?",
ProductConstants.PRODUCT_NAME,
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE
);
if (returnVal == JOptionPane.YES_OPTION) {
e.saveTemplate();
FineLoggerFactory.getLogger().info(
Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", e.getEditingFILE().getName())
);
return true;
} else {
return false;
}
} else {
return true;
}
}
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);
try (OutputStream 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 (RemoteDesignPermissionDeniedException exp) {
this.setProgress(100);
target.closeTemplate();
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Engine_Remote_Design_Permission_Denied"),
null,
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
} 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")
);
}
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(exportKey(), exportType(), outputStream, path, para);
} else {
byte[] contents =
WorkContext.getCurrent().get(TemplateExportOperator.class)
.export(exportKey(), exportType(), null, path, para);
outputStream.write(contents);
}
}
}

23
designer-base/src/main/java/com/fr/design/dialog/UIDialog.java

@ -73,7 +73,7 @@ public abstract class UIDialog extends JDialog {
}
this.setName(pane.title4PopupWindow());
this.setModal(true);
this.pack();
GUICoreUtils.centerWindow(this);
}
@ -90,12 +90,10 @@ public abstract class UIDialog extends JDialog {
//取消
addCancelButton(buttonsPane);
this.getRootPane().setDefaultButton(okButton);
return controlPane;
}
protected void addCustomButton(JPanel buttonsPane){
protected void addCustomButton(JPanel buttonsPane) {
}
@ -110,6 +108,18 @@ public abstract class UIDialog extends JDialog {
doCancel();
}
});
JPanel defaultPane = (JPanel) this.getContentPane();
InputMap inputMapAncestor = defaultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap actionMap = defaultPane.getActionMap();
// transfer focus to CurrentEditor
inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "dialogOK");
actionMap.put("dialogOK", new AbstractAction() {
public void actionPerformed(ActionEvent evt) {
doOK();
}
});
}
private void addOkButton(JPanel buttonsPane) {
@ -130,7 +140,6 @@ public abstract class UIDialog extends JDialog {
* 添加监听器
*
* @param l 监听器
*
*/
public void addDialogActionListener(DialogActionListener l) {
listeners.add(l);
@ -138,7 +147,6 @@ public abstract class UIDialog extends JDialog {
/**
* 清除所有监听器
*
*/
public void clearDialogActionListeners() {
listeners.clear();
@ -146,7 +154,6 @@ public abstract class UIDialog extends JDialog {
/**
* 确定操作
*
*/
public void doOK() {
try {
@ -177,7 +184,6 @@ public abstract class UIDialog extends JDialog {
/**
* 取消操作
*
*/
public void doCancel() {
@ -224,7 +230,6 @@ public abstract class UIDialog extends JDialog {
/**
* 检测结果是否合法
*
*/
public abstract void checkValid() throws Exception;

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

@ -1,16 +1,154 @@
package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import java.util.List;
/**
* 历史模板缓存
*
* <p>
* 为可能存在的插件做兼容处理
*
* @see HistoryTemplateListCache
* @deprecated use HistoryTemplateListCache instead
*/
@Deprecated
public class HistoryTemplateListPane {
public static HistoryTemplateListCache getInstance() {
public class HistoryTemplateListPane implements CallbackEvent {
private static volatile HistoryTemplateListPane THIS;
public static HistoryTemplateListPane getInstance() {
if (THIS == null) {
synchronized (HistoryTemplateListPane.class) {
if (THIS == null) {
THIS = new HistoryTemplateListPane();
}
}
}
return THIS;
}
private static HistoryTemplateListCache instead() {
return HistoryTemplateListCache.getInstance();
}
/**
* 关闭选择的文件
*
* @param selected 选择的
*/
public void closeSelectedReport(JTemplate<?, ?> selected) {
instead().closeSelectedReport(selected);
}
/**
* 临时关闭选择的文件
*
* @param selected 选择的
*/
public void closeVirtualSelectedReport(JTemplate<?, ?> selected) {
instead().closeVirtualSelectedReport(selected);
}
public JTemplate<?, ?> getCurrentEditingTemplate() {
return instead().getCurrentEditingTemplate();
}
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
instead().setCurrentEditingTemplate(jt);
}
/**
* 添加历史记录
*/
public void addHistory() {
instead().addHistory();
}
public List<JTemplate<?, ?>> getHistoryList() {
return instead().getHistoryList();
}
/**
* 清空历史记录
*/
public void removeAllHistory() {
instead().removeAllHistory();
}
public int getHistoryCount() {
return instead().getHistoryCount();
}
public JTemplate<?, ?> get(int index) {
return instead().get(index);
}
public JTemplate<?, ?> getTemplate(int index) {
return instead().getTemplate(index);
}
/**
* 获取模板的index
*
* @param jt 模板
* @return 位置
*/
public int contains(JTemplate<?, ?> jt) {
return instead().contains(jt);
}
/**
* 判断是否打开过该模板
*
* @param filename 文件名
* @return 文件位置
*/
public int contains(String filename) {
return instead().contains(filename);
}
/**
* 是否是当前编辑的文件
*
* @param filename 文件名
* @return 是则返回TRUE
*/
public boolean isCurrentEditingFile(String filename) {
return instead().isCurrentEditingFile(filename);
}
@Override
public void callback() {
instead().callback();
}
/**
* 打开new模板的同时关闭old模板,优先关已保存的先打开的
*/
public void closeOverLineTemplate() {
instead().closeOverLineTemplate();
}
public void deleteFile(FileNodeFILE file) {
instead().deleteFile(file);
}
public boolean rename(FILE tplFile, String from, String to) {
return instead().rename(tplFile, from, to);
}
}

14
designer-base/src/main/java/com/fr/design/fun/ConnectionProvider.java

@ -10,32 +10,36 @@ import com.fr.stable.fun.mark.Mutable;
*/
public interface ConnectionProvider extends Mutable {
public static final String XML_TAG = "ConnectionProvider";
String XML_TAG = "ConnectionProvider";
// 2016-12-14 1 -> 2 , 增加connection.feature方法导致不兼容.
int CURRENT_LEVEL = 2;
/**
* 数据连接弹出菜单的名字
*
* @return 名字
*/
public String nameForConnection();
String nameForConnection();
/**
* 数据连接弹出菜单的图标
*
* @return 图标路径
*/
public String iconPathForConnection();
String iconPathForConnection();
/**
* 数据连接的类型
*
* @return 连接类型
*/
public Class<? extends com.fr.data.impl.Connection> classForConnection();
Class<? extends com.fr.data.impl.Connection> classForConnection();
/**
* 数据连接的设计界面
*
* @return 设计界面
*/
public Class<? extends BasicBeanPane<? extends Connection>> appearanceForConnection();
Class<? extends BasicBeanPane<? extends Connection>> appearanceForConnection();
}

107
designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java

@ -4,10 +4,7 @@ import com.fr.base.BaseFormula;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.event.UIObserverListener;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula;
import com.fr.design.formula.VariableResolver;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
@ -20,9 +17,9 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.IOUtils;
import com.fr.js.ReportletHyperlink;
import com.fr.js.ReportletHyperlinkDialogAttr;
import com.fr.stable.CommonUtils;
import com.fr.stable.FormulaProvider;
import com.fr.stable.StringUtils;
@ -76,7 +73,7 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
/**
* 对话框标题输入框
*/
private JFormulaField titleFiled;
private TinyFormulaPane titleFiled;
/**
@ -186,14 +183,19 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
this.postComboBox.setSelectedIndex(link.isByPost() ? 1 : 0);
ReportletHyperlinkDialogAttr attr = link.getAttr();
titleFiled.setFormulaText(StringUtils.EMPTY);
titleFiled.populateBean(StringUtils.EMPTY);
leftLocation.setText(StringUtils.EMPTY);
topLocation.setText(StringUtils.EMPTY);
center.setSelected(true);
if (attr != null) {
FormulaProvider title = attr.getTitleFormula();
String titleContent = title == null ? StringUtils.EMPTY : title.getPureContent();
titleFiled.setFormulaText(titleContent);
Object title = attr.getTitle();
String titleContent;
if (title instanceof FormulaProvider) {
titleContent = ((FormulaProvider) title).getContent();
} else {
titleContent = title == null ? StringUtils.EMPTY : title.toString();
}
titleFiled.populateBean(titleContent);
boolean isCenter = attr.isCenter();
if (!isCenter) {
int left = attr.getLeft(), top = attr.getTop();
@ -222,7 +224,12 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
reportletHyperlink.setByPost(postComboBox.getSelectedIndex() == 1);
ReportletHyperlinkDialogAttr attr = new ReportletHyperlinkDialogAttr();
attr.setTitleFormula(BaseFormula.createFormulaBuilder().build(titleFiled.getFormulaText()));
String title = titleFiled.updateBean();
if (CommonUtils.maybeFormula(title)) {
attr.setTitle(BaseFormula.createFormulaBuilder().build(titleFiled.updateBean()));
} else {
attr.setTitle(title);
}
attr.setCenter(center.isSelected());
if (!attr.isCenter()) {
attr.setLeft((int) leftLocation.getValue());
@ -346,7 +353,8 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
private void initTitlePanel(List<Component[]> dialogComponents) {
// 对话框标题
titleFiled = new JFormulaField(15);
titleFiled = new TinyFormulaPane();
titleFiled.getUITextField().setColumns(15);
final JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
titlePanel.add(titleFiled);
Component[] titleComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Title") + ":"), titlePanel};
@ -359,6 +367,7 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
heightLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
sizeJPanel.add(heightLabel);
UINumberField heightTextFiled = new UINumberField();
heightTextFiled.setMinValue(0);
heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE));
heightTextFiled.setPreferredSize(new Dimension(40, 20));
sizeJPanel.add(heightTextFiled);
@ -367,6 +376,7 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
widthLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
sizeJPanel.add(widthLabel);
UINumberField widthTextFiled = new UINumberField();
widthTextFiled.setMinValue(0);
widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE));
widthTextFiled.setPreferredSize(new Dimension(40, 20));
sizeJPanel.add(widthTextFiled);
@ -395,11 +405,13 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
final UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Left"));
leftLabel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 10));
leftLocation = new UINumberField();
leftLocation.setMinValue(0);
leftLocation.setPreferredSize(new Dimension(40, 20));
// 位置 距上
final UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Top"));
topLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
topLocation = new UINumberField();
topLocation.setMinValue(0);
topLocation.setPreferredSize(new Dimension(40, 20));
locationPanel.add(leftLabel);
@ -435,75 +447,4 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
dialogComponents.add(footerComponents);
othersComponents.add(footerComponents);
}
/**
* 公式输入框
*/
public class JFormulaField extends JPanel {
private UITextField formulaTextField;
public JFormulaField(int columns) {
formulaTextField = new UITextField(columns);
JPanel textFieldPane = new JPanel(new BorderLayout());
textFieldPane.add(formulaTextField, BorderLayout.CENTER);
textFieldPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
UIButton formulaButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/m_insert/formula.png"));
formulaButton.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Formula") + "...");
formulaButton.setPreferredSize(new Dimension(24, formulaTextField.getPreferredSize().height));
formulaButton.addActionListener(formulaButtonActionListener);
JPanel pane = new JPanel(new BorderLayout());
pane.add(textFieldPane, BorderLayout.CENTER);
pane.add(formulaButton, BorderLayout.EAST);
this.setLayout(new BorderLayout());
this.add(pane, BorderLayout.NORTH);
}
public void setFormulaText(String formulaContent) {
this.formulaTextField.setText(formulaContent);
}
public String getFormulaText() {
String text = formulaTextField.getText();
if (text == null) {
text = StringUtils.EMPTY;
}
return text;
}
/**
* 添加事件监听器
*
* @param listener 公式文本输入框改动事件监听器
*/
public void addListener(UIObserverListener listener) {
this.formulaTextField.registerChangeListener(listener);
}
/**
* 取消事件监听器
*/
public void removeListener() {
this.formulaTextField.registerChangeListener(null);
}
private ActionListener formulaButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build();
valueFormula.setContent(getFormulaText());
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula();
formulaPane.populate(valueFormula, VariableResolver.DEFAULT);
formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(ReportletHyperNorthPane.this), new DialogActionAdapter() {
@Override
public void doOk() {
BaseFormula valueFormula = formulaPane.update();
setFormulaText(valueFormula.getContent());
}
}).setVisible(true);
}
};
}
}

27
designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java

@ -28,6 +28,7 @@ import java.util.ArrayList;
public class JSContentPane extends BasicPane {
private RSyntaxTextArea contentTextArea;
private UILabel funNameLabel;
private AutoCompletion ac;
private int titleWidth = 180;
@ -78,14 +79,6 @@ public class JSContentPane extends BasicPane {
contentTextArea.setCodeFoldingEnabled(true);
contentTextArea.setAntiAliasingEnabled(true);
CompletionProvider provider = createCompletionProvider();
AutoCompletion ac = new AutoCompletion(provider);
String shortCuts = DesignerEnvManager.getEnvManager().getAutoCompleteShortcuts();
ac.setTriggerKey(convert2KeyStroke(shortCuts));
ac.install(contentTextArea);
UIScrollPane sp = new UIScrollPane(contentTextArea);
this.add(sp, BorderLayout.CENTER);
@ -104,13 +97,31 @@ public class JSContentPane extends BasicPane {
}
public void populate(String js) {
if (ac == null) {
CompletionProvider provider = createCompletionProvider();
ac = new AutoCompletion(provider);
String shortCuts = DesignerEnvManager.getEnvManager().getAutoCompleteShortcuts();
ac.setTriggerKey(convert2KeyStroke(shortCuts));
ac.install(contentTextArea);
}
this.contentTextArea.setText(js);
}
public String update() {
if (ac != null) {
this.ac.uninstall();
ac = null;
}
return this.contentTextArea.getText();
}
public void reset() {
this.contentTextArea.setText(null);
}
public void setFunctionTitle(String[] args) {
funNameLabel.setText(createFunctionTitle(args));
}

4
designer-base/src/main/java/com/fr/design/javascript/JavaScriptImplPane.java

@ -138,6 +138,9 @@ public class JavaScriptImplPane extends AbstractHyperLinkPane<JavaScriptImpl> {
public void populateBean(JavaScriptImpl javaScriptImpl) {
if (javaScriptImpl == null) {
javaScriptImpl = new JavaScriptImpl();
jsPane.reset();
}else{
jsPane.populate(javaScriptImpl.getContent());
}
int rowCount = javaScriptImpl.getJSImportSize();
@ -147,7 +150,6 @@ public class JavaScriptImplPane extends AbstractHyperLinkPane<JavaScriptImpl> {
}
importedJsPane.populate(value);
parameterPane.populate(javaScriptImpl.getParameters());
jsPane.populate(javaScriptImpl.getContent());
if (itemNameTextField != null) {
itemNameTextField.setText(javaScriptImpl.getItemName());

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

@ -155,6 +155,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// 右边的虚线
private DottedLine rightDottedLine;
//用于判断设计器是否打开了
private boolean designerOpened = false;
private int contentWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth());
private int contentHeight = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight());
@ -351,7 +354,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/
public void addDesignerOpenedListener(DesignerOpenedListener listener) {
designerOpenedListenerList.add(listener);
if (!designerOpened) {
designerOpenedListenerList.add(listener);
}
}
/**
@ -362,6 +367,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
for (DesignerOpenedListener listener : designerOpenedListenerList) {
listener.designerOpened();
}
designerOpened = true;
//使用完清除监听
designerOpenedListenerList.clear();
}
protected DesktopCardPane getCenterTemplateCardPane() {

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

@ -780,7 +780,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
((JTemplateActionListener) listeners[i + 1]).templateClosed(this);
}
}
this.undoState = null;
this.repaint(30);
}

29
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -148,6 +148,9 @@ public abstract class ToolBarMenuDock {
};
private static final String FINEREPORT = "FineReport";
private static final int MENUBAR_HEIGHT = 22;
private static final List<PluginEventListener> PLUGIN_LISTENERS = new ArrayList<>();
private MenuDef[] menus;
private ToolBarDef toolBarDef;
private List<UpdateActionModel> shortCutsList;
@ -218,6 +221,8 @@ public abstract class ToolBarMenuDock {
}
public MenuDef[] menus(final ToolBarMenuDockPlus plus) {
//删除之前创建的插件菜单监听
clearPluginListeners();
java.util.List<MenuDef> menuList = new java.util.ArrayList<MenuDef>();
// 添加文件菜单
menuList.add(createFileMenuDef(plus));
@ -248,6 +253,15 @@ public abstract class ToolBarMenuDock {
return menuList.toArray(new MenuDef[menuList.size()]);
}
//清空监听
private static synchronized void clearPluginListeners() {
for (PluginEventListener listener : PLUGIN_LISTENERS) {
GeneralContext.stopListenPlugin(listener);
}
PLUGIN_LISTENERS.clear();
}
/**
* 获取所有actionmodel
*
@ -644,7 +658,7 @@ public abstract class ToolBarMenuDock {
}
};
GeneralContext.listenPlugin(PluginEventType.BeforeStop, new PluginEventListener() {
PluginEventListener beforeStop = new PluginEventListener() {
@Override
public void on(PluginEvent event) {
@ -652,8 +666,9 @@ public abstract class ToolBarMenuDock {
Set<MenuHandler> menuHandlers = runtime.get(MenuHandler.MARK_STRING);
removeExtraMenus(menuDef, anchor, action, menuHandlers);
}
}, filter);
GeneralContext.listenPlugin(PluginEventType.AfterRun, new PluginEventListener() {
};
PluginEventListener afterRun = new PluginEventListener() {
@Override
public void on(PluginEvent event) {
@ -662,7 +677,13 @@ public abstract class ToolBarMenuDock {
Set<MenuHandler> menuHandlers = runtime.get(MenuHandler.MARK_STRING);
addExtraMenus(menuDef, anchor, action, menuHandlers);
}
}, filter);
};
GeneralContext.listenPlugin(PluginEventType.BeforeStop, beforeStop, filter);
GeneralContext.listenPlugin(PluginEventType.AfterRun, afterRun, filter);
PLUGIN_LISTENERS.add(afterRun);
PLUGIN_LISTENERS.add(beforeStop);
}
private void removeExtraMenus(MenuDef menuDef, String anchor, ShortCutMethodAction action, Set<MenuHandler> set) {

33
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java

@ -4,11 +4,8 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.mobile.ui.TemplateStyleDefinePaneFactory;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.cardtag.mobile.DefaultMobileTemplateStyle;
import com.fr.general.cardtag.mobile.DownMenuStyle;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.SliderStyle;
import com.fr.general.cardtag.mobile.UpMenuStyle;
import com.fr.general.cardtag.mobile.MobileTemplateStyleType;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
@ -26,12 +23,12 @@ import java.util.List;
import java.util.Map;
public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTemplateStyle> {
private static final List<String> STYLE_LIST = new ArrayList<String>();
private static final List<MobileTemplateStyleType> STYLE_LIST = new ArrayList<MobileTemplateStyleType>();
static {
STYLE_LIST.add(DefaultMobileTemplateStyle.STYLE_NAME);
STYLE_LIST.add(UpMenuStyle.STYLE_NAME);
STYLE_LIST.add(DownMenuStyle.STYLE_NAME);
STYLE_LIST.add(SliderStyle.STYLE_NAME);
STYLE_LIST.add(MobileTemplateStyleType.DEFAULT_STYLE);
STYLE_LIST.add(MobileTemplateStyleType.UP_MENU_STYLE);
STYLE_LIST.add(MobileTemplateStyleType.DOWN_MENU_STYLE);
STYLE_LIST.add(MobileTemplateStyleType.SLIDER_STYLE);
}
private DefaultListModel listModel;
@ -49,11 +46,11 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTem
card = new CardLayout();
right = FRGUIPaneFactory.createCardLayout_S_Pane();
right.setLayout(card);
for(String style : STYLE_LIST){
listModel.addElement(style);
BasicBeanPane<MobileTemplateStyle> styleBasicBeanPane = TemplateStyleDefinePaneFactory.createDefinePane(style, tagLayout);
map.put(style, styleBasicBeanPane);
right.add(style, styleBasicBeanPane);
for(MobileTemplateStyleType style : STYLE_LIST){
listModel.addElement(style.getDisplayName());
BasicBeanPane<MobileTemplateStyle> styleBasicBeanPane = TemplateStyleDefinePaneFactory.createDefinePane(style.getStyle(), tagLayout);
map.put(style.getDisplayName(), styleBasicBeanPane);
right.add(style.getDisplayName(), styleBasicBeanPane);
}
styleList = new JList(listModel);
styleList.setCellRenderer(render);
@ -97,10 +94,12 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTem
public void populate(MobileTemplateStyle templateStyle) {
for(int i = 0; i< listModel.getSize(); i++){
if((listModel.getElementAt(i)).equals(templateStyle.getStyle())){
String style = templateStyle.getStyle();
MobileTemplateStyleType templateStyleType = MobileTemplateStyleType.parse(style);
if((listModel.getElementAt(i)).equals(templateStyleType.getDisplayName())){
styleList.setSelectedIndex(i);
map.get(templateStyle.getStyle()).populateBean(templateStyle);
card.show(right, templateStyle.getStyle());
map.get(templateStyle.toString()).populateBean(templateStyle);
card.show(right, templateStyle.toString());
return;
}
}

2
designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java

@ -95,7 +95,7 @@ public class ColorSelectDetailPane extends BasicPane {
public void stateChanged(ChangeEvent e) {
ColorSelectionModel model = (ColorSelectionModel) e.getSource();
colorChooserPreview.setMyColor(model.getSelectedColor());
colorChooserPreview.paint(colorChooserPreview.getGraphics());
colorChooserPreview.repaint();
}
});
previewPanel.add(colorChooserPreview);

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

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

306
designer-base/src/main/java/com/fr/file/FILEChooserPane.java

@ -7,6 +7,8 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
@ -15,6 +17,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.DefaultCompletionFilter;
import com.fr.design.gui.itextfield.UIAutoCompletionField;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itree.filetree.FileTreeIcon;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
@ -85,6 +88,7 @@ import java.awt.event.WindowEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -176,6 +180,28 @@ public class FILEChooserPane extends BasicPane {
return INSTANCE;
}
public static FILEChooserPane getMultiEnvInstance(boolean showLoc, boolean showWebReport, FILEFilter filter) {
INSTANCE.showEnv = true;
INSTANCE.showLoc = showLoc;
INSTANCE.showWebReport = showWebReport;
// 替换掉 PlaceListModel
INSTANCE.setMultiPlaceListModel();
INSTANCE.removeAllFilter();
INSTANCE.addChooseFILEFilter(filter, 0);
return INSTANCE;
}
public static FILEChooserPane getMultiEnvInstance(boolean showLoc, boolean showWebReport) {
INSTANCE.showEnv = true;
INSTANCE.showLoc = showLoc;
INSTANCE.showWebReport = showWebReport;
// 替换掉 PlaceListModel
INSTANCE.setMultiPlaceListModel();
INSTANCE.removeAllFilter();
return INSTANCE;
}
/**
* @param showEnv
* @param filter
@ -912,96 +938,10 @@ public class FILEChooserPane extends BasicPane {
return dialogName();
}
private class PlaceListModel extends AbstractListModel {
private FileNodeFILE envFILE;
private FileNodeFILE webReportFILE;
private List<FileFILE> filesOfSystem = new ArrayList<FileFILE>();
PlaceListModel() {
if (FILEChooserPane.this.showEnv) {
envFILE = new FileNodeFILE(new FileNode(ProjectConstants.REPORTLETS_NAME, true)) {
@Override
public String getName() {
return getEnvProjectName();
}
};
}
if (FILEChooserPane.this.showWebReport) {
webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebRootPath());
}
if (FILEChooserPane.this.showLoc) {
if (WindowsDetector.detect(true)) {
// windows下展示桌面
File[] desktop = FileSystemView.getFileSystemView().getRoots();
if (desktop != null) {
for (int i = 0; i < desktop.length; i++) {
if (desktop[i].exists()) {
filesOfSystem.add(new FileFILE(desktop[i]));
}
}
}
} else {
// *nix下展示家目录
filesOfSystem.add(new FileFILE(FileSystemView.getFileSystemView().getDefaultDirectory()));
}
// C, D, E等盘符
File[] roots = File.listRoots();
if (roots != null) {
for (int i = 0; i < roots.length; i++) {
if (roots[i].exists()) {
filesOfSystem.add(new FileFILE(roots[i]));
}
}
}
}
}
@Override
public FILE getElementAt(int index) {
int n = FILEChooserPane.this.showEnv ? 1 : 0;
int n2 = FILEChooserPane.this.showWebReport ? 1 : 0;
if (index < n) {
return envFILE;
} else if (index < n + n2) {
return webReportFILE;
} else if (index < n + n2 + filesOfSystem.size()) {
return filesOfSystem.get(index - n - n2);
}
throw new IndexOutOfBoundsException();
}
@Override
public int getSize() {
if (FILEChooserPane.this.showEnv && FILEChooserPane.this.showWebReport) {
return 2 + filesOfSystem.size();
} else if (FILEChooserPane.this.showEnv || FILEChooserPane.this.showWebReport) {
return 1 + filesOfSystem.size();
} else {
return filesOfSystem.size();
}
}
private void setCD(final FILE lastDirectory) {
for (int i = 0; i < this.getSize(); i++) {
FILE file = this.getElementAt(i);
if (ComparatorUtils.equals(lastDirectory.prefix(), file.prefix())) {
setCurrentDirectory(lastDirectory);
return;
}
}
setCurrentDirectory(this.getElementAt(0));
}
}
private void setPlaceListModel() {
private void setPlaceListModel(AbstractPlaceListModel model) {
if (placesList == null) {
return;
}
PlaceListModel model = new PlaceListModel();
placesList.setModel(model);
String lastDirectoryPath = DesignerEnvManager.getEnvManager().getDialogCurrentDirectory();
String prefix = DesignerEnvManager.getEnvManager().getCurrentDirectoryPrefix();
@ -1023,6 +963,20 @@ public class FILEChooserPane extends BasicPane {
}
}
private void setPlaceListModel() {
if (placesList == null) {
return;
}
setPlaceListModel(new PlaceListModel());
}
private void setMultiPlaceListModel() {
if (placesList == null) {
return;
}
setPlaceListModel(new MultiLocalEnvPlaceListModel());
}
/*
* 选中文件
*/
@ -1052,7 +1006,7 @@ public class FILEChooserPane extends BasicPane {
if (ComparatorUtils.equals(dir.prefix(), FILEFactory.ENV_PREFIX) || dir.prefix().endsWith(FILEFactory.WEBREPORT_PREFIX)) {
placesList.setSelectedIndex(0);
} else if (ComparatorUtils.equals(dir.prefix(), FILEFactory.FILE_PREFIX)) {
PlaceListModel defaultListModel = (PlaceListModel) placesList.getModel();
AbstractPlaceListModel defaultListModel = (AbstractPlaceListModel) placesList.getModel();
for (int i = 0; i < defaultListModel.getSize(); i++) {
if (defaultListModel.getElementAt(i) instanceof FileFILE) {
FileFILE popDir = (FileFILE) defaultListModel.getElementAt(i);
@ -1108,6 +1062,182 @@ public class FILEChooserPane extends BasicPane {
}
}
private abstract class AbstractPlaceListModel extends AbstractListModel<FILE> {
protected List<FileFILE> filesOfSystem = new ArrayList<FileFILE>();
protected void processSystemFile() {
if (WindowsDetector.detect(true)) {
// windows下展示桌面
File[] desktop = FileSystemView.getFileSystemView().getRoots();
if (desktop != null) {
for (int i = 0; i < desktop.length; i++) {
if (desktop[i].exists()) {
filesOfSystem.add(new FileFILE(desktop[i]));
}
}
}
} else {
// *nix下展示家目录
filesOfSystem.add(new FileFILE(FileSystemView.getFileSystemView().getDefaultDirectory()));
}
// C, D, E等盘符
File[] roots = File.listRoots();
if (roots != null) {
for (int i = 0; i < roots.length; i++) {
if (roots[i].exists()) {
filesOfSystem.add(new FileFILE(roots[i]));
}
}
}
}
protected void setCD(final FILE lastDirectory) {
for (int i = 0; i < this.getSize(); i++) {
FILE file = this.getElementAt(i);
if (ComparatorUtils.equals(lastDirectory.prefix(), file.prefix())) {
setCurrentDirectory(lastDirectory);
return;
}
}
setCurrentDirectory(this.getElementAt(0));
}
}
private class PlaceListModel extends AbstractPlaceListModel {
private FileNodeFILE envFILE;
private FileNodeFILE webReportFILE;
PlaceListModel() {
if (FILEChooserPane.this.showEnv) {
envFILE = new FileNodeFILE(new FileNode(ProjectConstants.REPORTLETS_NAME, true)) {
@Override
public String getName() {
return getEnvProjectName();
}
};
}
if (FILEChooserPane.this.showWebReport) {
webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebRootPath());
}
if (FILEChooserPane.this.showLoc) {
processSystemFile();
}
}
@Override
public FILE getElementAt(int index) {
int n = FILEChooserPane.this.showEnv ? 1 : 0;
int n2 = FILEChooserPane.this.showWebReport ? 1 : 0;
if (index < n) {
return envFILE;
} else if (index < n + n2) {
return webReportFILE;
} else if (index < n + n2 + filesOfSystem.size()) {
return filesOfSystem.get(index - n - n2);
}
throw new IndexOutOfBoundsException();
}
@Override
public int getSize() {
if (FILEChooserPane.this.showEnv && FILEChooserPane.this.showWebReport) {
return 2 + filesOfSystem.size();
} else if (FILEChooserPane.this.showEnv || FILEChooserPane.this.showWebReport) {
return 1 + filesOfSystem.size();
} else {
return filesOfSystem.size();
}
}
}
private class MultiLocalEnvPlaceListModel extends AbstractPlaceListModel {
private List<FileFILE> envFiles = new ArrayList<FileFILE>();
private FileNodeFILE webReportFILE;
MultiLocalEnvPlaceListModel() {
Iterator<String> iterator = DesignerEnvManager.getEnvManager().getEnvNameIterator();
while (iterator.hasNext()) {
final String envName = iterator.next();
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
if (info.getType() == DesignerWorkspaceType.Local) {
FileFILE fileFILE =
new FileFILE(new File(info.getPath() + CoreConstants.SEPARATOR + ProjectConstants.REPORTLETS_NAME)) {
@Override
public String getName() {
return envName;
}
};
if (fileFILE.exists() && fileFILE.isDirectory()) {
envFiles.add(fileFILE);
}
}
}
if (FILEChooserPane.this.showWebReport) {
webReportFILE = new FileNodeFILE(FRContext.getCommonOperator().getWebRootPath());
}
if (FILEChooserPane.this.showLoc) {
processSystemFile();
}
}
@Override
public FILE getElementAt(int index) {
int envCount = envFiles.size();
int webReportCount = FILEChooserPane.this.showWebReport ? 1 : 0;
if (index < envCount) {
return envFiles.get(index);
} else if (index < envCount + webReportCount) {
return webReportFILE;
} else if (index < envCount + webReportCount + filesOfSystem.size()) {
return filesOfSystem.get(index - envCount - webReportCount);
}
throw new IndexOutOfBoundsException();
}
@Override
public int getSize() {
int webReportCount = FILEChooserPane.this.showWebReport ? 1 : 0;
return envFiles.size() + filesOfSystem.size() + webReportCount;
}
private class FileFILE extends com.fr.file.FileFILE {
public FileFILE(File file) {
super(file);
}
@Override
public Icon getIcon() {
if (ComparatorUtils.equals(getTotalName(), ProjectConstants.REPORTLETS_NAME)) {
return BaseUtils.readIcon("/com/fr/base/images/oem/logo.png");
} else {
return FileTreeIcon.getIcon(new File(this.getPath()), false);
}
}
@Override
public FILE[] listFiles() {
FILE[] fileFILES = super.listFiles();
List<FileFILE> results = new ArrayList<>();
for (FILE fileFILE : fileFILES) {
results.add(new FileFILE(new File(fileFILE.getPath())));
}
return results.toArray(new FILE[results.size()]);
}
}
}
/*
* 上面的LocationButtonPane
*/

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

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

18
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/axis/ChartValuePane.java

@ -2,8 +2,8 @@ package com.fr.design.mainframe.chart.gui.style.axis;
import com.fr.base.BaseFormula;
import com.fr.base.Utils;
import com.fr.chart.base.AxisUnitType;
import com.fr.chart.base.ChartBaseUtils;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.Axis;
import com.fr.chart.chartattr.Bar2DPlot;
import com.fr.chart.chartattr.NumberAxis;
@ -78,7 +78,7 @@ public class ChartValuePane extends ChartAxisUsePane<Axis>{
axisLineStylePane = new ChartAxisLineStylePane();
zeroPane = aliagnZero4Second();
axisReversed = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_AxisReversed"));
unitCombox = new UIComboBox(ChartConstants.UNIT_I18N_VALUES);
unitCombox = new UIComboBox(AxisUnitType.getI18NValues());
formatPane = new FormatPaneWithOutFont();
axisLabelPane = new ChartAxisLabelPane();
dataPane = createDataDefinePane();
@ -257,10 +257,10 @@ public class ChartValuePane extends ChartAxisUsePane<Axis>{
axisLineStylePane.update(axis);
axis.setAxisReversed(this.axisReversed.isSelected());
String unitValue = Utils.objectToString(unitCombox.getSelectedItem());
if(ComparatorUtils.equals(unitValue, ChartConstants.UNIT_I18N_VALUES[0])) {
if(ComparatorUtils.equals(unitValue, AxisUnitType.UNIT_NONE.toLocaleString())) {
unitValue = null;
}
numberAxis.setShowUnit(ChartConstants.getUnitValueFromKey(unitValue));
numberAxis.setShowUnit(AxisUnitType.parse(unitValue));
if(numberAxis.isSurpportAxisTitle()) {
updateAxisTitle(numberAxis);
}
@ -378,11 +378,13 @@ public class ChartValuePane extends ChartAxisUsePane<Axis>{
axisLineStylePane.populate(axis);
axisReversed.setSelected(axis.hasAxisReversed());
String unitKey = numberAxis.getShowUnit();
if(StringUtils.isBlank(unitKey)) {
unitKey = ChartConstants.UNIT_I18N_KEYS[0];
String unitKey;
if(numberAxis.getShowUnit() != null) {
unitKey = numberAxis.getShowUnit().getStringType();
}else{
unitKey = AxisUnitType.UNIT_NONE.getStringType();
}
unitCombox.setSelectedItem(ChartConstants.getUnitKey2Value(unitKey));
unitCombox.setSelectedItem(AxisUnitType.parse(unitKey).toLocaleString());
if(numberAxis.isSurpportAxisTitle()) {
populateAxisTitle(axis);

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.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.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.Parameter;

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

@ -0,0 +1,77 @@
package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.extension.FileExtension;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JForm;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.form.main.Form;
import com.fr.io.exporter.DesignExportScope;
import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.ExporterKey;
import com.fr.stable.ArrayUtils;
import java.util.HashMap;
import java.util.Map;
/**
* Export Embedded.
*/
public class EmbeddedFormExportExportAction extends AbstractExportAction<JForm> {
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 ExporterKey exportKey() {
return DesignExportScope.FINE_FORM;
}
@Override
protected String getDefaultExtension() {
return getEditingComponent().suffix().substring(1);
}
@Override
public DesignExportType exportType() {
return DesignExportType.EMBEDDED_FORM;
}
@Override
protected Map<String, Object> processParameter() {
// 输入参数
final Map<String, Object> parameterMap = new HashMap<String, Object>();
Form tpl = this.getEditingComponent().getTarget();
Parameter[] parameters = tpl.getParameters();
// 检查Parameter.
if (ArrayUtils.isNotEmpty(parameters)) {
final ParameterInputPane pPane = new ParameterInputPane(parameters);
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
}
return parameterMap;
}
@Override
protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.FRM.getExtensions(), Toolkit.i18nText("Fine-Design_Form_EmbeddedTD"));
}
}

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

@ -5,7 +5,9 @@ import com.fr.base.PaperSize;
import com.fr.base.Parameter;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState;
import com.fr.design.actions.TemplateParameterAction;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.export.EmbeddedFormExportExportAction;
import com.fr.design.cell.FloatElementsProvider;
import com.fr.design.designer.TargetComponent;
import com.fr.design.designer.beans.actions.CopyAction;
@ -31,11 +33,8 @@ import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.xpane.FormHyperlinkGroupPane;
import com.fr.design.gui.xpane.FormHyperlinkGroupPaneNoPop;
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.FormECDesignerProvider;
import com.fr.design.report.fit.menupane.ReportFitAttrAction;
import com.fr.design.mainframe.templateinfo.JFormProcessInfo;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
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.preview.FormPreview;
import com.fr.design.preview.MobilePreview;
import com.fr.design.report.fit.menupane.ReportFitAttrAction;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.file.FILE;
@ -118,7 +118,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
@Override
public void refreshEastPropertiesPane() {
// 暂时用不到,遇到的时候再加刷新右侧tab面板的代码
return;
}
@Override
@ -152,7 +151,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
@Override
public void setJTemplateResolution(int resolution) {
return;
}
@Override
@ -195,7 +193,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
}
public void setAuthorityMode(boolean isUpMode) {
return;
}
public int getToolBarHeight() {
@ -208,7 +205,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
* @return 菜单数组
*/
public ShortCut[] shortcut4FileMenu() {
return (ShortCut[]) ArrayUtils.addAll(
return ArrayUtils.addAll(
super.shortcut4FileMenu(),
DesignerMode.isVcsMode() ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()}
);
@ -226,7 +223,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
* 取消格式
*/
public void cancelFormat() {
return;
}
/**
@ -292,30 +288,25 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
* 去除选择
*/
public void removeTemplateSelection() {
return;
}
public void setSheetCovered(boolean isCovered) {
return;
}
/**
* 刷新容器
*/
public void refreshContainer() {
return;
}
/**
* 去除参数面板选择
*/
public void removeParameterPaneSelection() {
return;
}
@Override
public void setScale(int resolution) {
return;
}
@Override
@ -469,6 +460,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
public void setPictureElem(Elem elem, CellImage cellImage) {
elem.setValue(cellImage.getImage());
}
/**
* 目标菜单
*
@ -477,8 +469,8 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
@Override
public MenuDef[] menus4Target() {
return this.index == FORM_TAB ?
(MenuDef[]) ArrayUtils.addAll(super.menus4Target(), this.formDesign.menus4Target()) :
(MenuDef[]) ArrayUtils.addAll(super.menus4Target(), this.elementCaseDesign.menus4Target());
ArrayUtils.addAll(super.menus4Target(), this.formDesign.menus4Target()) :
ArrayUtils.addAll(super.menus4Target(), this.elementCaseDesign.menus4Target());
}
@ -503,9 +495,9 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
@Override
public ShortCut[] shortcut4TemplateMenu() {
if (this.index == FORM_TAB) {
return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new ReportFitAttrAction(this)}, new ShortCut[0]);
return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new ReportFitAttrAction(this)}, new ShortCut[0]);
} else {
return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new ReportFitAttrAction(this)}, this.elementCaseDesign.shortcut4TemplateMenu());
return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new ReportFitAttrAction(this)}, this.elementCaseDesign.shortcut4TemplateMenu());
}
}
@ -932,6 +924,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
/**
* 支持的预览模式
*
* @return 预览模式
*/
@Override

19
designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java

@ -28,7 +28,7 @@ import java.util.Set;
* 控件属性表绘制
* Modified by fanglei
*/
public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane {
public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane {
private static final int PADDING = 10;
private static final int PADDING_M = 12;
@ -108,11 +108,10 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope
*/
private void initTables() {
formWidgetCardPane.populate();
eventTable.refresh();
if (mobileExtraPropertyPanes != null) {
for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) {
extraPane.initPropertyGroups(designer);
extraPane.populate(designer);
}
}
if (widgetPropertyTables != null) {
@ -222,7 +221,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal")
};
final CardLayout tabbedPane = new CardLayout();
final CardLayout tabbedPane = new CardLayout();
final JPanel center = new JPanel(tabbedPane);
center.add(formWidgetCardPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Properties"));
center.add(eventTable, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event"));
@ -232,6 +231,16 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope
tabsHeaderIconPane = new UIHeadGroup(tabTitles) {
@Override
public void tabChanged(int index) {
//切换的时候再populate
if (index == 1) {
eventTable.refresh();
} else if (index == 2) {
if (mobileExtraPropertyPanes != null) {
for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) {
extraPane.populate(designer);
}
}
}
tabbedPane.show(center, tabTitles[index]);
}
};
@ -292,7 +301,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) {
formWidgetCardPane.populate();
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED){
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
// 防止多次触发
if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) {
return;

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

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

@ -4,39 +4,40 @@
package com.fr.design.actions.file.export;
import com.fr.base.ExcelUtils;
import com.fr.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JWorkBook;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.main.TemplateWorkBook;
import com.fr.report.core.ReportUtils;
/**
* Export excel.
*/
public abstract class AbstractExcelExportAction extends AbstractExportAction {
/**
* Constructor
*/
protected AbstractExcelExportAction(JWorkBook jwb) {
super(jwb);
public abstract class AbstractExcelExportAction extends AbstractWorkBookExportAction {
protected AbstractExcelExportAction(JWorkBook jwb) {
super(jwb);
}
@Override
protected ChooseFileFilter getChooseFileFilter() {
TemplateWorkBook tpl = this.getTemplateWorkBook();
if (hasLayerReport(tpl)) {
return new ChooseFileFilter(new String[]{"zip"}, "ZIP");
} else {
return new ChooseFileFilter(new String[]{"xls", "xlsx"}, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_Excel"));
}
protected ChooseFileFilter getChooseFileFilter() {
TemplateWorkBook tpl = this.getTemplateWorkBook();
if (ReportUtils.hasLayerReport4Template(tpl)) {
return new ChooseFileFilter(FileExtension.ZIP, "ZIP");
} else {
return new ChooseFileFilter(new String[]{FileExtension.XLSX.getExtension(), FileExtension.XLS.getExtension()},
Toolkit.i18nText("Fine-Design_Report_Export_Excel"));
}
}
@Override
protected String getDefaultExtension() {
TemplateWorkBook tpl = this.getTemplateWorkBook();
if (hasLayerReport(tpl)) {
return "zip";
} else {
return ExcelUtils.checkThirdJarSupportPOI() ? "xlsx" : "xls";
}
protected String getDefaultExtension() {
TemplateWorkBook tpl = this.getTemplateWorkBook();
if (ReportUtils.hasLayerReport4Template(tpl)) {
return FileExtension.ZIP.getExtension();
} else {
return ExcelUtils.checkThirdJarSupportPOI() ? FileExtension.XLSX.getExtension() : FileExtension.XLS.getExtension();
}
}
}

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();
}

57
designer-realize/src/main/java/com/fr/design/actions/file/export/AbstractWorkBookExportAction.java

@ -0,0 +1,57 @@
/*
* 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.mainframe.DesignerContext;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.io.exporter.ExporterKey;
import com.fr.io.exporter.DesignExportScope;
import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
import java.util.HashMap;
import java.util.Map;
/**
* Abstract export action.
*/
public abstract class AbstractWorkBookExportAction extends AbstractExportAction<JWorkBook> {
protected AbstractWorkBookExportAction(JWorkBook jwb) {
super(jwb);
}
protected WorkBook getTemplateWorkBook() {
return this.getEditingComponent().getTarget();
}
public ExporterKey exportKey() {
return DesignExportScope.FINE_BOOK;
}
@Override
protected Map<String, Object> processParameter() {
// 弹出参数
final Map<String, Object> parameterMap = new HashMap<>();
final TemplateWorkBook tpl = getTemplateWorkBook();
Parameter[] parameters = tpl.getParameters();
// 检查Parameter
if (parameters != null && parameters.length > 0) {
final ParameterInputPane pPane = new ParameterInputPane(
parameters);
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
}
return parameterMap;
}
}

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

@ -5,52 +5,46 @@ package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.CSVExporter;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.LargeDataPageCSVExporter;
import com.fr.io.exporter.DesignExportType;
import com.fr.main.TemplateWorkBook;
import com.fr.report.core.ReportUtils;
/**
* Export CSV.
*/
public class CSVExportAction extends AbstractExportAction {
public class CSVExportAction extends AbstractWorkBookExportAction {
/**
* Constructor
*/
public CSVExportAction(JWorkBook jwb) {
super(jwb);
public CSVExportAction(JWorkBook jwb) {
super(jwb);
this.setMenuKeySet(KeySetUtils.CSV_EXPORT);
this.setName(getMenuKeySet().getMenuKeySetName()+ "...");
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
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
protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.CSV, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_CSV"));
protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.CSV, Toolkit.i18nText("Fine-Design_Report_Export_CSV"));
}
@Override
protected String getDefaultExtension() {
protected String getDefaultExtension() {
TemplateWorkBook tpl = this.getTemplateWorkBook();
if (hasLayerReport(tpl)) {
if (ReportUtils.hasLayerReport4Template(tpl)) {
return FileExtension.ZIP.getExtension();
} else {
return FileExtension.CSV.getExtension();
}
}
@Override
public DesignExportType exportType() {
return DesignExportType.CSV;
}
}

20
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.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.EmbeddedTableDataExporter;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.DesignExportType;
import java.util.EnumSet;
/**
* Export Embedded.
*/
public class EmbeddedExportExportAction extends AbstractExportAction {
public class EmbeddedExportExportAction extends AbstractWorkBookExportAction {
/**
* Constructor
*/
@ -26,20 +25,19 @@ public class EmbeddedExportExportAction extends AbstractExportAction {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/oem/logo.png"));
}
@Override
protected Exporter getExporter() {
return new EmbeddedTableDataExporter();
}
@Override
protected ChooseFileFilter getChooseFileFilter() {
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
protected String getDefaultExtension() {
return getEditingComponent().suffix().substring(1);
return FileExtension.CPT.getExtension();
}
@Override
public DesignExportType exportType() {
return DesignExportType.EMBEDDED_WORKBOOK;
}
}

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

@ -3,31 +3,22 @@ package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils;
import com.fr.io.exporter.ExcelExporter;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.LargeDataPageExcelExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.report.core.ReportUtils;
import com.fr.io.exporter.DesignExportType;
public class ExcelExportAction extends AbstractExcelExportAction {
/**
* Constructor
*/
public ExcelExportAction(JWorkBook jwb) {
super(jwb);
public ExcelExportAction(JWorkBook jwb) {
super(jwb);
this.setMenuKeySet(KeySetUtils.SIMPLE_EXCEL_EXPORT);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/excel.png"));
}
@Override
protected Exporter getExporter() {
TemplateWorkBook tpl = this.getTemplateWorkBook();
if (hasLayerReport(tpl)) {
return new LargeDataPageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl), false);
} else {
return new ExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl));
}
public DesignExportType exportType() {
return DesignExportType.EXCEL;
}
}

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

@ -5,42 +5,39 @@ package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.Exporter;
import com.fr.web.core.reserve.PDFExporterFactory;
import com.fr.io.exporter.DesignExportType;
/**
* Export pdf
*/
public class PDFExportAction extends AbstractExportAction {
public class PDFExportAction extends AbstractWorkBookExportAction {
/**
* Constructor
*/
public PDFExportAction(JWorkBook jwb) {
super(jwb);
public PDFExportAction(JWorkBook jwb) {
super(jwb);
this.setMenuKeySet(KeySetUtils.PDF_EXPORT);
this.setName(getMenuKeySet().getMenuKeySetName()+"...");
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/pdf.png"));
}
@Override
protected Exporter getExporter() {
return PDFExporterFactory.getPDFExporter();
protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.PDF, Toolkit.i18nText("Fine-Design_Report_Export_PDF"));
}
@Override
protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(FileExtension.PDF, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_PDF"));
protected String getDefaultExtension() {
return FileExtension.PDF.getExtension();
}
@Override
protected String getDefaultExtension() {
return FileExtension.PDF.getExtension();
public DesignExportType exportType() {
return DesignExportType.PDF;
}
}

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

@ -3,29 +3,20 @@ package com.fr.design.actions.file.export;
import com.fr.base.BaseUtils;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.LargeDataPageExcelExporter;
import com.fr.io.exporter.PageExcelExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.report.core.ReportUtils;
import com.fr.io.exporter.DesignExportType;
public class PageExcelExportAction extends AbstractExcelExportAction {
public PageExcelExportAction(JWorkBook jwb) {
super(jwb);
public PageExcelExportAction(JWorkBook jwb) {
super(jwb);
this.setMenuKeySet(KeySetUtils.PAGE_EXCEL_EXPORT);
this.setName(getMenuKeySet().getMenuKeySetName()+"...");
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/excel.png"));
}
@Override
protected Exporter getExporter() {
TemplateWorkBook tpl = this.getTemplateWorkBook();
if (hasLayerReport(tpl)) {
return new LargeDataPageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl), true);
} else {
return new PageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl));
}
public DesignExportType exportType() {
return DesignExportType.PAGE_EXCEL;
}
}

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.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.PageToSheetExcelExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.report.core.ReportUtils;
import com.fr.io.exporter.DesignExportType;
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"));
}
@Override
protected Exporter getExporter() {
TemplateWorkBook tpl = this.getTemplateWorkBook();
return new PageToSheetExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(tpl));
}
@Override
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
protected String getDefaultExtension() {
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.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.SVGExporter;
import com.fr.io.exporter.DesignExportType;
/**
* Export SVG
*/
public class SVGExportAction extends AbstractExportAction {
public class SVGExportAction extends AbstractWorkBookExportAction {
/**
* Constructor
*/
@ -28,18 +27,18 @@ public class SVGExportAction extends AbstractExportAction {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/svg.png"));
}
@Override
protected Exporter getExporter() {
return new SVGExporter();
}
@Override
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
protected String getDefaultExtension() {
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.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.TextExporter;
import com.fr.io.exporter.DesignExportType;
/**
* Export Text.
*/
public class TextExportAction extends AbstractExportAction {
/**
* Constructor
*/
public class TextExportAction extends AbstractWorkBookExportAction {
public TextExportAction(JWorkBook jwb) {
super(jwb);
this.setMenuKeySet(KeySetUtils.TEXT_EXPORT);
@ -28,13 +25,13 @@ public class TextExportAction extends AbstractExportAction {
}
@Override
protected Exporter getExporter() {
return new TextExporter();
public DesignExportType exportType() {
return DesignExportType.TEXT;
}
@Override
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

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.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.KeySetUtils;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.Exporter;
import com.fr.io.exporter.WordExporter;
import com.fr.io.exporter.DesignExportType;
/**
* Export excel.
*/
public class WordExportAction extends AbstractExportAction {
public class WordExportAction extends AbstractWorkBookExportAction {
/**
* Constructor
*/
@ -28,13 +27,13 @@ public class WordExportAction extends AbstractExportAction {
}
@Override
protected Exporter getExporter() {
return new WordExporter();
public DesignExportType exportType() {
return DesignExportType.WORD;
}
@Override
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

2
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -596,7 +596,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
* @return 是则返回true
*/
public boolean isSelectedOneCell() {
return selection.isSelectedOneCell(this);
return (selection == null) ? false : selection.isSelectedOneCell(this);
}
/**

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

@ -41,7 +41,6 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIModeControlContainer;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.mainframe.cell.QuickEditorRegion;
import com.fr.design.report.fit.menupane.ReportFitAttrAction;
import com.fr.design.mainframe.templateinfo.JWorkBookProcessInfo;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
@ -58,6 +57,7 @@ import com.fr.design.preview.PagePreview;
import com.fr.design.preview.ViewPreview;
import com.fr.design.preview.WriteEnhancePreview;
import com.fr.design.preview.WritePreview;
import com.fr.design.report.fit.menupane.ReportFitAttrAction;
import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.selection.QuickEditor;
@ -68,7 +68,6 @@ import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.ModuleContext;
import com.fr.grid.Grid;
import com.fr.grid.GridUtils;
@ -96,7 +95,9 @@ import com.fr.stable.project.ProjectConstants;
import com.fr.web.controller.ViewRequestConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileOutputStream;
@ -351,7 +352,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
return parameterPane.getParaDesigner().getEastUpPane();
}
if (delegate4ToolbarMenuAdapter() instanceof PolyDesigner) {
return ((PolyDesigner) delegate4ToolbarMenuAdapter()).getEastUpPane();
return delegate4ToolbarMenuAdapter().getEastUpPane();
} else {
ElementCasePane casePane = ((ReportComponent) delegate4ToolbarMenuAdapter()).elementCasePane;
if (casePane != null) {
@ -370,7 +371,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
if (((PolyDesigner) delegate4ToolbarMenuAdapter()).getSelectionType() == PolyDesigner.SelectionType.NONE) {
return new JPanel();
} else {
return ((PolyDesigner) delegate4ToolbarMenuAdapter()).getEastDownPane();
return delegate4ToolbarMenuAdapter().getEastDownPane();
}
} else {
ElementCasePane casePane = ((ReportComponent) delegate4ToolbarMenuAdapter()).elementCasePane;
@ -634,11 +635,10 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
*/
@Override
public ShortCut[] shortcut4FileMenu() {
boolean showWorkBookExportMenu = DesignerMode.isVcsMode()
|| DesignerMode.isAuthorityEditing()
|| !WorkContext.getCurrent().isLocal();
return (ShortCut[]) ArrayUtils.addAll(super.shortcut4FileMenu(),
showWorkBookExportMenu ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()}
boolean hideWorkBookExportMenu = DesignerMode.isVcsMode()
|| DesignerMode.isAuthorityEditing();
return ArrayUtils.addAll(super.shortcut4FileMenu(),
hideWorkBookExportMenu ? new ShortCut[0] : new ShortCut[]{this.createWorkBookExportMenu()}
);
}
@ -649,7 +649,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
*/
@Override
public MenuDef[] menus4Target() {
return (MenuDef[]) ArrayUtils.addAll(
return ArrayUtils.addAll(
super.menus4Target(), this.delegate4ToolbarMenuAdapter().menus4Target()
);
}
@ -695,7 +695,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
*/
@Override
public ShortCut[] shortcut4TemplateMenu() {
return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{
return ArrayUtils.addAll(new ShortCut[]{
new ReportWebAttrAction(this),
new ReportExportAttrAction(this),
new ReportParameterAction(this),
@ -925,7 +925,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
*/
@Override
public void previewMenuActionPerformed(PreviewProvider provider) {
super.previewMenuActionPerformed(provider);
super.previewMenuActionPerformed(provider);
}
/**

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.mainframe.DecodeDialog;
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.file.FILE;
import com.fr.log.FineLoggerFactory;
@ -58,7 +58,7 @@ class CptApp extends AbstractWorkBookApp {
namestyle.clear();
try {
tpl.readStream(file.asInputStream());
} catch (PermissionDeniedException exp) {
} catch (RemoteDesignPermissionDeniedException exp) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp);
} catch (TplLockedException 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.InvalidWorkBookException;
import com.fr.design.i18n.Toolkit;
import com.fr.exception.PermissionDeniedException;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.exception.TplLockedException;
import com.fr.file.FILE;
import com.fr.log.FineLoggerFactory;
@ -38,7 +38,7 @@ class CptxApp extends AbstractWorkBookApp {
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);
} catch (TplLockedException 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.DecodeDialog;
import com.fr.design.mainframe.JTemplate;
import com.fr.exception.PermissionDeniedException;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.exception.TplLockedException;
import com.fr.file.FILE;
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()) + "...");
try {
tpl.readStream(file.asInputStream());
} catch (PermissionDeniedException exp) {
} catch (RemoteDesignPermissionDeniedException exp) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp);
} catch (TplLockedException 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.design.i18n.Toolkit;
import com.fr.exception.PermissionDeniedException;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.exception.TplLockedException;
import com.fr.file.FILE;
import com.fr.io.importer.ExcelReportImporter;
@ -26,7 +26,7 @@ class XlsApp extends AbstractWorkBookApp {
WorkBook workbook = null;
try {
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);
} catch (TplLockedException 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.design.i18n.Toolkit;
import com.fr.exception.PermissionDeniedException;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.exception.TplLockedException;
import com.fr.file.FILE;
import com.fr.io.importer.Excel2007ReportImporter;
@ -27,7 +27,7 @@ class XlsxApp extends AbstractWorkBookApp {
try {
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);
} catch (TplLockedException exp) {
FineLoggerFactory.getLogger().error(tplFile + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), exp);

34
designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSConstants.java

@ -26,29 +26,51 @@ public class BBSConstants {
private static Properties PROP = null;
/**
* 获取所有的感谢对象无法获取在线使用默认
* @return 感谢对象的数组
*/
public static String[] getAllGuest() {
return loadAllGuestsInfoOnline(GUEST_KEY_ONLINE, loadAllGuestsInfo(GUEST_KEY));
}
/**
* 获取所有的链接无法获取在线使用默认
* @return 链接的数组
*/
public static String[] getAllLink() {
return loadAllGuestsInfoOnline(LINK_KEY_ONLINE, loadAllGuestsInfo(LINK_KEY));
}
//加载所有用户的信息, 用户名, 论坛连接
/**
* 获取所有的感谢对象手动选择策略
* @return 感谢对象的数组
*/
public static String[] getAllGuestManual(boolean isOnline) {
String guest;
if (isOnline) {
guest = CloudCenter.getInstance().acquireUrlByKind(GUEST_KEY_ONLINE, StringUtils.EMPTY);
} else {
guest = loadAllGuestsInfo(GUEST_KEY);
}
if (StringUtils.isNotEmpty(guest)) {
return guest.split("\\|");
}
return new String[0];
}
private static String loadAllGuestsInfo(String key) {
return loadAttribute(key, StringUtils.EMPTY);
}
//加载所有用户的信息, 用户名, 论坛连接
private static String[] loadAllGuestsInfoOnline(String key, String defaultValue) {
String[] allGuests = new String[0];
String guest = CloudCenter.getInstance().acquireUrlByKind(key, defaultValue);
if (StringUtils.isNotEmpty(guest)) {
allGuests = guest.split("\\|");
return guest.split("\\|");
}
return allGuests;
return new String[0];
}
//如果要定制, 直接改bbs.properties就行了
private static String loadAttribute(String key, String defaultValue) {
if (PROP == null) {

41
designer-realize/src/main/java/com/fr/start/SplashContext.java

@ -24,6 +24,7 @@ public class SplashContext {
public static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif";
public static final String SPLASH_CACHE_NAME = "splash_10.gif";
private static final int FETCH_ONLINE_MAX_TIMES = 10;
private static final SplashContext SPLASH_CONTEXT = new SplashContext();
@ -33,7 +34,8 @@ public class SplashContext {
private int loadingIndex = 0;
private String[] loading = new String[]{"..", "....", "......"};
private static final String GUEST = getRandomUser();
private int fetchOnlineTimes = 0;
private String guest = StringUtils.EMPTY;
private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
@ -81,6 +83,7 @@ public class SplashContext {
scheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
showThanks();
loadingIndex++;
updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]);
}
@ -90,7 +93,6 @@ public class SplashContext {
@Override
public void on(Event event, String i18n) {
showThanks();
moduleID = i18n;
loadingIndex++;
updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]);
@ -110,21 +112,42 @@ public class SplashContext {
/**
* 获取随机感谢人员
*/
private static String getRandomUser() {
String[] allGuest = BBSConstants.getAllGuest();
if (allGuest.length == 0) {
return StringUtils.EMPTY;
}
private String getRandomUser(String[] allGuest) {
int num = new Random().nextInt(allGuest.length);
return StringUtils.BLANK + allGuest[num];
}
/**
* 展示感谢信息
* 尝试获取在线资源达到尝试上限之后使用默认值
*/
private void tryFetchOnline() {
if (StringUtils.isNotEmpty(guest)) {
return;
}
String[] allGuest;
if (fetchOnlineTimes < FETCH_ONLINE_MAX_TIMES) {
allGuest = BBSConstants.getAllGuestManual(true);
if (allGuest.length == 0) {
fetchOnlineTimes++;
return;
}
} else {
allGuest = BBSConstants.getAllGuestManual(false);
}
guest = getRandomUser(allGuest);
}
/**
* 展示感谢信息这里场景是优先使用在线名单
* 甚至可以因此可以延迟几秒显示目前是尝试
* 获取10次在线资源最大时间3秒
*/
private void showThanks() {
if (shouldShowThanks()) {
updateThanksLog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Thanks_To") + GUEST);
tryFetchOnline();
if (StringUtils.isNotEmpty(guest)) {
updateThanksLog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Thanks_To") + guest);
}
}
}

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

@ -6,6 +6,7 @@ import com.fr.base.MultiFieldParameter;
import com.fr.base.process.ProcessOperator;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.NewFormAction;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.BiasCellAction;
import com.fr.design.actions.insert.cell.ChartCellAction;
@ -42,7 +43,6 @@ import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.actions.NewFormAction;
import com.fr.design.mainframe.bbs.BBSGuestPane;
import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.mainframe.form.FormECCompositeProvider;
@ -59,7 +59,6 @@ import com.fr.design.parameter.WorkBookParameterReader;
import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane;
import com.fr.form.stable.ElementCaseThumbnailProcessor;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.ModuleContext;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.js.EmailJavaScript;
import com.fr.js.JavaScriptImpl;
@ -100,7 +99,7 @@ import com.fr.stable.xml.ObjectXMLWriterFinder;
import com.fr.start.BBSGuestPaneProvider;
import com.fr.xml.ReportXMLUtils;
import java.awt.*;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
@ -108,8 +107,6 @@ import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.fr.stable.module.Module.ENGINE_MODULE;
/**
* Created by juhaoyu on 2018/1/31.
* 触发原来的DesignerModule的启动
@ -152,14 +149,13 @@ public class DesignerActivator extends Activator {
}
}
private static void designerModuleStart() {
private void designerModuleStart() {
StableFactory.registerMarkedClass(ExtraDesignClassManagerProvider.XML_TAG, ExtraDesignClassManager.class);
ActionFactory.registerCellInsertActionClass(actionsForInsertCellElement());
ActionFactory.registerFloatInsertActionClass(actionsForInsertFloatElement());
DesignModuleFactory.registerCreators4Hyperlink(hyperlinkTypes());
justStartModules4Engine();
justStartModules4Designer();
CalculatorProviderContext.setValueConverter(valueConverter());
@ -260,13 +256,6 @@ public class DesignerActivator extends Activator {
};
}
/**
* kunsnat: 一些模块信息 必须跟随设计器启动,
* 比如 读取CC.XML, 设计器启动之后, 马上会读取XML, 需要Chart_Module中的注册信息
*/
private static void justStartModules4Engine() {
ModuleContext.startModule(ENGINE_MODULE);
}
private static void justStartModules4Designer() {
formDesignerRegister();

BIN
designer-realize/src/main/resources/com/fr/start/jni/splash.dylib

Binary file not shown.
Loading…
Cancel
Save