Example usage for org.eclipse.jface.action IContributionManager add

List of usage examples for org.eclipse.jface.action IContributionManager add

Introduction

In this page you can find the example usage for org.eclipse.jface.action IContributionManager add.

Prototype

void add(IContributionItem item);

Source Link

Document

Adds a contribution item to this manager.

Usage

From source file:de.walware.statet.rtm.ftable.internal.ui.editors.FTableActionBarContributor.java

License:Open Source License

/**
 * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
 * by inserting them before the specified contribution item <code>contributionID</code>.
 * If <code>contributionID</code> is <code>null</code>, they are simply added.
 * <!-- begin-user-doc -->/*from  w ww . j  a  va  2 s .com*/
 * <!-- end-user-doc -->
 * @generated
 */
protected void populateManager(final IContributionManager manager, final Collection<? extends IAction> actions,
        final String contributionID) {
    if (actions != null) {
        for (final IAction action : actions) {
            if (contributionID != null) {
                manager.insertBefore(contributionID, action);
            } else {
                manager.add(action);
            }
        }
    }
}

From source file:es.cv.gvcase.ide.navigator.provider.MOSKittSubmenuActionProvider.java

License:Open Source License

/**
 * Fills a {@link IContributionManager} with two levels of menus, as
 * specified by the {@link Map} of {@link String}s to {@link Collection}s of
 * {@link IAction}s./*from  www.  j  a va  2s. com*/
 * 
 * @param manager
 *            the manager
 * @param submenuActions
 *            the submenu actions
 * @param contributionID
 *            the contribution id
 */
protected void populateManager(IContributionManager manager, Map<String, Collection<IAction>> submenuActions,
        String contributionID) {
    if (submenuActions != null) {
        for (Map.Entry<String, Collection<IAction>> entry : submenuActions.entrySet()) {
            MenuManager submenuManager = new MenuManager(entry.getKey());
            if (contributionID != null) {
                manager.insertBefore(contributionID, submenuManager);
            } else {
                manager.add(submenuManager);
            }
            populateManager(submenuManager, entry.getValue(), null);
        }
    }
}

From source file:fable.imageviewer.component.ImageComponentUI.java

License:Open Source License

private void createImageControlSwitches(final IActionBars iActionBars) {

    final IContributionManager man = iActionBars.getToolBarManager();
    man.add(new Separator(getClass().getName() + ".switches1"));
    man.add(actions.showHeaderTableAction);

    man.add(new Separator(getClass().getName() + ".switches2"));

    // Row 2//  www  .j a v  a 2 s  .  co  m
    autoscaleButton = new Action("Autoscale Intensity", IAction.AS_CHECK_BOX) {
        public void run() {
            resetAutoscale(true);
            image.displayImage();
        }
    };
    man.add(autoscaleButton);
    autoscaleButton.setText("Autoscale Intensity");
    autoscaleButton
            .setToolTipText("Scale the palette between the " + "minimum and maximum intensity in the data");
    autoscaleButton.setChecked(
            Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.P_AUTOSCALE));
    autoscaleButton.setImageDescriptor(Activator.getImageDescriptor("/icons/autoscale.png"));

    // Row 3
    aspectButton = new Action("Keep Aspect", IAction.AS_CHECK_BOX) {
        public void run() {
            Activator.getDefault().getPreferenceStore().setValue(PreferenceConstants.P_KEEPASPECT, isChecked());
            image.clearCanvas();
            image.displayImage();
        }
    };
    man.add(aspectButton);
    aspectButton.setText("Keep Aspect");
    aspectButton.setToolTipText("Keep aspect ratio when displaying image");

    final boolean isKeepAspect = Activator.getDefault().getPreferenceStore()
            .getBoolean(PreferenceConstants.P_KEEPASPECT);
    aspectButton.setChecked(isKeepAspect);
    aspectButton.setImageDescriptor(Activator.getImageDescriptor("/icons/aspect.gif"));

    peaksButton = new Action("Show Peaks", IAction.AS_CHECK_BOX) {
        public void run() {
            iv.setPeaksOn(peaksButton.isChecked());
            image.displayImage();
        }
    };
    man.add(peaksButton);
    peaksButton.setText("Show Peaks");
    peaksButton.setToolTipText("Display peaks");
    peaksButton.setChecked(iv.isPeaksOn());
    peaksButton.setImageDescriptor(Activator.getImageDescriptor("/icons/chart_curve_go.png"));

}

From source file:fable.imageviewer.component.ImageComponentUI.java

License:Open Source License

private void createImageControlMenus(final IActionBars iActionBars) {

    final IContributionManager man = iActionBars.getMenuManager();
    man.add(new Separator(getClass().getName() + "menus"));

    final IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
    int orientation = prefs.getInt(PreferenceConstants.P_ORIENT);
    iv.setOrientation(orientation);/*  w w  w  .ja  v  a2  s  .c o  m*/

    // TODO Icons
    orientCombo = new MenuAction("Orientation", false);
    orientCombo.setId(getClass().getName() + orientCombo.getText());
    man.add(orientCombo);

    CheckableActionGroup group = new CheckableActionGroup();
    for (int i = 0; i < 8; i++) {
        final int index = i;
        final Action action = new Action(orientNameValues[i][0], IAction.AS_CHECK_BOX) {
            public void run() {
                iv.setOrientation(index);
            }
        };
        group.add(action);
        orientCombo.add(action);
        action.setChecked(index == orientation);
    }
    orientCombo.setToolTipText("Adjust the orientation with O parameters " + "(o11 o12 o21 o22)");

    orientCombo.setImageDescriptor(Activator.getImageDescriptor("/icons/orientation.gif"));
    man.add(new Separator(getClass().getName() + "orient"));

    // Initialize the custom saved parameters
    if (!customSavedParametersInitialized) {
        // Keep the item being processed for the possible error message
        String processing = "xName";
        try {
            iv.setXNameSave(prefs.getString(PreferenceConstants.P_COORD_XNAME));
            processing = "yName";
            iv.setYNameSave(prefs.getString(PreferenceConstants.P_COORD_YNAME));
            processing = "x0";
            iv.setX0Save(Double.parseDouble(prefs.getString(PreferenceConstants.P_COORD_X0)));
            processing = "y0";
            iv.setY0Save(Double.parseDouble(prefs.getString(PreferenceConstants.P_COORD_Y0)));
            processing = "pixelHeight";
            iv.setPixelWidthSave(Double.parseDouble(prefs.getString(PreferenceConstants.P_COORD_PIXELWIDTH)));
            processing = "pixelHeight";
            iv.setPixelHeightSave(Double.parseDouble(prefs.getString(PreferenceConstants.P_COORD_PIXELHEIGHT)));
            customSavedParametersInitialized = true;
        } catch (NumberFormatException ex) {
            FableUtils.excMsg(this, "Error setting custom coordinates" + " from preferences for " + processing,
                    ex);
        }
    }

    // Orientation
    int coordOrigin = prefs.getInt(PreferenceConstants.P_COORD);
    coordCombo = new MenuAction("Coordinates", false);
    coordCombo.setImageDescriptor(Activator.getImageDescriptor("/icons/coords.png"));
    coordCombo.setId(getClass().getName() + coordCombo.getText());
    man.add(coordCombo);
    group = new CheckableActionGroup();
    for (int i = 0; i < 5; i++) {
        final int index = i;
        final Action action = new Action(coordNameValues[i][0], IAction.AS_CHECK_BOX) {
            public void run() {
                setCoordinateChoice(index);
            }
        };
        group.add(action);
        coordCombo.add(action);
        action.setChecked(index == coordOrigin);
    }
    coordCombo.setToolTipText("Select the origin of the coordinate system for mouse movement");
    man.add(new Separator(getClass().getName() + "coord"));

    // Default (will be zero if not found)
    if (coordOrigin == COORD_CUSTOM) {
        Coordinates coordinates = iv.getCoordinates();
        try {
            coordinates.reset(coordOrigin, iv.getX0Save(), iv.getY0Save(), iv.getPixelWidthSave(),
                    iv.getPixelHeightSave(), iv.getXNameSave(), iv.getYNameSave());
        } catch (NumberFormatException ex) {
            FableUtils.excMsg(this, "Error setting custom coordinates", ex);
            coordinates.resetToDefault();
        }
    } else {
        iv.resetCoordinates();
    }

    // Palette
    int paletteIndex = prefs.getInt(PreferenceConstants.P_PALETTE);
    iv.setPalette(paletteIndex);

    lutCombo = new MenuAction("Color", false);
    lutCombo.setId(getClass().getName() + lutCombo.getText());
    lutCombo.setImageDescriptor(Activator.getImageDescriptor("/icons/color_wheel.png"));
    man.add(lutCombo);
    group = new CheckableActionGroup();
    for (final String paletteName : PaletteFactory.PALETTES.keySet()) {
        final Action action = new Action(paletteName, IAction.AS_CHECK_BOX) {
            public void run() {
                int paletteIndex = PaletteFactory.PALETTES.get(paletteName);
                iv.setPalette(paletteIndex);
                setChecked(PaletteFactory.PALETTES.get(paletteName) == paletteIndex);
            }
        };
        group.add(action);
        lutCombo.add(action);
        action.setChecked(PaletteFactory.PALETTES.get(paletteName) == paletteIndex);
    }
    lutCombo.setToolTipText("Set the Color Map");

    man.add(new Separator(getClass().getName() + "menusend"));

}

From source file:fable.imageviewer.views.ReliefView.java

License:Open Source License

private void createActions() {

    final IContributionManager man = getViewSite().getActionBars().getToolBarManager();

    freezeButton = new Action("Freeze", IAction.AS_CHECK_BOX) {
        public void run() {
            freeze = freezeButton.isChecked();
        }/*from w w w .  ja  v  a  2 s  .c  om*/
    };
    freezeButton.setToolTipText("Freeze 3d relief, disable rotation");
    freezeButton.setImageDescriptor(Activator.getImageDescriptor("/icons/freeze.png"));
    man.add(freezeButton);

    man.add(new Separator(getClass().getName() + ".zoom"));

    final Action zoomIn = new Action("Zoom In", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.zoomIn();
        }
    };
    zoomIn.setToolTipText("Zoom in (Page Up)");
    zoomIn.setImageDescriptor(Activator.getImageDescriptor("/icons/magnifier_zoom_in.png"));
    man.add(zoomIn);

    final Action zoomOut = new Action("Zoom Out", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.zoomOut();
        }
    };
    zoomOut.setToolTipText("Zoom out (Page Down)");
    zoomOut.setImageDescriptor(Activator.getImageDescriptor("/icons/magnifier_zoom_out.png"));
    man.add(zoomOut);

    man.add(new Separator(getClass().getName() + ".translate"));

    Action action = new Action("Translate up", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.translate(SWT.ARROW_UP);
        }
    };
    action.setToolTipText("Translate up (Up Arrow)");
    action.setImageDescriptor(Activator.getImageDescriptor("/icons/arrow_up.png"));
    man.add(action);

    action = new Action("Translate down", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.translate(SWT.ARROW_DOWN);
        }
    };
    action.setToolTipText("Translate down (Down Arrow)");
    action.setImageDescriptor(Activator.getImageDescriptor("/icons/arrow_down.png"));
    man.add(action);

    action = new Action("Translate left", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.translate(SWT.ARROW_LEFT);
        }
    };
    action.setToolTipText("Translate left (Left Arrow)");
    action.setImageDescriptor(Activator.getImageDescriptor("/icons/arrow_left.png"));
    man.add(action);

    action = new Action("Translate right", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.translate(SWT.ARROW_RIGHT);
        }
    };
    action.setToolTipText("Translate right (Right Arrow)");
    action.setImageDescriptor(Activator.getImageDescriptor("/icons/arrow_right.png"));
    man.add(action);

    man.add(new Separator(getClass().getName() + ".rotate"));

    action = new Action("Rotate X, high Y", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.rotate(SWT.ARROW_UP);
        }
    };
    action.setToolTipText("Rotate X, high Y (Control + Up Arrow)");
    action.setImageDescriptor(Activator.getImageDescriptor("/icons/rotate_up.png"));
    man.add(action);

    action = new Action("Rotate X, low Y", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.rotate(SWT.ARROW_DOWN);
        }
    };
    action.setToolTipText("Rotate X, low Y (Contol + Down Arrow)");
    action.setImageDescriptor(Activator.getImageDescriptor("/icons/rotate_down.png"));
    man.add(action);

    action = new Action("Rotate Y, low X", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.rotate(SWT.ARROW_LEFT);
        }
    };
    action.setToolTipText("Rotate Y, low X (Control + Left Arrow)");
    action.setImageDescriptor(Activator.getImageDescriptor("/icons/rotate_left.png"));
    man.add(action);

    action = new Action("Rotate Y, high X", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.rotate(SWT.ARROW_RIGHT);
        }
    };
    action.setToolTipText("Rotate Y, high X (Control + Right Arrow)");
    action.setImageDescriptor(Activator.getImageDescriptor("/icons/rotate_right.png"));
    man.add(action);

    man.add(new Separator(getClass().getName() + ".reset"));
    highZReset = new Action("Reset", IAction.AS_PUSH_BUTTON) {
        public void run() {
            grip.init();
        }
    };
    highZReset.setText("Reset");
    highZReset.setToolTipText("Reset 3d projection to be flat and fill the canvas and use X/Y view.");
    highZReset.setImageDescriptor(Activator.getImageDescriptor("/icons/z-high.png"));
    man.add(highZReset);

    autoscaleButton = new Action("Autoscale", IAction.AS_CHECK_BOX) {
        public void run() {
            if (autoscaleButton.isChecked()) {
                if (!autoscale) {
                    autoscale = true;
                    scaleImage();
                    drawReliefList();
                }
                minimumSpinner.setEnabled(false);
                maximumSpinner.setEnabled(false);
            } else {
                if (autoscale) {
                    autoscale = false;
                    scaleImage();
                    drawReliefList();
                }
                minimumSpinner.setEnabled(true);
                maximumSpinner.setEnabled(true);
            }
        }
    };
    autoscaleButton.setText("Autoscale");
    autoscaleButton.setToolTipText("Autoscale 3d relief between minimum and mean");
    autoscaleButton.setImageDescriptor(Activator.getImageDescriptor("/icons/autoscale.png"));
    autoscaleButton.setChecked(true);
    man.add(autoscaleButton);

    updateButton = new Action("Refresh", IAction.AS_PUSH_BUTTON) {
        public void run() {
            scaleImage();
            drawReliefList();
            drawRelief();
        }
    };
    updateButton.setText("Refresh");
    updateButton.setToolTipText("Redraw 3d relief plot");
    updateButton.setImageDescriptor(Activator.getImageDescriptor("/icons/update.png"));
    man.add(updateButton);
}

From source file:fr.imag.adele.cadse.cadseg.menu.DefaultMenuContributor.java

License:Apache License

public IContributionItem findUsingPath(IContributionManager manager, String path) {
    String group;/*w ww  .j a va2s.  c  o m*/
    String rest = null;
    IContributionItem findMenuManager = null;
    int separator = path.indexOf('/');
    if (separator != -1) {
        group = path.substring(0, separator);
        rest = path.substring(separator + 1);
    } else {
        group = path;
    }
    findMenuManager = manager.find(group);
    if (findMenuManager == null) {
        findMenuManager = new Separator(group);
        manager.add(findMenuManager);
    }
    if (rest != null) {
        path = rest;
        separator = path.indexOf('/');
        String id;
        if (separator != -1) {
            id = path.substring(0, separator);
            rest = path.substring(separator + 1);
        } else {
            id = path;
        }
        findMenuManager = manager.find(id);
        if (findMenuManager == null) {
            findMenuManager = new MenuManager(id, id);
            manager.appendToGroup(group, findMenuManager);
        }
    }

    if (findMenuManager instanceof IMenuManager && rest != null) {
        manager = (IMenuManager) findMenuManager;
        return findUsingPath(manager, rest);
    }
    return findMenuManager;
}

From source file:net.bioclipse.plugins.views.ChartView.java

License:Open Source License

private void addActions(IContributionManager manager) {
    manager.add(saveImageActionSVG);
    manager.add(saveImageActionPNG);/*from w  w  w . j  a v  a 2  s.  c  om*/
    manager.add(saveImageActionJPG);
    manager.add(new Separator());
}

From source file:net.sourceforge.tagsea.core.ui.internal.tags.TagActionGroup.java

License:Open Source License

private void fillContributionManager(IContributionManager manager) {
    manager.add(renameAction);
    manager.add(generalizeAction);/*  ww  w .  ja v  a2  s  .  co  m*/
    manager.add(new Separator());
    manager.add(deleteAction);
    manager.add(new Separator());
    //      manager.add(openWaypointViewAction);

    //MenuManager viewMenu = new MenuManager("View", "view");

    //viewMenu.add(toggleTreeNamingAction);
    //manager.add(viewMenu);
}

From source file:org.apache.commons.jelly.tags.jface.ActionTag.java

License:Apache License

/**
  * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
  *//*  w  ww.  ja  v  a2s . c  o  m*/
public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {

    Map attributes = getAttributes();

    Action action = new ActionImpl();
    setBeanProperties(action, attributes);

    IContributionManager cm = getParentContributionManager();
    if (cm != null) {
        cm.add(action);
    }

    this.output = output;
}

From source file:org.apache.commons.jelly.tags.jface.ContributionItemTag.java

License:Apache License

/**
  * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
  *//*from  ww  w .  j a  v a 2  s.  c  o  m*/
public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {

    super.doTag(output);

    Object bean = getBean();
    if (bean != null && bean instanceof ContributionItem) {
        IContributionManager cm = getParentContributionManager();
        if (cm != null) {
            cm.add((ContributionItem) bean);
        }
    }

}