|
|
|
@ -3,6 +3,7 @@ package com.fr.design.javascript;
|
|
|
|
|
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.dialog.BasicDialog; |
|
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
@ -15,6 +16,10 @@ import com.fr.design.gui.icheckbox.UICheckBox;
|
|
|
|
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
|
|
|
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.gui.itableeditorpane.ParameterTableModel; |
|
|
|
|
import com.fr.design.gui.itableeditorpane.UITableEditAction; |
|
|
|
|
import com.fr.design.gui.itableeditorpane.UITableEditorPane; |
|
|
|
|
import com.fr.design.gui.itableeditorpane.UITableModelAdapter; |
|
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
import com.fr.design.gui.itree.filetree.TemplateFileTree; |
|
|
|
|
import com.fr.design.hyperlink.AbstractHyperLinkPane; |
|
|
|
@ -23,32 +28,40 @@ import com.fr.design.layout.FRGUIPaneFactory;
|
|
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.design.scrollruler.ModLineBorder; |
|
|
|
|
import com.fr.file.filetree.IOFileNodeFilter; |
|
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
|
import com.fr.js.ExportJavaScript; |
|
|
|
|
import com.fr.js.SingleJavaScript; |
|
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.AbstractButton; |
|
|
|
|
import javax.swing.AbstractCellEditor; |
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.ButtonGroup; |
|
|
|
|
import javax.swing.DefaultComboBoxModel; |
|
|
|
|
import javax.swing.JList; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.JScrollPane; |
|
|
|
|
import javax.swing.JTable; |
|
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
|
import javax.swing.event.CellEditorListener; |
|
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
|
import javax.swing.event.TableModelEvent; |
|
|
|
|
import javax.swing.event.TableModelListener; |
|
|
|
|
import javax.swing.table.TableCellEditor; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.CardLayout; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
import java.awt.event.ItemEvent; |
|
|
|
|
import java.awt.event.ItemListener; |
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.List; |
|
|
|
@ -59,21 +72,20 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
private ExportRadioGroup templateRadioGroup; |
|
|
|
|
private UIRadioButton currentTemplateRadio; |
|
|
|
|
private UIRadioButton otherTemplateRadio; |
|
|
|
|
private UITextField reportPathTextField; |
|
|
|
|
private UIButton browserButton; |
|
|
|
|
private UIComboBox exportTypeComboBox; |
|
|
|
|
private ExportRadioGroup fileNameRadioGroup; |
|
|
|
|
private UIRadioButton defaultNameRadio; |
|
|
|
|
private UIRadioButton customNameRadio; |
|
|
|
|
private FormulaEditor fileNameFormulaEditor; |
|
|
|
|
private UICheckBox extendParametersCheckBox; |
|
|
|
|
private ReportletParameterViewPane parameterViewPane; |
|
|
|
|
private CardLayout card; |
|
|
|
|
private JPanel templatePanel; |
|
|
|
|
private CurrentTemplatePane currentTemplatePane; |
|
|
|
|
private OtherTemplatePane otherTemplatePane; |
|
|
|
|
|
|
|
|
|
private static final double p = TableLayout.PREFERRED; |
|
|
|
|
private static final Map<String, String> EXPORT_TYPES_MAP = new HashMap<>(); |
|
|
|
|
private static final String CURRENT_TEMPLATE = "current"; |
|
|
|
|
private static final String DEFAULT_FILENAME = "default"; |
|
|
|
|
|
|
|
|
|
private static final Map<String, String> FILENAME_TYPE_MAP = new HashMap<>(); |
|
|
|
|
private static final Map<String, String> PARAMETER_TYPE_MAP = new HashMap<>(); |
|
|
|
|
private static final String DEFAULT = "default"; |
|
|
|
|
private static final String CUSTOM = "custom"; |
|
|
|
|
private static final String CURRENT_TEMPLATE = "cur"; |
|
|
|
|
private static final String OTHER_TEMPLATE = "other"; |
|
|
|
|
|
|
|
|
|
static { |
|
|
|
|
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF")); |
|
|
|
@ -82,134 +94,601 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SHEET, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Sheet")); |
|
|
|
|
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_WORD, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Word")); |
|
|
|
|
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_IMAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Image")); |
|
|
|
|
FILENAME_TYPE_MAP.put(DEFAULT, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default")); |
|
|
|
|
FILENAME_TYPE_MAP.put(CUSTOM, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom")); |
|
|
|
|
PARAMETER_TYPE_MAP.put(DEFAULT, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Extend_Parameters")); |
|
|
|
|
PARAMETER_TYPE_MAP.put(CUSTOM, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ExportJavaScriptPane() { |
|
|
|
|
initComponents(); |
|
|
|
|
} |
|
|
|
|
// 当前模板
|
|
|
|
|
class CurrentTemplatePane extends BasicPane { |
|
|
|
|
|
|
|
|
|
private void initComponents() { |
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
this.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting"))); |
|
|
|
|
private ExportRadioGroup fileNameRadioGroup; |
|
|
|
|
private UIRadioButton defaultNameRadio; |
|
|
|
|
private UIRadioButton customNameRadio; |
|
|
|
|
private FormulaEditor fileNameFormulaEditor; |
|
|
|
|
private UICheckBox extendParametersCheckBox; |
|
|
|
|
private ReportletParameterViewPane parameterViewPane; |
|
|
|
|
|
|
|
|
|
//导出模板+导出方式+导出文件名
|
|
|
|
|
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
public CurrentTemplatePane() { |
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current"))); |
|
|
|
|
|
|
|
|
|
//导出模板
|
|
|
|
|
JPanel chooseTemplatePane = initChooseTemplatePane(); |
|
|
|
|
northPane.add(chooseTemplatePane, BorderLayout.NORTH); |
|
|
|
|
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
//导出方式
|
|
|
|
|
JPanel exportTypePane = initExportTypePane(); |
|
|
|
|
northPane.add(exportTypePane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
//导出方式
|
|
|
|
|
JPanel exportTypePane = initExportTypePane(); |
|
|
|
|
northPane.add(exportTypePane, BorderLayout.CENTER); |
|
|
|
|
//导出文件名
|
|
|
|
|
JPanel fileNamePane = initFileNamePane(); |
|
|
|
|
northPane.add(fileNamePane, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
|
|
//导出文件名
|
|
|
|
|
JPanel fileNamePane = initFileNamePane(); |
|
|
|
|
northPane.add(fileNamePane, BorderLayout.SOUTH); |
|
|
|
|
//参数
|
|
|
|
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
JPanel paramsPane = initParamsPane(); |
|
|
|
|
centerPane.add(paramsPane); |
|
|
|
|
|
|
|
|
|
//参数
|
|
|
|
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
JPanel paramsPane = initParamsPane(); |
|
|
|
|
centerPane.add(paramsPane); |
|
|
|
|
this.add(northPane, BorderLayout.NORTH); |
|
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.add(northPane, BorderLayout.NORTH); |
|
|
|
|
this.add(centerPane, BorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
private JPanel initParamsPane() { |
|
|
|
|
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.setVisible(false); |
|
|
|
|
addListener(parameterViewPane); |
|
|
|
|
extendParametersCheckBox.addItemListener(new ItemListener() { |
|
|
|
|
@Override |
|
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel initParamsPane() { |
|
|
|
|
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters")); |
|
|
|
|
extendParametersCheckBox.setSelected(true); |
|
|
|
|
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); |
|
|
|
|
parameterViewPane.setVisible(false); |
|
|
|
|
parameterViewPane.addTableEditorListener(new TableModelListener() { |
|
|
|
|
public void tableChanged(TableModelEvent e) { |
|
|
|
|
List<ParameterProvider> list = parameterViewPane.update(); |
|
|
|
|
HashSet<String> tempSet = new HashSet<>(); |
|
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
if (StringUtils.isEmpty(list.get(i).getName())) { |
|
|
|
|
continue; |
|
|
|
|
private JPanel initFileNamePane() { |
|
|
|
|
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); |
|
|
|
|
customNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom")); |
|
|
|
|
addRadioToGroup(fileNameRadioGroup, defaultNameRadio, customNameRadio); |
|
|
|
|
fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula")); |
|
|
|
|
fileNameFormulaEditor.setVisible(false); |
|
|
|
|
fileNameFormulaEditor.setEnabled(false); |
|
|
|
|
UILabel fileNameTipLabel = new UILabel("<html><body style=\"color:rgb(147,147,147)\">" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + "</html>"); |
|
|
|
|
fileNameTipLabel.setVisible(false); |
|
|
|
|
fileNameRadioGroup.addActionListener(new ActionListener() { |
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
if (defaultNameRadio.isSelected()) { |
|
|
|
|
fileNameFormulaEditor.setVisible(false); |
|
|
|
|
fileNameFormulaEditor.setEnabled(false); |
|
|
|
|
fileNameTipLabel.setVisible(false); |
|
|
|
|
} else { |
|
|
|
|
fileNameFormulaEditor.setVisible(true); |
|
|
|
|
fileNameFormulaEditor.setEnabled(true); |
|
|
|
|
fileNameTipLabel.setVisible(true); |
|
|
|
|
} |
|
|
|
|
if (tempSet.contains(list.get(i).toString())) { |
|
|
|
|
list.remove(i); |
|
|
|
|
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
tempSet.add(list.get(i).toString()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 其他模板
|
|
|
|
|
class OtherTemplatePane extends BasicPane { |
|
|
|
|
|
|
|
|
|
private UITableEditorPane<SingleJavaScript> editorPane; |
|
|
|
|
|
|
|
|
|
public OtherTemplatePane() { |
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other"))); |
|
|
|
|
|
|
|
|
|
editorPane = new UITableEditorPane<>(new ExportJSTableModel()); |
|
|
|
|
|
|
|
|
|
this.add(editorPane, BorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class ExportJSTableModel extends UITableModelAdapter<SingleJavaScript> { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = -3697206557955735642L; |
|
|
|
|
|
|
|
|
|
public ExportJSTableModel() { |
|
|
|
|
super(new String[]{ |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_File"), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type"), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename"), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Custom"), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Export_JS_Parameters_Setting"), |
|
|
|
|
StringUtils.EMPTY}); |
|
|
|
|
this.setColumnClass(new Class[]{ |
|
|
|
|
ExportTemplateChooser.class, |
|
|
|
|
ExportTypeCombobox.class, |
|
|
|
|
FileNameCombobox.class, |
|
|
|
|
FileNameFormulaEditor.class, |
|
|
|
|
ParameterCombobox.class, |
|
|
|
|
ParameterSettingButton.class |
|
|
|
|
}); |
|
|
|
|
this.setDefaultEditor(ExportTemplateChooser.class, new ExportTemplateChooser()); |
|
|
|
|
this.setDefaultEditor(ExportTypeCombobox.class, new ExportTypeCombobox()); |
|
|
|
|
this.setDefaultEditor(FileNameCombobox.class, new FileNameCombobox()); |
|
|
|
|
this.setDefaultEditor(FileNameFormulaEditor.class, new FileNameFormulaEditor()); |
|
|
|
|
this.setDefaultEditor(ParameterCombobox.class, new ParameterCombobox()); |
|
|
|
|
this.setDefaultEditor(ParameterSettingButton.class, new ParameterSettingButton()); |
|
|
|
|
this.createTable().getColumnModel().getColumn(2).setMaxWidth(60); |
|
|
|
|
this.createTable().getColumnModel().getColumn(4).setMaxWidth(60); |
|
|
|
|
this.createTable().getColumnModel().getColumn(5).setMaxWidth(40); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public UITableEditAction[] createAction() { |
|
|
|
|
return new UITableEditAction[] {new AddJSAction(), new DeleteAction()}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getValueAt(int rowIndex, int columnIndex) { |
|
|
|
|
SingleJavaScript js = this.getList().get(rowIndex); |
|
|
|
|
switch (columnIndex) { |
|
|
|
|
case 0: |
|
|
|
|
return js.getTemplatePath(); |
|
|
|
|
case 1: |
|
|
|
|
return EXPORT_TYPES_MAP.get(js.getExportType()); |
|
|
|
|
case 2: |
|
|
|
|
return js.isDefaultFileName() ? Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default") : Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom"); |
|
|
|
|
case 3: |
|
|
|
|
return js.getFileName(); |
|
|
|
|
case 4: |
|
|
|
|
return js.isExtendParameters() ? Toolkit.i18nText("Fine-Design_Basic_Export_JS_Extend_Parameters") : Toolkit.i18nText("Fine-Design_Basic_Export_JS_Custom"); |
|
|
|
|
case 5: |
|
|
|
|
return js.getParameters(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
extendParametersCheckBox.addItemListener(new ItemListener() { |
|
|
|
|
@Override |
|
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
|
parameterViewPane.setVisible(e.getStateChange() == ItemEvent.DESELECTED); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean isCellEditable(int row, int col) { |
|
|
|
|
if(col == 3) { |
|
|
|
|
// 命名详情
|
|
|
|
|
return this.getList().get(row) != null && !this.getList().get(row).isDefaultFileName(); |
|
|
|
|
} |
|
|
|
|
if (col == 5) { |
|
|
|
|
// 参数设置按钮
|
|
|
|
|
return this.getList().get(row) != null && !this.getList().get(row).isExtendParameters(); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private class AddJSAction extends AddTableRowAction { |
|
|
|
|
|
|
|
|
|
public AddJSAction() { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
JPanel paramsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
paramsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Parameters"))); |
|
|
|
|
paramsPane.add(extendParametersCheckBox, BorderLayout.NORTH); |
|
|
|
|
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
dynamicPaneWrapper.add(parameterViewPane); |
|
|
|
|
paramsPane.add(dynamicPaneWrapper, BorderLayout.CENTER); |
|
|
|
|
return paramsPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel initFileNamePane() { |
|
|
|
|
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); |
|
|
|
|
customNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Custom")); |
|
|
|
|
addRadioToGroup(fileNameRadioGroup, defaultNameRadio, customNameRadio); |
|
|
|
|
fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula")); |
|
|
|
|
fileNameFormulaEditor.setEnabled(false); |
|
|
|
|
fileNameRadioGroup.addActionListener(new ActionListener() { |
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
if (defaultNameRadio.isSelected()) { |
|
|
|
|
fileNameFormulaEditor.setEnabled(false); |
|
|
|
|
super.actionPerformed(e); |
|
|
|
|
if (otherTemplatePane.editorPane.getTableModel().getList().size() <= 50) { |
|
|
|
|
addJS(); |
|
|
|
|
} else { |
|
|
|
|
fileNameFormulaEditor.setEnabled(true); |
|
|
|
|
FineJOptionPane.showMessageDialog(otherTemplatePane, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Batch_Export_Limit")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
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(); |
|
|
|
|
UILabel fileNameTipLabel = new UILabel("<html><body style=\"color:red\">" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + "</html>"); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel initExportTypePane() { |
|
|
|
|
UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":"); |
|
|
|
|
exportTypeComboBox = new UIComboBox(new DefaultComboBoxModel<String>()); |
|
|
|
|
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) exportTypeComboBox.getModel(); |
|
|
|
|
String[] allExportTypes = new String[]{ExportJavaScript.EXPORT_PDF, ExportJavaScript.EXPORT_EXCEL_PAGE, ExportJavaScript.EXPORT_EXCEL_SIMPLE, ExportJavaScript.EXPORT_EXCEL_SHEET, ExportJavaScript.EXPORT_WORD, ExportJavaScript.EXPORT_IMAGE}; |
|
|
|
|
for (int i = 0; i < allExportTypes.length; i++) { |
|
|
|
|
comboBoxModel.addElement(allExportTypes[i]); |
|
|
|
|
private void addJS() { |
|
|
|
|
SingleJavaScript js = new SingleJavaScript(); |
|
|
|
|
addRow(js); |
|
|
|
|
fireTableDataChanged(); |
|
|
|
|
table.getSelectionModel().setSelectionInterval(table.getRowCount() - 1, table.getRowCount() - 1); |
|
|
|
|
} |
|
|
|
|
this.exportTypeComboBox.setRenderer(new UIComboBoxRenderer() { |
|
|
|
|
|
|
|
|
|
// 导出文件选择
|
|
|
|
|
class ExportTemplateChooser extends AbstractCellEditor implements TableCellEditor { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = -9112506131272704717L; |
|
|
|
|
private JPanel reportletNamePane; |
|
|
|
|
private UITextField reportPathTextField; |
|
|
|
|
private UIButton browserButton; |
|
|
|
|
|
|
|
|
|
public ExportTemplateChooser() { |
|
|
|
|
reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
// 路径输入框
|
|
|
|
|
reportPathTextField = new UITextField(7); |
|
|
|
|
reportPathTextField.setEnabled(false); |
|
|
|
|
reportletNamePane.add(reportPathTextField, BorderLayout.WEST); |
|
|
|
|
|
|
|
|
|
// 选择路径按钮
|
|
|
|
|
browserButton = new UIButton("..."); |
|
|
|
|
browserButton.setVisible(true); |
|
|
|
|
reportletNamePane.add(browserButton, BorderLayout.EAST); |
|
|
|
|
browserButton.addActionListener(new ActionListener() { |
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
|
final ReportletPane reportletPane = new ReportletPane(); |
|
|
|
|
reportletPane.setSelectedReportletPath(reportPathTextField.getText()); |
|
|
|
|
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this)); |
|
|
|
|
|
|
|
|
|
reportletDialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void doOk() { |
|
|
|
|
reportPathTextField.setText(reportletPane.getSelectedReportletPath()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
reportletDialog.setVisible(true); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.addCellEditorListener(new CellEditorListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingCanceled(ChangeEvent e) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingStopped(ChangeEvent e) { |
|
|
|
|
if (table.getSelectedRow() == -1){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(table.getSelectedRow()); |
|
|
|
|
String value = StringUtils.trimToNull(reportPathTextField.getText()); |
|
|
|
|
js.setTemplatePath(value); |
|
|
|
|
js.setCurrentTemplate(false); |
|
|
|
|
fireTableDataChanged(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
|
if (value instanceof String) { |
|
|
|
|
this.setText(EXPORT_TYPES_MAP.get(value)); |
|
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
|
reportPathTextField.setText((String) value); |
|
|
|
|
return reportletNamePane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getCellEditorValue() { |
|
|
|
|
return reportPathTextField.getText(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 导出方式下拉框
|
|
|
|
|
class ExportTypeCombobox extends AbstractCellEditor implements TableCellEditor { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = -6564079764032351372L; |
|
|
|
|
|
|
|
|
|
public ExportTypeCombobox() { |
|
|
|
|
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); |
|
|
|
|
this.addCellEditorListener(new CellEditorListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingCanceled(ChangeEvent e) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingStopped(ChangeEvent e) { |
|
|
|
|
if (table.getSelectedRow() == -1){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(table.getSelectedRow()); |
|
|
|
|
Object ob = exportTypeComboBox.getSelectedItem(); |
|
|
|
|
if (ob != null) { |
|
|
|
|
String value = ob.toString(); |
|
|
|
|
js.setExportType(value); |
|
|
|
|
} |
|
|
|
|
fireTableDataChanged(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
|
exportTypeComboBox.setSelectedItem(value); |
|
|
|
|
return exportTypeComboBox; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getCellEditorValue() { |
|
|
|
|
Object ob = exportTypeComboBox.getSelectedItem(); |
|
|
|
|
if (ob != null) { |
|
|
|
|
return ob.toString(); |
|
|
|
|
} |
|
|
|
|
return this; |
|
|
|
|
return ExportJavaScript.EXPORT_PDF; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 命名方式下拉框
|
|
|
|
|
class FileNameCombobox extends AbstractCellEditor implements TableCellEditor { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1829005772744444269L; |
|
|
|
|
private UIComboBox fileNameComboBox; |
|
|
|
|
|
|
|
|
|
public FileNameCombobox() { |
|
|
|
|
fileNameComboBox = getComboBoxWithModel(new String[]{DEFAULT, CUSTOM}, FILENAME_TYPE_MAP); |
|
|
|
|
this.addCellEditorListener(new CellEditorListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingCanceled(ChangeEvent e) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingStopped(ChangeEvent e) { |
|
|
|
|
if (table.getSelectedRow() == -1){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(table.getSelectedRow()); |
|
|
|
|
Object ob = fileNameComboBox.getSelectedItem(); |
|
|
|
|
if (ob != null) { |
|
|
|
|
String value = ob.toString(); |
|
|
|
|
js.setDefaultFileName(StringUtils.equals(value, DEFAULT)); |
|
|
|
|
} |
|
|
|
|
fireTableDataChanged(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
|
fileNameComboBox.setSelectedItem(value); |
|
|
|
|
return fileNameComboBox; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getCellEditorValue() { |
|
|
|
|
return fileNameComboBox.getSelectedItem().toString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 命名方式公式框
|
|
|
|
|
class FileNameFormulaEditor extends AbstractCellEditor implements TableCellEditor { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 7120075192535645493L; |
|
|
|
|
private FormulaEditor fileNameFormulaEditor; |
|
|
|
|
|
|
|
|
|
public FileNameFormulaEditor() { |
|
|
|
|
fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula")); |
|
|
|
|
this.addCellEditorListener(new CellEditorListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingCanceled(ChangeEvent e) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingStopped(ChangeEvent e) { |
|
|
|
|
if (table.getSelectedRow() == -1){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(table.getSelectedRow()); |
|
|
|
|
String value = fileNameFormulaEditor.getUITextField().getText(); |
|
|
|
|
js.setFileName(value); |
|
|
|
|
fireTableDataChanged(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
|
fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build()); |
|
|
|
|
return fileNameFormulaEditor; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getCellEditorValue() { |
|
|
|
|
return fileNameFormulaEditor.getUITextField().getText(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FormulaEditor getFileNameEditor() { |
|
|
|
|
return fileNameFormulaEditor; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//参数设置下拉框
|
|
|
|
|
class ParameterCombobox extends AbstractCellEditor implements TableCellEditor { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 2630964402770993584L; |
|
|
|
|
private UIComboBox parameterSetting; |
|
|
|
|
|
|
|
|
|
public ParameterCombobox() { |
|
|
|
|
parameterSetting = getComboBoxWithModel(new String[]{DEFAULT, CUSTOM}, PARAMETER_TYPE_MAP); |
|
|
|
|
this.addCellEditorListener(new CellEditorListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingCanceled(ChangeEvent e) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingStopped(ChangeEvent e) { |
|
|
|
|
if (table.getSelectedRow() == -1){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(table.getSelectedRow()); |
|
|
|
|
Object ob = parameterSetting.getSelectedItem(); |
|
|
|
|
if (ob != null) { |
|
|
|
|
String value = ob.toString(); |
|
|
|
|
js.setExtendParameters(StringUtils.equals(value, DEFAULT)); |
|
|
|
|
} |
|
|
|
|
fireTableDataChanged(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
|
parameterSetting.setSelectedItem(value); |
|
|
|
|
return parameterSetting; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getCellEditorValue() { |
|
|
|
|
return parameterSetting.getSelectedItem().toString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 参数设置按钮
|
|
|
|
|
class ParameterSettingButton extends AbstractCellEditor implements TableCellEditor { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 4021592871993049137L; |
|
|
|
|
private UIButton paraButton; |
|
|
|
|
private ParameterSettingPane paraSettingPane; |
|
|
|
|
ParameterProvider[] parameterArr; |
|
|
|
|
|
|
|
|
|
public ParameterSettingButton() { |
|
|
|
|
paraSettingPane = new ParameterSettingPane(); |
|
|
|
|
paraButton = new UIButton(); |
|
|
|
|
paraButton.setBackground(Color.GRAY); |
|
|
|
|
paraButton.addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
BasicDialog dialog = paraSettingPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this)); |
|
|
|
|
dialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void doOk() { |
|
|
|
|
List<ParameterProvider> parameterList = paraSettingPane.getParameterList(); |
|
|
|
|
parameterArr = parameterList.toArray(new Parameter[parameterList.size()]); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
dialog.setVisible(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
this.addCellEditorListener(new CellEditorListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingCanceled(ChangeEvent e) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingStopped(ChangeEvent e) { |
|
|
|
|
if (table.getSelectedRow() == -1){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(table.getSelectedRow()); |
|
|
|
|
js.setParameters(parameterArr); |
|
|
|
|
fireTableDataChanged(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
|
paraSettingPane.refresh(new ArrayList<>(Arrays.asList((ParameterProvider[]) value))); |
|
|
|
|
return paraButton; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getCellEditorValue() { |
|
|
|
|
return paraSettingPane.getParameterList(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 参数设置弹出框
|
|
|
|
|
class ParameterSettingPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
private ReportletParameterViewPane parameterViewPane; |
|
|
|
|
|
|
|
|
|
public ParameterSettingPane() { |
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
parameterViewPane = new ReportletParameterViewPane(ParameterTableModel.NO_CHART_USE, getValueEditorPane(), getValueEditorPane()); |
|
|
|
|
addListener(parameterViewPane); |
|
|
|
|
this.add(parameterViewPane); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Parameters_Setting"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<ParameterProvider> getParameterList() { |
|
|
|
|
return parameterViewPane.update(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void refresh(List list) { |
|
|
|
|
parameterViewPane.update(list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ExportJavaScriptPane() { |
|
|
|
|
initComponents(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
templatePanel = FRGUIPaneFactory.createCardLayout_S_Pane(); |
|
|
|
|
card = new CardLayout(); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel initExportTypePane() { |
|
|
|
|
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)); |
|
|
|
|
exportTypePane.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 2)); |
|
|
|
|
return exportTypePane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -220,51 +699,28 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
currentTemplateRadio.setSelected(true); |
|
|
|
|
otherTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other")); |
|
|
|
|
addRadioToGroup(templateRadioGroup, currentTemplateRadio, otherTemplateRadio); |
|
|
|
|
templateRadioGroup.addActionListener(new ActionListener() { |
|
|
|
|
currentTemplateRadio.addItemListener(new ItemListener() { |
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
if (currentTemplateRadio.isSelected()) { |
|
|
|
|
browserButton.setEnabled(false); |
|
|
|
|
} else { |
|
|
|
|
browserButton.setEnabled(true); |
|
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
|
if (e.getStateChange() == ItemEvent.SELECTED) { |
|
|
|
|
card.show(templatePanel, CURRENT_TEMPLATE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}}; |
|
|
|
|
JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p}); |
|
|
|
|
|
|
|
|
|
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
// 路径输入框
|
|
|
|
|
reportPathTextField = new UITextField(20); |
|
|
|
|
reportPathTextField.setEnabled(false); |
|
|
|
|
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
// 选择路径按钮
|
|
|
|
|
browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select")); |
|
|
|
|
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20)); |
|
|
|
|
browserButton.setEnabled(false); |
|
|
|
|
reportletNamePane.add(browserButton, BorderLayout.EAST); |
|
|
|
|
browserButton.addActionListener(new ActionListener() { |
|
|
|
|
otherTemplateRadio.addItemListener(new ItemListener() { |
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
|
final ReportletPane reportletPane = new ReportletPane(); |
|
|
|
|
reportletPane.setSelectedReportletPath(reportPathTextField.getText()); |
|
|
|
|
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this)); |
|
|
|
|
|
|
|
|
|
reportletDialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void doOk() { |
|
|
|
|
reportPathTextField.setText(reportletPane.getSelectedReportletPath()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
reportletDialog.setVisible(true); |
|
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
|
if (e.getStateChange() == ItemEvent.SELECTED) { |
|
|
|
|
card.show(templatePanel, OTHER_TEMPLATE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}}; |
|
|
|
|
JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p}); |
|
|
|
|
|
|
|
|
|
JPanel chooseTemplatePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
JPanel chooseTemplatePane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); |
|
|
|
|
chooseTemplatePane.add(reportletRadioPane, BorderLayout.NORTH); |
|
|
|
|
chooseTemplatePane.add(reportletNamePane, BorderLayout.CENTER); |
|
|
|
|
chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0,2,5,2)); |
|
|
|
|
chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0, 7, 5, 2)); |
|
|
|
|
|
|
|
|
|
return chooseTemplatePane; |
|
|
|
|
} |
|
|
|
@ -276,27 +732,26 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
} |
|
|
|
|
this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1); |
|
|
|
|
if (ob.isCurrentTemplate()) { |
|
|
|
|
this.browserButton.setEnabled(false); |
|
|
|
|
} else { |
|
|
|
|
this.browserButton.setEnabled(true); |
|
|
|
|
this.reportPathTextField.setText(ob.getTemplatePath()); |
|
|
|
|
} |
|
|
|
|
this.exportTypeComboBox.setSelectedItem(ob.getExportType()); |
|
|
|
|
this.fileNameRadioGroup.selectIndexButton(ob.isDefaultFileName() ? 0 : 1); |
|
|
|
|
if (ob.isDefaultFileName()) { |
|
|
|
|
this.fileNameFormulaEditor.setEnabled(false); |
|
|
|
|
} else { |
|
|
|
|
this.fileNameFormulaEditor.setEnabled(true); |
|
|
|
|
this.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(ob.getFileName())); |
|
|
|
|
} |
|
|
|
|
if (ob.isExtendParameters()) { |
|
|
|
|
this.extendParametersCheckBox.setSelected(true); |
|
|
|
|
SingleJavaScript js = ob.getJavaScript(); |
|
|
|
|
exportTypeComboBox.setSelectedItem(js.getExportType()); |
|
|
|
|
currentTemplatePane.fileNameRadioGroup.selectIndexButton(js.isDefaultFileName() ? 0 : 1); |
|
|
|
|
if (!js.isDefaultFileName()) { |
|
|
|
|
currentTemplatePane.fileNameFormulaEditor.setEnabled(true); |
|
|
|
|
currentTemplatePane.fileNameFormulaEditor.setVisible(true); |
|
|
|
|
currentTemplatePane.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(js.getFileName())); |
|
|
|
|
} |
|
|
|
|
if (js.isExtendParameters()) { |
|
|
|
|
currentTemplatePane.extendParametersCheckBox.setSelected(true); |
|
|
|
|
} else { |
|
|
|
|
currentTemplatePane.extendParametersCheckBox.setSelected(false); |
|
|
|
|
List<ParameterProvider> parameterList = this.parameterViewPane.update(); |
|
|
|
|
parameterList.clear(); |
|
|
|
|
ParameterProvider[] parameters = js.getParameters(); |
|
|
|
|
this.parameterViewPane.populate(parameters); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
this.extendParametersCheckBox.setSelected(false); |
|
|
|
|
List<ParameterProvider> parameterList = this.parameterViewPane.update(); |
|
|
|
|
parameterList.clear(); |
|
|
|
|
ParameterProvider[] parameters = ob.getParameters(); |
|
|
|
|
this.parameterViewPane.populate(parameters); |
|
|
|
|
OtherTemplatePane pane = (OtherTemplatePane) this.templatePanel.getComponent(1); |
|
|
|
|
pane.editorPane.populate(ob.getJsList().toArray(new SingleJavaScript[ob.getJsList().size()])); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -309,32 +764,78 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void updateBean(ExportJavaScript exportJavaScript) { |
|
|
|
|
exportJavaScript.setCurrentTemplate(this.currentTemplateRadio.isSelected()); |
|
|
|
|
exportJavaScript.setTemplatePath(getTemplatePath()); |
|
|
|
|
exportJavaScript.setExportType(GeneralUtils.objectToString(this.exportTypeComboBox.getSelectedItem())); |
|
|
|
|
exportJavaScript.setDefaultFileName(this.defaultNameRadio.isSelected()); |
|
|
|
|
exportJavaScript.setFileName(getFileName()); |
|
|
|
|
exportJavaScript.setExtendParameters(this.extendParametersCheckBox.isSelected()); |
|
|
|
|
if (extendParametersCheckBox.isSelected()) { |
|
|
|
|
exportJavaScript.setParameters(null); |
|
|
|
|
boolean selected = currentTemplateRadio.isSelected(); |
|
|
|
|
exportJavaScript.setCurrentTemplate(selected); |
|
|
|
|
if (selected) { |
|
|
|
|
SingleJavaScript js = new SingleJavaScript(); |
|
|
|
|
js.setCurrentTemplate(true); |
|
|
|
|
js.setTemplatePath(DEFAULT); |
|
|
|
|
js.setExportType(GeneralUtils.objectToString(exportTypeComboBox.getSelectedItem())); |
|
|
|
|
js.setDefaultFileName(currentTemplatePane.defaultNameRadio.isSelected()); |
|
|
|
|
js.setFileName(getFileName()); |
|
|
|
|
js.setExtendParameters(currentTemplatePane.extendParametersCheckBox.isSelected()); |
|
|
|
|
if (currentTemplatePane.extendParametersCheckBox.isSelected()) { |
|
|
|
|
exportJavaScript.setParameters(null); |
|
|
|
|
} else { |
|
|
|
|
List<ParameterProvider> parameterList = parameterViewPane.update(); |
|
|
|
|
if (!parameterList.isEmpty()) { |
|
|
|
|
Parameter[] parameters = new Parameter[parameterList.size()]; |
|
|
|
|
parameterList.toArray(parameters); |
|
|
|
|
js.setParameters(parameters); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
exportJavaScript.addJS(js); |
|
|
|
|
} else { |
|
|
|
|
List<ParameterProvider> parameterList = this.parameterViewPane.update(); |
|
|
|
|
if (!parameterList.isEmpty()) { |
|
|
|
|
Parameter[] parameters = new Parameter[parameterList.size()]; |
|
|
|
|
parameterList.toArray(parameters); |
|
|
|
|
exportJavaScript.setParameters(parameters); |
|
|
|
|
List<SingleJavaScript> javaScripts = otherTemplatePane.editorPane.update(); |
|
|
|
|
for (SingleJavaScript js : javaScripts) { |
|
|
|
|
exportJavaScript.addJS(js); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getTemplatePath() { |
|
|
|
|
return currentTemplateRadio.isSelected() ? CURRENT_TEMPLATE : reportPathTextField.getText(); |
|
|
|
|
private String getFileName() { |
|
|
|
|
return currentTemplatePane.defaultNameRadio.isSelected() ? DEFAULT : currentTemplatePane.fileNameFormulaEditor.getUITextField().getText(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getFileName() { |
|
|
|
|
return defaultNameRadio.isSelected() ? DEFAULT_FILENAME : fileNameFormulaEditor.getUITextField().getText(); |
|
|
|
|
private UIComboBox getComboBoxWithModel(String[] itemTextArr, Map<String, String> itemTextDic) { |
|
|
|
|
UIComboBox comboBox = new UIComboBox(new DefaultComboBoxModel<String>()); |
|
|
|
|
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) comboBox.getModel(); |
|
|
|
|
for (int i = 0; i < itemTextArr.length; i++) { |
|
|
|
|
comboBoxModel.addElement(itemTextArr[i]); |
|
|
|
|
} |
|
|
|
|
comboBox.setRenderer(new UIComboBoxRenderer() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
|
if (value instanceof String) { |
|
|
|
|
this.setText(itemTextDic.get(value)); |
|
|
|
|
} |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return comboBox; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void addListener(ReportletParameterViewPane paraPane) { |
|
|
|
|
paraPane.addTableEditorListener(new TableModelListener() { |
|
|
|
|
public void tableChanged(TableModelEvent e) { |
|
|
|
|
List<ParameterProvider> list = paraPane.update(); |
|
|
|
|
HashSet<String> tempSet = new HashSet<>(); |
|
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
if (StringUtils.isEmpty(list.get(i).getName())) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (tempSet.contains(list.get(i).toString())) { |
|
|
|
|
list.remove(i); |
|
|
|
|
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
tempSet.add(list.get(i).toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean accept(Object ob) { |
|
|
|
|