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

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

Introduction

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

Prototype

void add(IAction action);

Source Link

Document

Adds an action as a contribution item to this manager.

Usage

From source file:de.ovgu.featureide.fm.ui.views.outline.FmOutlinePageContextMenu.java

License:Open Source License

/**
 * @param iToolBarManager//  ww  w.ja v a2 s.  co  m
 */
public void addToolbar(IToolBarManager iToolBarManager) {
    iToolBarManager.add(collapseAllAction);
    iToolBarManager.add(expandAllAction);
}

From source file:de.ovgu.featureide.ui.views.collaboration.CollaborationView.java

License:Open Source License

private void fillLocalToolBar(IToolBarManager manager) {
    manager.add(toolbarAction);
    toolbarAction.setToolTipText(TOOL_TIP_LABEL);
    toolbarAction.setImageDescriptor(ImageDescriptor.createFromImage(REFESH_TAB_IMAGE));
}

From source file:de.ovgu.featureide.ui.views.collaboration.outline.CollaborationOutline.java

License:Open Source License

/**
 * provides functionality to expand and collapse all items in viewer
 * /* w  w w .  j  a  va2  s  .c o  m*/
 * @param iToolBarManager
 */
public void addToolbar(IToolBarManager iToolBarManager) {
    Action collapseAllAction = new Action() {
        public void run() {
            viewer.collapseAll();
            viewer.expandToLevel(2);
            viewer.refresh();
        }
    };
    collapseAllAction.setToolTipText("Collapse All");
    collapseAllAction.setImageDescriptor(IMG_COLLAPSE);

    Action expandAllAction = new Action() {
        public void run() {
            viewer.expandAll();
            // treeExpanded event is not triggered, so we manually have to
            // call this function
            colorizeItems(viewer.getTree().getItems());
        }
    };
    expandAllAction.setToolTipText("Expand All");
    expandAllAction.setImageDescriptor(IMG_EXPAND);

    iToolBarManager.add(collapseAllAction);
    iToolBarManager.add(expandAllAction);
}

From source file:de.ovgu.featureide.ui.views.collaboration.outline.ContextOutline.java

License:Open Source License

@Override
protected void initToolbarActions(IToolBarManager manager) {
    FilterOutlineAction hideAllFields = new FilterOutlineAction(new HideAllFields()) {
        @Override//from  www .j  av  a2 s.c o m
        public void run() {
            OutlineTreeContentProvider treeProvider = getTreeProvider();
            if (!treeProvider.hasFilter(getFilter())) {
                treeProvider.addFilter(getFilter());
            } else {
                treeProvider.removeFilter(getFilter());
            }
            viewer.setInput(file);
        }
    };
    manager.add(hideAllFields);
    FilterOutlineAction hideAllMethods = new FilterOutlineAction(new HideAllMethods()) {
        @Override
        public void run() {
            OutlineTreeContentProvider treeProvider = getTreeProvider();
            if (!treeProvider.hasFilter(getFilter())) {
                treeProvider.addFilter(getFilter());
            } else {
                treeProvider.removeFilter(getFilter());
            }
            viewer.setInput(file);
        }
    };
    manager.add(hideAllMethods);
    FilterOutlineAction sortByOccurrenceInFeature = new FilterOutlineAction(new SortByOccurrenceInFeature()) {
        @Override
        public void run() {
            OutlineTreeContentProvider treeProvider = getTreeProvider();
            if (!treeProvider.hasFilter(getFilter())) {
                treeProvider.addFilter(getFilter());
            } else {
                treeProvider.removeFilter(getFilter());
            }
            viewer.setInput(file);
        }
    };
    manager.add(sortByOccurrenceInFeature);
}

From source file:de.ovgu.featureide.ui.views.collaboration.outline.Outline.java

License:Open Source License

/**
 * @param toolBarManager/* w w w  .  j  a v  a 2 s.  com*/
 */
private void fillLocalToolBar(IToolBarManager manager) {
    dropDownAction.setMenuCreator(new IMenuCreator() {
        Menu fMenu = null;

        @Override
        public Menu getMenu(Menu parent) {
            return null;
        }

        @Override
        public Menu getMenu(Control parent) {
            fMenu = new Menu(parent);

            for (IAction curAction : actionOfProv) {
                curAction.addPropertyChangeListener(Outline.this);
                if (curAction instanceof ProviderAction && ((ProviderAction) curAction).getLabelProvider()
                        .getOutlineType() == selectedOutlineType) {
                    ActionContributionItem item = new ActionContributionItem(curAction);

                    item.fill(fMenu, -1);
                }
            }
            return fMenu;
        }

        @Override
        public void dispose() {
            if (fMenu != null) {
                fMenu.dispose();
            }
        }
    });
    manager.add(dropDownAction);
}

From source file:de.ovgu.featureide.ui.views.collaboration.outline.Outline.java

License:Open Source License

/**
 * provides functionality to expand and collapse all items in viewer
 * /*  ww  w .  j  a v  a  2s. c o m*/
 * @param iToolBarManager
 */
public void addToolbar(IToolBarManager iToolBarManager) {
    Action collapseAllAction = new Action() {
        public void run() {
            viewer.collapseAll();
            viewer.expandToLevel(2);
            colorizeItems(viewer.getTree().getItems());
        }
    };
    collapseAllAction.setToolTipText("Collapse All");
    collapseAllAction.setImageDescriptor(IMG_COLLAPSE);

    Action expandAllAction = new Action() {
        public void run() {
            viewer.expandAll();
            // treeExpanded event is not triggered, so we manually have to
            // call this function
            colorizeItems(viewer.getTree().getItems());
        }
    };
    expandAllAction.setToolTipText("Expand All");
    expandAllAction.setImageDescriptor(IMG_EXPAND);

    iToolBarManager.add(collapseAllAction);
    iToolBarManager.add(expandAllAction);
}

From source file:de.ovgu.featureide.ui.views.configMap.ConfigurationMap.java

License:Open Source License

private void createToolbar() {
    final IActionBars bars = getViewSite().getActionBars();
    final IToolBarManager toolbarManager = bars.getToolBarManager();
    toolbarManager.removeAll();//from w w w  .  ja v a 2 s  . co  m
    ;
    if (filterMenu == null) {
        final IConfigurationMapFilter[] filtersArray = new IConfigurationMapFilter[getFilters().size()];
        getFilters().toArray(filtersArray);
        filterMenu = new ConfigMapFilterMenuAction(treeViewerContentProvider, filtersArray);
    }
    toolbarManager.add(filterMenu);

    if (refresh == null) {
        refresh = new ConfigMapRefreshAction(this);
    }
    toolbarManager.add(refresh);
}

From source file:de.quamoco.adaptation.model.presentation.AdaptationModelActionBarContributor.java

License:Apache License

/**
 * This adds Separators for editor additions to the tool bar.
 * <!-- begin-user-doc -->//from   ww w. ja  v a  2s .  c om
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void contributeToToolBar(IToolBarManager toolBarManager) {
    toolBarManager.add(new Separator("adaptationmodel-settings"));
    toolBarManager.add(new Separator("adaptationmodel-additions"));
}

From source file:de.quamoco.qm.application.QmWindowActionBarAdvisor.java

License:Apache License

/**
 * {@inheritDoc}/*from w  w  w . ja  v a  2 s .  co  m*/
 */
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
    IActionBarConfigurer configurer = getActionBarConfigurer();
    IWorkbenchWindow window = configurer.getWindowConfigurer().getWindow();

    // add marker for additions
    coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

    // navigation history
    IToolBarManager navToolBar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
    navToolBar.add(new Separator(IWorkbenchActionConstants.HISTORY_GROUP));

    IWorkbenchAction forwardHistoryAction = ActionFactory.FORWARD_HISTORY.create(window);
    configurer.registerGlobalAction(forwardHistoryAction);
    IWorkbenchAction backwardHistoryAction = ActionFactory.BACKWARD_HISTORY.create(window);
    configurer.registerGlobalAction(backwardHistoryAction);

    navToolBar.add(backwardHistoryAction);
    navToolBar.add(forwardHistoryAction);
    coolBar.add(new ToolBarContributionItem(navToolBar, IWorkbenchActionConstants.TOOLBAR_NAVIGATE));
}

From source file:de.quamoco.qm.editor.result.ResultTreeMapView.java

License:Apache License

/** {@inheritDoc} */
@Override// w ww .  j a  v  a2s .  com
public void createPartControl(Composite parent) {
    super.createPartControl(parent);

    Composite composite = new Composite(parent, SWT.None);
    GridLayout layout = new GridLayout();
    layout.marginWidth = layout.marginHeight = 0;
    layout.horizontalSpacing = layout.verticalSpacing = 2;
    layout.marginLeft = layout.marginTop = 2;
    composite.setLayout(layout);

    contextLabel = new Label(composite, SWT.None);
    contextLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    widget = new TreeMapWidget<Result>(composite);
    widget.setLayoutData(new GridData(GridData.FILL_BOTH));
    widget.setContentProvider(new TreeMapContentProvider());
    widget.setColorProvider(new TreeMapColorProvider());
    widget.addTreeMapListener(new TreeMapListener());
    widget.setTextColor(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
    widget.setLabelProvider(new TreeMapLabelProvider());
    widget.setRenderer(new CushionTreeMapRenderer(0.7, 0.7));

    childLabel = new Label(composite, SWT.None);
    childLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager();
    actions = new IdentityHashMap<ResultTreeMapView.EColoring, Action>();
    for (final EColoring coloring : EColoring.values()) {
        Action action = new Action(coloring.name(), IAction.AS_RADIO_BUTTON) {

            /** {@inheritDoc} */
            @Override
            public void run() {
                if (isChecked()) {
                    setColoring(coloring);
                }
            }
        };
        if (coloring.ordinal() == 0) {
            action.setChecked(true);
        }
        toolBar.add(action);
        actions.put(coloring, action);
    }
}