|
|
|
@ -1,9 +1,10 @@
|
|
|
|
|
package com.fr.design.javascript; |
|
|
|
|
|
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
|
import com.fr.base.BaseFormula; |
|
|
|
|
import com.fr.base.Parameter; |
|
|
|
|
import com.fr.base.extension.FileExtension; |
|
|
|
|
import com.fr.design.border.UITitledBorder; |
|
|
|
|
import com.fr.design.constants.LayoutConstants; |
|
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
@ -35,9 +36,12 @@ import com.fr.js.SingleJavaScript;
|
|
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.CardLayout; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import javax.swing.AbstractButton; |
|
|
|
|
import javax.swing.AbstractCellEditor; |
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.ButtonGroup; |
|
|
|
|
import javax.swing.DefaultComboBoxModel; |
|
|
|
|
import javax.swing.JList; |
|
|
|
@ -51,9 +55,6 @@ import javax.swing.event.TableModelEvent;
|
|
|
|
|
import javax.swing.event.TableModelListener; |
|
|
|
|
import javax.swing.table.TableCellEditor; |
|
|
|
|
import javax.swing.table.TableCellRenderer; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.CardLayout; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
import java.awt.event.ItemEvent; |
|
|
|
@ -67,6 +68,12 @@ import java.util.HashSet;
|
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell; |
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.column; |
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.row; |
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.flex; |
|
|
|
|
import static com.fine.theme.utils.FineUIUtils.wrapComponentWithTitle; |
|
|
|
|
|
|
|
|
|
public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript> { |
|
|
|
|
|
|
|
|
|
private ExportRadioGroup templateRadioGroup; |
|
|
|
@ -114,31 +121,22 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
public CurrentTemplatePane() { |
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current"))); |
|
|
|
|
|
|
|
|
|
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
//导出方式
|
|
|
|
|
JPanel exportTypePane = initExportTypePane(); |
|
|
|
|
northPane.add(exportTypePane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
//导出文件名
|
|
|
|
|
JPanel fileNamePane = initFileNamePane(); |
|
|
|
|
northPane.add(fileNamePane, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
|
|
//参数
|
|
|
|
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
JPanel paramsPane = initParamsPane(); |
|
|
|
|
centerPane.add(paramsPane); |
|
|
|
|
|
|
|
|
|
this.add(northPane, BorderLayout.NORTH); |
|
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
|
this.add(column(LayoutConstants.VERTICAL_GAP, |
|
|
|
|
//导出方式
|
|
|
|
|
cell(initExportTypePane()), |
|
|
|
|
//命名方式
|
|
|
|
|
cell(initFileNamePane()), |
|
|
|
|
//参数
|
|
|
|
|
cell(initParamsPane()) |
|
|
|
|
).getComponent()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel initParamsPane() { |
|
|
|
|
UILabel parameterLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Parameters_Setting") + ':'); |
|
|
|
|
UILabel parameterLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Parameters_Setting")); |
|
|
|
|
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Extend_Parameters")); |
|
|
|
|
extendParametersCheckBox.setSelected(true); |
|
|
|
|
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); |
|
|
|
|
parameterViewPane.setPreferredSize(FineUIScale.scale(new Dimension(-1, 200))); |
|
|
|
|
parameterViewPane.setVisible(false); |
|
|
|
|
addListener(parameterViewPane); |
|
|
|
|
extendParametersCheckBox.addItemListener(new ItemListener() { |
|
|
|
@ -147,19 +145,14 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
parameterViewPane.setVisible(e.getStateChange() == ItemEvent.DESELECTED); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
JPanel paramsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
Component[][] components = new Component[][]{{parameterLabel, extendParametersCheckBox}}; |
|
|
|
|
JPanel paramsCheckPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p}); |
|
|
|
|
paramsCheckPane.setBorder(BorderFactory.createEmptyBorder(0, 2, 5, 2)); |
|
|
|
|
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
dynamicPaneWrapper.add(parameterViewPane); |
|
|
|
|
paramsPane.add(paramsCheckPane, BorderLayout.NORTH); |
|
|
|
|
paramsPane.add(dynamicPaneWrapper, BorderLayout.CENTER); |
|
|
|
|
return paramsPane; |
|
|
|
|
return column(LayoutConstants.VERTICAL_GAP, |
|
|
|
|
row(cell(parameterLabel).weight(0.1), cell(extendParametersCheckBox).weight(0.2), flex(0.7)), |
|
|
|
|
cell(parameterViewPane) |
|
|
|
|
).getComponent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel initFileNamePane() { |
|
|
|
|
UILabel nameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename") + ":"); |
|
|
|
|
UILabel nameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename")); |
|
|
|
|
fileNameRadioGroup = new ExportRadioGroup(); |
|
|
|
|
defaultNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default")); |
|
|
|
|
defaultNameRadio.setSelected(true); |
|
|
|
@ -184,18 +177,14 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
Component[][] components = new Component[][]{{nameLabel, defaultNameRadio, customNameRadio, fileNameFormulaEditor}}; |
|
|
|
|
JPanel fileNameRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p, p}); |
|
|
|
|
|
|
|
|
|
JPanel fileNameTipPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
fileNameTipPane.add(fileNameTipLabel); |
|
|
|
|
|
|
|
|
|
JPanel fileNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
fileNamePane.add(fileNameRadioPane, BorderLayout.NORTH); |
|
|
|
|
fileNamePane.add(fileNameTipPane, BorderLayout.CENTER); |
|
|
|
|
fileNameTipPane.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 2)); |
|
|
|
|
fileNamePane.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 2)); |
|
|
|
|
return fileNamePane; |
|
|
|
|
return column(LayoutConstants.HORIZONTAL_GAP, |
|
|
|
|
row( |
|
|
|
|
cell(nameLabel).weight(0.1), |
|
|
|
|
cell(defaultNameRadio).weight(0.15), |
|
|
|
|
row(LayoutConstants.HGAP_LARGE, cell(customNameRadio), cell(fileNameFormulaEditor)).weight(0.75) |
|
|
|
|
), |
|
|
|
|
cell(fileNameTipLabel) |
|
|
|
|
).getComponent(); |
|
|
|
|
} |
|
|
|
|
public void updateSingleJavaScript(SingleJavaScript js){ |
|
|
|
|
js.setTemplatePath(DEFAULT); |
|
|
|
@ -241,14 +230,10 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
private JPanel initExportTypePane() { |
|
|
|
|
UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":"); |
|
|
|
|
UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type")); |
|
|
|
|
exportTypeComboBox = getComboBoxWithModel(new String[]{ExportJavaScript.EXPORT_PDF, ExportJavaScript.EXPORT_EXCEL_PAGE, ExportJavaScript.EXPORT_EXCEL_SIMPLE, ExportJavaScript.EXPORT_EXCEL_SHEET, ExportJavaScript.EXPORT_WORD, ExportJavaScript.EXPORT_IMAGE} |
|
|
|
|
, EXPORT_TYPES_MAP); |
|
|
|
|
Component[][] components = new Component[][]{{typeLabel, exportTypeComboBox}}; |
|
|
|
|
|
|
|
|
|
JPanel exportTypePane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p}); |
|
|
|
|
exportTypePane.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 2)); |
|
|
|
|
return exportTypePane; |
|
|
|
|
return row(cell(typeLabel).weight(0.1), cell(exportTypeComboBox).weight(0.5), flex(0.4)).getComponent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -265,12 +250,10 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
public OtherTemplatePane() { |
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other"))); |
|
|
|
|
|
|
|
|
|
editorPane = new UITableEditorPane<>(new ExportJSTableModel()); |
|
|
|
|
editorPane.setHeaderResizing(false); |
|
|
|
|
|
|
|
|
|
this.add(editorPane, BorderLayout.CENTER); |
|
|
|
|
editorPane.setPreferredSize(FineUIScale.scale(new Dimension(-1,300))); |
|
|
|
|
this.add(wrapComponentWithTitle(editorPane, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void reset() { |
|
|
|
@ -769,14 +752,6 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initComponents() { |
|
|
|
|
JPanel totalPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
totalPanel.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting"))); |
|
|
|
|
|
|
|
|
|
// 导出模板
|
|
|
|
|
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
JPanel chooseTemplatePane = initChooseTemplatePane(); |
|
|
|
|
northPane.add(chooseTemplatePane, BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
// 默认当前模板
|
|
|
|
|
currentTemplatePane = new CurrentTemplatePane(); |
|
|
|
|
otherTemplatePane = new OtherTemplatePane(); |
|
|
|
@ -785,16 +760,18 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
templatePanel.setLayout(card); |
|
|
|
|
templatePanel.add(CURRENT_TEMPLATE, currentTemplatePane); |
|
|
|
|
templatePanel.add(OTHER_TEMPLATE, otherTemplatePane); |
|
|
|
|
|
|
|
|
|
totalPanel.add(northPane, BorderLayout.NORTH); |
|
|
|
|
totalPanel.add(templatePanel, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
this.add(totalPanel); |
|
|
|
|
JPanel exportPanel = new JPanel(new BorderLayout()); |
|
|
|
|
exportPanel.add(column(LayoutConstants.VERTICAL_GAP, cell(initChooseTemplatePane()), cell(templatePanel)).getComponent()); |
|
|
|
|
this.add(wrapComponentWithTitle(exportPanel, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting")), BorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 导出模板 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private JPanel initChooseTemplatePane() { |
|
|
|
|
UILabel templateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template") + ":"); |
|
|
|
|
UILabel templateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template")); |
|
|
|
|
templateRadioGroup = new ExportRadioGroup(); |
|
|
|
|
currentTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")); |
|
|
|
|
currentTemplateRadio.setSelected(true); |
|
|
|
@ -816,14 +793,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}}; |
|
|
|
|
JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p}); |
|
|
|
|
|
|
|
|
|
JPanel chooseTemplatePane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); |
|
|
|
|
chooseTemplatePane.add(reportletRadioPane, BorderLayout.NORTH); |
|
|
|
|
chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0, 7, 5, 2)); |
|
|
|
|
|
|
|
|
|
return chooseTemplatePane; |
|
|
|
|
return row(cell(templateLabel).weight(0.1), cell(currentTemplateRadio).weight(0.15), cell(otherTemplateRadio).weight(0.15), flex(0.6)).getComponent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|