Search in sources :

Example 1 with LayerRecordMenu

use of com.revolsys.swing.map.layer.record.LayerRecordMenu 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 2 with LayerRecordMenu

use of com.revolsys.swing.map.layer.record.LayerRecordMenu in project com.revolsys.open by revolsys.

the class EditRecordGeometryOverlay method modePopupMenu.

private boolean modePopupMenu(final MouseEvent event) {
    if (event.isPopupTrigger()) {
        for (final CloseLocation location : getMouseOverLocations()) {
            final LayerRecord record = location.getRecord();
            if (record != null) {
                final LayerRecordMenu menu = record.getMenu();
                menu.showMenu(record, event);
            }
            return true;
        }
    }
    return false;
}
Also used : CloseLocation(com.revolsys.swing.map.overlay.CloseLocation) LayerRecordMenu(com.revolsys.swing.map.layer.record.LayerRecordMenu) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Aggregations

LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)2 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)2 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)1 RecordLayerTable (com.revolsys.swing.map.layer.record.table.RecordLayerTable)1 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)1 BaseJPopupMenu (com.revolsys.swing.menu.BaseJPopupMenu)1 JMenuItem (javax.swing.JMenuItem)1