Browse Source

REPORT-3348 数据列基本设置添加过滤条件设置,多个文件换行符和todo

master
yaoh.wu 7 years ago
parent
commit
98eec20b71
  1. 11
      designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java
  2. 359
      designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java
  3. 13
      designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

11
designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java

@ -23,11 +23,14 @@ public class DSColumnBasicEditorPane extends CellEditorPane {
private ResultSetGroupDockingPane groupPane;
//当前编辑的单元格
private TemplateCellElement cellElement;
//条件过滤按钮面板
private JPanel conditionPane;
public DSColumnBasicEditorPane(TemplateCellElement cellElement, SelectedDataColumnPane dataPane, ResultSetGroupDockingPane groupPane) {
public DSColumnBasicEditorPane(TemplateCellElement cellElement, SelectedDataColumnPane dataPane, ResultSetGroupDockingPane groupPane, JPanel conditionPane) {
this.cellElement = cellElement;
this.dataPane = dataPane;
this.groupPane = groupPane;
this.conditionPane = conditionPane;
this.add(this.createContentPane(), BorderLayout.CENTER);
}
@ -66,12 +69,14 @@ public class DSColumnBasicEditorPane extends CellEditorPane {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p, p};
double[] rowSize = {p, p, p};
Component[][] components = new Component[][]{
//数据集列选择
new Component[]{this.dataPane, null},
//数据分组设置
new Component[]{this.groupPane, null}
new Component[]{this.groupPane, null},
//条件过滤
new Component[]{this.conditionPane, null}
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}

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

@ -1,22 +1,22 @@
package com.fr.design.dscolumn;
import com.fr.base.Parameter;
import com.fr.design.data.DesignTableDataManager;
import com.fr.data.SimpleDSColumn;
import com.fr.data.TableDataSource;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.LazyComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.gui.icombobox.LazyComboBox;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.general.Inter;
import com.fr.general.data.TableDataColumn;
import com.fr.report.cell.CellElement;
@ -35,80 +35,190 @@ import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
/**
* 数据集列动态参数设置组件
*
* @author yaoh.wu
* @version 2017年7月26日
* todo 9.0设计器更新修改动态参数注入按钮部分,使其能在右侧边栏正常显示
* @since 8.0
*/
public class SelectedDataColumnPane extends BasicPane {
protected UITableEditorPane<ParameterProvider> editorPane;
protected Parameter[] ps;
protected UITableEditorPane<ParameterProvider> editorPane;
protected Parameter[] ps;
protected TableDataComboBox tableNameComboBox;
protected LazyComboBox columnNameComboBox;
private ItemListener itemListener;
protected TableDataComboBox tableNameComboBox;
protected LazyComboBox columnNameComboBox;
private ItemListener itemListener;
private UIButton paramButton;
private UIButton paramButton;
public SelectedDataColumnPane() {
this(true);
}
public SelectedDataColumnPane() {
this(true);
}
public SelectedDataColumnPane(boolean showParameterButton) {
initComponent(showParameterButton);
}
public SelectedDataColumnPane(boolean showParameterButton) {
initComponent(showParameterButton);
}
/**
* 初始化组件
*
* @param 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);
}
}
public void populate(TableDataSource source, TemplateCellElement cellElement) {
if (cellElement == null) {
return;
}
if (itemListener != null) {
removeListener(itemListener);
}
Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) {
return;
}
DSColumn dsColumn = (DSColumn) value;
String dsName = dsColumn.getDSName();
tableNameComboBox.setSelectedTableDataByName(dsName);
columnNameComboBox.setSelectedItem(TableDataColumn.getColumnName(dsColumn.getColumn()));
ps = dsColumn.getParameters();
addListener(itemListener);
}
public void update(CellElement cellElement) {
if (cellElement == null) {
return;
}
Object value = cellElement.getValue();
if (this.tableNameComboBox.getSelectedItem() == null && this.columnNameComboBox.getSelectedItem() == null) {
return;
}
DSColumn dsColumn = null;
if (value == null || !(value instanceof DSColumn)) {
dsColumn = new DSColumn();
cellElement.setValue(dsColumn);
}
dsColumn = (DSColumn) cellElement.getValue();
SimpleDSColumn simpleDSColumn = updateColumnPane();
dsColumn.setDSName(simpleDSColumn.getDsName());
dsColumn.setColumn(simpleDSColumn.getColumn());
dsColumn.setParameters((ps != null && ps.length > 0) ? ps : null);
}
/**
* 更新面板
*
* @return 更新后的值
*/
public SimpleDSColumn updateColumnPane() {
SimpleDSColumn dsColumn = new SimpleDSColumn();
TableDataWrapper tableDataWrappe = this.tableNameComboBox.getSelectedItem();
if (tableDataWrappe == null) {
return null;
}
dsColumn.setDsName(tableDataWrappe.getTableDataName());
TableDataColumn column;
String columnExp = (String) this.columnNameComboBox.getSelectedItem();
if (isColumnName(columnExp)) {
String number = columnExp.substring(1);
Pattern pattern = Pattern.compile("[^\\d]");
if (pattern.matcher(number).find()) {
column = TableDataColumn.createColumn(columnExp);
} else {
int serialNumber = Integer.parseInt(columnExp.substring(1));
column = TableDataColumn.createColumn(serialNumber);
}
} else {
column = TableDataColumn.createColumn(columnExp);
}
dsColumn.setColumn(column);
return dsColumn;
}
/**
* 添加监听事件
*
* @param i 监听事件
*/
public void addListener(ItemListener i) {
itemListener = i;
tableNameComboBox.addItemListener(i);
columnNameComboBox.addItemListener(i);
}
/**
* 移除监听事件
*
* @param i 监听事件
*/
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);
}
}
protected void initTableNameComboBox() {
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource());
tableNameComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
columnNameComboBox.setLoaded(false);
// columnNameComboBox.loadList();
}
});
tableNameComboBox.setPreferredSize(new Dimension(100, 20));
}
public void removeListener(ItemListener i) {
tableNameComboBox.removeItemListener(i);
columnNameComboBox.removeItemListener(i);
}
protected void initTableNameComboBox() {
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource());
tableNameComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
columnNameComboBox.setLoaded(false);
}
});
tableNameComboBox.setPreferredSize(new Dimension(100, 20));
}
@Override
protected String title4PopupWindow() {
return "DSColumn";
}
private void initWithParameterButton() {
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel());
@ -129,119 +239,16 @@ public class SelectedDataColumnPane extends BasicPane {
});
}
@Override
protected String title4PopupWindow() {
return "DSColumn";
}
public void populate(TableDataSource source, TemplateCellElement cellElement) {
if (cellElement == null) {
return;
}
if (itemListener != null) {
removeListener(itemListener);
}
Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) {
return;
}
DSColumn dsColumn = (DSColumn) value;
String dsName = dsColumn.getDSName();
tableNameComboBox.setSelectedTableDataByName(dsName);
columnNameComboBox.setSelectedItem(TableDataColumn.getColumnName(dsColumn.getColumn()));
ps = dsColumn.getParameters();
addListener(itemListener);
}
public void update(CellElement cellElement) {
if (cellElement == null) {
return;
}
Object value = cellElement.getValue();
if (this.tableNameComboBox.getSelectedItem() == null && this.columnNameComboBox.getSelectedItem() == null) {
return;
}
DSColumn dsColumn = null;
if (value == null || !(value instanceof DSColumn)) {
dsColumn = new DSColumn();
cellElement.setValue(dsColumn);
}
dsColumn = (DSColumn) cellElement.getValue();
SimpleDSColumn simpleDSColumn = updateColumnPane();
dsColumn.setDSName(simpleDSColumn.getDsName());
dsColumn.setColumn(simpleDSColumn.getColumn());
dsColumn.setParameters((ps != null && ps.length > 0) ? ps : null);
}
/**
* 更新面板
*
* @return 更新后的值
*
*/
public SimpleDSColumn updateColumnPane() {
SimpleDSColumn dsColumn = new SimpleDSColumn();
TableDataWrapper tableDataWrappe = this.tableNameComboBox.getSelectedItem();
if (tableDataWrappe == null) {
return null;
}
dsColumn.setDsName(tableDataWrappe.getTableDataName());
TableDataColumn column;
String columnExp = (String) this.columnNameComboBox.getSelectedItem();
if (isColumnName(columnExp)) {
String number = columnExp.substring(1);
Pattern pattern = Pattern.compile("[^\\d]");
if (pattern.matcher(number).find()) {
column = TableDataColumn.createColumn(columnExp);
} else {
int serialNumber = Integer.parseInt(columnExp.substring(1));
column = TableDataColumn.createColumn(serialNumber);
}
} else {
column = TableDataColumn.createColumn(columnExp);
}
dsColumn.setColumn(column);
return dsColumn;
}
private boolean isColumnName(String columnExp) {
return StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#");
}
/**
* 添加监听事件
*
* @param i 监听事件
*
*/
public void addListener(ItemListener i) {
itemListener = i;
tableNameComboBox.addItemListener(i);
columnNameComboBox.addItemListener(i);
}
/**
* 移除监听事件
*
* @param i 监听事件
*
*/
public void removeListener(ItemListener i) {
tableNameComboBox.removeItemListener(i);
columnNameComboBox.removeItemListener(i);
}
private List<String> calculateColumnNameList() {
if (this.tableNameComboBox.getSelectedItem() != null) {
return this.tableNameComboBox.getSelectedItem().calculateColumnNameList();
}
return new ArrayList<String>();
}
private List<String> calculateColumnNameList() {
if (this.tableNameComboBox.getSelectedItem() != null) {
return this.tableNameComboBox.getSelectedItem().calculateColumnNameList();
}
return new ArrayList<String>();
}
}

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

@ -1,10 +1,13 @@
package com.fr.quickeditor.cellquick;
import com.fr.design.actions.columnrow.DSColumnConditionAction;
import com.fr.design.dscolumn.DSColumnAdvancedEditorPane;
import com.fr.design.dscolumn.DSColumnBasicEditorPane;
import com.fr.design.dscolumn.ResultSetGroupDockingPane;
import com.fr.design.dscolumn.SelectedDataColumnPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.cell.CellEditorPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.quickeditor.CellQuickEditor;
@ -30,6 +33,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
private SelectedDataColumnPane dataPane;
//数据分组设置组件
private ResultSetGroupDockingPane groupPane;
//过滤条件面板
private JPanel conditionPane;
// 基本和高级设置
private ArrayList<CellEditorPane> paneList;
// 基本和高级设置 卡片布局
@ -171,9 +176,15 @@ public class CellDSColumnEditor extends CellQuickEditor {
/*基本设置面板*/
this.dataPane = new SelectedDataColumnPane(false);
this.groupPane = new ResultSetGroupDockingPane(tc);
this.conditionPane = new JPanel(new BorderLayout());
conditionPane.add(new UILabel("filter"), BorderLayout.WEST);
if (tc != null) {
//第一次初始化时tc为空,引发NullPointerException
conditionPane.add(new UIButton(new DSColumnConditionAction(tc)), BorderLayout.EAST);
}
dataPane.addListener(dataListener);
groupPane.addListener(groupListener);
paneList.add(new DSColumnBasicEditorPane(cellElement, dataPane, groupPane));
paneList.add(new DSColumnBasicEditorPane(cellElement, dataPane, groupPane, conditionPane));
/*高级设置面板*/

Loading…
Cancel
Save