use of com.revolsys.swing.map.layer.record.table.RecordLayerTable in project com.revolsys.open by revolsys.
the class AbstractUpdateField method newEnableCheck.
protected static EnableCheck newEnableCheck() {
final EnableCheck enableCheck = Menus.enableCheck((final RecordLayerTable table) -> {
final int columnIndex = TablePanel.getEventColumn();
final RecordLayerTableModel tableModel = table.getModel();
if (tableModel.isFieldEditable(columnIndex)) {
if (tableModel.isIdField(columnIndex)) {
return false;
} else {
return true;
}
} else {
return false;
}
});
return enableCheck;
}
use of com.revolsys.swing.map.layer.record.table.RecordLayerTable in project com.revolsys.open by revolsys.
the class RecordLayerTableModel method setFilter.
public void setFilter(final Condition filter) {
Invoke.later(() -> {
final Condition filter2;
if (filter == null) {
filter2 = Condition.ALL;
} else {
filter2 = filter;
}
if (!DataType.equal(filter2, this.filter)) {
final Object oldValue = this.filter;
this.filter = filter2;
if (Property.isEmpty(filter2)) {
this.rowFilterCondition = null;
} else {
this.rowFilterCondition = new RecordRowPredicateRowFilter(filter2);
if (!DataType.equal(oldValue, filter2)) {
this.filterHistory.remove(filter2);
this.filterHistory.addFirst(filter2);
while (this.filterHistory.size() > 20) {
this.filterHistory.removeLast();
}
firePropertyChange("hasFilterHistory", false, true);
}
}
if (isSortable()) {
final RecordLayerTable table = getTable();
table.setRowFilter(this.rowFilterCondition);
} else {
refresh();
}
firePropertyChange("filter", oldValue, this.filter);
final boolean hasFilter = isHasFilter();
firePropertyChange("hasFilter", !hasFilter, hasFilter);
}
});
}
use of com.revolsys.swing.map.layer.record.table.RecordLayerTable in project com.revolsys.open by revolsys.
the class RecordLayerTableModel method newTable.
public static RecordLayerTable newTable(final AbstractRecordLayer layer, final Collection<String> fieldNames) {
final RecordDefinition recordDefinition = layer.getRecordDefinition();
if (recordDefinition == null) {
return null;
} else {
final RecordLayerTableModel model = new RecordLayerTableModel(layer, fieldNames);
final RecordLayerTable table = new RecordLayerTable(model);
model.selectionChangedListener = EventQueue.addPropertyChange(layer, "hasSelectedRecords", () -> selectionChanged(table, model));
return table;
}
}
use of com.revolsys.swing.map.layer.record.table.RecordLayerTable in project com.revolsys.open by revolsys.
the class RecordLayerTableModel method getMenu.
@Override
public BaseJPopupMenu getMenu(final int rowIndex, final int columnIndex) {
final LayerRecord record = getRecord(rowIndex);
if (record != null) {
final AbstractRecordLayer layer = getLayer();
if (layer != null) {
LayerRecordMenu.setEventRecord(record);
if (isUseRecordMenu()) {
final LayerRecordMenu menu = record.getMenu();
final BaseJPopupMenu popupMenu = menu.newJPopupMenu();
popupMenu.addSeparator();
final RecordLayerTable table = getTable();
final boolean cellEditable = isCellEditable(rowIndex, columnIndex);
final Object value = getValueAt(rowIndex, columnIndex);
final boolean canCopy = Property.hasValue(value);
if (cellEditable) {
final JMenuItem cutMenu = RunnableAction.newMenuItem("Cut Field Value", "cut", table::cutFieldValue);
cutMenu.setEnabled(canCopy);
popupMenu.add(cutMenu);
}
final JMenuItem copyMenu = RunnableAction.newMenuItem("Copy Field Value", "page_copy", table::copyFieldValue);
copyMenu.setEnabled(canCopy);
popupMenu.add(copyMenu);
if (cellEditable) {
popupMenu.add(RunnableAction.newMenuItem("Paste Field Value", "paste_plain", table::pasteFieldValue));
}
return popupMenu;
} else {
return super.getMenu().newJPopupMenu();
}
}
}
return null;
}
use of com.revolsys.swing.map.layer.record.table.RecordLayerTable in project com.revolsys.open by revolsys.
the class RecordLayerTableModel method setTableRecordsMode.
public void setTableRecordsMode(final TableRecordsMode tableRecordsMode) {
Invoke.later(() -> {
final TableRecordsMode oldMode = this.tableRecordsMode;
final RecordLayerTable table = getTable();
if (table != null && tableRecordsMode != null && tableRecordsMode != oldMode) {
if (oldMode != null) {
oldMode.deactivate();
}
final String oldGeometryFilterMode = getGeometryFilterMode();
this.tableRecordsMode = MODE_EMPTY;
fireTableDataChanged();
table.setSortable(false);
table.setSelectionModel(null);
table.setRowFilter(null);
tableRecordsMode.activate();
final ListSelectionModel selectionModel = tableRecordsMode.getSelectionModel();
table.setSelectionModel(selectionModel);
final boolean sortable = tableRecordsMode.isSortable();
table.setSortable(sortable);
final RowFilter<RecordRowTableModel, Integer> rowFilter = getRowFilter();
table.setRowFilter(rowFilter);
final boolean filterByBoundingBoxSupported = tableRecordsMode.isFilterByBoundingBoxSupported();
if (!filterByBoundingBoxSupported) {
this.filterByBoundingBox = false;
}
this.tableRecordsMode = tableRecordsMode;
refresh();
firePropertyChange("tableRecordsMode", oldMode, this.tableRecordsMode);
firePropertyChange("geometryFilterMode", oldGeometryFilterMode, getGeometryFilterMode());
firePropertyChange("filterByBoundingBox", !this.filterByBoundingBox, this.filterByBoundingBox);
firePropertyChange("filterByBoundingBoxSupported", !filterByBoundingBoxSupported, filterByBoundingBoxSupported);
}
});
}
Aggregations