use of org.knime.core.node.util.dialog.OutFieldsTableModel.FieldType in project knime-core by knime.
the class OutFieldsTable method updateData.
/**
* Set the table data.
*
* @param fields the fields
* @param spec the input spec
* @param flowVars the flow variables
*/
public void updateData(final FieldCollection fields, final DataTableSpec spec, final Map<String, FlowVariable> flowVars) {
m_spec = spec;
m_flowVars = flowVars;
m_model.clear();
for (int r = 0; r < fields.getOutColumnList().size(); r++) {
OutColumnField field = fields.getOutColumnList().get(r);
addRow(field);
}
for (int r = 0; r < fields.getOutFlowVariableList().size(); r++) {
OutFlowVariableField field = fields.getOutFlowVariableList().get(r);
addRow(field);
}
JTable table = getTable();
table.getColumnModel().getColumn(m_model.getIndex(Column.REPLACE_EXISTING)).setCellRenderer(new BooleanRenderer());
table.getColumnModel().getColumn(m_model.getIndex(Column.REPLACE_EXISTING)).setCellEditor(new DefaultCellEditor(new JCheckBox()));
if (!m_flowVarsOnly) {
table.getColumnModel().getColumn(m_model.getIndex(Column.FIELD_TYPE)).setCellEditor(createFieldTypeCellEditor());
}
table.getColumnModel().getColumn(m_model.getIndex(Column.COLUMN)).setCellRenderer(new InputTableCellRenderer());
table.getColumnModel().getColumn(m_model.getIndex(Column.COLUMN)).setCellEditor(new InputTableCellEditor(this, m_spec, m_flowVars));
table.getColumnModel().getColumn(m_model.getIndex(Column.DATA_TYPE)).setCellRenderer(new DataTypeTableCellRenderer());
table.getColumnModel().getColumn(m_model.getIndex(Column.DATA_TYPE)).setCellEditor(new DataTypeTableCellEditor(this, m_spec, m_flowVars));
if (!m_flowVarsOnly) {
table.getColumnModel().getColumn(m_model.getIndex(Column.IS_COLLECTION)).setCellRenderer(new BooleanRenderer() {
/**
* {@inheritDoc}
*/
@Override
public Component getTableCellRendererComponent(final JTable fooTable, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
Component comp = super.getTableCellRendererComponent(fooTable, value, isSelected, hasFocus, row, column);
FieldType fieldType = getFieldType(row);
comp.setEnabled(fieldType.equals(FieldType.Column));
return comp;
}
});
table.getColumnModel().getColumn(m_model.getIndex(Column.IS_COLLECTION)).setCellEditor(new DefaultCellEditor(new JCheckBox()) {
/**
* {@inheritDoc}
*/
@Override
public boolean isCellEditable(final EventObject anEvent) {
int row = getTable().rowAtPoint(((MouseEvent) anEvent).getPoint());
FieldType fieldType = getFieldType(row);
return fieldType.equals(FieldType.Column);
}
});
}
if (m_defineDefaultValues) {
table.getColumnModel().getColumn(m_model.getIndex(Column.DEFAULT_VALUE)).setCellRenderer(new DefaultFieldTableCellRenderer());
}
}
use of org.knime.core.node.util.dialog.OutFieldsTableModel.FieldType in project knime-core by knime.
the class OutFieldsTable method createFieldTypeCellEditor.
// CELL EDITORS
/**
* Create cell editor for for the input columns / flow variables.
* @return an editor for the type field
*/
protected TableCellEditor createFieldTypeCellEditor() {
JComboBox<FieldType> comboBox = new JComboBox<FieldType>();
comboBox.addItem(FieldType.Column);
comboBox.addItem(FieldType.FlowVariable);
DefaultCellEditor editor = new DefaultCellEditor(comboBox);
editor.setClickCountToStart(2);
return editor;
}
Aggregations