Browse Source

Pull request #6259: REPORT-60991 导出-导出事件-其它模板-参数设置自定义时无按钮

Merge in DESIGN/design from ~VITO/c-design:release/11.0 to release/11.0

* commit '7e78ffd7e327118f2fd27fa4e284f542fdd7202a':
  无jira任务 漏了编辑事件
  REPORT-60991 导出-导出事件-其它模板-参数设置自定义时无按钮
bugfix/11.0
vito 3 years ago
parent
commit
d3d25d3681
  1. 94
      designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java

94
designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java

@ -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"));
@ -245,19 +246,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 +285,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 +317,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;
@ -364,7 +363,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());
@ -387,6 +386,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;
}
}
// 导出方式下拉框
@ -396,7 +401,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript
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
@ -406,7 +411,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());
@ -453,7 +458,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());
@ -496,7 +501,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());
@ -524,13 +529,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
@ -540,15 +561,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();
}
});
@ -567,7 +580,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;
@ -576,8 +589,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
@ -603,7 +615,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());
@ -616,7 +628,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(Arrays.asList(providers));
}
return paraButton;
}
@ -624,6 +642,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;
}
}
// 参数设置弹出框
@ -747,10 +773,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);

Loading…
Cancel
Save