|
|
|
@ -50,9 +50,9 @@ import javax.swing.event.ChangeEvent;
|
|
|
|
|
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.Color; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
@ -86,6 +86,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
private static final String CUSTOM = "custom"; |
|
|
|
|
private static final String CURRENT_TEMPLATE = "cur"; |
|
|
|
|
private static final String OTHER_TEMPLATE = "other"; |
|
|
|
|
private static final UILabel EMPTY_LABEL = new UILabel(); |
|
|
|
|
|
|
|
|
|
static { |
|
|
|
|
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF")); |
|
|
|
@ -217,6 +218,10 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
this.add(editorPane, BorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void reset() { |
|
|
|
|
editorPane.populate(new SingleJavaScript[0]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting"); |
|
|
|
@ -245,19 +250,21 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
ParameterSettingButton.class |
|
|
|
|
}); |
|
|
|
|
this.setDefaultEditor(ExportTemplateChooser.class, new ExportTemplateChooser()); |
|
|
|
|
this.setDefaultRenderer(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.setDefaultRenderer(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); |
|
|
|
|
this.createTable().getColumnModel().getColumn(5).setMaxWidth(50); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public UITableEditAction[] createAction() { |
|
|
|
|
return new UITableEditAction[] {new AddJSAction(), new DeleteAction()}; |
|
|
|
|
return new UITableEditAction[]{new AddJSAction(), new DeleteAction()}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -282,14 +289,10 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean isCellEditable(int row, int col) { |
|
|
|
|
if(col == 3) { |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -318,7 +321,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 导出文件选择
|
|
|
|
|
class ExportTemplateChooser extends AbstractCellEditor implements TableCellEditor { |
|
|
|
|
class ExportTemplateChooser extends AbstractCellEditor implements TableCellEditor, TableCellRenderer { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = -9112506131272704717L; |
|
|
|
|
private JPanel reportletNamePane; |
|
|
|
@ -326,16 +329,19 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
private UIButton browserButton; |
|
|
|
|
|
|
|
|
|
public ExportTemplateChooser() { |
|
|
|
|
reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
// 路径输入框
|
|
|
|
|
reportPathTextField = new UITextField(7); |
|
|
|
|
reportPathTextField = new UITextField(8); |
|
|
|
|
reportPathTextField.setEnabled(false); |
|
|
|
|
reportletNamePane.add(reportPathTextField, BorderLayout.WEST); |
|
|
|
|
|
|
|
|
|
// 选择路径按钮
|
|
|
|
|
browserButton = new UIButton("..."); |
|
|
|
|
browserButton.setVisible(true); |
|
|
|
|
reportletNamePane.add(browserButton, BorderLayout.EAST); |
|
|
|
|
|
|
|
|
|
Component[][] templateChooserComponent = {{reportPathTextField, browserButton}}; |
|
|
|
|
double[] rowSize = {TableLayout.PREFERRED}; |
|
|
|
|
double[] columnSize = {TableLayout.FILL, 22}; |
|
|
|
|
reportletNamePane = TableLayoutHelper.createCommonTableLayoutPane(templateChooserComponent, rowSize, columnSize, 0); |
|
|
|
|
|
|
|
|
|
browserButton.addActionListener(new ActionListener() { |
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
@ -361,7 +367,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingStopped(ChangeEvent e) { |
|
|
|
|
if (table.getSelectedRow() == -1){ |
|
|
|
|
if (table.getSelectedRow() == -1) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(table.getSelectedRow()); |
|
|
|
@ -384,6 +390,12 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
public Object getCellEditorValue() { |
|
|
|
|
return reportPathTextField.getText(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
|
|
|
|
reportPathTextField.setText((String) value); |
|
|
|
|
return reportletNamePane; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 导出方式下拉框
|
|
|
|
@ -391,9 +403,11 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = -6564079764032351372L; |
|
|
|
|
|
|
|
|
|
private UIComboBox exportTypeComboBox; |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
, EXPORT_TYPES_MAP); |
|
|
|
|
this.addCellEditorListener(new CellEditorListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -403,7 +417,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingStopped(ChangeEvent e) { |
|
|
|
|
if (table.getSelectedRow() == -1){ |
|
|
|
|
if (table.getSelectedRow() == -1) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(table.getSelectedRow()); |
|
|
|
@ -441,6 +455,24 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
public FileNameCombobox() { |
|
|
|
|
fileNameComboBox = getComboBoxWithModel(new String[]{DEFAULT, CUSTOM}, FILENAME_TYPE_MAP); |
|
|
|
|
fileNameComboBox.addItemListener(e -> { |
|
|
|
|
if (e.getStateChange() == ItemEvent.SELECTED) { |
|
|
|
|
final int row = table.getSelectedRow(); |
|
|
|
|
if (row == -1) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(row); |
|
|
|
|
Object ob = fileNameComboBox.getSelectedItem(); |
|
|
|
|
if (ob != null) { |
|
|
|
|
String value = ob.toString(); |
|
|
|
|
js.setDefaultFileName(StringUtils.equals(value, DEFAULT)); |
|
|
|
|
if (js.isDefaultFileName()) { |
|
|
|
|
js.setFileName(StringUtils.EMPTY); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
table.repaint(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.addCellEditorListener(new CellEditorListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -450,15 +482,6 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
@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(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -493,7 +516,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingStopped(ChangeEvent e) { |
|
|
|
|
if (table.getSelectedRow() == -1){ |
|
|
|
|
if (table.getSelectedRow() == -1) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(table.getSelectedRow()); |
|
|
|
@ -506,7 +529,11 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
|
fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build()); |
|
|
|
|
if (value != null) { |
|
|
|
|
fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(value)); |
|
|
|
|
} else { |
|
|
|
|
fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build()); |
|
|
|
|
} |
|
|
|
|
return fileNameFormulaEditor; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -521,13 +548,29 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//参数设置下拉框
|
|
|
|
|
class ParameterCombobox extends AbstractCellEditor implements TableCellEditor { |
|
|
|
|
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); |
|
|
|
|
parameterSetting.addItemListener(e -> { |
|
|
|
|
if (e.getStateChange() == ItemEvent.SELECTED) { |
|
|
|
|
final int row = table.getSelectedRow(); |
|
|
|
|
if (row == -1) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(row); |
|
|
|
|
Object ob = parameterSetting.getSelectedItem(); |
|
|
|
|
if (ob != null) { |
|
|
|
|
String value = ob.toString(); |
|
|
|
|
js.setExtendParameters(StringUtils.equals(value, DEFAULT)); |
|
|
|
|
} |
|
|
|
|
// 单纯为了刷新表格,使某些联动生效
|
|
|
|
|
table.repaint(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.addCellEditorListener(new CellEditorListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -537,15 +580,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
@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(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -564,7 +599,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 参数设置按钮
|
|
|
|
|
class ParameterSettingButton extends AbstractCellEditor implements TableCellEditor { |
|
|
|
|
class ParameterSettingButton extends AbstractCellEditor implements TableCellEditor, TableCellRenderer { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 4021592871993049137L; |
|
|
|
|
private UIButton paraButton; |
|
|
|
@ -573,8 +608,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
public ParameterSettingButton() { |
|
|
|
|
paraSettingPane = new ParameterSettingPane(); |
|
|
|
|
paraButton = new UIButton(); |
|
|
|
|
paraButton.setBackground(Color.GRAY); |
|
|
|
|
paraButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_Set")); |
|
|
|
|
paraButton.addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -600,7 +634,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void editingStopped(ChangeEvent e) { |
|
|
|
|
if (table.getSelectedRow() == -1){ |
|
|
|
|
if (table.getSelectedRow() == -1) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SingleJavaScript js = getList().get(table.getSelectedRow()); |
|
|
|
@ -613,7 +647,13 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
|
paraSettingPane.refresh(new ArrayList<>(Arrays.asList((ParameterProvider[]) value))); |
|
|
|
|
if (getList().get(row) == null || getList().get(row).isExtendParameters()) { |
|
|
|
|
return EMPTY_LABEL; |
|
|
|
|
} |
|
|
|
|
ParameterProvider[] providers = (ParameterProvider[]) value; |
|
|
|
|
if (providers != null) { |
|
|
|
|
paraSettingPane.refresh(new ArrayList<>(Arrays.asList(providers))); |
|
|
|
|
} |
|
|
|
|
return paraButton; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -621,6 +661,14 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
public Object getCellEditorValue() { |
|
|
|
|
return paraSettingPane.getParameterList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
|
|
|
|
if (getList().get(row) == null || getList().get(row).isExtendParameters()) { |
|
|
|
|
return EMPTY_LABEL; |
|
|
|
|
} |
|
|
|
|
return paraButton; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 参数设置弹出框
|
|
|
|
@ -729,6 +777,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
public void populateBean(ExportJavaScript ob) { |
|
|
|
|
if (ob == null) { |
|
|
|
|
ob = new ExportJavaScript(); |
|
|
|
|
otherTemplatePane.reset(); |
|
|
|
|
} |
|
|
|
|
this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1); |
|
|
|
|
if (ob.isCurrentTemplate()) { |
|
|
|
@ -744,10 +793,12 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
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); |
|
|
|
|
if (this.parameterViewPane != null) { |
|
|
|
|
List<ParameterProvider> parameterList = this.parameterViewPane.update(); |
|
|
|
|
parameterList.clear(); |
|
|
|
|
ParameterProvider[] parameters = js.getParameters(); |
|
|
|
|
this.parameterViewPane.populate(parameters); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
OtherTemplatePane pane = (OtherTemplatePane) this.templatePanel.getComponent(1); |
|
|
|
@ -777,11 +828,13 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
|
|
|
|
|
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); |
|
|
|
|
if (parameterViewPane != null) { |
|
|
|
|
List<ParameterProvider> parameterList = parameterViewPane.update(); |
|
|
|
|
if (!parameterList.isEmpty()) { |
|
|
|
|
Parameter[] parameters = new Parameter[parameterList.size()]; |
|
|
|
|
parameterList.toArray(parameters); |
|
|
|
|
js.setParameters(parameters); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
exportJavaScript.addJS(js); |
|
|
|
|