Search in sources :

Example 1 with RecordLayerTable

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;
}
Also used : RecordLayerTableModel(com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel) EnableCheck(com.revolsys.swing.action.enablecheck.EnableCheck) RecordLayerTable(com.revolsys.swing.map.layer.record.table.RecordLayerTable)

Example 2 with RecordLayerTable

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);
        }
    });
}
Also used : Condition(com.revolsys.record.query.Condition) RecordRowPredicateRowFilter(com.revolsys.swing.table.record.filter.RecordRowPredicateRowFilter) RecordLayerTable(com.revolsys.swing.map.layer.record.table.RecordLayerTable)

Example 3 with RecordLayerTable

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;
    }
}
Also used : RecordLayerTable(com.revolsys.swing.map.layer.record.table.RecordLayerTable) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 4 with RecordLayerTable

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;
}
Also used : LayerRecordMenu(com.revolsys.swing.map.layer.record.LayerRecordMenu) BaseJPopupMenu(com.revolsys.swing.menu.BaseJPopupMenu) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) RecordLayerTable(com.revolsys.swing.map.layer.record.table.RecordLayerTable) JMenuItem(javax.swing.JMenuItem)

Example 5 with RecordLayerTable

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);
        }
    });
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel) RecordRowTableModel(com.revolsys.swing.table.record.model.RecordRowTableModel) RecordLayerTable(com.revolsys.swing.map.layer.record.table.RecordLayerTable)

Aggregations

RecordLayerTable (com.revolsys.swing.map.layer.record.table.RecordLayerTable)6 Condition (com.revolsys.record.query.Condition)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1 EnableCheck (com.revolsys.swing.action.enablecheck.EnableCheck)1 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)1 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)1 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)1 RecordLayerTableModel (com.revolsys.swing.map.layer.record.table.model.RecordLayerTableModel)1 BaseJPopupMenu (com.revolsys.swing.menu.BaseJPopupMenu)1 RecordRowPredicateRowFilter (com.revolsys.swing.table.record.filter.RecordRowPredicateRowFilter)1 RecordRowTableModel (com.revolsys.swing.table.record.model.RecordRowTableModel)1 JMenuItem (javax.swing.JMenuItem)1 ListSelectionModel (javax.swing.ListSelectionModel)1