Browse Source

REPORT-3348 复用添加数据列对话框代码,保留原始对话框布局

master
yaoh.wu 7 years ago
parent
commit
e8df144eaf
  1. 42
      designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java
  2. 99
      designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java
  3. 64
      designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java
  4. 59
      designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java
  5. 2
      designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

42
designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java

@ -2,6 +2,7 @@ package com.fr.design.dscolumn;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.CustomVariableResolver;
@ -19,6 +20,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.cell.CellEditorPane; import com.fr.design.mainframe.cell.CellEditorPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
@ -270,21 +272,26 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane {
if (selectIndex == 1) { if (selectIndex == 1) {
setCardPaneLayout.show(setCardPane, FilterType.TOP.name()); setCardPaneLayout.show(setCardPane, FilterType.TOP.name());
tipCardPaneLayout.show(tipCardPane, FilterType.TOP.name()); tipCardPaneLayout.show(tipCardPane, FilterType.TOP.name());
//隐藏tip
} else if (selectIndex == 2) { } else if (selectIndex == 2) {
setCardPaneLayout.show(setCardPane, FilterType.BOTTOM.name()); setCardPaneLayout.show(setCardPane, FilterType.BOTTOM.name());
tipCardPaneLayout.show(tipCardPane, FilterType.BOTTOM.name()); tipCardPaneLayout.show(tipCardPane, FilterType.BOTTOM.name());
//隐藏tip
} else if (selectIndex == 3) { } else if (selectIndex == 3) {
setCardPaneLayout.show(setCardPane, FilterType.ODD.name()); setCardPaneLayout.show(setCardPane, FilterType.ODD.name());
tipCardPaneLayout.show(tipCardPane, FilterType.ODD.name()); tipCardPaneLayout.show(tipCardPane, FilterType.ODD.name());
//隐藏set
} else if (selectIndex == 4) { } else if (selectIndex == 4) {
setCardPaneLayout.show(setCardPane, FilterType.EVEN.name()); setCardPaneLayout.show(setCardPane, FilterType.EVEN.name());
tipCardPaneLayout.show(tipCardPane, FilterType.EVEN.name()); tipCardPaneLayout.show(tipCardPane, FilterType.EVEN.name());
//隐藏set
} else if (selectIndex == 5) { } else if (selectIndex == 5) {
setCardPaneLayout.show(setCardPane, FilterType.SPECIFY.name()); setCardPaneLayout.show(setCardPane, FilterType.SPECIFY.name());
tipCardPaneLayout.show(tipCardPane, FilterType.SPECIFY.name()); tipCardPaneLayout.show(tipCardPane, FilterType.SPECIFY.name());
} else { } else {
setCardPaneLayout.show(setCardPane, FilterType.UNDEFINE.name()); setCardPaneLayout.show(setCardPane, FilterType.UNDEFINE.name());
tipCardPaneLayout.show(tipCardPane, FilterType.UNDEFINE.name()); tipCardPaneLayout.show(tipCardPane, FilterType.UNDEFINE.name());
//隐藏set和tip
} }
} }
}); });
@ -413,18 +420,29 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane {
private String defaultValue; private String defaultValue;
public JFormulaField(String defaultValue) { public JFormulaField(String defaultValue) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p};
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
formulaTextField = new UITextField();
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
formulaTextField = new UITextField(11);
this.add(formulaTextField);
formulaTextField.setText(defaultValue); formulaTextField.setText(defaultValue);
UIButton formulaButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); UIButton formulaButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/m_insert/formula.png"));
this.add(formulaButton);
formulaButton.setToolTipText(Inter.getLocText("Formula") + "..."); formulaButton.setToolTipText(Inter.getLocText("Formula") + "...");
formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height)); formulaButton.setPreferredSize(new Dimension(24, formulaTextField.getPreferredSize().height));
formulaButton.addActionListener(formulaButtonActionListener); formulaButton.addActionListener(formulaButtonActionListener);
Component[] buttonComponent = new Component[]{
formulaButton
};
JPanel pane = new JPanel(new BorderLayout(0, 0));
pane.add(formulaTextField, BorderLayout.CENTER);
pane.add(GUICoreUtils.createFlowPane(buttonComponent, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST);
Component[][] components = new Component[][]{
new Component[]{pane}
};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout());
this.add(panel, BorderLayout.CENTER);
} }
public void populate(String formulaContent) { public void populate(String formulaContent) {
@ -485,13 +503,17 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane {
* @see DSColumnAdvancedPane.ValuePane * @see DSColumnAdvancedPane.ValuePane
*/ */
private static class CustomValuePane extends JPanel { private static class CustomValuePane extends JPanel {
private DSColumnAdvancedEditorPane.JFormulaField formulaField; private JFormulaField formulaField;
public CustomValuePane() { public CustomValuePane() {
double p = TableLayout.PREFERRED, f = TableLayout.FILL;
this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); this.setLayout(FRGUIPaneFactory.createBoxFlowLayout());
UILabel customValueLabel = new UILabel("显示值"); UILabel customValueLabel = new UILabel("显示值");
this.add(Box.createHorizontalStrut(2)); formulaField = new JFormulaField("$$$");
this.add((formulaField = new DSColumnAdvancedEditorPane.JFormulaField("$$$"))); formulaField.setPreferredSize(new Dimension(159, 20));
this.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{
{customValueLabel, formulaField},
}, new double[]{p}, new double[]{p, f}), BorderLayout.CENTER);
} }
public void populate(CellElement cellElement) { public void populate(CellElement cellElement) {

99
designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java

@ -1,25 +1,23 @@
package com.fr.design.dscolumn; package com.fr.design.dscolumn;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.design.dialog.BasicPane;
import com.fr.design.expand.ConditionParentPane; import com.fr.design.expand.ConditionParentPane;
import com.fr.design.expand.ExpandDirectionPane; import com.fr.design.expand.ExpandDirectionPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.dialog.BasicPane;
import com.fr.general.Inter;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class DSColumnBasicPane extends BasicPane { public class DSColumnBasicPane extends BasicPane {
@ -30,7 +28,7 @@ public class DSColumnBasicPane extends BasicPane {
private CellElement cellElement; private CellElement cellElement;
public DSColumnBasicPane() { public DSColumnBasicPane() {
this(DSColumnPane.SETTING_ALL); this(DSColumnPane.SETTING_ALL);
} }
public DSColumnBasicPane(int setting) { public DSColumnBasicPane(int setting) {
@ -38,44 +36,44 @@ public class DSColumnBasicPane extends BasicPane {
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
if (setting > DSColumnPane.SETTING_DSRELATED) { if (setting > DSColumnPane.SETTING_DSRELATED) {
selectDataColumnPane = new SelectedDataColumnPane(); selectDataColumnPane = new SelectedDataColumnPane();
} else { } else {
selectDataColumnPane = new SelectedConfirmedDataColumnPane(); selectDataColumnPane = new SelectedConfirmedDataColumnPane();
} }
selectDataColumnPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Select_DataColumn"), null)); selectDataColumnPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Select_DataColumn"), null));
if (setting > DSColumnPane.SETTING_DSRELATED) { if (setting > DSColumnPane.SETTING_DSRELATED) {
conditionParentPane = new ConditionParentPane(); conditionParentPane = new ConditionParentPane();
conditionParentPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ParentCell_Setting"), null)); conditionParentPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ParentCell_Setting"), null));
} }
resultSetGroupPane = new ResultSetGroupPopUpPane(setting > DSColumnPane.SETTING_DSRELATED); resultSetGroupPane = new ResultSetGroupPopUpPane(setting > DSColumnPane.SETTING_DSRELATED);
resultSetGroupPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Data_Setting"), null)); resultSetGroupPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Data_Setting"), null));
if (setting > DSColumnPane.SETTING_DSRELATED) { if (setting > DSColumnPane.SETTING_DSRELATED) {
expandDirectionPane = new ExpandDirectionPane(); expandDirectionPane = new ExpandDirectionPane();
expandDirectionPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ExpandD-Expand_Direction"), null)); expandDirectionPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("ExpandD-Expand_Direction"), null));
} }
double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED,
TableLayout.PREFERRED, TableLayout.PREFERRED}; TableLayout.PREFERRED, TableLayout.PREFERRED};
double[] columnSize = {TableLayout.FILL}; double[] columnSize = {TableLayout.FILL};
Component[][] components = null; Component[][] components = null;
if (setting > DSColumnPane.SETTING_DSRELATED) { if (setting > DSColumnPane.SETTING_DSRELATED) {
components = new Component[][]{ components = new Component[][]{
{selectDataColumnPane}, {selectDataColumnPane},
{conditionParentPane}, {conditionParentPane},
{resultSetGroupPane}, {resultSetGroupPane},
{expandDirectionPane} {expandDirectionPane}
}; };
} else { } else {
components = new Component[][]{ components = new Component[][]{
{selectDataColumnPane}, {selectDataColumnPane},
{resultSetGroupPane}, {resultSetGroupPane},
}; };
} }
this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER);
@ -85,7 +83,7 @@ public class DSColumnBasicPane extends BasicPane {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("Basic"); return Inter.getLocText("Basic");
} }
public void populate(TableDataSource source, TemplateCellElement cellElement) { public void populate(TableDataSource source, TemplateCellElement cellElement) {
@ -99,10 +97,10 @@ public class DSColumnBasicPane extends BasicPane {
CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr();
if (conditionParentPane != null) { if (conditionParentPane != null) {
conditionParentPane.populate(cellExpandAttr); conditionParentPane.populate(cellExpandAttr);
} }
if (expandDirectionPane != null) { if (expandDirectionPane != null) {
expandDirectionPane.populate(cellExpandAttr); expandDirectionPane.populate(cellExpandAttr);
} }
resultSetGroupPane.populate(cellElement); resultSetGroupPane.populate(cellElement);
@ -128,27 +126,28 @@ public class DSColumnBasicPane extends BasicPane {
} }
if (conditionParentPane != null) { if (conditionParentPane != null) {
conditionParentPane.update(cellExpandAttr); conditionParentPane.update(cellExpandAttr);
} }
if (expandDirectionPane != null) { if (expandDirectionPane != null) {
expandDirectionPane.update(cellExpandAttr); expandDirectionPane.update(cellExpandAttr);
} }
resultSetGroupPane.update(); resultSetGroupPane.update();
} }
ActionListener summary_direction_ActionListener = new ActionListener() { ActionListener summary_direction_ActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
if (expandDirectionPane != null) { if (expandDirectionPane != null) {
expandDirectionPane.setNoneRadioButtonSelected(true); expandDirectionPane.setNoneRadioButtonSelected(true);
} }
} }
}; };
ActionListener otherGroup_direction_ActionListener = new ActionListener() { ActionListener otherGroup_direction_ActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
if (expandDirectionPane != null) { if (expandDirectionPane != null) {
expandDirectionPane.setNoneRadioButtonSelected(false); expandDirectionPane.setNoneRadioButtonSelected(false);
} }
} }
}; };
ActionListener sdcUpdate_ActionListener = new ActionListener() { ActionListener sdcUpdate_ActionListener = new ActionListener() {
@ -157,14 +156,16 @@ public class DSColumnBasicPane extends BasicPane {
selectDataColumnPane.update(cellElement); selectDataColumnPane.update(cellElement);
} }
}; };
public void putElementcase(ElementCasePane t){
if (conditionParentPane != null) { public void putElementcase(ElementCasePane t) {
conditionParentPane.putElementcase(t); if (conditionParentPane != null) {
} conditionParentPane.putElementcase(t);
} }
public void putCellElement(TemplateCellElement tplEC2) { }
if (conditionParentPane != null) {
conditionParentPane.putCellElement(tplEC2); public void putCellElement(TemplateCellElement tplEC2) {
} if (conditionParentPane != null) {
} conditionParentPane.putCellElement(tplEC2);
}
}
} }

64
designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java

@ -1,45 +1,45 @@
package com.fr.design.dscolumn; package com.fr.design.dscolumn;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Iterator;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Iterator;
public class SelectedConfirmedDataColumnPane extends SelectedDataColumnPane { public class SelectedConfirmedDataColumnPane extends SelectedDataColumnPane {
public SelectedConfirmedDataColumnPane () { public SelectedConfirmedDataColumnPane() {
super(false); super(false, false);
} }
protected void initTableNameComboBox() { protected void initTableNameComboBox() {
tableNameComboBox = new TableDataComboBox(new WorkBook()); tableNameComboBox = new TableDataComboBox(new WorkBook());
tableNameComboBox.addItemListener(new ItemListener() { tableNameComboBox.addItemListener(new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
columnNameComboBox.setLoaded(false); columnNameComboBox.setLoaded(false);
} }
}); });
tableNameComboBox.setPreferredSize(new Dimension(100, 20)); tableNameComboBox.setPreferredSize(new Dimension(100, 20));
} }
public void populate(TableDataSource source, TemplateCellElement cell) { public void populate(TableDataSource source, TemplateCellElement cell) {
tableNameComboBox.refresh(source); tableNameComboBox.refresh(source);
tableNameComboBox.setEditable(false); tableNameComboBox.setEditable(false);
tableNameComboBox.setEnabled(false); tableNameComboBox.setEnabled(false);
super.populate(source, cell); super.populate(source, cell);
try { try {
Iterator it = source.getTableDataNameIterator(); Iterator it = source.getTableDataNameIterator();
String name = (String)it.next(); String name = (String) it.next();
TemplateTableDataWrapper wrapper = new TemplateTableDataWrapper(source.getTableData(name), name); TemplateTableDataWrapper wrapper = new TemplateTableDataWrapper(source.getTableData(name), name);
tableNameComboBox.setSelectedItem(wrapper); tableNameComboBox.setSelectedItem(wrapper);
tableNameComboBox.getModel().setSelectedItem(wrapper); tableNameComboBox.getModel().setSelectedItem(wrapper);
} catch (Exception e) { } catch (Exception e) {
} }
} }
} }

59
designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java

@ -39,8 +39,8 @@ import java.util.regex.Pattern;
* 数据集列动态参数设置组件 * 数据集列动态参数设置组件
* *
* @author yaoh.wu * @author yaoh.wu
* @version 2017年7月26 * @version 2017年8月3
* 9.0设计器更新修改动态参数注入按钮部分,使其显示动态参数按钮时能在右侧边栏正常显示 * 复用对话框代码保留对话框原始布局
* @since 8.0 * @since 8.0
*/ */
public class SelectedDataColumnPane extends BasicPane { public class SelectedDataColumnPane extends BasicPane {
@ -54,11 +54,15 @@ public class SelectedDataColumnPane extends BasicPane {
private UIButton paramButton; private UIButton paramButton;
public SelectedDataColumnPane() { public SelectedDataColumnPane() {
this(true); this(true, false);
} }
SelectedDataColumnPane(boolean showParameterButton) { public SelectedDataColumnPane(boolean showParameterButton, boolean verticalLayout) {
initComponent(showParameterButton); if (verticalLayout) {
initComponentVerticalLayout(true);
} else {
initComponent(showParameterButton);
}
} }
/** /**
@ -67,6 +71,51 @@ public class SelectedDataColumnPane extends BasicPane {
* @param showParameterButton 是否显示参数按钮 * @param showParameterButton 是否显示参数按钮
*/ */
public void initComponent(boolean showParameterButton) { public void initComponent(boolean showParameterButton) {
initTableNameComboBox();
if (showParameterButton) {
initWithParameterButton();
}
columnNameComboBox = new LazyComboBox() {
@Override
public Object[] load() {
List<String> l = calculateColumnNameList();
return l.toArray(new String[l.size()]);
}
};
columnNameComboBox.setEditable(true);
double p = TableLayout.PREFERRED;
UILabel label1 = new UILabel(Inter.getLocText("TableData") + ":");
UILabel label2 = new UILabel(Inter.getLocText("DataColumn") + ":");
if (showParameterButton) {
label1.setPreferredSize(new Dimension(200, 25));
label2.setPreferredSize(new Dimension(200, 25));
}
if (showParameterButton) {
Component[][] comps = {{label1, null, label2}, {tableNameComboBox, paramButton, columnNameComboBox}};
this.add(TableLayoutHelper.createTableLayoutPane(comps, new double[]{p, p}, new double[]{p, p, p}));
} else {
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{label1, tableNameComboBox},
new Component[]{label2, columnNameComboBox}
};
JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout());
this.add(jPanel, BorderLayout.CENTER);
}
}
/**
* 初始化组件
*
* @param showParameterButton 是否显示参数按钮
*/
public void initComponentVerticalLayout(boolean showParameterButton) {
initTableNameComboBox(); initTableNameComboBox();
if (showParameterButton) { if (showParameterButton) {
initWithParameterButton(); initWithParameterButton();

2
designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -176,7 +176,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
private void createPanes() { private void createPanes() {
paneList = new ArrayList<>(); paneList = new ArrayList<>();
/*基本设置面板*/ /*基本设置面板*/
this.dataPane = new SelectedDataColumnPane(); this.dataPane = new SelectedDataColumnPane(true, true);
this.groupPane = new ResultSetGroupDockingPane(tc); this.groupPane = new ResultSetGroupDockingPane(tc);
double p = TableLayout.PREFERRED, f = TableLayout.FILL; double p = TableLayout.PREFERRED, f = TableLayout.FILL;
double[] rowSize = {p}, columnSize = {p, f}; double[] rowSize = {p}, columnSize = {p, f};

Loading…
Cancel
Save