Browse Source

Merge pull request #300 in BA/design from ~ZACK/design:dev to dev

* commit '7ad696659067d15b56b18d2ea9789cee1c0b755f':
  补个注释
  填报校验信息支持公式,把前面的条件框也改成公式编辑
master
superman 8 years ago
parent
commit
df4b44482f
  1. 11
      designer/src/com/fr/design/report/ValueVerifierEditPane.java
  2. 68
      designer_base/src/com/fr/design/gui/itableeditorpane/UIArrayFormulaTableModel.java

11
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.base.Formula;
import com.fr.data.VerifyItem; import com.fr.data.VerifyItem;
import com.fr.design.gui.itableeditorpane.ActionStyle; 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.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.report.write.ValueVerifier; import com.fr.report.write.ValueVerifier;
import com.fr.stable.FormulaProvider; import com.fr.stable.FormulaProvider;
import com.fr.stable.StableUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -23,7 +24,7 @@ public class ValueVerifierEditPane extends JPanel {
public ValueVerifierEditPane() { public ValueVerifierEditPane() {
// ben:UITableEditorPane; // ben:UITableEditorPane;
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
tableEditorPane = new UITableEditorPane<Object[]>(new UIArrayTableModel(columnNames, new int[] { tableEditorPane = new UITableEditorPane(new UIArrayFormulaTableModel(columnNames, new int[] {
ActionStyle.ADDSTYLE, ActionStyle.DELETESTYLE, ActionStyle.ADDSTYLE, ActionStyle.DELETESTYLE,
ActionStyle.MOVEUPSTYLE, ActionStyle.MOVEDOWNSTYLE})); ActionStyle.MOVEUPSTYLE, ActionStyle.MOVEDOWNSTYLE}));
this.add(tableEditorPane, BorderLayout.CENTER); this.add(tableEditorPane, BorderLayout.CENTER);
@ -45,7 +46,11 @@ public class ValueVerifierEditPane extends JPanel {
if (formula == null) { if (formula == null) {
continue; 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); this.tableEditorPane.populate(os);
} }

68
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();
}
}
}
Loading…
Cancel
Save