Browse Source

REPORT-381:程序数据集添加参数界面

master
neil 8 years ago
parent
commit
49a4629684
  1. 72
      designer_base/src/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java

72
designer_base/src/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java

@ -1,16 +1,23 @@
package com.fr.design.data.tabledata.tabledatapane; package com.fr.design.data.tabledata.tabledatapane;
import com.fr.base.Parameter;
import com.fr.data.impl.ClassTableData; import com.fr.data.impl.ClassTableData;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.JavaEditorPane; import com.fr.design.formula.JavaEditorPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import javax.swing.*; import javax.swing.*;
@ -21,6 +28,7 @@ import java.io.File;
public class ClassTableDataPane extends AbstractTableDataPane<ClassTableData> { public class ClassTableDataPane extends AbstractTableDataPane<ClassTableData> {
private UITextField classNameTextField; private UITextField classNameTextField;
private UITableEditorPane<ParameterProvider> editorPane;
public ClassTableDataPane() { public ClassTableDataPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -89,11 +97,60 @@ public class ClassTableDataPane extends AbstractTableDataPane<ClassTableData> {
}; };
JPanel northPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); JPanel northPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.add(northPane, BorderLayout.NORTH); this.add(northPane, BorderLayout.NORTH);
// TODO alex_ENV this.add(initSouthPanel(), BorderLayout.SOUTH);
// northPane.add(flowTableLayoutHelper.createLabelFlowPane( }
// " ", new UILabel(Inter.getLocText("Example") + ":" + private JPanel initSouthPanel() {
// BaseCoreUtils.pathJoin(new String[] {FRContext.getCurrentEnv().getPath(), "classes"})))); JPanel jpanel = new JPanel();
jpanel.setPreferredSize(new Dimension(-1, 150));
jpanel.setLayout(new BorderLayout());
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel() {
@Override
public UITableEditAction[] createAction() {
return new UITableEditAction[]{
new AddParaAction(),
new RemoveParaAction()
};
}
}, " " + Inter.getLocText(new String[]{"DS-TableData", "DEFAULT", "Parameter"}));
jpanel.add(editorPane, BorderLayout.CENTER);
return jpanel;
}
public class AddParaAction extends UITableEditAction {
public AddParaAction() {
this.setName(Inter.getLocText("FR-Designer_Add"));
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
}
public void actionPerformed(ActionEvent e) {
java.util.List<ParameterProvider> oldParas = editorPane.update();
oldParas.add(new Parameter());
editorPane.populate(oldParas.toArray(new ParameterProvider[oldParas.size()]));
}
@Override
public void checkEnabled() {
}
}
private class RemoveParaAction extends UITableEditAction {
public RemoveParaAction() {
this.setName(Inter.getLocText("FR-Designer_Remove"));
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/control/remove.png"));
}
public void actionPerformed(ActionEvent e) {
ParameterProvider selectedPara = editorPane.getTableModel().getSelectedValue();
java.util.List<ParameterProvider> oldParas = editorPane.update();
oldParas.remove(selectedPara);
editorPane.populate(oldParas.toArray(new ParameterProvider[oldParas.size()]));
}
@Override
public void checkEnabled() {
}
} }
@Override @Override
@ -103,12 +160,17 @@ public class ClassTableDataPane extends AbstractTableDataPane<ClassTableData> {
@Override @Override
public void populateBean(ClassTableData ob) { public void populateBean(ClassTableData ob) {
this.editorPane.populate(ob.getParameters(Calculator.createCalculator()));
this.classNameTextField.setText(ob.getClassName()); this.classNameTextField.setText(ob.getClassName());
} }
@Override @Override
public ClassTableData updateBean() { public ClassTableData updateBean() {
return new ClassTableData(this.classNameTextField.getText()); ClassTableData tableData = new ClassTableData(this.classNameTextField.getText());
java.util.List<ParameterProvider> paras = this.editorPane.update();
tableData.setParameters(paras.toArray(new ParameterProvider[paras.size()]));
return tableData;
} }

Loading…
Cancel
Save