From 50804bd563df5b3813db1fd147abd2c9ce28e434 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 25 Jul 2017 21:45:40 +0800 Subject: [PATCH 1/5] =?UTF-8?q?REPORT-3348=EF=BC=8C=E8=B8=A9=E5=9D=91?= =?UTF-8?q?=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=88=97=E5=B1=95=E7=8E=B0=E6=96=B9?= =?UTF-8?q?=E6=A1=88=E7=A1=AE=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dscolumn/DSColumnAdvancedEditorPane.java | 38 +++ .../dscolumn/DSColumnBasicEditorPane.java | 71 +++++ .../design/mainframe/cell/CellEditorPane.java | 30 ++ .../mainframe/cell/QuickEditorRegion.java | 90 +++--- .../com/fr/quickeditor/CellQuickEditor.java | 250 +++++++-------- .../cellquick/CellBiasTextPainterEditor.java | 94 +++--- .../cellquick/CellDSColumnEditor.java | 291 +++++++++++------- .../cellquick/CellImageQuickEditor.java | 106 +++---- .../cellquick/CellRichTextEditor.java | 80 ++--- .../cellquick/CellStringQuickEditor.java | 98 +++--- .../cellquick/CellSubReportEditor.java | 67 ++-- 11 files changed, 721 insertions(+), 494 deletions(-) create mode 100644 designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java create mode 100644 designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java create mode 100644 designer/src/com/fr/design/mainframe/cell/CellEditorPane.java diff --git a/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java new file mode 100644 index 0000000000..57af1a340a --- /dev/null +++ b/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) { + + } + +} diff --git a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java new file mode 100644 index 0000000000..2c7b0d3111 --- /dev/null +++ b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java @@ -0,0 +1,71 @@ +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; + + public DSColumnBasicEditorPane(TemplateCellElement cellElement, SelectedDataColumnPane dataPane, ResultSetGroupDockingPane groupPane) { + this.cellElement = cellElement; + this.dataPane = dataPane; + this.groupPane = groupPane; + this.add(this.createContentPane(), BorderLayout.CENTER); + } + + private JPanel createContentPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + Component[][] components = new Component[][]{ + //数据集列选择 + new Component[]{this.dataPane, null}, + //数据分组设置 + new Component[]{this.groupPane, null} + }; + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + } + + @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); + } +} diff --git a/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java b/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java new file mode 100644 index 0000000000..b0f09af437 --- /dev/null +++ b/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); +} diff --git a/designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java b/designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java index f105ad4792..c11e0cc883 100644 --- a/designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java +++ b/designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java @@ -1,57 +1,57 @@ 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.general.Inter; import com.fr.design.selection.QuickEditor; +import com.fr.general.Inter; + +import javax.swing.*; +import java.awt.*; /** * QuickEditorRegion - * - * @editor zhou - * @since 2012-3-23下午3:21:36 + * + * @author zhou, yaoh.wu + * @version 2017年7月25日 + * @since 8.0 */ public class QuickEditorRegion extends JPanel { - public static QuickEditorRegion getInstance() { - return singleton; - } - - public static JPanel getEmptyEditor() { - if(EMPTY == null) { - EMPTY = new JPanel(new BorderLayout()); - UILabel content = new UILabel(Inter.getLocText(new String[]{"DataFunction-None", "HJS-Message", "Form-Widget_Property_Table"})+"!"); - content.setBorder(BorderFactory.createEmptyBorder(0, 70, 0, 0)); - EMPTY.add(content, BorderLayout.CENTER); - } - return EMPTY; - } - - private static QuickEditorRegion singleton = new QuickEditorRegion(); - private static JPanel EMPTY; - - public QuickEditorRegion() { - this.setLayout(new BorderLayout()); - } - - /** - * 传值 - * - * @param ePane - */ - public void populate(final QuickEditor quickEditor) { - this.removeAll(); - if(quickEditor.getComponentCount() == 0) { - this.add(getEmptyEditor(), BorderLayout.CENTER); - } else { - this.add(quickEditor, BorderLayout.CENTER); - } - validate(); - repaint(); - } + + private static QuickEditorRegion singleton = new QuickEditorRegion(); + private static JPanel EMPTY; + + private QuickEditorRegion() { + this.setLayout(new BorderLayout()); + } + + public static QuickEditorRegion getInstance() { + return singleton; + } + + public static JPanel getEmptyEditor() { + if (EMPTY == null) { + EMPTY = new JPanel(new BorderLayout()); + UILabel content = new UILabel(Inter.getLocText(new String[]{"DataFunction-None", "HJS-Message", "Form-Widget_Property_Table"}) + "!"); + content.setBorder(BorderFactory.createEmptyBorder(0, 70, 0, 0)); + EMPTY.add(content, BorderLayout.CENTER); + } + return EMPTY; + } + + /** + * 更新面板显示数据 + * + * @param currentEditor 当前正在编辑的单元格编辑器或者默认的单元格编辑器 + */ + public void populate(final QuickEditor currentEditor) { + this.removeAll(); + if (currentEditor.getComponentCount() == 0) { + this.add(getEmptyEditor(), BorderLayout.CENTER); + } else { + this.add(currentEditor, BorderLayout.CENTER); + } + validate(); + repaint(); + } } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/CellQuickEditor.java b/designer/src/com/fr/quickeditor/CellQuickEditor.java index 1190b433a6..7ae3dbba36 100644 --- a/designer/src/com/fr/quickeditor/CellQuickEditor.java +++ b/designer/src/com/fr/quickeditor/CellQuickEditor.java @@ -1,123 +1,129 @@ -package com.fr.quickeditor; - -import com.fr.base.BaseUtils; -import com.fr.design.actions.utils.DeprecatedActionManager; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.selection.QuickEditor; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.Inter; -import com.fr.grid.selection.CellSelection; -import com.fr.report.cell.TemplateCellElement; -import com.fr.stable.ColumnRow; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -/** - * - * @author zhou - * @since 2012-7-23下午5:16:53 - */ -public abstract class CellQuickEditor extends QuickEditor { - - protected UITextField columnRowTextField; - protected UIButton cellElementEditButton; - protected TemplateCellElement cellElement; - - public CellQuickEditor() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = { p, f }; - double[] rowSize = { p,p,p}; - - Component[][] components = new Component[][]{ - new Component[]{new UILabel(" "+Inter.getLocText("Cell")),columnRowTextField = initColumnRowTextField()}, - new Component[]{new UILabel(Inter.getLocText("HF-Insert_Content")+" "),cellElementEditButton = initCellElementEditButton()}, - new Component[]{createCenterBody(),null} - }; - - JPanel panel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); - this.setLayout(new BorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - this.add(panel,BorderLayout.CENTER); - - - - } - - protected UIButton initCellElementEditButton() { - final UIButton cellElementEditButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); - cellElementEditButton.addMouseListener(new MouseAdapter() { - - @Override - public void mousePressed(MouseEvent evt) { - GUICoreUtils.showPopMenuWithParentWidth(DeprecatedActionManager.getCellMenu(tc).createJPopupMenu(), cellElementEditButton, 0, cellElementEditButton.getY() - 6); - } - }); - return cellElementEditButton; - } - - protected UITextField initColumnRowTextField() { - final UITextField columnRowTextField = new UITextField(4); - // barry:输入位置定位单元格 - columnRowTextField.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - ColumnRow columnRowEdit = ColumnRow.valueOf(columnRowTextField.getText()); - - // barry:检查输入是否正确 - if (!ColumnRow.validate(columnRowEdit)) { - - Object[] options = { Inter.getLocText("OK") }; - 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]); - - // 重新选中当前的selection,把columnRowTextField - tc.setSelection(tc.getSelection()); - return; - } - - JScrollBar verticalBar = tc.getVerticalScrollBar(), horizontalBar = tc.getHorizontalScrollBar(); - int m = columnRowEdit.getColumn(), n = columnRowEdit.getRow(); - - verticalBar.setMaximum(n); - verticalBar.setValue(n < 21 ? verticalBar.getValue() : n - 20); - horizontalBar.setMaximum(m); - horizontalBar.setValue(m < 13 ? horizontalBar.getValue() : m - 12); - - tc.setSelection(new CellSelection(m, n, 1, 1)); - tc.requestFocus(); - } - }); - return columnRowTextField; - } - - public abstract JComponent createCenterBody(); - - @Override - protected void refresh() { - CellSelection cs = (CellSelection)tc.getSelection(); - ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); - columnRowTextField.setText(columnRow.toString()); - cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); - refreshDetails(); - } - - protected abstract void refreshDetails(); - - - - - +package com.fr.quickeditor; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.utils.DeprecatedActionManager; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.selection.QuickEditor; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.grid.selection.CellSelection; +import com.fr.report.cell.TemplateCellElement; +import com.fr.stable.ColumnRow; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author zhou + * @since 2012-7-23下午5:16:53 + */ +public abstract class CellQuickEditor extends QuickEditor { + + protected UITextField columnRowTextField; + private UIButton cellElementEditButton; + protected TemplateCellElement cellElement; + + public CellQuickEditor() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p, p}; + Component[][] components = new Component[][]{ + new Component[]{new UILabel(" " + Inter.getLocText("Cell")), columnRowTextField = initColumnRowTextField()}, + new Component[]{new UILabel(Inter.getLocText("HF-Insert_Content") + " "), cellElementEditButton = initCellElementEditButton()}, + new Component[]{createCenterBody(), null} + }; + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.setLayout(new BorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + this.add(panel, BorderLayout.CENTER); + } + + /** + * 初始化添加按钮 + * TODO 9.0 换成下拉菜单后原来的快捷键不好处理,先跳过。 + * + * @return UIButton + */ + private UIButton initCellElementEditButton() { + final UIButton cellElementEditButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); + cellElementEditButton.addMouseListener(new MouseAdapter() { + + @Override + public void mousePressed(MouseEvent evt) { + GUICoreUtils.showPopMenuWithParentWidth(DeprecatedActionManager.getCellMenu(tc).createJPopupMenu(), cellElementEditButton, 0, cellElementEditButton.getY() - 6); + } + }); + return cellElementEditButton; + } + + /** + * 初始化单元格域,存储当前选择的单元格,例A3,B4等 + * + * @return 单元格信息文本域 + */ + private UITextField initColumnRowTextField() { + final UITextField columnRowTextField = new UITextField(4); + + // barry:输入位置定位单元格 + columnRowTextField.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ColumnRow columnRowEdit = ColumnRow.valueOf(columnRowTextField.getText()); + // barry:检查输入是否正确 + if (!ColumnRow.validate(columnRowEdit)) { + Object[] options = {Inter.getLocText("OK")}; + 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]); + // 重新选中当前的selection,把columnRowTextField + tc.setSelection(tc.getSelection()); + return; + } + JScrollBar verticalBar = tc.getVerticalScrollBar(), horizontalBar = tc.getHorizontalScrollBar(); + int m = columnRowEdit.getColumn(), n = columnRowEdit.getRow(); + verticalBar.setMaximum(n); + verticalBar.setValue(n < 21 ? verticalBar.getValue() : n - 20); + horizontalBar.setMaximum(m); + horizontalBar.setValue(m < 13 ? horizontalBar.getValue() : m - 12); + tc.setSelection(new CellSelection(m, n, 1, 1)); + tc.requestFocus(); + } + }); + return columnRowTextField; + } + + + /** + * 初始化详细信息面板 + * + * @return JComponent 待显示的详细信息面板 + */ + public abstract JComponent createCenterBody(); + + /** + * 刷新 + */ + @Override + protected void refresh() { + CellSelection cs = (CellSelection) tc.getSelection(); + ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); + columnRowTextField.setText(columnRow.toString()); + cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); + refreshDetails(); + } + + /** + * 刷新详细信息 + */ + protected abstract void refreshDetails(); } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java index e9387cccc5..a2217301d2 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java @@ -1,61 +1,63 @@ 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.design.cell.editor.BiasTextPainterCellEditor.BiasTextPainterPane; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.dialog.DialogActionAdapter; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.quickeditor.CellQuickEditor; 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 { - @Override - public JComponent createCenterBody() { - UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/bias.png")); - editbutton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - showEditingDialog(); - } - }); - editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); - editbutton.setMargin(null); - editbutton.setOpaque(false); - return editbutton; - } - - private void showEditingDialog() { - final BiasTextPainter oldbiasTextPainter = (BiasTextPainter)cellElement.getValue(); - final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane(); - biasTextPainterPane.populate(oldbiasTextPainter); - biasTextPainterPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - - @Override - public void doOk() { - BiasTextPainter newbiasTextPainter = biasTextPainterPane.update(); - if (!ComparatorUtils.equals(oldbiasTextPainter, newbiasTextPainter)) { - cellElement.setValue(newbiasTextPainter); - fireTargetModified(); - } - } - - }).setVisible(true); - } - - @Override - protected void refreshDetails() { - // TODO Auto-generated method stub - - } + @Override + public JComponent createCenterBody() { + UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/bias.png")); + editbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + showEditingDialog(); + } + }); + editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + editbutton.setMargin(null); + editbutton.setOpaque(false); + return editbutton; + } + + private void showEditingDialog() { + final BiasTextPainter oldbiasTextPainter = (BiasTextPainter) cellElement.getValue(); + final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane(); + biasTextPainterPane.populate(oldbiasTextPainter); + biasTextPainterPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + + @Override + public void doOk() { + BiasTextPainter newbiasTextPainter = biasTextPainterPane.update(); + if (!ComparatorUtils.equals(oldbiasTextPainter, newbiasTextPainter)) { + cellElement.setValue(newbiasTextPainter); + fireTargetModified(); + } + } + + }).setVisible(true); + } + + @Override + protected void refreshDetails() { + // TODO Auto-generated method stub + + } } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 11cea3e152..32ed44d0ae 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -1,111 +1,182 @@ -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.constants.LayoutConstants; -import com.fr.design.dscolumn.ResultSetGroupDockingPane; -import com.fr.design.dscolumn.SelectedDataColumnPane; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.quickeditor.CellQuickEditor; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -public class CellDSColumnEditor extends CellQuickEditor { - private JPanel dsColumnRegion; - private JPanel centerPane; - private SelectedDataColumnPane dataPane; - private ResultSetGroupDockingPane groupPane; - private ItemListener groupListener = new ItemListener() { - - @Override - public void itemStateChanged(ItemEvent e) { - if (e == null) { - //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 - groupPane.update(); - fireTargetModified(); - return; - } - if (e.getStateChange() == ItemEvent.DESELECTED) { - if (!isEditing) { - return; - } - groupPane.update(); - fireTargetModified(); - } - } - }; - - private ItemListener dataListener = new ItemListener() { - - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - if (!isEditing) { - return; - } - dataPane.update(cellElement); - fireTargetModified(); - } - } - }; - - private CellDSColumnEditor() { - super(); - } - - @Override - public JComponent createCenterBody() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p, p, p}; - Component[][] components = new Component[][]{}; - dsColumnRegion = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - centerPane = new JPanel(new BorderLayout(0, 0)); - centerPane.add(dsColumnRegion, BorderLayout.CENTER); - return centerPane; - } - - // august:这里面的东西都全部重新动态生成,不然容易出错 - @Override - protected void refreshDetails() { - JPanel pane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0)); - pane.add(new UIButton(new DSColumnConditionAction(tc)), BorderLayout.WEST); - pane.add(new UIButton(new DSColumnAdvancedAction(tc)), BorderLayout.CENTER); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p, p, p}; - 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(); - dsColumnRegion = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - centerPane.add(dsColumnRegion, BorderLayout.CENTER); - dataPane.addListener(dataListener); - groupPane.addListener(groupListener); - dataPane.populate(null, cellElement); - groupPane.populate(cellElement); - this.validate(); - } - - - /** - * for 关闭时候释放 - */ - public void release () { - super.release(); - dsColumnRegion = null; - centerPane = null; - } - +package com.fr.quickeditor.cellquick; + +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.UIHeadGroup; +import com.fr.design.mainframe.cell.CellEditorPane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.quickeditor.CellQuickEditor; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; + +/** + * 单元格元素 数据列编辑器 + * + * @author yaoh.wu + * @version 2017年7月24日 + * @since 9.0 + */ +public class CellDSColumnEditor extends CellQuickEditor { + + private JPanel dsColumnRegion; + private JPanel centerPane; + //数据集列选择组件 + private SelectedDataColumnPane dataPane; + //数据分组设置组件 + private ResultSetGroupDockingPane groupPane; + // 基本和高级设置 + private ArrayList paneList; + // 基本和高级设置 卡片布局 + private CardLayout card; + // 基本和高级设置 容器面板 + private JPanel center; + // 卡片布局TAB切换按钮 + private UIHeadGroup tabsHeaderIconPane; + // 分组设置监听器 + private ItemListener groupListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e == null) { + //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 + groupPane.update(); + fireTargetModified(); + return; + } + if (e.getStateChange() == ItemEvent.DESELECTED) { + if (!isEditing) { + return; + } + groupPane.update(); + fireTargetModified(); + } + } + }; + //数据集列设置监听器 + private ItemListener dataListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + if (!isEditing) { + return; + } + dataPane.update(cellElement); + fireTargetModified(); + } + } + }; + + private CellDSColumnEditor() { + 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 + public JComponent createCenterBody() { + this.initPaneList(); + this.initSwitchTab(); + dsColumnRegion = new JPanel(new BorderLayout()); + dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH); + dsColumnRegion.add(center, BorderLayout.CENTER); + centerPane = new JPanel(new BorderLayout()); + centerPane.add(dsColumnRegion, BorderLayout.CENTER); + return centerPane; + } + + /** + * TODO 内容全部重新动态生成,不然容易出错 + * 刷新详细信息面板 + */ + @Override + protected void refreshDetails() { + + for (CellEditorPane cellEditorPane : paneList) { + cellEditorPane.populate(cellElement); + } + this.validate(); + } + + + /** + * 关闭时候释放 + */ + public void release() { + super.release(); + dsColumnRegion = null; + centerPane = null; + } + + /** + * 初始化数据列基本和高级设置面板 + */ + private void initPaneList() { + paneList = new ArrayList<>(); + + paneList.add(this.initBasicPane()); + paneList.add(this.initAdvancedPane()); + + /* + todo 预留插件的接口 + doSomething() + */ + } + + /** + * 初始化基本和高级设置切换tab + */ + private void initSwitchTab() { + String[] iconArray = new String[paneList.size()]; + card = new CardLayout(); + center = new JPanel(card); + 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 DSColumnBasicEditorPane initBasicPane() { + + this.dataPane = new SelectedDataColumnPane(false); + this.groupPane = new ResultSetGroupDockingPane(tc); + dataPane.addListener(dataListener); + groupPane.addListener(groupListener); + return new DSColumnBasicEditorPane(cellElement, dataPane, groupPane); + } + + private DSColumnAdvancedEditorPane initAdvancedPane() { + return new DSColumnAdvancedEditorPane(); + } + } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java index 98fab671d1..be3d3f7a2b 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java @@ -1,75 +1,77 @@ 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.Style; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; import com.fr.design.report.SelectImagePane; -import com.fr.design.dialog.DialogActionAdapter; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.quickeditor.CellQuickEditor; 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 { - private static CellImageQuickEditor THIS; - - public static final CellImageQuickEditor getInstance() { - if(THIS == null) { - THIS = new CellImageQuickEditor(); - } - return THIS; - } + private static CellImageQuickEditor THIS; + + public static final CellImageQuickEditor getInstance() { + if (THIS == null) { + THIS = new CellImageQuickEditor(); + } + return THIS; + } - private CellImageQuickEditor() { - super(); - } + private CellImageQuickEditor() { + super(); + } - @Override - public JComponent createCenterBody() { - UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); - editbutton.addActionListener(new ActionListener() { + @Override + public JComponent createCenterBody() { + UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); + editbutton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - showEditingDialog(); - } - }); - editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); - editbutton.setMargin(null); - editbutton.setOpaque(false); - return editbutton; - } + @Override + public void actionPerformed(ActionEvent e) { + showEditingDialog(); + } + }); + editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + editbutton.setMargin(null); + editbutton.setOpaque(false); + return editbutton; + } - private void showEditingDialog() { - final SelectImagePane imageEditorPane = new SelectImagePane(); - imageEditorPane.populate(cellElement); - final Object oldValue = cellElement.getValue(); - final Style oldStyle = cellElement.getStyle(); - imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + private void showEditingDialog() { + final SelectImagePane imageEditorPane = new SelectImagePane(); + imageEditorPane.populate(cellElement); + final Object oldValue = cellElement.getValue(); + final Style oldStyle = cellElement.getStyle(); + imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - @Override - public void doOk() { - CellImage cellImage = imageEditorPane.update(); - if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) { - cellElement.setValue(cellImage.getImage()); - cellElement.setStyle(cellImage.getStyle()); - fireTargetModified(); - } - } + @Override + public void doOk() { + CellImage cellImage = imageEditorPane.update(); + if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) { + cellElement.setValue(cellImage.getImage()); + cellElement.setStyle(cellImage.getStyle()); + fireTargetModified(); + } + } - }).setVisible(true); - } + }).setVisible(true); + } - @Override - protected void refreshDetails() { + @Override + protected void refreshDetails() { - } + } } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java index f49fcdff18..32835803d3 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java @@ -1,50 +1,50 @@ 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.gui.ibutton.UIButton; import com.fr.general.Inter; import com.fr.quickeditor.CellQuickEditor; +import javax.swing.*; + +/** + * 单元格元素富文本编辑器 + * TODO 9.0 大体上没有改动 + */ public class CellRichTextEditor extends CellQuickEditor { - private UIButton subReportButton; - private static CellRichTextEditor THIS; - - public static final CellRichTextEditor getInstance() { - if(THIS == null) { - THIS = new CellRichTextEditor(); - } - return THIS; - } - - private CellRichTextEditor() { - super(); - } - - /** - * 创建界面上中间的部分 - * - * @return 界面元素 - * - * - * @date 2014-12-7-下午9:41:52 - * - */ - public JComponent createCenterBody() { - subReportButton = new UIButton(); - subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); - subReportButton.setMargin(null); - subReportButton.setOpaque(false); - return subReportButton; - } - - @Override - protected void refreshDetails() { - RichTextCellAction subReportCellAction = new RichTextCellAction(tc); - subReportCellAction.setName(Inter.getLocText("FR-Designer_RichTextEditor")); - subReportButton.setAction(subReportCellAction); - } + private UIButton subReportButton; + private static CellRichTextEditor THIS; + + public static final CellRichTextEditor getInstance() { + if (THIS == null) { + THIS = new CellRichTextEditor(); + } + return THIS; + } + + private CellRichTextEditor() { + super(); + } + + /** + * 创建界面上中间的部分 + * + * @return 界面元素 + * @date 2014-12-7-下午9:41:52 + */ + public JComponent createCenterBody() { + subReportButton = new UIButton(); + subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + subReportButton.setMargin(null); + subReportButton.setOpaque(false); + return subReportButton; + } + + @Override + protected void refreshDetails() { + RichTextCellAction subReportCellAction = new RichTextCellAction(tc); + subReportCellAction.setName(Inter.getLocText("FR-Designer_RichTextEditor")); + subReportButton.setAction(subReportCellAction); + } } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java index fa200631db..6e6d7a7a9c 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java @@ -1,12 +1,5 @@ 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.Style; import com.fr.base.TextFormat; @@ -18,71 +11,78 @@ import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.stable.ColumnRow; 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; - + //文本域 + //TODO 9.0 文本域要根据具体文本数量自适应大小,比较难搞,先跳过。 private UITextField stringTextField; + //编辑状态 + private boolean isEditing = false; - private boolean isEditing = false; - - public static final CellStringQuickEditor getInstance() { + public static CellStringQuickEditor getInstance() { if (THIS == null) { THIS = new CellStringQuickEditor(); } return THIS; } - // august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置 + //august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置。 private boolean reserveInResult = false; 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() { super(); } - @Override /** - * + * 详细信息面板 + * todo 文本框可自适应大小,公式编辑也是在这边,如果是公式那么要加一个公式编辑器的触发按钮 */ + @Override public JComponent createCenterBody() { stringTextField = new UITextField(); stringTextField.addKeyListener(new KeyAdapter() { - @Override public void keyReleased(KeyEvent e) { if (tc != null) { tc.getGrid().dispatchEvent(e); } } - }); - return stringTextField; } - 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()); - } - - }; - - protected void changeReportPaneCell(String tmpText) { - isEditing = true; + private void changeReportPaneCell(String tmpText) { + isEditing = true; //refresh一下,如果单元格内有新添加的控件,此时并不知道 CellSelection cs1 = (CellSelection) tc.getSelection(); ColumnRow columnRow = ColumnRow.valueOf(cs1.getColumn(), cs1.getRow()); @@ -101,7 +101,7 @@ public class CellStringQuickEditor extends CellQuickEditor { cellElement.setValue(textFormula); } else { 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); } else { cellElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); @@ -109,12 +109,15 @@ public class CellStringQuickEditor extends CellQuickEditor { } fireTargetModified(); stringTextField.requestFocus(); - isEditing = false; + isEditing = false; } + /** + * 刷新详细内容 + */ @Override protected void refreshDetails() { - String str = null; + String str; if (cellElement == null) { str = StringUtils.EMPTY; } else { @@ -135,14 +138,15 @@ public class CellStringQuickEditor extends CellQuickEditor { } /** + * 显示文本 * - * @param str + * @param str 文本 */ public void showText(String str) { - // 本编辑框在输入过程中引发的后续事件如果还调用了本框的setText方法不能执行 - if (isEditing) { - return; - } + // 正在编辑时不处理 + if (isEditing) { + return; + } stringTextField.getDocument().removeDocumentListener(documentListener); stringTextField.setText(str); stringTextField.getDocument().addDocumentListener(documentListener); diff --git a/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java index db26bdb385..309b896549 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java @@ -1,42 +1,45 @@ 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.gui.ibutton.UIButton; import com.fr.general.Inter; import com.fr.quickeditor.CellQuickEditor; +import javax.swing.*; + +/** + * 单元格元素子报表编辑器 + * TODO 9.0大体上没有改动 + */ public class CellSubReportEditor extends CellQuickEditor { - private UIButton subReportButton; - private static CellSubReportEditor THIS; - - public static final CellSubReportEditor getInstance() { - if(THIS == null) { - THIS = new CellSubReportEditor(); - } - return THIS; - } - - private CellSubReportEditor() { - super(); - } - - @Override - public JComponent createCenterBody() { - subReportButton = new UIButton(); - subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); - subReportButton.setMargin(null); - subReportButton.setOpaque(false); - return subReportButton; - } - - @Override - protected void refreshDetails() { - SubReportCellAction subReportCellAction = new SubReportCellAction(tc); - subReportCellAction.setName(Inter.getLocText(new String[]{"Edit", "Sub_Report"})); - subReportButton.setAction(subReportCellAction); - } + private UIButton subReportButton; + private static CellSubReportEditor THIS; + + public static final CellSubReportEditor getInstance() { + if (THIS == null) { + THIS = new CellSubReportEditor(); + } + return THIS; + } + + private CellSubReportEditor() { + super(); + } + + @Override + public JComponent createCenterBody() { + subReportButton = new UIButton(); + subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + subReportButton.setMargin(null); + subReportButton.setOpaque(false); + return subReportButton; + } + + @Override + protected void refreshDetails() { + SubReportCellAction subReportCellAction = new SubReportCellAction(tc); + subReportCellAction.setName(Inter.getLocText(new String[]{"Edit", "Sub_Report"})); + subReportButton.setAction(subReportCellAction); + } } \ No newline at end of file From 2d0177c6cce1ddde8bd3d6f01c28bb3411fd2c27 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 26 Jul 2017 10:37:11 +0800 Subject: [PATCH 2/5] =?UTF-8?q?REPORT-3348=20=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E6=95=B0=E6=8D=AE=E5=88=97=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=8A=A8=E6=80=81=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dscolumn/DSColumnBasicEditorPane.java | 33 ++++++++----- .../cellquick/CellDSColumnEditor.java | 48 +++++++++---------- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java index 2c7b0d3111..a04397c7bb 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java @@ -31,19 +31,6 @@ public class DSColumnBasicEditorPane extends CellEditorPane { this.add(this.createContentPane(), BorderLayout.CENTER); } - private JPanel createContentPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p}; - Component[][] components = new Component[][]{ - //数据集列选择 - new Component[]{this.dataPane, null}, - //数据分组设置 - new Component[]{this.groupPane, null} - }; - return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - } @Override public String getIconPath() { @@ -68,4 +55,24 @@ public class DSColumnBasicEditorPane extends CellEditorPane { dataPane.populate(null, cellElement); groupPane.populate(cellElement); } + + + /** + * 创建有内容的面板显示信息 + * + * @return content JPanel + */ + private JPanel createContentPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + Component[][] components = new Component[][]{ + //数据集列选择 + new Component[]{this.dataPane, null}, + //数据分组设置 + new Component[]{this.groupPane, null} + }; + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + } } diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 32ed44d0ae..de5cf51671 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -92,12 +92,14 @@ public class CellDSColumnEditor extends CellQuickEditor { } /** + * 创建面板占位 + * * @return JComponent 详细信息面板 */ @Override public JComponent createCenterBody() { - this.initPaneList(); - this.initSwitchTab(); + this.createPanes(); + this.createSwitchTab(); dsColumnRegion = new JPanel(new BorderLayout()); dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH); dsColumnRegion.add(center, BorderLayout.CENTER); @@ -107,12 +109,20 @@ public class CellDSColumnEditor extends CellQuickEditor { } /** - * TODO 内容全部重新动态生成,不然容易出错 + * 内容全部重新动态生成,不然容易出错 * 刷新详细信息面板 */ @Override protected void refreshDetails() { + this.createPanes(); + this.createSwitchTab(); + dsColumnRegion = new JPanel(new BorderLayout()); + dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH); + dsColumnRegion.add(center, BorderLayout.CENTER); + //必须removeAll之后再添加;重新再实例化一个centerJPanel,因为对象变了会显示不出来 + centerPane.removeAll(); + centerPane.add(dsColumnRegion, BorderLayout.CENTER); for (CellEditorPane cellEditorPane : paneList) { cellEditorPane.populate(cellElement); } @@ -129,25 +139,11 @@ public class CellDSColumnEditor extends CellQuickEditor { centerPane = null; } - /** - * 初始化数据列基本和高级设置面板 - */ - private void initPaneList() { - paneList = new ArrayList<>(); - - paneList.add(this.initBasicPane()); - paneList.add(this.initAdvancedPane()); - - /* - todo 预留插件的接口 - doSomething() - */ - } /** * 初始化基本和高级设置切换tab */ - private void initSwitchTab() { + private void createSwitchTab() { String[] iconArray = new String[paneList.size()]; card = new CardLayout(); center = new JPanel(card); @@ -166,17 +162,21 @@ public class CellDSColumnEditor extends CellQuickEditor { tabsHeaderIconPane.setNeedLeftRightOutLine(false); } - private DSColumnBasicEditorPane initBasicPane() { + /** + * 刷新数据列基本和高级设置面板 + */ + private void createPanes() { + paneList = new ArrayList<>(); + /*基本设置面板*/ this.dataPane = new SelectedDataColumnPane(false); this.groupPane = new ResultSetGroupDockingPane(tc); dataPane.addListener(dataListener); groupPane.addListener(groupListener); - return new DSColumnBasicEditorPane(cellElement, dataPane, groupPane); - } + paneList.add(new DSColumnBasicEditorPane(cellElement, dataPane, groupPane)); - private DSColumnAdvancedEditorPane initAdvancedPane() { - return new DSColumnAdvancedEditorPane(); - } + /*高级设置面板*/ + paneList.add(new DSColumnAdvancedEditorPane()); + } } \ No newline at end of file From 98eec20b71573d81f801b802e8e5247e9fe34d5c Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 26 Jul 2017 11:36:00 +0800 Subject: [PATCH 3/5] =?UTF-8?q?REPORT-3348=20=E6=95=B0=E6=8D=AE=E5=88=97?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E8=AE=BE=E7=BD=AE=E6=B7=BB=E5=8A=A0=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E6=9D=A1=E4=BB=B6=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E6=96=87=E4=BB=B6=E6=8D=A2=E8=A1=8C=E7=AC=A6=E5=92=8C?= =?UTF-8?q?todo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dscolumn/DSColumnBasicEditorPane.java | 11 +- .../dscolumn/SelectedDataColumnPane.java | 499 +++++++++--------- .../mainframe/cell/QuickEditorRegion.java | 112 ++-- .../cellquick/CellBiasTextPainterEditor.java | 124 ++--- .../cellquick/CellDSColumnEditor.java | 13 +- .../cellquick/CellImageQuickEditor.java | 152 +++--- .../cellquick/CellRichTextEditor.java | 98 ++-- .../cellquick/CellStringQuickEditor.java | 308 +++++------ .../cellquick/CellSubReportEditor.java | 88 +-- 9 files changed, 714 insertions(+), 691 deletions(-) diff --git a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java index a04397c7bb..92ffedb288 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java +++ b/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); } diff --git a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java index 780e81e948..9f047c0d3b 100644 --- a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java @@ -1,247 +1,254 @@ -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.datapane.TableDataComboBox; -import com.fr.design.data.tabledata.wrapper.TableDataWrapper; -import com.fr.design.gui.ibutton.UIButton; -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; -import com.fr.report.cell.TemplateCellElement; -import com.fr.report.cell.cellattr.core.group.DSColumn; -import com.fr.stable.ParameterProvider; -import com.fr.stable.StringUtils; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; - -public class SelectedDataColumnPane extends BasicPane { - protected UITableEditorPane editorPane; - protected Parameter[] ps; - - protected TableDataComboBox tableNameComboBox; - protected LazyComboBox columnNameComboBox; - private ItemListener itemListener; - - private UIButton paramButton; - - public SelectedDataColumnPane() { - this(true); - } - - 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 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)); - } - - private void initWithParameterButton() { - editorPane = new UITableEditorPane(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 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) { - 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 calculateColumnNameList() { - if (this.tableNameComboBox.getSelectedItem() != null) { - return this.tableNameComboBox.getSelectedItem().calculateColumnNameList(); - } - return new ArrayList(); - } +package com.fr.design.dscolumn; + +import com.fr.base.Parameter; +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.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.general.Inter; +import com.fr.general.data.TableDataColumn; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.stable.ParameterProvider; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +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 editorPane; + protected Parameter[] ps; + + protected TableDataComboBox tableNameComboBox; + protected LazyComboBox columnNameComboBox; + private ItemListener itemListener; + + private UIButton paramButton; + + public SelectedDataColumnPane() { + this(true); + } + + 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 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 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(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 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 calculateColumnNameList() { + if (this.tableNameComboBox.getSelectedItem() != null) { + return this.tableNameComboBox.getSelectedItem().calculateColumnNameList(); + } + return new ArrayList(); + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java b/designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java index c11e0cc883..517f983125 100644 --- a/designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java +++ b/designer/src/com/fr/design/mainframe/cell/QuickEditorRegion.java @@ -1,57 +1,57 @@ -package com.fr.design.mainframe.cell; - -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.selection.QuickEditor; -import com.fr.general.Inter; - -import javax.swing.*; -import java.awt.*; - -/** - * QuickEditorRegion - * - * @author zhou, yaoh.wu - * @version 2017年7月25日 - * @since 8.0 - */ - -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() { - return singleton; - } - - public static JPanel getEmptyEditor() { - if (EMPTY == null) { - EMPTY = new JPanel(new BorderLayout()); - UILabel content = new UILabel(Inter.getLocText(new String[]{"DataFunction-None", "HJS-Message", "Form-Widget_Property_Table"}) + "!"); - content.setBorder(BorderFactory.createEmptyBorder(0, 70, 0, 0)); - EMPTY.add(content, BorderLayout.CENTER); - } - return EMPTY; - } - - /** - * 更新面板显示数据 - * - * @param currentEditor 当前正在编辑的单元格编辑器或者默认的单元格编辑器 - */ - public void populate(final QuickEditor currentEditor) { - this.removeAll(); - if (currentEditor.getComponentCount() == 0) { - this.add(getEmptyEditor(), BorderLayout.CENTER); - } else { - this.add(currentEditor, BorderLayout.CENTER); - } - validate(); - repaint(); - } +package com.fr.design.mainframe.cell; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.selection.QuickEditor; +import com.fr.general.Inter; + +import javax.swing.*; +import java.awt.*; + +/** + * QuickEditorRegion + * + * @author zhou, yaoh.wu + * @version 2017年7月25日 + * @since 8.0 + */ + +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() { + return singleton; + } + + public static JPanel getEmptyEditor() { + if (EMPTY == null) { + EMPTY = new JPanel(new BorderLayout()); + UILabel content = new UILabel(Inter.getLocText(new String[]{"DataFunction-None", "HJS-Message", "Form-Widget_Property_Table"}) + "!"); + content.setBorder(BorderFactory.createEmptyBorder(0, 70, 0, 0)); + EMPTY.add(content, BorderLayout.CENTER); + } + return EMPTY; + } + + /** + * 更新面板显示数据 + * + * @param currentEditor 当前正在编辑的单元格编辑器或者默认的单元格编辑器 + */ + public void populate(final QuickEditor currentEditor) { + this.removeAll(); + if (currentEditor.getComponentCount() == 0) { + this.add(getEmptyEditor(), BorderLayout.CENTER); + } else { + this.add(currentEditor, BorderLayout.CENTER); + } + validate(); + repaint(); + } } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java index a2217301d2..fcb36c8cb0 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java @@ -1,63 +1,63 @@ -package com.fr.quickeditor.cellquick; - -import com.fr.base.BaseUtils; -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.mainframe.DesignerContext; -import com.fr.general.ComparatorUtils; -import com.fr.general.Inter; -import com.fr.quickeditor.CellQuickEditor; -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 { - - @Override - public JComponent createCenterBody() { - UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/bias.png")); - editbutton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - showEditingDialog(); - } - }); - editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); - editbutton.setMargin(null); - editbutton.setOpaque(false); - return editbutton; - } - - private void showEditingDialog() { - final BiasTextPainter oldbiasTextPainter = (BiasTextPainter) cellElement.getValue(); - final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane(); - biasTextPainterPane.populate(oldbiasTextPainter); - biasTextPainterPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - - @Override - public void doOk() { - BiasTextPainter newbiasTextPainter = biasTextPainterPane.update(); - if (!ComparatorUtils.equals(oldbiasTextPainter, newbiasTextPainter)) { - cellElement.setValue(newbiasTextPainter); - fireTargetModified(); - } - } - - }).setVisible(true); - } - - @Override - protected void refreshDetails() { - // TODO Auto-generated method stub - - } - +package com.fr.quickeditor.cellquick; + +import com.fr.base.BaseUtils; +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.mainframe.DesignerContext; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.quickeditor.CellQuickEditor; +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 { + + @Override + public JComponent createCenterBody() { + UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/bias.png")); + editbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + showEditingDialog(); + } + }); + editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + editbutton.setMargin(null); + editbutton.setOpaque(false); + return editbutton; + } + + private void showEditingDialog() { + final BiasTextPainter oldbiasTextPainter = (BiasTextPainter) cellElement.getValue(); + final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane(); + biasTextPainterPane.populate(oldbiasTextPainter); + biasTextPainterPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + + @Override + public void doOk() { + BiasTextPainter newbiasTextPainter = biasTextPainterPane.update(); + if (!ComparatorUtils.equals(oldbiasTextPainter, newbiasTextPainter)) { + cellElement.setValue(newbiasTextPainter); + fireTargetModified(); + } + } + + }).setVisible(true); + } + + @Override + protected void refreshDetails() { + // TODO Auto-generated method stub + + } + } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index de5cf51671..a3c38d0575 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/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 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)); /*高级设置面板*/ diff --git a/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java index be3d3f7a2b..b39514ef65 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java @@ -1,77 +1,77 @@ -package com.fr.quickeditor.cellquick; - -import com.fr.base.BaseUtils; -import com.fr.base.Style; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.report.SelectImagePane; -import com.fr.general.ComparatorUtils; -import com.fr.general.Inter; -import com.fr.quickeditor.CellQuickEditor; -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 { - private static CellImageQuickEditor THIS; - - public static final CellImageQuickEditor getInstance() { - if (THIS == null) { - THIS = new CellImageQuickEditor(); - } - return THIS; - } - - private CellImageQuickEditor() { - super(); - } - - @Override - public JComponent createCenterBody() { - UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); - editbutton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - showEditingDialog(); - } - }); - editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); - editbutton.setMargin(null); - editbutton.setOpaque(false); - return editbutton; - } - - private void showEditingDialog() { - final SelectImagePane imageEditorPane = new SelectImagePane(); - imageEditorPane.populate(cellElement); - final Object oldValue = cellElement.getValue(); - final Style oldStyle = cellElement.getStyle(); - imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - - @Override - public void doOk() { - CellImage cellImage = imageEditorPane.update(); - if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) { - cellElement.setValue(cellImage.getImage()); - cellElement.setStyle(cellImage.getStyle()); - fireTargetModified(); - } - } - - }).setVisible(true); - } - - @Override - protected void refreshDetails() { - - } - +package com.fr.quickeditor.cellquick; + +import com.fr.base.BaseUtils; +import com.fr.base.Style; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.report.SelectImagePane; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.quickeditor.CellQuickEditor; +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 { + private static CellImageQuickEditor THIS; + + public static final CellImageQuickEditor getInstance() { + if (THIS == null) { + THIS = new CellImageQuickEditor(); + } + return THIS; + } + + private CellImageQuickEditor() { + super(); + } + + @Override + public JComponent createCenterBody() { + UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); + editbutton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + showEditingDialog(); + } + }); + editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + editbutton.setMargin(null); + editbutton.setOpaque(false); + return editbutton; + } + + private void showEditingDialog() { + final SelectImagePane imageEditorPane = new SelectImagePane(); + imageEditorPane.populate(cellElement); + final Object oldValue = cellElement.getValue(); + final Style oldStyle = cellElement.getStyle(); + imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + + @Override + public void doOk() { + CellImage cellImage = imageEditorPane.update(); + if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) { + cellElement.setValue(cellImage.getImage()); + cellElement.setStyle(cellImage.getStyle()); + fireTargetModified(); + } + } + + }).setVisible(true); + } + + @Override + protected void refreshDetails() { + + } + } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java index 32835803d3..41596ddba5 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java @@ -1,50 +1,50 @@ -package com.fr.quickeditor.cellquick; - -import com.fr.design.actions.insert.cell.RichTextCellAction; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.general.Inter; -import com.fr.quickeditor.CellQuickEditor; - -import javax.swing.*; - -/** - * 单元格元素富文本编辑器 - * TODO 9.0 大体上没有改动 - */ -public class CellRichTextEditor extends CellQuickEditor { - private UIButton subReportButton; - private static CellRichTextEditor THIS; - - public static final CellRichTextEditor getInstance() { - if (THIS == null) { - THIS = new CellRichTextEditor(); - } - return THIS; - } - - private CellRichTextEditor() { - super(); - } - - /** - * 创建界面上中间的部分 - * - * @return 界面元素 - * @date 2014-12-7-下午9:41:52 - */ - public JComponent createCenterBody() { - subReportButton = new UIButton(); - subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); - subReportButton.setMargin(null); - subReportButton.setOpaque(false); - return subReportButton; - } - - @Override - protected void refreshDetails() { - RichTextCellAction subReportCellAction = new RichTextCellAction(tc); - subReportCellAction.setName(Inter.getLocText("FR-Designer_RichTextEditor")); - subReportButton.setAction(subReportCellAction); - } - +package com.fr.quickeditor.cellquick; + +import com.fr.design.actions.insert.cell.RichTextCellAction; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.general.Inter; +import com.fr.quickeditor.CellQuickEditor; + +import javax.swing.*; + +/** + * 单元格元素富文本编辑器 + * TODO 9.0 大体上没有改动 + */ +public class CellRichTextEditor extends CellQuickEditor { + private UIButton subReportButton; + private static CellRichTextEditor THIS; + + public static final CellRichTextEditor getInstance() { + if (THIS == null) { + THIS = new CellRichTextEditor(); + } + return THIS; + } + + private CellRichTextEditor() { + super(); + } + + /** + * 创建界面上中间的部分 + * + * @return 界面元素 + * @date 2014-12-7-下午9:41:52 + */ + public JComponent createCenterBody() { + subReportButton = new UIButton(); + subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + subReportButton.setMargin(null); + subReportButton.setOpaque(false); + return subReportButton; + } + + @Override + protected void refreshDetails() { + RichTextCellAction subReportCellAction = new RichTextCellAction(tc); + subReportCellAction.setName(Inter.getLocText("FR-Designer_RichTextEditor")); + subReportButton.setAction(subReportCellAction); + } + } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java index 6e6d7a7a9c..01d3c7d6e0 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java @@ -1,155 +1,155 @@ -package com.fr.quickeditor.cellquick; - -import com.fr.base.Formula; -import com.fr.base.Style; -import com.fr.base.TextFormat; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.grid.selection.CellSelection; -import com.fr.quickeditor.CellQuickEditor; -import com.fr.report.ReportHelper; -import com.fr.report.cell.DefaultTemplateCellElement; -import com.fr.stable.ColumnRow; -import com.fr.stable.StringUtils; - -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; - //文本域 - //TODO 9.0 文本域要根据具体文本数量自适应大小,比较难搞,先跳过。 - private UITextField stringTextField; - //编辑状态 - private boolean isEditing = false; - - public static CellStringQuickEditor getInstance() { - if (THIS == null) { - THIS = new CellStringQuickEditor(); - } - return THIS; - } - - //august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置。 - private boolean reserveInResult = false; - 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() { - super(); - } - - /** - * 详细信息面板 - * todo 文本框可自适应大小,公式编辑也是在这边,如果是公式那么要加一个公式编辑器的触发按钮 - */ - @Override - public JComponent createCenterBody() { - stringTextField = new UITextField(); - stringTextField.addKeyListener(new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - if (tc != null) { - tc.getGrid().dispatchEvent(e); - } - } - }); - return stringTextField; - } - - - private void changeReportPaneCell(String tmpText) { - isEditing = true; - //refresh一下,如果单元格内有新添加的控件,此时并不知道 - CellSelection cs1 = (CellSelection) tc.getSelection(); - ColumnRow columnRow = ColumnRow.valueOf(cs1.getColumn(), cs1.getRow()); - columnRowTextField.setText(columnRow.toString()); - cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow()); - - if (cellElement == null) { - CellSelection cs = (CellSelection) tc.getSelection(); - cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); - tc.getEditingElementCase().addCellElement(cellElement, false); - } - if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { - Formula textFormula = new Formula(tmpText); - textFormula.setReserveInResult(reserveInResult); - textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly); - cellElement.setValue(textFormula); - } else { - Style style = cellElement.getStyle(); - if (style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) { - cellElement.setValue(tmpText); - } else { - cellElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); - } - } - fireTargetModified(); - stringTextField.requestFocus(); - isEditing = false; - } - - /** - * 刷新详细内容 - */ - @Override - protected void refreshDetails() { - String str; - if (cellElement == null) { - str = StringUtils.EMPTY; - } else { - Object value = cellElement.getValue(); - if (value == null) { - str = StringUtils.EMPTY; - } else if (value instanceof Formula) { - Formula formula = (Formula) value; - str = formula.getContent(); - reserveInResult = formula.isReserveInResult(); - reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly(); - } else { - str = value.toString(); - } - } - showText(str); - stringTextField.setEditable(tc.isSelectedOneCell()); - } - - /** - * 显示文本 - * - * @param str 文本 - */ - public void showText(String str) { - // 正在编辑时不处理 - if (isEditing) { - return; - } - stringTextField.getDocument().removeDocumentListener(documentListener); - stringTextField.setText(str); - stringTextField.getDocument().addDocumentListener(documentListener); - } - +package com.fr.quickeditor.cellquick; + +import com.fr.base.Formula; +import com.fr.base.Style; +import com.fr.base.TextFormat; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.grid.selection.CellSelection; +import com.fr.quickeditor.CellQuickEditor; +import com.fr.report.ReportHelper; +import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.stable.ColumnRow; +import com.fr.stable.StringUtils; + +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; + //文本域 + //TODO 9.0 文本域要根据具体文本数量自适应大小,比较难搞,先跳过。 + private UITextField stringTextField; + //编辑状态 + private boolean isEditing = false; + + public static CellStringQuickEditor getInstance() { + if (THIS == null) { + THIS = new CellStringQuickEditor(); + } + return THIS; + } + + //august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置。 + private boolean reserveInResult = false; + 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() { + super(); + } + + /** + * 详细信息面板 + * todo 文本框可自适应大小,公式编辑也是在这边,如果是公式那么要加一个公式编辑器的触发按钮 + */ + @Override + public JComponent createCenterBody() { + stringTextField = new UITextField(); + stringTextField.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + if (tc != null) { + tc.getGrid().dispatchEvent(e); + } + } + }); + return stringTextField; + } + + + private void changeReportPaneCell(String tmpText) { + isEditing = true; + //refresh一下,如果单元格内有新添加的控件,此时并不知道 + CellSelection cs1 = (CellSelection) tc.getSelection(); + ColumnRow columnRow = ColumnRow.valueOf(cs1.getColumn(), cs1.getRow()); + columnRowTextField.setText(columnRow.toString()); + cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow()); + + if (cellElement == null) { + CellSelection cs = (CellSelection) tc.getSelection(); + cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); + tc.getEditingElementCase().addCellElement(cellElement, false); + } + if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { + Formula textFormula = new Formula(tmpText); + textFormula.setReserveInResult(reserveInResult); + textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly); + cellElement.setValue(textFormula); + } else { + Style style = cellElement.getStyle(); + if (style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) { + cellElement.setValue(tmpText); + } else { + cellElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); + } + } + fireTargetModified(); + stringTextField.requestFocus(); + isEditing = false; + } + + /** + * 刷新详细内容 + */ + @Override + protected void refreshDetails() { + String str; + if (cellElement == null) { + str = StringUtils.EMPTY; + } else { + Object value = cellElement.getValue(); + if (value == null) { + str = StringUtils.EMPTY; + } else if (value instanceof Formula) { + Formula formula = (Formula) value; + str = formula.getContent(); + reserveInResult = formula.isReserveInResult(); + reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly(); + } else { + str = value.toString(); + } + } + showText(str); + stringTextField.setEditable(tc.isSelectedOneCell()); + } + + /** + * 显示文本 + * + * @param str 文本 + */ + public void showText(String str) { + // 正在编辑时不处理 + if (isEditing) { + return; + } + stringTextField.getDocument().removeDocumentListener(documentListener); + stringTextField.setText(str); + stringTextField.getDocument().addDocumentListener(documentListener); + } + } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java index 309b896549..de755f1df7 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java @@ -1,45 +1,45 @@ -package com.fr.quickeditor.cellquick; - -import com.fr.design.actions.insert.cell.SubReportCellAction; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.general.Inter; -import com.fr.quickeditor.CellQuickEditor; - -import javax.swing.*; - -/** - * 单元格元素子报表编辑器 - * TODO 9.0大体上没有改动 - */ -public class CellSubReportEditor extends CellQuickEditor { - private UIButton subReportButton; - private static CellSubReportEditor THIS; - - public static final CellSubReportEditor getInstance() { - if (THIS == null) { - THIS = new CellSubReportEditor(); - } - return THIS; - } - - private CellSubReportEditor() { - super(); - } - - @Override - public JComponent createCenterBody() { - subReportButton = new UIButton(); - subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); - subReportButton.setMargin(null); - subReportButton.setOpaque(false); - return subReportButton; - } - - @Override - protected void refreshDetails() { - SubReportCellAction subReportCellAction = new SubReportCellAction(tc); - subReportCellAction.setName(Inter.getLocText(new String[]{"Edit", "Sub_Report"})); - subReportButton.setAction(subReportCellAction); - } - +package com.fr.quickeditor.cellquick; + +import com.fr.design.actions.insert.cell.SubReportCellAction; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.general.Inter; +import com.fr.quickeditor.CellQuickEditor; + +import javax.swing.*; + +/** + * 单元格元素子报表编辑器 + * TODO 9.0大体上没有改动 + */ +public class CellSubReportEditor extends CellQuickEditor { + private UIButton subReportButton; + private static CellSubReportEditor THIS; + + public static final CellSubReportEditor getInstance() { + if (THIS == null) { + THIS = new CellSubReportEditor(); + } + return THIS; + } + + private CellSubReportEditor() { + super(); + } + + @Override + public JComponent createCenterBody() { + subReportButton = new UIButton(); + subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + subReportButton.setMargin(null); + subReportButton.setOpaque(false); + return subReportButton; + } + + @Override + protected void refreshDetails() { + SubReportCellAction subReportCellAction = new SubReportCellAction(tc); + subReportCellAction.setName(Inter.getLocText(new String[]{"Edit", "Sub_Report"})); + subReportButton.setAction(subReportCellAction); + } + } \ No newline at end of file From 89bd13daafd062ff823353291f159c6ce2d6f1d6 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 26 Jul 2017 13:42:11 +0800 Subject: [PATCH 4/5] =?UTF-8?q?REPORT-3348=20=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E6=95=B0=E6=8D=AE=E5=88=97=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E8=AE=BE=E7=BD=AEOK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dscolumn/DSColumnBasicEditorPane.java | 1 + .../dscolumn/SelectedDataColumnPane.java | 38 +++++++++---------- .../cellquick/CellDSColumnEditor.java | 7 ++-- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java index 92ffedb288..cdebc29f41 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java @@ -27,6 +27,7 @@ public class DSColumnBasicEditorPane extends CellEditorPane { 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; diff --git a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java index 9f047c0d3b..3d97abd411 100644 --- a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java @@ -40,15 +40,15 @@ import java.util.regex.Pattern; * * @author yaoh.wu * @version 2017年7月26日 - * todo 9.0设计器更新,修改动态参数注入按钮部分,使其能在右侧边栏正常显示 + * 9.0设计器更新,修改动态参数注入按钮部分,使其显示动态参数按钮时能在右侧边栏正常显示 * @since 8.0 */ public class SelectedDataColumnPane extends BasicPane { - protected UITableEditorPane editorPane; - protected Parameter[] ps; + private UITableEditorPane editorPane; + private Parameter[] ps; - protected TableDataComboBox tableNameComboBox; - protected LazyComboBox columnNameComboBox; + TableDataComboBox tableNameComboBox; + LazyComboBox columnNameComboBox; private ItemListener itemListener; private UIButton paramButton; @@ -57,7 +57,7 @@ public class SelectedDataColumnPane extends BasicPane { this(true); } - public SelectedDataColumnPane(boolean showParameterButton) { + SelectedDataColumnPane(boolean showParameterButton) { initComponent(showParameterButton); } @@ -72,32 +72,33 @@ public class SelectedDataColumnPane extends BasicPane { initWithParameterButton(); } columnNameComboBox = new LazyComboBox() { - @Override public Object[] load() { List l = calculateColumnNameList(); return l.toArray(new String[l.size()]); } - }; columnNameComboBox.setEditable(true); + double f = TableLayout.FILL; double p = TableLayout.PREFERRED; 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) { - Component[][] comps = {{label1, null, label2}, {tableNameComboBox, paramButton, columnNameComboBox}}; - this.add(TableLayoutHelper.createTableLayoutPane(comps, new double[]{p, p}, new double[]{p, p, p})); + //todo 国际化 + 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 { - double f = TableLayout.FILL; double[] columnSize = {p, f}; double[] rowSize = {p, p}; Component[][] components = new Component[][]{ new Component[]{label1, tableNameComboBox}, - new Component[]{label2, columnNameComboBox} + new Component[]{label3, columnNameComboBox} }; JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); this.setLayout(new BorderLayout()); @@ -110,16 +111,13 @@ public class SelectedDataColumnPane extends BasicPane { 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); diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index a3c38d0575..0e439a0bae 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -174,19 +174,18 @@ public class CellDSColumnEditor extends CellQuickEditor { paneList = new ArrayList<>(); /*基本设置面板*/ - this.dataPane = new SelectedDataColumnPane(false); + this.dataPane = new SelectedDataColumnPane(); this.groupPane = new ResultSetGroupDockingPane(tc); this.conditionPane = new JPanel(new BorderLayout()); - conditionPane.add(new UILabel("filter"), BorderLayout.WEST); + conditionPane.add(new UILabel("filter:"), BorderLayout.WEST); if (tc != null) { //第一次初始化时tc为空,引发NullPointerException - conditionPane.add(new UIButton(new DSColumnConditionAction(tc)), BorderLayout.EAST); + conditionPane.add(new UIButton(new DSColumnConditionAction(tc)), BorderLayout.CENTER); } dataPane.addListener(dataListener); groupPane.addListener(groupListener); paneList.add(new DSColumnBasicEditorPane(cellElement, dataPane, groupPane, conditionPane)); - /*高级设置面板*/ paneList.add(new DSColumnAdvancedEditorPane()); } From 1bd82501ff4752a5d5c2c575038d01f7238663ad Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 26 Jul 2017 18:57:36 +0800 Subject: [PATCH 5/5] =?UTF-8?q?REPORT-3348=20=E6=95=B0=E6=8D=AE=E5=88=97?= =?UTF-8?q?=E9=9B=86=E9=80=89=E6=8B=A9=E7=BB=84=E4=BB=B6=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=B8=80=E4=BA=9B=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/dscolumn/DSColumnBasicEditorPane.java | 8 ++++---- .../design/dscolumn/SelectedDataColumnPane.java | 6 +++--- .../quickeditor/cellquick/CellDSColumnEditor.java | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java index cdebc29f41..ef0c5e0b51 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnBasicEditorPane.java @@ -69,15 +69,15 @@ public class DSColumnBasicEditorPane extends CellEditorPane { private JPanel createContentPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] columnSize = {p, f}; + double[] columnSize = {f}; double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ //数据集列选择 - new Component[]{this.dataPane, null}, + new Component[]{this.dataPane}, //数据分组设置 - new Component[]{this.groupPane, null}, + new Component[]{this.groupPane}, //条件过滤 - new Component[]{this.conditionPane, null} + new Component[]{this.conditionPane} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } diff --git a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java index 3d97abd411..dd583e1efe 100644 --- a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java @@ -81,11 +81,11 @@ public class SelectedDataColumnPane extends BasicPane { columnNameComboBox.setEditable(true); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - UILabel label1 = new UILabel(Inter.getLocText("TableData") + ":"); - UILabel label3 = new UILabel(Inter.getLocText("DataColumn") + ":"); + UILabel label1 = new UILabel(Inter.getLocText("TableData")); + UILabel label3 = new UILabel(Inter.getLocText("DataColumn")); if (showParameterButton) { //todo 国际化 - UILabel label2 = new UILabel("param" + ":"); + UILabel label2 = new UILabel("param"); Component[][] components = { {label1, tableNameComboBox}, {label2, paramButton}, diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 0e439a0bae..321da63fb5 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -8,6 +8,8 @@ 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.layout.TableLayout; +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; @@ -152,6 +154,7 @@ public class CellDSColumnEditor extends CellQuickEditor { 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(); @@ -176,12 +179,18 @@ public class CellDSColumnEditor extends CellQuickEditor { /*基本设置面板*/ this.dataPane = new SelectedDataColumnPane(); this.groupPane = new ResultSetGroupDockingPane(tc); - this.conditionPane = new JPanel(new BorderLayout()); - conditionPane.add(new UILabel("filter:"), BorderLayout.WEST); + 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 - conditionPane.add(new UIButton(new DSColumnConditionAction(tc)), BorderLayout.CENTER); + 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));