Package com.volantis.mcs.eclipse.ab.actions

Examples of com.volantis.mcs.eclipse.ab.actions.ODOMAction


    protected static void populateUndefinedSubMenuActions(Map actions) {
        // Build the New sub-menu
        SubMenuAction newMenu =
                (SubMenuAction) actions.get(ActionID.UNDEFINED_NEW_MENU);

        newMenu.add(new ODOMAction(new DefaultActionCommand(),
                BUNDLE,
                "dummy")); //$NON-NLS-1$

        // Build the Wrap sub-menu
        SubMenuAction wrapMenu =
                (SubMenuAction) actions.get(ActionID.UNDEFINED_WRAP_MENU);

        wrapMenu.add(new ODOMAction(new DefaultActionCommand(),
                BUNDLE,
                "dummy")); //$NON-NLS-1$
    }
View Full Code Here


                    selectNewPolicy(policyName);
                }
            }
        };

        newPolicyAction = new ODOMAction(command,
                context,
                null,
                DevicesMessages.getResourceBundle(),
                RESOURCE_PREFIX + "newPolicy.");

        // Delete policy
        command = new ODOMActionCommand() {
            public boolean enable(ODOMActionDetails details) {
                boolean enabled = categoriesComposite.getSelectedPolicyElement()
                        != null;

                if (enabled) {
                    // New policy is always enabled in admin mode when there
                    // is a selection.
                    enabled = context.isAdminProject();
                    if (!enabled) {
                        String categoryName = categoriesComposite.
                                getSelectedCategoryElement().
                                getAttributeValue(DeviceRepositorySchemaConstants.
                                CATEGORY_NAME_ATTRIBUTE);
                        enabled = categoryName.equals(
                                DeviceRepositorySchemaConstants.CUSTOM_CATEGORY_NAME);
                    }
                }
                return enabled;
            }

            public void run(ODOMActionDetails details) {
                final String selectedPolicy = details.getElement(0).
                        getAttributeValue(DeviceRepositorySchemaConstants.
                        POLICY_NAME_ATTRIBUTE);
                final String dialogMessage =
                        POLICY_DELETION_DIALOG_MESSAGE_FORMAT.format(
                                new Object[]{selectedPolicy});

                // Get the shell for the dialog.
                final Shell shell =
                        categoriesComposite.getShell();

                // Create the confirmation dialog for the policy deletion.
                // The Yes button is at index 0 and has focus. There is no
                // image.
                final MessageDialog dialog = new MessageDialog(
                        shell,
                        POLICY_DELETION_DIALOG_TITLE,
                        null,
                        dialogMessage,
                        MessageDialog.INFORMATION, new String[]{
                            POLICY_DELETION_DIALOG_YES_TEXT,
                            POLICY_DELETION_DIALOG_NO_TEXT},
                        0);
                // Open the dialog.
                dialog.open();

                // Only delete the policy if the user has confirmed the action
                // by pressing the Yes button at index 0.
                if (dialog.getReturnCode() == 0) {
                    // Delete takes a while so use a BusyIndicator.
                    BusyIndicator.showWhile(shell.getDisplay(),
                            new Runnable() {
                                public void run() {
                                    // BusyIndicator should display a busy
                                    // cursor automatically, but for some
                                    // reason does not do so here (it works
                                    // elsewhere within MCS). Experimentation
                                    // showed that manually setting a busy
                                    // cursor with Display.asyncExec or
                                    // Display.syncExec still did not produce
                                    // a busy cursor. Strangely, the only
                                    // combination that did work was manually
                                    // setting the busy cursor with
                                    // BusyIndicator.showWhile!
                                    // Also, NOT using any of Display.syncExec,
                                    // Display.asyncExec and BusyIndicator,
                                    // but running the code "as is" with manual
                                    // setting of the cursor also did NOT work.
                                    // @todo This is odd. BusyIndicator is broken?
                                    final Cursor busyCursor =
                                            new Cursor(shell.getDisplay(),
                                                    SWT.CURSOR_WAIT);

                                    shell.setCursor(busyCursor);
                                    try {
                                        // we don't allow policy deletions to
                                        // be undoable
                                        context.getUndoRedoManager().enable(false);
                                        String policyName = categoriesComposite.
                                                getSelectedPolicyElement().
                                                getAttributeValue(
                                                        DeviceRepositorySchemaConstants.
                                                POLICY_NAME_ATTRIBUTE);
                                        context.getDeviceRepositoryAccessorManager().
                                                cleansePolicy(policyName);
                                    } catch (RepositoryException e) {
                                        EclipseCommonPlugin.handleError(ABPlugin.
                                                getDefault(), e);
                                    } finally {
                                        // ensure the undo redo manager is enabled.
                                        context.getUndoRedoManager().enable(true);

                                        // Restore the shell's default cursor
                                        // and dispose of the busy cursor
                                        // resources.
                                        shell.setCursor(null);
                                    }
                                }
                            });
                }
            }
        };

        deletePolicyAction = new ODOMAction(command,
                context,
                null,
                DevicesMessages.getResourceBundle(),
                RESOURCE_PREFIX + "deletePolicy.");
    }
View Full Code Here

                new SubMenuAction(
                        new DefaultActionCommand(),
                        LayoutActions.BUNDLE,
                        ActionID.NEW_PANE_MENU.getPrefix()));
        actions.put(ActionID.NEW_PANE,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.PANE,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_PANE.getPrefix()));
        actions.put(ActionID.NEW_ROW_ITERATOR_PANE,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.ROW_ITERATOR_PANE,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_ROW_ITERATOR_PANE.getPrefix()));
        actions.put(ActionID.NEW_COLUMN_ITERATOR_PANE,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.COLUMN_ITERATOR_PANE,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_COLUMN_ITERATOR_PANE.getPrefix()));
        actions.put(ActionID.NEW_DISSECTING_PANE,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.DISSECTING_PANE,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_DISSECTING_PANE.getPrefix()));
        actions.put(ActionID.NEW_ITERATOR_MENU,
                new SubMenuAction(
                        new DefaultActionCommand(),
                        LayoutActions.BUNDLE,
                        ActionID.NEW_ITERATOR_MENU.getPrefix()));
        actions.put(ActionID.NEW_SPATIAL_ITERATOR,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.SPATIAL_FORMAT_ITERATOR,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_SPATIAL_ITERATOR.getPrefix()));
        actions.put(ActionID.NEW_TEMPORAL_ITERATOR,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.TEMPORAL_FORMAT_ITERATOR,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_TEMPORAL_ITERATOR.getPrefix()));
        actions.put(ActionID.NEW_GRID_MENU,
                new SubMenuAction(
                        new DefaultActionCommand(),
                        LayoutActions.BUNDLE,
                        ActionID.NEW_GRID_MENU.getPrefix()));
        actions.put(ActionID.NEW_2_COLUMN_GRID,
                new ODOMAction(
                        new NewGridFormatActionCommand(FormatType.GRID,
                                manager) {
                            protected Dimension getGridDimensions() {
                                return new Dimension(2, 1);
                            }
                        },
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_2_COLUMN_GRID.getPrefix()));
        actions.put(ActionID.NEW_3_ROW_GRID,
                new ODOMAction(
                        new NewGridFormatActionCommand(FormatType.GRID,
                                manager) {
                            protected Dimension getGridDimensions() {
                                return new Dimension(1, 3);
                            }
                        },
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_3_ROW_GRID.getPrefix()));
        actions.put(ActionID.NEW_N_BY_M_GRID,
                new ODOMAction(
                        new NewGridFormatActionCommand(FormatType.GRID,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_N_BY_M_GRID.getPrefix()));
        actions.put(ActionID.NEW_FRAGMENT,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.FRAGMENT, manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_FRAGMENT.getPrefix()));
        actions.put(ActionID.NEW_FORM,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.FORM,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_FORM.getPrefix()));
        actions.put(ActionID.NEW_REGION,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.REGION,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_REGION.getPrefix()));
        actions.put(ActionID.NEW_REPLICA,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.REPLICA,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_REPLICA.getPrefix()));
        actions.put(ActionID.NEW_FORM_FRAGMENT,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.FORM_FRAGMENT,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_FORM_FRAGMENT.getPrefix()));

        actions.put(ActionID.MONTAGE_NEW_MENU,
                new SubMenuAction(
                        new NewMenuActionCommand(manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.MONTAGE_NEW_MENU.getPrefix()));
        actions.put(ActionID.NEW_SEGMENT_GRID_MENU,
                new SubMenuAction(
                        new DefaultActionCommand(),
                        LayoutActions.BUNDLE,
                        ActionID.NEW_SEGMENT_GRID_MENU.getPrefix()));
        actions.put(ActionID.NEW_2_COLUMN_SEGMENT_GRID,
                new ODOMAction(
                        new NewGridFormatActionCommand(
                                FormatType.SEGMENT_GRID,
                                manager) {
                            protected Dimension getGridDimensions() {
                                return new Dimension(2, 1);
                            }
                        },
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_2_COLUMN_SEGMENT_GRID.getPrefix()));
        actions.put(ActionID.NEW_3_ROW_SEGMENT_GRID,
                new ODOMAction(
                        new NewGridFormatActionCommand(
                                FormatType.SEGMENT_GRID,
                                manager) {
                            protected Dimension getGridDimensions() {
                                return new Dimension(1, 3);
                            }
                        },
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_3_ROW_SEGMENT_GRID.getPrefix()));
        actions.put(ActionID.NEW_N_BY_M_SEGMENT_GRID,
                new ODOMAction(
                        new NewGridFormatActionCommand(
                                FormatType.SEGMENT_GRID,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_N_BY_M_SEGMENT_GRID.getPrefix()));
        actions.put(ActionID.NEW_SEGMENT,
                new ODOMAction(
                        new NewNonGridFormatActionCommand(
                                FormatType.SEGMENT,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.NEW_SEGMENT.getPrefix()));

        actions.put(ActionID.UNDEFINED_NEW_MENU,
                new SubMenuAction(
                        new DefaultActionCommand() {
                            // javadoc inherited
                            public boolean enable(ODOMActionDetails context) {
                                return false;
                            }
                        },
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.UNDEFINED_NEW_MENU.getPrefix()));

        actions.put(ActionID.CANVAS_WRAP_MENU,
                new SubMenuAction(
                        new WrapMenuActionCommand(manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.CANVAS_WRAP_MENU.getPrefix()));
        actions.put(ActionID.WRAP_ITERATOR_MENU,
                new SubMenuAction(
                        new DefaultActionCommand(),
                        LayoutActions.BUNDLE,
                        ActionID.WRAP_ITERATOR_MENU.getPrefix()));
        actions.put(ActionID.WRAP_SPATIAL_ITERATOR,
                new ODOMAction(
                        new WrapNonGridFormatActionCommand(
                                FormatType.SPATIAL_FORMAT_ITERATOR,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.WRAP_SPATIAL_ITERATOR.getPrefix()));
        actions.put(ActionID.WRAP_TEMPORAL_ITERATOR,
                new ODOMAction(
                        new WrapNonGridFormatActionCommand(
                                FormatType.TEMPORAL_FORMAT_ITERATOR,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.WRAP_TEMPORAL_ITERATOR.getPrefix()));
        actions.put(ActionID.WRAP_N_BY_M_GRID,
                new ODOMAction(
                        new WrapGridFormatActionCommand(FormatType.GRID,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.WRAP_N_BY_M_GRID.getPrefix()));
        actions.put(ActionID.WRAP_FRAGMENT,
                new ODOMAction(
                        new WrapNonGridFormatActionCommand(
                                FormatType.FRAGMENT, manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.WRAP_FRAGMENT.getPrefix()));
        actions.put(ActionID.WRAP_FORM,
                new ODOMAction(
                        new WrapNonGridFormatActionCommand(
                                FormatType.FORM,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.WRAP_FORM.getPrefix()));
        actions.put(ActionID.WRAP_FORM_FRAGMENT,
                new ODOMAction(
                        new WrapNonGridFormatActionCommand(
                                FormatType.FORM_FRAGMENT,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.WRAP_FORM_FRAGMENT.getPrefix()));

        actions.put(ActionID.MONTAGE_WRAP_MENU,
                new SubMenuAction(
                        new WrapMenuActionCommand(manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.MONTAGE_WRAP_MENU.getPrefix()));
        actions.put(ActionID.WRAP_N_BY_M_SEGMENT_GRID,
                new ODOMAction(
                        new WrapGridFormatActionCommand(
                                FormatType.SEGMENT_GRID,
                                manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.WRAP_N_BY_M_SEGMENT_GRID.getPrefix()));

        actions.put(ActionID.UNDEFINED_WRAP_MENU,
                new SubMenuAction(
                        new DefaultActionCommand() {
                            // javadoc inherited
                            public boolean enable(ODOMActionDetails context) {
                                return false;
                            }
                        },
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.UNDEFINED_WRAP_MENU.getPrefix()));

        actions.put(ActionID.CUT,
                new ODOMAction(
                        new CutActionCommand(
                                EclipseCommonPlugin.getClipboard(
                                        Display.getDefault()), manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.CUT.getPrefix()));
        actions.put(ActionID.COPY,
                new ODOMAction(
                        new CopyActionCommand(
                                EclipseCommonPlugin.getClipboard(
                                        Display.getDefault()), manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.COPY.getPrefix()));
        actions.put(ActionID.PASTE,
                new ODOMAction(
                        new PasteActionCommand(
                                EclipseCommonPlugin.getClipboard(
                                        Display.getDefault()),
                                context),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.PASTE.getPrefix()));
        actions.put(ActionID.DELETE,
                new ODOMAction(
                        new DeleteActionCommand(manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.DELETE.getPrefix()));
        actions.put(ActionID.REPLACE,
                new ODOMAction(
                        new ReplaceActionCommand(
                                EclipseCommonPlugin.getClipboard(
                                        Display.getDefault()),
                                context),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.REPLACE.getPrefix()));
        actions.put(ActionID.SWAP,
                new ODOMAction(new SwapActionCommand(manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.SWAP.getPrefix()));
        actions.put(ActionID.GRID_MODIFY_MENU,
                new SubMenuAction(
                        // @todo later implement: placeholder only
                        new DefaultActionCommand(),
                        LayoutActions.BUNDLE,
                        ActionID.GRID_MODIFY_MENU.getPrefix()));
        actions.put(ActionID.INSERT_ROWS,
                new ODOMAction(
                        new RowInsertActionCommand(manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.INSERT_ROWS.getPrefix()));
        actions.put(ActionID.INSERT_COLUMNS,
                new ODOMAction(
                        new ColumnInsertActionCommand(manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.INSERT_COLUMNS.getPrefix()));
        actions.put(ActionID.DELETE_COLUMN,
                new ODOMAction(
                        new ColumnDeleteActionCommand(manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.DELETE_COLUMN.getPrefix()));
        actions.put(ActionID.DELETE_ROW,
                new ODOMAction(
                        new RowDeleteActionCommand(manager),
                        context,
                        null,
                        LayoutActions.BUNDLE,
                        ActionID.DELETE_ROW.getPrefix()));
View Full Code Here

TOP

Related Classes of com.volantis.mcs.eclipse.ab.actions.ODOMAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.