private List<Parameter> loadParameters(NodeSettingsRO settings, String key, boolean safe)
     throws InvalidSettingsException {
   List<Parameter> fields = new ArrayList<>();
   if (!settings.containsKey(key)) return fields;
   ConfigBaseRO config = settings.getConfigBase(key);
   int count = safe ? config.getInt("count", 0) : config.getInt("count");
   for (int index = 0; index < count; index++)
     fields.add(
         new Parameter(
             config.getString(String.format("name%d", index)),
             Type.valueOf(config.getString(String.format("type%d", index))),
             config.getBoolean(String.format("optional%d", index))));
   return fields;
 }
Exemple #2
0
  /** Create a new component. */
  public ParameterTable() {
    super(new ParameterTableModel());
    final JTable table = this.getTable();

    this.model = (ParameterTableModel) this.getModel();

    DefaultCellEditor textEditor = new DefaultCellEditor(new JTextField());
    textEditor.setClickCountToStart(1);
    table.setDefaultEditor(String.class, textEditor);

    TableColumn nameColumn = table.getColumnModel().getColumn(this.model.getIndex(Column.NAME));
    nameColumn.setCellEditor(textEditor);
    TableColumn typeColumn = table.getColumnModel().getColumn(this.model.getIndex(Column.TYPE));
    typeColumn.setCellEditor(new DefaultCellEditor(new JComboBox<Type>(Type.values())));

    // commit editor on focus lost
    this.getTable().putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
  }