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);
}
}
}
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);
}
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;
}
}
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;
}
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));
}
}
Aggregations