Search in sources :

Example 1 with RecordRowTableModel

use of com.revolsys.swing.table.record.model.RecordRowTableModel in project com.revolsys.open by revolsys.

the class RecordLayerTable method copyFieldValue.

public void copyFieldValue() {
    if (isEditingCurrentCell()) {
        final RecordTableCellEditor tableCellEditor = getTableCellEditor();
        final JComponent editorComponent = tableCellEditor.getEditorComponent();
        SwingUtil.dndCopy(editorComponent);
    } else {
        final RecordRowTableModel model = getTableModel();
        final int row = TablePanel.getEventRow();
        final int column = TablePanel.getEventColumn();
        final Object value = model.getValueAt(row, column);
        if (value != null) {
            final String copyValue;
            if (value instanceof Geometry) {
                final Geometry geometry = (Geometry) value;
                copyValue = geometry.toEwkt();
            } else {
                copyValue = model.toDisplayValue(row, column, value);
            }
            final StringSelection transferable = new StringSelection(copyValue);
            ClipboardUtil.setContents(transferable);
        }
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) JComponent(javax.swing.JComponent) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) EventObject(java.util.EventObject) RecordTableCellEditor(com.revolsys.swing.table.record.editor.RecordTableCellEditor) StringSelection(java.awt.datatransfer.StringSelection)

Example 2 with RecordRowTableModel

use of com.revolsys.swing.table.record.model.RecordRowTableModel in project com.revolsys.open by revolsys.

the class ErrorPredicate method add.

public static void add(final RecordRowTable table) {
    final RecordRowTableModel model = table.getTableModel();
    final Highlighter highlighter = getHighlighter(model);
    table.addHighlighter(highlighter);
}
Also used : RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) Highlighter(org.jdesktop.swingx.decorator.Highlighter) ColorHighlighter(org.jdesktop.swingx.decorator.ColorHighlighter)

Example 3 with RecordRowTableModel

use of com.revolsys.swing.table.record.model.RecordRowTableModel in project com.revolsys.open by revolsys.

the class RecordRowTableCellRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int rowIndex, final int columnIndex) {
    final RecordRowTableModel model = (RecordRowTableModel) table.getModel();
    final Record record = model.getRecord(rowIndex);
    if (record == null) {
        return EMPTY_LABEL;
    } else {
        final boolean selected = isSelected || model.isSelected(isSelected, rowIndex, columnIndex);
        final Object displayValue;
        final int fieldsOffset = model.getColumnFieldsOffset();
        if (columnIndex < fieldsOffset) {
            displayValue = value;
        } else {
            displayValue = model.toDisplayValue(rowIndex, columnIndex, value);
        }
        super.getTableCellRendererComponent(table, displayValue, selected, hasFocus, rowIndex, columnIndex);
        if (value instanceof Number) {
            setHorizontalAlignment(SwingConstants.RIGHT);
            setHorizontalTextPosition(SwingConstants.RIGHT);
        } else {
            setHorizontalAlignment(SwingConstants.LEFT);
            setHorizontalTextPosition(SwingConstants.LEFT);
        }
        setToolTipText(null);
        return this;
    }
}
Also used : RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) Record(com.revolsys.record.Record)

Example 4 with RecordRowTableModel

use of com.revolsys.swing.table.record.model.RecordRowTableModel in project com.revolsys.open by revolsys.

the class RecordRowTable method getEventRecord.

public static <V extends Record> V getEventRecord() {
    final BaseJTable eventTable = TablePanel.getEventTable();
    if (eventTable instanceof RecordRowTable) {
        final RecordRowTable table = (RecordRowTable) eventTable;
        if (table != null) {
            final int eventRow = TablePanel.getEventRow();
            if (eventRow != -1) {
                final RecordRowTableModel model = table.getTableModel();
                final V record = model.getRecord(eventRow);
                return record;
            }
        }
    }
    return null;
}
Also used : BaseJTable(com.revolsys.swing.table.BaseJTable) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel)

Example 5 with RecordRowTableModel

use of com.revolsys.swing.table.record.model.RecordRowTableModel in project com.revolsys.open by revolsys.

the class RecordRowTable method initializeColumnPreferredWidth.

@Override
protected void initializeColumnPreferredWidth(final TableColumn column) {
    super.initializeColumnPreferredWidth(column);
    final RecordRowTableModel model = getTableModel();
    final int columnIndex = column.getModelIndex();
    final FieldDefinition fieldDefinition = model.getColumnFieldDefinition(columnIndex);
    if (fieldDefinition != null) {
        Integer columnWidth = fieldDefinition.getProperty("tableColumnWidth");
        final String columnName = fieldDefinition.getTitle();
        if (columnWidth == null) {
            columnWidth = fieldDefinition.getMaxStringLength() * 7;
            columnWidth = Math.min(columnWidth, 200);
            fieldDefinition.setProperty("tableColumnWidth", columnWidth);
        }
        final int nameWidth = columnName.length() * 8 + 15;
        column.setPreferredWidth(Math.max(nameWidth, columnWidth));
    }
}
Also used : FieldDefinition(com.revolsys.record.schema.FieldDefinition) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel)

Aggregations

RecordRowTableModel (com.revolsys.swing.table.record.model.RecordRowTableModel)14 RecordTableCellEditor (com.revolsys.swing.table.record.editor.RecordTableCellEditor)3 JComponent (javax.swing.JComponent)3 Geometry (com.revolsys.geometry.model.Geometry)2 Record (com.revolsys.record.Record)2 EventObject (java.util.EventObject)2 FieldDefinition (com.revolsys.record.schema.FieldDefinition)1 RecordLayerTable (com.revolsys.swing.map.layer.record.table.RecordLayerTable)1 RecordLayerTableModel (com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel)1 BaseJTable (com.revolsys.swing.table.BaseJTable)1 ColorHighlighter (com.revolsys.swing.table.highlighter.ColorHighlighter)1 Color (java.awt.Color)1 StringSelection (java.awt.datatransfer.StringSelection)1 Transferable (java.awt.datatransfer.Transferable)1 ListSelectionModel (javax.swing.ListSelectionModel)1 SortOrder (javax.swing.SortOrder)1 TableColumn (javax.swing.table.TableColumn)1 TableColumnModel (javax.swing.table.TableColumnModel)1 ColorHighlighter (org.jdesktop.swingx.decorator.ColorHighlighter)1 Highlighter (org.jdesktop.swingx.decorator.Highlighter)1