Browse Source

Merge pull request #1 in ~MOMEAK/design9.0 from ~YAOH.WU/design9.0:9.0 to 9.0

* commit '1bd82501ff4752a5d5c2c575038d01f7238663ad':
  REPORT-3348 数据列集选择组件布局修改,一些代码结构
  REPORT-3348 单元格元素数据列基本设置OK
  REPORT-3348 数据列基本设置添加过滤条件设置,多个文件换行符和todo
  REPORT-3348 单元格元素数据列基本设置动态加载
  REPORT-3348,踩坑,数据列展现方案确定
master
MoMeak 7 years ago
parent
commit
ac7255ebef
  1. 38
      designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java
  2. 84
      designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java
  3. 143
      designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java
  4. 30
      designer/src/com/fr/design/mainframe/cell/CellEditorPane.java
  5. 44
      designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java
  6. 66
      designer/src/com/fr/quickeditor/CellQuickEditor.java
  7. 18
      designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java
  8. 158
      designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java
  9. 18
      designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java
  10. 14
      designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java
  11. 86
      designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java
  12. 11
      designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java

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

@ -0,0 +1,38 @@
package com.fr.design.dscolumn;
import com.fr.design.mainframe.cell.CellEditorPane;
import com.fr.report.cell.TemplateCellElement;
/**
* 单元格元素 数据列 基本设置内容面板
*
* @author yaoh.wu
* @version 2017年7月25日
* @since 9.0
*/
public class DSColumnAdvancedEditorPane extends CellEditorPane {
@Override
public String getIconPath() {
return "Advanced";
}
@Override
public String title4PopupWindow() {
return "Advanced";
}
@Override
public void update() {
}
@Override
public void populate(TemplateCellElement cellElement) {
}
}

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

@ -0,0 +1,84 @@
package com.fr.design.dscolumn;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.cell.CellEditorPane;
import com.fr.report.cell.TemplateCellElement;
import javax.swing.*;
import java.awt.*;
/**
* 单元格元素 数据列 高级设置内容面板
*
* @author yaoh.wu
* @version 2017年7月25日
* @since 9.0
*/
public class DSColumnBasicEditorPane extends CellEditorPane {
//数据集和数据列
private SelectedDataColumnPane dataPane;
//数据分组设置
private ResultSetGroupDockingPane groupPane;
//当前编辑的单元格
private TemplateCellElement cellElement;
//条件过滤按钮面板
private JPanel conditionPane;
public DSColumnBasicEditorPane(TemplateCellElement cellElement, SelectedDataColumnPane dataPane, ResultSetGroupDockingPane groupPane, JPanel conditionPane) {
this.setLayout(new BorderLayout());
this.cellElement = cellElement;
this.dataPane = dataPane;
this.groupPane = groupPane;
this.conditionPane = conditionPane;
this.add(this.createContentPane(), BorderLayout.CENTER);
}
@Override
public String getIconPath() {
return "Basic";
}
@Override
public String title4PopupWindow() {
return "Basic";
}
@Override
public void update() {
dataPane.update(this.cellElement);
groupPane.update();
}
@Override
public void populate(TemplateCellElement cellElement) {
this.cellElement = cellElement;
dataPane.populate(null, cellElement);
groupPane.populate(cellElement);
}
/**
* 创建有内容的面板显示信息
*
* @return content JPanel
*/
private JPanel createContentPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p, p, p};
Component[][] components = new Component[][]{
//数据集列选择
new Component[]{this.dataPane},
//数据分组设置
new Component[]{this.groupPane},
//条件过滤
new Component[]{this.conditionPane}
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
}

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

@ -1,22 +1,22 @@
package com.fr.design.dscolumn; package com.fr.design.dscolumn;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.design.data.DesignTableDataManager;
import com.fr.data.SimpleDSColumn; import com.fr.data.SimpleDSColumn;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; 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.ibutton.UIButton;
import com.fr.design.gui.icombobox.LazyComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditorPane; 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.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; 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.Inter;
import com.fr.general.data.TableDataColumn; import com.fr.general.data.TableDataColumn;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
@ -35,12 +35,20 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/**
* 数据集列动态参数设置组件
*
* @author yaoh.wu
* @version 2017年7月26日
* 9.0设计器更新修改动态参数注入按钮部分,使其显示动态参数按钮时能在右侧边栏正常显示
* @since 8.0
*/
public class SelectedDataColumnPane extends BasicPane { public class SelectedDataColumnPane extends BasicPane {
protected UITableEditorPane<ParameterProvider> editorPane; private UITableEditorPane<ParameterProvider> editorPane;
protected Parameter[] ps; private Parameter[] ps;
protected TableDataComboBox tableNameComboBox; TableDataComboBox tableNameComboBox;
protected LazyComboBox columnNameComboBox; LazyComboBox columnNameComboBox;
private ItemListener itemListener; private ItemListener itemListener;
private UIButton paramButton; private UIButton paramButton;
@ -49,7 +57,7 @@ public class SelectedDataColumnPane extends BasicPane {
this(true); this(true);
} }
public SelectedDataColumnPane(boolean showParameterButton) { SelectedDataColumnPane(boolean showParameterButton) {
initComponent(showParameterButton); initComponent(showParameterButton);
} }
@ -57,7 +65,6 @@ public class SelectedDataColumnPane extends BasicPane {
* 初始化组件 * 初始化组件
* *
* @param showParameterButton 是否显示参数按钮 * @param showParameterButton 是否显示参数按钮
*
*/ */
public void initComponent(boolean showParameterButton) { public void initComponent(boolean showParameterButton) {
initTableNameComboBox(); initTableNameComboBox();
@ -65,32 +72,33 @@ public class SelectedDataColumnPane extends BasicPane {
initWithParameterButton(); initWithParameterButton();
} }
columnNameComboBox = new LazyComboBox() { columnNameComboBox = new LazyComboBox() {
@Override @Override
public Object[] load() { public Object[] load() {
List<String> l = calculateColumnNameList(); List<String> l = calculateColumnNameList();
return l.toArray(new String[l.size()]); return l.toArray(new String[l.size()]);
} }
}; };
columnNameComboBox.setEditable(true); columnNameComboBox.setEditable(true);
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
UILabel label1 = new UILabel(Inter.getLocText("TableData") + ":"); UILabel label1 = new UILabel(Inter.getLocText("TableData"));
UILabel label2 = new UILabel(Inter.getLocText("DataColumn") + ":"); UILabel label3 = new UILabel(Inter.getLocText("DataColumn"));
if (showParameterButton) {
label1.setPreferredSize(new Dimension(200, 25));
label2.setPreferredSize(new Dimension(200, 25));
}
if (showParameterButton) { if (showParameterButton) {
Component[][] comps = {{label1, null, label2}, {tableNameComboBox, paramButton, columnNameComboBox}}; //todo 国际化
this.add(TableLayoutHelper.createTableLayoutPane(comps, new double[]{p, p}, new double[]{p, p, p})); UILabel label2 = new UILabel("param");
Component[][] components = {
{label1, tableNameComboBox},
{label2, paramButton},
{label3, columnNameComboBox}
};
this.setLayout(new BorderLayout());
this.add(TableLayoutHelper.createTableLayoutPane(components, new double[]{p, p, p}, new double[]{p, f}));
} else { } else {
double f = TableLayout.FILL;
double[] columnSize = {p, f}; double[] columnSize = {p, f};
double[] rowSize = {p, p}; double[] rowSize = {p, p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{label1, tableNameComboBox}, new Component[]{label1, tableNameComboBox},
new Component[]{label2, columnNameComboBox} new Component[]{label3, columnNameComboBox}
}; };
JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
@ -98,56 +106,18 @@ public class SelectedDataColumnPane extends BasicPane {
} }
} }
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));
}
private void initWithParameterButton() {
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel());
paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting"));
paramButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BasicDialog paramDialog = editorPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
List<ParameterProvider> parameterList = editorPane.update();
ps = parameterList.toArray(new Parameter[parameterList.size()]);
}
});
editorPane.populate(ps == null ? new Parameter[0] : ps);
paramDialog.setVisible(true);
}
});
}
@Override
protected String title4PopupWindow() {
return "DSColumn";
}
public void populate(TableDataSource source, TemplateCellElement cellElement) { public void populate(TableDataSource source, TemplateCellElement cellElement) {
if (cellElement == null) { if (cellElement == null) {
return; return;
} }
if (itemListener != null) { if (itemListener != null) {
removeListener(itemListener); removeListener(itemListener);
} }
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (!(value instanceof DSColumn)) { if (!(value instanceof DSColumn)) {
return; return;
} }
DSColumn dsColumn = (DSColumn) value; DSColumn dsColumn = (DSColumn) value;
String dsName = dsColumn.getDSName(); String dsName = dsColumn.getDSName();
tableNameComboBox.setSelectedTableDataByName(dsName); tableNameComboBox.setSelectedTableDataByName(dsName);
@ -183,7 +153,6 @@ public class SelectedDataColumnPane extends BasicPane {
* 更新面板 * 更新面板
* *
* @return 更新后的值 * @return 更新后的值
*
*/ */
public SimpleDSColumn updateColumnPane() { public SimpleDSColumn updateColumnPane() {
SimpleDSColumn dsColumn = new SimpleDSColumn(); SimpleDSColumn dsColumn = new SimpleDSColumn();
@ -210,16 +179,10 @@ public class SelectedDataColumnPane extends BasicPane {
return dsColumn; return dsColumn;
} }
private boolean isColumnName(String columnExp) {
return StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#");
}
/** /**
* 添加监听事件 * 添加监听事件
* *
* @param i 监听事件 * @param i 监听事件
*
*/ */
public void addListener(ItemListener i) { public void addListener(ItemListener i) {
itemListener = i; itemListener = i;
@ -231,13 +194,55 @@ public class SelectedDataColumnPane extends BasicPane {
* 移除监听事件 * 移除监听事件
* *
* @param i 监听事件 * @param i 监听事件
*
*/ */
public void removeListener(ItemListener i) { public void removeListener(ItemListener i) {
tableNameComboBox.removeItemListener(i); tableNameComboBox.removeItemListener(i);
columnNameComboBox.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());
paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting"));
paramButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
BasicDialog paramDialog = editorPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
List<ParameterProvider> parameterList = editorPane.update();
ps = parameterList.toArray(new Parameter[parameterList.size()]);
}
});
editorPane.populate(ps == null ? new Parameter[0] : ps);
paramDialog.setVisible(true);
}
});
}
private boolean isColumnName(String columnExp) {
return StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#");
}
private List<String> calculateColumnNameList() { private List<String> calculateColumnNameList() {
if (this.tableNameComboBox.getSelectedItem() != null) { if (this.tableNameComboBox.getSelectedItem() != null) {
return this.tableNameComboBox.getSelectedItem().calculateColumnNameList(); return this.tableNameComboBox.getSelectedItem().calculateColumnNameList();

30
designer/src/com/fr/design/mainframe/cell/CellEditorPane.java

@ -0,0 +1,30 @@
package com.fr.design.mainframe.cell;
import com.fr.design.dialog.BasicPane;
import com.fr.report.cell.TemplateCellElement;
/**
* 右侧单元格元素面板抽象类
*
* @author yaoh.wu
* @version 2017年7月25日
* @since 9.0
*/
public abstract class CellEditorPane extends BasicPane {
public abstract String getIconPath();
public abstract String title4PopupWindow();
/**
* 从面板拿数据保存
*/
public abstract void update();
/**
* 更新面板数据
*
* @param cellElement 单元格
*/
public abstract void populate(TemplateCellElement cellElement);
}

44
designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java

@ -1,55 +1,55 @@
package com.fr.design.mainframe.cell; package com.fr.design.mainframe.cell;
import java.awt.BorderLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.general.Inter;
import com.fr.design.selection.QuickEditor; import com.fr.design.selection.QuickEditor;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
/** /**
* QuickEditorRegion * QuickEditorRegion
* *
* @editor zhou * @author zhou, yaoh.wu
* @since 2012-3-23下午3:21:36 * @version 2017年7月25日
* @since 8.0
*/ */
public class QuickEditorRegion extends JPanel { public class QuickEditorRegion extends JPanel {
private static QuickEditorRegion singleton = new QuickEditorRegion();
private static JPanel EMPTY;
private QuickEditorRegion() {
this.setLayout(new BorderLayout());
}
public static QuickEditorRegion getInstance() { public static QuickEditorRegion getInstance() {
return singleton; return singleton;
} }
public static JPanel getEmptyEditor() { public static JPanel getEmptyEditor() {
if(EMPTY == null) { if (EMPTY == null) {
EMPTY = new JPanel(new BorderLayout()); EMPTY = new JPanel(new BorderLayout());
UILabel content = new UILabel(Inter.getLocText(new String[]{"DataFunction-None", "HJS-Message", "Form-Widget_Property_Table"})+"!"); UILabel content = new UILabel(Inter.getLocText(new String[]{"DataFunction-None", "HJS-Message", "Form-Widget_Property_Table"}) + "!");
content.setBorder(BorderFactory.createEmptyBorder(0, 70, 0, 0)); content.setBorder(BorderFactory.createEmptyBorder(0, 70, 0, 0));
EMPTY.add(content, BorderLayout.CENTER); EMPTY.add(content, BorderLayout.CENTER);
} }
return EMPTY; return EMPTY;
} }
private static QuickEditorRegion singleton = new QuickEditorRegion();
private static JPanel EMPTY;
public QuickEditorRegion() {
this.setLayout(new BorderLayout());
}
/** /**
* 传值 * 更新面板显示数据
* *
* @param ePane * @param currentEditor 当前正在编辑的单元格编辑器或者默认的单元格编辑器
*/ */
public void populate(final QuickEditor quickEditor) { public void populate(final QuickEditor currentEditor) {
this.removeAll(); this.removeAll();
if(quickEditor.getComponentCount() == 0) { if (currentEditor.getComponentCount() == 0) {
this.add(getEmptyEditor(), BorderLayout.CENTER); this.add(getEmptyEditor(), BorderLayout.CENTER);
} else { } else {
this.add(quickEditor, BorderLayout.CENTER); this.add(currentEditor, BorderLayout.CENTER);
} }
validate(); validate();
repaint(); repaint();

66
designer/src/com/fr/quickeditor/CellQuickEditor.java

@ -24,38 +24,38 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
/** /**
*
* @author zhou * @author zhou
* @since 2012-7-23下午5:16:53 * @since 2012-7-23下午5:16:53
*/ */
public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
protected UITextField columnRowTextField; protected UITextField columnRowTextField;
protected UIButton cellElementEditButton; private UIButton cellElementEditButton;
protected TemplateCellElement cellElement; protected TemplateCellElement cellElement;
public CellQuickEditor() { public CellQuickEditor() {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = { p, f }; double[] columnSize = {p, f};
double[] rowSize = { p,p,p}; double[] rowSize = {p, p, p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(" "+Inter.getLocText("Cell")),columnRowTextField = initColumnRowTextField()}, new Component[]{new UILabel(" " + Inter.getLocText("Cell")), columnRowTextField = initColumnRowTextField()},
new Component[]{new UILabel(Inter.getLocText("HF-Insert_Content")+" "),cellElementEditButton = initCellElementEditButton()}, new Component[]{new UILabel(Inter.getLocText("HF-Insert_Content") + " "), cellElementEditButton = initCellElementEditButton()},
new Component[]{createCenterBody(),null} new Component[]{createCenterBody(), null}
}; };
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
JPanel panel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
this.add(panel,BorderLayout.CENTER); this.add(panel, BorderLayout.CENTER);
} }
protected UIButton initCellElementEditButton() { /**
* 初始化添加按钮
* TODO 9.0 换成下拉菜单后原来的快捷键不好处理先跳过
*
* @return UIButton
*/
private UIButton initCellElementEditButton() {
final UIButton cellElementEditButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); final UIButton cellElementEditButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
cellElementEditButton.addMouseListener(new MouseAdapter() { cellElementEditButton.addMouseListener(new MouseAdapter() {
@ -67,35 +67,34 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
return cellElementEditButton; return cellElementEditButton;
} }
protected UITextField initColumnRowTextField() { /**
* 初始化单元格域存储当前选择的单元格例A3,B4等
*
* @return 单元格信息文本域
*/
private UITextField initColumnRowTextField() {
final UITextField columnRowTextField = new UITextField(4); final UITextField columnRowTextField = new UITextField(4);
// barry:输入位置定位单元格 // barry:输入位置定位单元格
columnRowTextField.addActionListener(new ActionListener() { columnRowTextField.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ColumnRow columnRowEdit = ColumnRow.valueOf(columnRowTextField.getText()); ColumnRow columnRowEdit = ColumnRow.valueOf(columnRowTextField.getText());
// barry:检查输入是否正确 // barry:检查输入是否正确
if (!ColumnRow.validate(columnRowEdit)) { if (!ColumnRow.validate(columnRowEdit)) {
Object[] options = {Inter.getLocText("OK")};
Object[] options = { Inter.getLocText("OK") };
JOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Please_Input_Letters+Numbers(A1,AA1,A11....)"), Inter.getLocText("Warning"), JOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Please_Input_Letters+Numbers(A1,AA1,A11....)"), Inter.getLocText("Warning"),
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
// 重新选中当前的selection,把columnRowTextField // 重新选中当前的selection,把columnRowTextField
tc.setSelection(tc.getSelection()); tc.setSelection(tc.getSelection());
return; return;
} }
JScrollBar verticalBar = tc.getVerticalScrollBar(), horizontalBar = tc.getHorizontalScrollBar(); JScrollBar verticalBar = tc.getVerticalScrollBar(), horizontalBar = tc.getHorizontalScrollBar();
int m = columnRowEdit.getColumn(), n = columnRowEdit.getRow(); int m = columnRowEdit.getColumn(), n = columnRowEdit.getRow();
verticalBar.setMaximum(n); verticalBar.setMaximum(n);
verticalBar.setValue(n < 21 ? verticalBar.getValue() : n - 20); verticalBar.setValue(n < 21 ? verticalBar.getValue() : n - 20);
horizontalBar.setMaximum(m); horizontalBar.setMaximum(m);
horizontalBar.setValue(m < 13 ? horizontalBar.getValue() : m - 12); horizontalBar.setValue(m < 13 ? horizontalBar.getValue() : m - 12);
tc.setSelection(new CellSelection(m, n, 1, 1)); tc.setSelection(new CellSelection(m, n, 1, 1));
tc.requestFocus(); tc.requestFocus();
} }
@ -103,21 +102,28 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
return columnRowTextField; return columnRowTextField;
} }
/**
* 初始化详细信息面板
*
* @return JComponent 待显示的详细信息面板
*/
public abstract JComponent createCenterBody(); public abstract JComponent createCenterBody();
/**
* 刷新
*/
@Override @Override
protected void refresh() { protected void refresh() {
CellSelection cs = (CellSelection)tc.getSelection(); CellSelection cs = (CellSelection) tc.getSelection();
ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow());
columnRowTextField.setText(columnRow.toString()); columnRowTextField.setText(columnRow.toString());
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow());
refreshDetails(); refreshDetails();
} }
/**
* 刷新详细信息
*/
protected abstract void refreshDetails(); protected abstract void refreshDetails();
} }

18
designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java

@ -1,21 +1,23 @@
package com.fr.quickeditor.cellquick; package com.fr.quickeditor.cellquick;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.cell.editor.BiasTextPainterCellEditor.BiasTextPainterPane; import com.fr.design.cell.editor.BiasTextPainterCellEditor.BiasTextPainterPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.painter.BiasTextPainter; import com.fr.report.cell.painter.BiasTextPainter;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* 单元格元素斜线编辑器
* TODO 9.0 大体没有改动
*/
public class CellBiasTextPainterEditor extends CellQuickEditor { public class CellBiasTextPainterEditor extends CellQuickEditor {
@Override @Override
@ -35,7 +37,7 @@ public class CellBiasTextPainterEditor extends CellQuickEditor {
} }
private void showEditingDialog() { private void showEditingDialog() {
final BiasTextPainter oldbiasTextPainter = (BiasTextPainter)cellElement.getValue(); final BiasTextPainter oldbiasTextPainter = (BiasTextPainter) cellElement.getValue();
final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane(); final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane();
biasTextPainterPane.populate(oldbiasTextPainter); biasTextPainterPane.populate(oldbiasTextPainter);
biasTextPainterPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { biasTextPainterPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {

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

@ -1,28 +1,52 @@
package com.fr.quickeditor.cellquick; package com.fr.quickeditor.cellquick;
import com.fr.design.actions.columnrow.DSColumnAdvancedAction;
import com.fr.design.actions.columnrow.DSColumnBasicAction;
import com.fr.design.actions.columnrow.DSColumnConditionAction; import com.fr.design.actions.columnrow.DSColumnConditionAction;
import com.fr.design.constants.LayoutConstants; import com.fr.design.dscolumn.DSColumnAdvancedEditorPane;
import com.fr.design.dscolumn.DSColumnBasicEditorPane;
import com.fr.design.dscolumn.ResultSetGroupDockingPane; import com.fr.design.dscolumn.ResultSetGroupDockingPane;
import com.fr.design.dscolumn.SelectedDataColumnPane; import com.fr.design.dscolumn.SelectedDataColumnPane;
import com.fr.design.gui.ibutton.UIButton; 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.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.utils.gui.GUICoreUtils;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList;
/**
* 单元格元素 数据列编辑器
*
* @author yaoh.wu
* @version 2017年7月24日
* @since 9.0
*/
public class CellDSColumnEditor extends CellQuickEditor { public class CellDSColumnEditor extends CellQuickEditor {
private JPanel dsColumnRegion; private JPanel dsColumnRegion;
private JPanel centerPane; private JPanel centerPane;
//数据集列选择组件
private SelectedDataColumnPane dataPane; private SelectedDataColumnPane dataPane;
//数据分组设置组件
private ResultSetGroupDockingPane groupPane; private ResultSetGroupDockingPane groupPane;
//过滤条件面板
private JPanel conditionPane;
// 基本和高级设置
private ArrayList<CellEditorPane> paneList;
// 基本和高级设置 卡片布局
private CardLayout card;
// 基本和高级设置 容器面板
private JPanel center;
// 卡片布局TAB切换按钮
private UIHeadGroup tabsHeaderIconPane;
// 分组设置监听器
private ItemListener groupListener = new ItemListener() { private ItemListener groupListener = new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (e == null) { if (e == null) {
@ -40,9 +64,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
} }
} }
}; };
//数据集列设置监听器
private ItemListener dataListener = new ItemListener() { private ItemListener dataListener = new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getStateChange() == ItemEvent.SELECTED) {
@ -59,53 +82,120 @@ public class CellDSColumnEditor extends CellQuickEditor {
super(); super();
} }
/**
* Test Main
*
* @param args 参数
*/
public static void main(String[] args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(new CellDSColumnEditor(), BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(220, 400);
jf.setVisible(true);
}
/**
* 创建面板占位
*
* @return JComponent 详细信息面板
*/
@Override @Override
public JComponent createCenterBody() { public JComponent createCenterBody() {
double p = TableLayout.PREFERRED; this.createPanes();
double f = TableLayout.FILL; this.createSwitchTab();
double[] columnSize = {p, f}; dsColumnRegion = new JPanel(new BorderLayout());
double[] rowSize = {p, p, p, p}; dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH);
Component[][] components = new Component[][]{}; dsColumnRegion.add(center, BorderLayout.CENTER);
dsColumnRegion = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); centerPane = new JPanel(new BorderLayout());
centerPane = new JPanel(new BorderLayout(0, 0));
centerPane.add(dsColumnRegion, BorderLayout.CENTER); centerPane.add(dsColumnRegion, BorderLayout.CENTER);
return centerPane; return centerPane;
} }
// august:这里面的东西都全部重新动态生成,不然容易出错 /**
* 内容全部重新动态生成不然容易出错
* 刷新详细信息面板
*/
@Override @Override
protected void refreshDetails() { protected void refreshDetails() {
JPanel pane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0));
pane.add(new UIButton(new DSColumnConditionAction(tc)), BorderLayout.WEST); this.createPanes();
pane.add(new UIButton(new DSColumnAdvancedAction(tc)), BorderLayout.CENTER); this.createSwitchTab();
double p = TableLayout.PREFERRED; dsColumnRegion = new JPanel(new BorderLayout());
double f = TableLayout.FILL; dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH);
double[] columnSize = {p, f}; dsColumnRegion.add(center, BorderLayout.CENTER);
double[] rowSize = {p, p, p, p}; //必须removeAll之后再添加;重新再实例化一个centerJPanel,因为对象变了会显示不出来
Component[][] components = new Component[][]{
new Component[]{new UIButton(new DSColumnBasicAction(tc)), null},
new Component[]{pane, null},
new Component[]{dataPane = new SelectedDataColumnPane(false), null},
new Component[]{groupPane = new ResultSetGroupDockingPane(tc), null}
};
centerPane.removeAll(); centerPane.removeAll();
dsColumnRegion = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
centerPane.add(dsColumnRegion, BorderLayout.CENTER); centerPane.add(dsColumnRegion, BorderLayout.CENTER);
dataPane.addListener(dataListener); for (CellEditorPane cellEditorPane : paneList) {
groupPane.addListener(groupListener); cellEditorPane.populate(cellElement);
dataPane.populate(null, cellElement); }
groupPane.populate(cellElement);
this.validate(); this.validate();
} }
/** /**
* for 关闭时候释放 * 关闭时候释放
*/ */
public void release () { public void release() {
super.release(); super.release();
dsColumnRegion = null; dsColumnRegion = null;
centerPane = null; centerPane = null;
} }
/**
* 初始化基本和高级设置切换tab
*/
private void createSwitchTab() {
String[] iconArray = new String[paneList.size()];
card = new CardLayout();
center = new JPanel(card);
center.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
for (int i = 0; i < paneList.size(); i++) {
CellEditorPane pane = paneList.get(i);
iconArray[i] = pane.getIconPath();
center.add(pane, pane.title4PopupWindow());
}
tabsHeaderIconPane = new UIHeadGroup(iconArray) {
@Override
public void tabChanged(int index) {
card.show(center, paneList.get(index).title4PopupWindow());
paneList.get(index).populate(cellElement);
}
};
tabsHeaderIconPane.setNeedLeftRightOutLine(false);
}
/**
* 刷新数据列基本和高级设置面板
*/
private void createPanes() {
paneList = new ArrayList<>();
/*基本设置面板*/
this.dataPane = new SelectedDataColumnPane();
this.groupPane = new ResultSetGroupDockingPane(tc);
double p = TableLayout.PREFERRED, f = TableLayout.FILL;
double[] rowSize = {p}, columnSize = {p, f};
UILabel uiLabel = new UILabel("filter");
UIButton uiButton = new UIButton();
if (tc != null) {
//第一次初始化时tc为空,引发NullPointerException
uiButton = new UIButton(new DSColumnConditionAction(tc));
}
Component[][] components = new Component[][]{
new Component[]{uiLabel, uiButton}
};
this.conditionPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
dataPane.addListener(dataListener);
groupPane.addListener(groupListener);
paneList.add(new DSColumnBasicEditorPane(cellElement, dataPane, groupPane, conditionPane));
/*高级设置面板*/
paneList.add(new DSColumnAdvancedEditorPane());
}
} }

18
designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java

@ -1,27 +1,29 @@
package com.fr.quickeditor.cellquick; package com.fr.quickeditor.cellquick;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.report.SelectImagePane; import com.fr.design.report.SelectImagePane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.cellattr.CellImage; import com.fr.report.cell.cellattr.CellImage;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* 单元格元素图片编辑器
* TODO 9.0大体上没有改动
*/
public class CellImageQuickEditor extends CellQuickEditor { public class CellImageQuickEditor extends CellQuickEditor {
private static CellImageQuickEditor THIS; private static CellImageQuickEditor THIS;
public static final CellImageQuickEditor getInstance() { public static final CellImageQuickEditor getInstance() {
if(THIS == null) { if (THIS == null) {
THIS = new CellImageQuickEditor(); THIS = new CellImageQuickEditor();
} }
return THIS; return THIS;

14
designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java

@ -1,19 +1,22 @@
package com.fr.quickeditor.cellquick; package com.fr.quickeditor.cellquick;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import com.fr.design.actions.insert.cell.RichTextCellAction; import com.fr.design.actions.insert.cell.RichTextCellAction;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import javax.swing.*;
/**
* 单元格元素富文本编辑器
* TODO 9.0 大体上没有改动
*/
public class CellRichTextEditor extends CellQuickEditor { public class CellRichTextEditor extends CellQuickEditor {
private UIButton subReportButton; private UIButton subReportButton;
private static CellRichTextEditor THIS; private static CellRichTextEditor THIS;
public static final CellRichTextEditor getInstance() { public static final CellRichTextEditor getInstance() {
if(THIS == null) { if (THIS == null) {
THIS = new CellRichTextEditor(); THIS = new CellRichTextEditor();
} }
return THIS; return THIS;
@ -27,10 +30,7 @@ public class CellRichTextEditor extends CellQuickEditor {
* 创建界面上中间的部分 * 创建界面上中间的部分
* *
* @return 界面元素 * @return 界面元素
*
*
* @date 2014-12-7-下午9:41:52 * @date 2014-12-7-下午9:41:52
*
*/ */
public JComponent createCenterBody() { public JComponent createCenterBody() {
subReportButton = new UIButton(); subReportButton = new UIButton();

86
designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java

@ -1,12 +1,5 @@
package com.fr.quickeditor.cellquick; package com.fr.quickeditor.cellquick;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JComponent;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.TextFormat; import com.fr.base.TextFormat;
@ -18,70 +11,77 @@ import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
public class CellStringQuickEditor extends CellQuickEditor { import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
/**
*
*/
public class CellStringQuickEditor extends CellQuickEditor {
//instance
private static CellStringQuickEditor THIS; private static CellStringQuickEditor THIS;
//文本域
//TODO 9.0 文本域要根据具体文本数量自适应大小,比较难搞,先跳过。
private UITextField stringTextField; private UITextField stringTextField;
//编辑状态
private boolean isEditing = false; private boolean isEditing = false;
public static final CellStringQuickEditor getInstance() { public static CellStringQuickEditor getInstance() {
if (THIS == null) { if (THIS == null) {
THIS = new CellStringQuickEditor(); THIS = new CellStringQuickEditor();
} }
return THIS; return THIS;
} }
// august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置 //august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置
private boolean reserveInResult = false; private boolean reserveInResult = false;
private boolean reserveOnWriteOrAnaly = true; private boolean reserveOnWriteOrAnaly = true;
private DocumentListener documentListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
changeReportPaneCell(stringTextField.getText().trim());
}
@Override
public void removeUpdate(DocumentEvent e) {
changeReportPaneCell(stringTextField.getText().trim());
}
@Override
public void changedUpdate(DocumentEvent e) {
changeReportPaneCell(stringTextField.getText().trim());
}
};
private CellStringQuickEditor() { private CellStringQuickEditor() {
super(); super();
} }
@Override
/** /**
* * 详细信息面板
* todo 文本框可自适应大小公式编辑也是在这边如果是公式那么要加一个公式编辑器的触发按钮
*/ */
@Override
public JComponent createCenterBody() { public JComponent createCenterBody() {
stringTextField = new UITextField(); stringTextField = new UITextField();
stringTextField.addKeyListener(new KeyAdapter() { stringTextField.addKeyListener(new KeyAdapter() {
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
if (tc != null) { if (tc != null) {
tc.getGrid().dispatchEvent(e); tc.getGrid().dispatchEvent(e);
} }
} }
}); });
return stringTextField; return stringTextField;
} }
DocumentListener documentListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
changeReportPaneCell(stringTextField.getText().trim());
}
@Override private void changeReportPaneCell(String tmpText) {
public void removeUpdate(DocumentEvent e) {
changeReportPaneCell(stringTextField.getText().trim());
}
@Override
public void changedUpdate(DocumentEvent e) {
changeReportPaneCell(stringTextField.getText().trim());
}
};
protected void changeReportPaneCell(String tmpText) {
isEditing = true; isEditing = true;
//refresh一下,如果单元格内有新添加的控件,此时并不知道 //refresh一下,如果单元格内有新添加的控件,此时并不知道
CellSelection cs1 = (CellSelection) tc.getSelection(); CellSelection cs1 = (CellSelection) tc.getSelection();
@ -101,7 +101,7 @@ public class CellStringQuickEditor extends CellQuickEditor {
cellElement.setValue(textFormula); cellElement.setValue(textFormula);
} else { } else {
Style style = cellElement.getStyle(); Style style = cellElement.getStyle();
if (cellElement != null && style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) { if (style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) {
cellElement.setValue(tmpText); cellElement.setValue(tmpText);
} else { } else {
cellElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); cellElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText));
@ -112,9 +112,12 @@ public class CellStringQuickEditor extends CellQuickEditor {
isEditing = false; isEditing = false;
} }
/**
* 刷新详细内容
*/
@Override @Override
protected void refreshDetails() { protected void refreshDetails() {
String str = null; String str;
if (cellElement == null) { if (cellElement == null) {
str = StringUtils.EMPTY; str = StringUtils.EMPTY;
} else { } else {
@ -135,11 +138,12 @@ public class CellStringQuickEditor extends CellQuickEditor {
} }
/** /**
* 显示文本
* *
* @param str * @param str 文本
*/ */
public void showText(String str) { public void showText(String str) {
// 本编辑框在输入过程中引发的后续事件如果还调用了本框的setText方法不能执行 // 正在编辑时不处理
if (isEditing) { if (isEditing) {
return; return;
} }

11
designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java

@ -1,19 +1,22 @@
package com.fr.quickeditor.cellquick; package com.fr.quickeditor.cellquick;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import com.fr.design.actions.insert.cell.SubReportCellAction; import com.fr.design.actions.insert.cell.SubReportCellAction;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import javax.swing.*;
/**
* 单元格元素子报表编辑器
* TODO 9.0大体上没有改动
*/
public class CellSubReportEditor extends CellQuickEditor { public class CellSubReportEditor extends CellQuickEditor {
private UIButton subReportButton; private UIButton subReportButton;
private static CellSubReportEditor THIS; private static CellSubReportEditor THIS;
public static final CellSubReportEditor getInstance() { public static final CellSubReportEditor getInstance() {
if(THIS == null) { if (THIS == null) {
THIS = new CellSubReportEditor(); THIS = new CellSubReportEditor();
} }
return THIS; return THIS;

Loading…
Cancel
Save