Search in sources :

Example 6 with MenuFactory

use of com.revolsys.swing.menu.MenuFactory in project com.revolsys.open by revolsys.

the class LambdaTableModelColumn method withHeaderMenu.

public LambdaTableModelColumn<R, V> withHeaderMenu(final BiConsumer<LambdaTableModelColumn<R, V>, MenuFactory> action) {
    final MenuFactory headerMenuFactory = getHeaderMenuFactory();
    action.accept(this, headerMenuFactory);
    return this;
}
Also used : MenuFactory(com.revolsys.swing.menu.MenuFactory)

Example 7 with MenuFactory

use of com.revolsys.swing.menu.MenuFactory in project com.revolsys.open by revolsys.

the class ProjectFrame method newMenuTools.

protected MenuFactory newMenuTools() {
    final MenuFactory tools = new MenuFactory("Tools");
    final MapPanel map = getMapPanel();
    final MeasureOverlay measureOverlay = map.getMapOverlay(MeasureOverlay.class);
    tools.addCheckboxMenuItem("map", new RunnableAction("Measure Length", Icons.getIcon("ruler_line"), () -> measureOverlay.toggleMeasureMode(DataTypes.LINE_STRING)), new ObjectPropertyEnableCheck(measureOverlay, "measureDataType", DataTypes.LINE_STRING));
    tools.addCheckboxMenuItem("map", new RunnableAction("Measure Area", Icons.getIcon("ruler_polygon"), () -> measureOverlay.toggleMeasureMode(DataTypes.POLYGON)), new ObjectPropertyEnableCheck(measureOverlay, "measureDataType", DataTypes.POLYGON));
    tools.addMenuItem("script", "Run Script...", "script_go", this::actionRunScript);
    return tools;
}
Also used : ObjectPropertyEnableCheck(com.revolsys.swing.action.enablecheck.ObjectPropertyEnableCheck) MeasureOverlay(com.revolsys.swing.map.overlay.MeasureOverlay) MenuFactory(com.revolsys.swing.menu.MenuFactory) RunnableAction(com.revolsys.swing.action.RunnableAction)

Example 8 with MenuFactory

use of com.revolsys.swing.menu.MenuFactory in project com.revolsys.open by revolsys.

the class AbstractRecordLayer method initRecordMenu.

protected LayerRecordMenu initRecordMenu() {
    final LayerRecordMenu menu = new LayerRecordMenu(this);
    this.recordMenu = menu;
    if (this.recordDefinition != null) {
        final RecordDefinition recordDefinition = getRecordDefinition();
        final boolean hasGeometry = recordDefinition.hasGeometryField();
        final Predicate<LayerRecord> modified = LayerRecord::isModified;
        final Predicate<LayerRecord> notDeleted = ((Predicate<LayerRecord>) this::isDeleted).negate();
        final Predicate<LayerRecord> modifiedOrDeleted = modified.or(LayerRecord::isDeleted);
        final EnableCheck editableEnableCheck = this::isEditable;
        menu.addGroup(0, "default");
        menu.addGroup(1, "record");
        menu.addGroup(2, "dnd");
        final MenuFactory layerMenuFactory = MenuFactory.findMenu(this);
        if (layerMenuFactory != null) {
            menu.addComponentFactory("default", 0, new WrappedMenuFactory("Layer", layerMenuFactory));
        }
        menu.addMenuItem("record", "View/Edit Record", "table_edit", notDeleted, this::showForm);
        if (hasGeometry) {
            menu.addMenuItem("record", "Zoom to Record", "magnifier_zoom_selected", notDeleted, this::zoomToRecord);
            menu.addMenuItem("record", "Pan to Record", "pan_selected", notDeleted, (record) -> {
                final MapPanel mapPanel = getMapPanel();
                if (mapPanel != null) {
                    mapPanel.panToRecord(record);
                }
            });
            final MenuFactory editMenu = new MenuFactory("Edit Record Operations");
            editMenu.setEnableCheck(LayerRecordMenu.enableCheck(notDeleted));
            final DataType geometryDataType = recordDefinition.getGeometryField().getDataType();
            if (geometryDataType == DataTypes.LINE_STRING || geometryDataType == DataTypes.MULTI_LINE_STRING) {
                if (DirectionalFields.getProperty(recordDefinition).hasDirectionalFields()) {
                    LayerRecordMenu.addMenuItem(editMenu, "geometry", LayerRecordForm.FLIP_RECORD_NAME, LayerRecordForm.FLIP_RECORD_ICON, editableEnableCheck, this::actionFlipRecordOrientation);
                    LayerRecordMenu.addMenuItem(editMenu, "geometry", LayerRecordForm.FLIP_LINE_ORIENTATION_NAME, LayerRecordForm.FLIP_LINE_ORIENTATION_ICON, editableEnableCheck, this::actionFlipLineOrientation);
                    LayerRecordMenu.addMenuItem(editMenu, "geometry", LayerRecordForm.FLIP_FIELDS_NAME, LayerRecordForm.FLIP_FIELDS_ICON, editableEnableCheck, this::actionFlipFields);
                } else {
                    LayerRecordMenu.addMenuItem(editMenu, "geometry", "Flip Line Orientation", "flip_line", editableEnableCheck, this::actionFlipLineOrientation);
                }
            }
            menu.addComponentFactory("record", editMenu);
        }
        menu.addMenuItem("record", "Delete Record", "table_row_delete", LayerRecord::isDeletable, this::deleteRecord);
        menu.addMenuItem("record", "Revert Record", "arrow_revert", modifiedOrDeleted, LayerRecord::revertChanges);
        final Predicate<LayerRecord> hasModifiedEmptyFields = LayerRecord::isHasModifiedEmptyFields;
        menu.addMenuItem("record", "Revert Empty Fields", "field_empty_revert", hasModifiedEmptyFields, LayerRecord::revertEmptyFields);
        menu.addMenuItem("dnd", "Copy Record", "page_copy", this::copyRecordToClipboard);
        if (hasGeometry) {
            menu.addMenuItem("dnd", "Paste Geometry", "geometry_paste", this::canPasteRecordGeometry, this::pasteRecordGeometry);
        }
    }
    return menu;
}
Also used : MapPanel(com.revolsys.swing.map.MapPanel) WrappedMenuFactory(com.revolsys.swing.menu.WrappedMenuFactory) MenuFactory(com.revolsys.swing.menu.MenuFactory) WrappedMenuFactory(com.revolsys.swing.menu.WrappedMenuFactory) DataType(com.revolsys.datatype.DataType) EnableCheck(com.revolsys.swing.action.enablecheck.EnableCheck) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 9 with MenuFactory

use of com.revolsys.swing.menu.MenuFactory in project com.revolsys.open by revolsys.

the class BaseTreeListener method popup.

private void popup(final MouseEvent e) {
    if (this.tree.isMenuEnabled()) {
        final int x = e.getX() + 5;
        final int y = e.getY();
        final TreePath path = this.tree.getPathForLocation(x, y);
        if (path != null) {
            TreePath[] selectionPaths = this.tree.getSelectionPaths();
            if (selectionPaths == null || !Arrays.asList(selectionPaths).contains(path)) {
                selectionPaths = new TreePath[] { path };
                this.tree.setSelectionPaths(selectionPaths);
            }
            final MenuFactory menu = this.tree.getMenuFactory(path);
            final BaseTreeNode node = (BaseTreeNode) path.getLastPathComponent();
            BaseTree.setMenuNode(node);
            Object userObject = node.getUserObject();
            if (userObject == null) {
                userObject = node;
            }
            if (menu != null) {
                menu.showMenu(userObject, this.tree, x, y);
            }
        }
        this.tree.repaint();
    }
}
Also used : MenuFactory(com.revolsys.swing.menu.MenuFactory) TreePath(javax.swing.tree.TreePath)

Aggregations

MenuFactory (com.revolsys.swing.menu.MenuFactory)9 RecordDefinition (com.revolsys.record.schema.RecordDefinition)3 EnableCheck (com.revolsys.swing.action.enablecheck.EnableCheck)3 ObjectPropertyEnableCheck (com.revolsys.swing.action.enablecheck.ObjectPropertyEnableCheck)3 MapPanel (com.revolsys.swing.map.MapPanel)3 DataType (com.revolsys.datatype.DataType)2 RunnableAction (com.revolsys.swing.action.RunnableAction)2 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)2 ToolBar (com.revolsys.swing.toolbar.ToolBar)2 Component (java.awt.Component)2 LinkedHashMapEx (com.revolsys.collection.map.LinkedHashMapEx)1 MapEx (com.revolsys.collection.map.MapEx)1 Maps (com.revolsys.collection.map.Maps)1 Identifier (com.revolsys.identifier.Identifier)1 MapSerializer (com.revolsys.io.map.MapSerializer)1 Condition (com.revolsys.record.query.Condition)1 FieldDefinition (com.revolsys.record.schema.FieldDefinition)1 Icons (com.revolsys.swing.Icons)1 ConsumerAction (com.revolsys.swing.action.ConsumerAction)1 FieldNamesSetPanel (com.revolsys.swing.map.form.FieldNamesSetPanel)1