From 0d2ad4464118aac3cba767c58dce7fa532f8f0ee Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 1 Sep 2016 10:54:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A1=AB=E6=8A=A5=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=94=AF=E6=8C=81=E5=85=AC=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E6=8A=8A=E5=89=8D=E9=9D=A2=E7=9A=84=E6=9D=A1=E4=BB=B6=E6=A1=86?= =?UTF-8?q?=E4=B9=9F=E6=94=B9=E6=88=90=E5=85=AC=E5=BC=8F=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/report/ValueVerifierEditPane.java | 11 ++- .../UIArrayFormulaTableModel.java | 68 +++++++++++++++++++ 2 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 designer_base/src/com/fr/design/gui/itableeditorpane/UIArrayFormulaTableModel.java diff --git a/designer/src/com/fr/design/report/ValueVerifierEditPane.java b/designer/src/com/fr/design/report/ValueVerifierEditPane.java index ebbc9901b5..0490ea7829 100644 --- a/designer/src/com/fr/design/report/ValueVerifierEditPane.java +++ b/designer/src/com/fr/design/report/ValueVerifierEditPane.java @@ -3,13 +3,14 @@ package com.fr.design.report; import com.fr.base.Formula; import com.fr.data.VerifyItem; import com.fr.design.gui.itableeditorpane.ActionStyle; -import com.fr.design.gui.itableeditorpane.UIArrayTableModel; +import com.fr.design.gui.itableeditorpane.UIArrayFormulaTableModel; import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.GeneralUtils; import com.fr.general.Inter; import com.fr.report.write.ValueVerifier; import com.fr.stable.FormulaProvider; +import com.fr.stable.StableUtils; import javax.swing.*; import java.awt.*; @@ -23,7 +24,7 @@ public class ValueVerifierEditPane extends JPanel { public ValueVerifierEditPane() { // ben:UITableEditorPane; this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); - tableEditorPane = new UITableEditorPane(new UIArrayTableModel(columnNames, new int[] { + tableEditorPane = new UITableEditorPane(new UIArrayFormulaTableModel(columnNames, new int[] { ActionStyle.ADDSTYLE, ActionStyle.DELETESTYLE, ActionStyle.MOVEUPSTYLE, ActionStyle.MOVEDOWNSTYLE})); this.add(tableEditorPane, BorderLayout.CENTER); @@ -45,7 +46,11 @@ public class ValueVerifierEditPane extends JPanel { if (formula == null) { continue; } - os[tableDataCount++] = new Object[]{formula.getPureContent(), item.getMessage()}; + String msg = item.getMessage(); + if (!StableUtils.canBeFormula(msg)) { + msg = "\"" + msg + "\""; + } + os[tableDataCount++] = new Object[]{formula, new Formula(msg)}; } this.tableEditorPane.populate(os); } diff --git a/designer_base/src/com/fr/design/gui/itableeditorpane/UIArrayFormulaTableModel.java b/designer_base/src/com/fr/design/gui/itableeditorpane/UIArrayFormulaTableModel.java new file mode 100644 index 0000000000..a3106b2711 --- /dev/null +++ b/designer_base/src/com/fr/design/gui/itableeditorpane/UIArrayFormulaTableModel.java @@ -0,0 +1,68 @@ +package com.fr.design.gui.itableeditorpane; + +import com.fr.design.editor.ValueEditorPane; +import com.fr.design.editor.ValueEditorPaneFactory; + +import javax.swing.*; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.table.TableCellEditor; +import java.awt.*; + +/** + * 全部是公式编辑的model + * Coder: zack + * Date: 2016/8/31 + * Time: 18:58 + */ +public class UIArrayFormulaTableModel extends UIArrayTableModel { + public UIArrayFormulaTableModel(String[] s, int[] array) { + super(s, array); + setDefaultEditors(); + } + + public void setDefaultEditors() { + for (int i = 0; i < getColumnCount(); i++) { + setDefaultEditor(Object.class, new FormulaValueEditor()); + } + } + + private class FormulaValueEditor extends AbstractCellEditor implements TableCellEditor { + private static final long serialVersionUID = 1L; + private ValueEditorPane editor; + + public FormulaValueEditor() { + + editor = ValueEditorPaneFactory.createFormulaValueEditorPane(); + + this.addCellEditorListener(new CellEditorListener() { + + @Override + public void editingCanceled(ChangeEvent e) { + } + + @Override + public void editingStopped(ChangeEvent e) { + if (table.getSelectedRow() == -1 || table.getSelectedColumn() == -1) { + return; + } + Object[] para = getList().get(table.getSelectedRow()); + para[table.getSelectedColumn()] = getCellEditorValue(); + fireTableDataChanged(); + } + }); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + editor.clearComponentsData(); + editor.populate(value == null ? "" : value); + return editor; + } + + @Override + public Object getCellEditorValue() { + return editor.update(); + } + } +} From 7ad696659067d15b56b18d2ea9789cee1c0b755f Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 1 Sep 2016 10:58:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A1=A5=E4=B8=AA=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/report/ValueVerifierEditPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer/src/com/fr/design/report/ValueVerifierEditPane.java b/designer/src/com/fr/design/report/ValueVerifierEditPane.java index 0490ea7829..f3ebda61a5 100644 --- a/designer/src/com/fr/design/report/ValueVerifierEditPane.java +++ b/designer/src/com/fr/design/report/ValueVerifierEditPane.java @@ -48,7 +48,7 @@ public class ValueVerifierEditPane extends JPanel { } String msg = item.getMessage(); if (!StableUtils.canBeFormula(msg)) { - msg = "\"" + msg + "\""; + msg = "\"" + msg + "\"";//如果报错信息是以前的写法(字符串)就拼上"" } os[tableDataCount++] = new Object[]{formula, new Formula(msg)}; }