Search in sources :

Example 1 with ElementsTable

use of com.ramussoft.gui.qualifier.table.ElementsTable in project ramus by Vitaliy-Yakovchuk.

the class OtherElementTableCellEditor method getTableCellEditorComponent.

@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int rowIndex, int columnIndex) {
    this.table = table;
    if (value instanceof String) {
        Row r = rowSet.findRow((String) value);
        if (r != null)
            value = r.getElementId();
        else
            value = null;
    }
    if (value instanceof Long) {
        value = new RowAttributeWrapper(rowSet.findRow((Long) value), nameAttribute);
    }
    this.value = value;
    if (value != null)
        this.value = ((RowAttributeWrapper) value).getRow().getElementId();
    Row row = (value != null) ? ((RowAttributeWrapper) value).getRow() : null;
    if (row == null) {
        codeField.setText("");
        valueField.setText("");
    } else {
        codeField.setText(row.getCode());
        valueField.setText(value.toString());
        valueField.setCaretPosition(0);
    }
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            codeField.selectAll();
            codeField.requestFocus();
        }
    });
    if (table instanceof ElementsTable) {
        element = ((ElementsTable) table).getElementForRow(rowIndex);
    }
    return component;
}
Also used : ElementsTable(com.ramussoft.gui.qualifier.table.ElementsTable) Row(com.ramussoft.database.common.Row) RowAttributeWrapper(com.ramussoft.gui.attribute.OtherElementPlugin.RowAttributeWrapper)

Aggregations

Row (com.ramussoft.database.common.Row)1 RowAttributeWrapper (com.ramussoft.gui.attribute.OtherElementPlugin.RowAttributeWrapper)1 ElementsTable (com.ramussoft.gui.qualifier.table.ElementsTable)1