org.eclipse.jface.action.IContributionItem Java Examples

The following examples show how to use org.eclipse.jface.action.IContributionItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraphStatsView.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Adds the actions to the tableviewer context menu.
 *
 * @param actions
 *          a collection of IAction objets
 */
private void hookContextMenu(final Collection<Object> actions, StructuredViewer viewer) {
  MenuManager menuMgr = new MenuManager();
  menuMgr.setRemoveAllWhenShown(true);
  menuMgr.addMenuListener(new IMenuListener() {
    @Override
    public void menuAboutToShow(IMenuManager manager) {
      for (Iterator<Object> iter = actions.iterator(); iter.hasNext();) {
        Object item = iter.next();
        if (item instanceof IContributionItem) {
          manager.add((IContributionItem) item);
        } else if (item instanceof IAction) {
          manager.add((IAction) item);
        }
      }
      manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    }
  });
  Menu menu = menuMgr.createContextMenu(viewer.getControl());
  viewer.getControl().setMenu(menu);

  getSite().registerContextMenu(menuMgr, viewer);
}
 
Example #2
Source File: MemoryActionBarContributor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.MenuManager}s and their
 * {@link org.eclipse.jface.action.ActionContributionItem}s based on the {@link org.eclipse.jface.action.IAction}s
 * contained in the <code>submenuActions</code> map.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager ( IContributionManager manager, Map<String, Collection<IAction>> submenuActions )
{
    if ( submenuActions != null )
    {
        IContributionItem[] items = manager.getItems ();
        for ( int i = 0; i < items.length; i++ )
        {
            IContributionItem contributionItem = items[i];
            if ( contributionItem instanceof MenuManager )
            {
                MenuManager submenuManager = (MenuManager)contributionItem;
                if ( submenuActions.containsKey ( submenuManager.getMenuText () ) )
                {
                    depopulateManager ( submenuManager, submenuActions.get ( contributionItem ) );
                    manager.remove ( contributionItem );
                }
            }
        }
    }
}
 
Example #3
Source File: CoreActionBarContributor.java    From ifml-editor with MIT License 6 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
	if (actions != null) {
		IContributionItem[] items = manager.getItems();
		for (int i = 0; i < items.length; i++) {
			// Look into SubContributionItems
			//
			IContributionItem contributionItem = items[i];
			while (contributionItem instanceof SubContributionItem) {
				contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
			}

			// Delete the ActionContributionItems with matching action.
			//
			if (contributionItem instanceof ActionContributionItem) {
				IAction action = ((ActionContributionItem)contributionItem).getAction();
				if (actions.contains(action)) {
					manager.remove(contributionItem);
				}
			}
		}
	}
}
 
Example #4
Source File: WorldActionBarContributor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.MenuManager}s and their
 * {@link org.eclipse.jface.action.ActionContributionItem}s based on the {@link org.eclipse.jface.action.IAction}s
 * contained in the <code>submenuActions</code> map.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager ( IContributionManager manager, Map<String, Collection<IAction>> submenuActions )
{
    if ( submenuActions != null )
    {
        IContributionItem[] items = manager.getItems ();
        for ( int i = 0; i < items.length; i++ )
        {
            IContributionItem contributionItem = items[i];
            if ( contributionItem instanceof MenuManager )
            {
                MenuManager submenuManager = (MenuManager)contributionItem;
                if ( submenuActions.containsKey ( submenuManager.getMenuText () ) )
                {
                    depopulateManager ( submenuManager, submenuActions.get ( contributionItem ) );
                    manager.remove ( contributionItem );
                }
            }
        }
    }
}
 
Example #5
Source File: HdViewPart.java    From http4e with Apache License 2.0 6 votes vote down vote up
public void fireAuthEnable( boolean enabled){
   IToolBarManager toolbar = this.getViewSite().getActionBars().getToolBarManager();
   IContributionItem[] items = toolbar.getItems();

   for (IContributionItem it : items) {
      if (it instanceof ActionContributionItem) {
         ActionContributionItem aci = (ActionContributionItem) it;
         if (aci.getAction() instanceof AuthenticationAction) {
            AuthenticationAction aa = (AuthenticationAction) aci.getAction();
            String img = null;
            if (enabled) {
               img = CoreImages.AUTH_ENABLED;
            } else {
               img = CoreImages.AUTH;
            }
            aa.setImageDescriptor(ImageDescriptor.createFromImage(ResourceUtils.getImage(CoreConstants.PLUGIN_UI, img)));
         }
      }
   }
}
 
Example #6
Source File: OsgiActionBarContributor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.MenuManager}s and their
 * {@link org.eclipse.jface.action.ActionContributionItem}s based on the {@link org.eclipse.jface.action.IAction}s
 * contained in the <code>submenuActions</code> map.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager ( IContributionManager manager, Map<String, Collection<IAction>> submenuActions )
{
    if ( submenuActions != null )
    {
        IContributionItem[] items = manager.getItems ();
        for ( int i = 0; i < items.length; i++ )
        {
            IContributionItem contributionItem = items[i];
            if ( contributionItem instanceof MenuManager )
            {
                MenuManager submenuManager = (MenuManager)contributionItem;
                if ( submenuActions.containsKey ( submenuManager.getMenuText () ) )
                {
                    depopulateManager ( submenuManager, submenuActions.get ( contributionItem ) );
                    manager.remove ( contributionItem );
                }
            }
        }
    }
}
 
Example #7
Source File: HdViewPart.java    From http4e with Apache License 2.0 6 votes vote down vote up
public void fireProxyEnable( boolean enabled){
   IToolBarManager toolbar = this.getViewSite().getActionBars().getToolBarManager();
   IContributionItem[] items = toolbar.getItems();
   for (IContributionItem it : items) {
      if (it instanceof ActionContributionItem) {
         ActionContributionItem aci = (ActionContributionItem) it;
         if (aci.getAction() instanceof ProxyAction) {
            ProxyAction aa = (ProxyAction) aci.getAction();
            String img = null;
            if (enabled) {
               img = CoreImages.PROXY_ENABLED;
            } else {
               img = CoreImages.PROXY;
            }
            aa.setImageDescriptor(ImageDescriptor.createFromImage(ResourceUtils.getImage(CoreConstants.PLUGIN_UI, img)));
         }
      }
   }
}
 
Example #8
Source File: ProfileActionBarContributor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.MenuManager}s and their
 * {@link org.eclipse.jface.action.ActionContributionItem}s based on the {@link org.eclipse.jface.action.IAction}s
 * contained in the <code>submenuActions</code> map.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager ( IContributionManager manager, Map<String, Collection<IAction>> submenuActions )
{
    if ( submenuActions != null )
    {
        IContributionItem[] items = manager.getItems ();
        for ( int i = 0; i < items.length; i++ )
        {
            IContributionItem contributionItem = items[i];
            if ( contributionItem instanceof MenuManager )
            {
                MenuManager submenuManager = (MenuManager)contributionItem;
                if ( submenuActions.containsKey ( submenuManager.getMenuText () ) )
                {
                    depopulateManager ( submenuManager, submenuActions.get ( contributionItem ) );
                    manager.remove ( contributionItem );
                }
            }
        }
    }
}
 
Example #9
Source File: BeansActionBarContributor.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
	if (actions != null) {
		IContributionItem[] items = manager.getItems();
		for (int i = 0; i < items.length; i++) {
			// Look into SubContributionItems
			//
			IContributionItem contributionItem = items[i];
			while (contributionItem instanceof SubContributionItem) {
				contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
			}

			// Delete the ActionContributionItems with matching action.
			//
			if (contributionItem instanceof ActionContributionItem) {
				IAction action = ((ActionContributionItem)contributionItem).getAction();
				if (actions.contains(action)) {
					manager.remove(contributionItem);
				}
			}
		}
	}
}
 
Example #10
Source File: MenuManagerCopiedToAddCreateMenuWithMenuParent.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean isVisible() {
    if (!visible) {
        return false; // short circuit calculations in this case
    }

    if (removeAllWhenShown) {
        // we have no way of knowing if the menu has children
        return true;
    }

    // menus aren't visible if all of its children are invisible (or only contains visible separators).
    IContributionItem[] childItems = getItems();
    boolean visibleChildren = false;
    for (int j = 0; j < childItems.length; j++) {
        if (isChildVisible(childItems[j]) && !childItems[j].isSeparator()) {
            visibleChildren = true;
            break;
        }
    }

    return visibleChildren;
}
 
Example #11
Source File: DeploymentActionBarContributor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.MenuManager}s and their
 * {@link org.eclipse.jface.action.ActionContributionItem}s based on the {@link org.eclipse.jface.action.IAction}s
 * contained in the <code>submenuActions</code> map.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager ( IContributionManager manager, Map<String, Collection<IAction>> submenuActions )
{
    if ( submenuActions != null )
    {
        IContributionItem[] items = manager.getItems ();
        for ( int i = 0; i < items.length; i++ )
        {
            IContributionItem contributionItem = items[i];
            if ( contributionItem instanceof MenuManager )
            {
                MenuManager submenuManager = (MenuManager)contributionItem;
                if ( submenuActions.containsKey ( submenuManager.getMenuText () ) )
                {
                    depopulateManager ( submenuManager, submenuActions.get ( contributionItem ) );
                    manager.remove ( contributionItem );
                }
            }
        }
    }
}
 
Example #12
Source File: AbstractFormPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void loadErrorPage() {
    if (scrolledForm != null) {
        Stream.of(toolBarManager.getItems()).forEach(IContributionItem::update);
        disposePageContent();

        final Composite composite = toolkit.createComposite(scrolledForm.getBody());
        composite.setLayout(GridLayoutFactory.fillDefaults().create());
        composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).align(SWT.CENTER, SWT.CENTER).create());

        final ImageHyperlink imageHyperlink = toolkit.createImageHyperlink(composite, SWT.NONE);
        imageHyperlink.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).create());
        imageHyperlink.setImage(UIPlugin.getImage("icons/error.png"));
        imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
                getEditor().setActiveEditor(getSourceEditor());
            }
        });
        final Label label = toolkit.createLabel(composite, Messages.parseError);
        label.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).create());
        label.setFont(BonitaStudioFontRegistry.getPreferenceTitleFont());
        scrolledForm.getParent().layout(true, true);
    }
}
 
Example #13
Source File: RecipeActionBarContributor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.MenuManager}s and their
 * {@link org.eclipse.jface.action.ActionContributionItem}s based on the {@link org.eclipse.jface.action.IAction}s
 * contained in the <code>submenuActions</code> map.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager ( IContributionManager manager, Map<String, Collection<IAction>> submenuActions )
{
    if ( submenuActions != null )
    {
        IContributionItem[] items = manager.getItems ();
        for ( int i = 0; i < items.length; i++ )
        {
            IContributionItem contributionItem = items[i];
            if ( contributionItem instanceof MenuManager )
            {
                MenuManager submenuManager = (MenuManager)contributionItem;
                if ( submenuActions.containsKey ( submenuManager.getMenuText () ) )
                {
                    depopulateManager ( submenuManager, submenuActions.get ( contributionItem ) );
                    manager.remove ( contributionItem );
                }
            }
        }
    }
}
 
Example #14
Source File: AbstractSliceSystem.java    From dawnsci with Eclipse Public License 1.0 6 votes vote down vote up
public void setSliceActionsEnabled(boolean enabled) {
	
	if (sliceToolbar==null) return;
	final IContributionItem[] items = sliceToolbar.getItems();
	for (IContributionItem toolItem : items) {
		if (toolItem instanceof ActionContributionItem) {
			((ActionContributionItem)toolItem).getAction().setEnabled(enabled);
		}
	}
	sliceToolbar.update(true);
	
	if (plotTypeActions!=null) {
		if (sliceActionEnabledMap==null) sliceActionEnabledMap = new HashMap<Enum<?>, Boolean>();
		for (Enum<?> type : plotTypeActions.keySet()) sliceActionEnabledMap.put(type, false);
	}

}
 
Example #15
Source File: ChartActionBarContributor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager(IContributionManager manager,
		Collection<? extends IAction> actions) {
	if (actions != null) {
		IContributionItem[] items = manager.getItems();
		for (int i = 0; i < items.length; i++) {
			// Look into SubContributionItems
			//
			IContributionItem contributionItem = items[i];
			while (contributionItem instanceof SubContributionItem) {
				contributionItem = ((SubContributionItem) contributionItem)
						.getInnerItem();
			}

			// Delete the ActionContributionItems with matching action.
			//
			if (contributionItem instanceof ActionContributionItem) {
				IAction action = ((ActionContributionItem) contributionItem)
						.getAction();
				if (actions.contains(action)) {
					manager.remove(contributionItem);
				}
			}
		}
	}
}
 
Example #16
Source File: ViewMenus.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private void fillContextMenu(IMenuManager manager, List<IContributionItem> contributionItems){
	manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
	for (IContributionItem contributionItem : contributionItems) {
		if (contributionItem == null) {
			manager.add(new Separator());
			continue;
		} else if (contributionItem instanceof ActionContributionItem) {
			ActionContributionItem ac = (ActionContributionItem) contributionItem;
			if (ac.getAction() instanceof RestrictedAction) {
				((RestrictedAction) ac.getAction()).reflectRight();
			}
		}
		contributionItem.update();
		manager.add(contributionItem);
	}
}
 
Example #17
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void addLRUFilterActions(IMenuManager mm) {
	if (fLRUFilterIdsStack.isEmpty()) {
		fFilterIdsUsedInLastViewMenu= null;
		return;
	}

	SortedSet<String> sortedFilters= new TreeSet<String>(fLRUFilterIdsStack);
	String[] recentlyChangedFilterIds= sortedFilters.toArray(new String[sortedFilters.size()]);

	fFilterIdsUsedInLastViewMenu= new String[recentlyChangedFilterIds.length];
	for (int i= 0; i < recentlyChangedFilterIds.length; i++) {
		String id= recentlyChangedFilterIds[i];
		fFilterIdsUsedInLastViewMenu[i]= id;
		FilterItem filterItem= fFilterItems.get(id);
		if (filterItem != null) {
			IContributionItem item= new FilterActionMenuContributionItem(this, id, filterItem.descriptor.getName(), filterItem.enabled, i+1);
			mm.insertBefore(RECENT_FILTERS_GROUP_NAME, item);
		}
	}
}
 
Example #18
Source File: ExtensionsActionBarContributor.java    From ifml-editor with MIT License 6 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
	if (actions != null) {
		IContributionItem[] items = manager.getItems();
		for (int i = 0; i < items.length; i++) {
			// Look into SubContributionItems
			//
			IContributionItem contributionItem = items[i];
			while (contributionItem instanceof SubContributionItem) {
				contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
			}

			// Delete the ActionContributionItems with matching action.
			//
			if (contributionItem instanceof ActionContributionItem) {
				IAction action = ((ActionContributionItem)contributionItem).getAction();
				if (actions.contains(action)) {
					manager.remove(contributionItem);
				}
			}
		}
	}
}
 
Example #19
Source File: AbstractWorkbenchTestCase.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
protected IAction getPyUnitViewAction(ViewPart view, Class<?> class1) {
    IAction action = null;
    IContributionItem[] items = view.getViewSite().getActionBars().getToolBarManager().getItems();
    for (IContributionItem iContributionItem : items) {
        if (iContributionItem instanceof ActionContributionItem) {
            ActionContributionItem item = (ActionContributionItem) iContributionItem;
            IAction lAction = item.getAction();
            if (class1.isInstance(lAction)) {
                action = lAction;
            }
        }
    }
    if (action == null) {
        fail("Could not find action of class: " + class1);
    }
    return action;
}
 
Example #20
Source File: Zoom.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Set action check state of a view action for a given action ID.
 *
 * @param id The action ID
 * @param checked true to check the action, false to uncheck the action
 */
protected void setActionChecked(String id, boolean checked) {
    if (getView() != null) {
        IActionBars bar = getView().getViewSite().getActionBars();
        if (bar == null) {
            return;
        }
        IToolBarManager barManager = bar.getToolBarManager();
        if (barManager == null) {
            return;
        }
        IContributionItem nextPage = barManager.find(id);
        if (nextPage instanceof ActionContributionItem) {
            IAction action = ((ActionContributionItem) nextPage).getAction();
            if (action != null) {
                action.setChecked(checked);
            }
        }
    }
}
 
Example #21
Source File: CustomPopupMenuExtender.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Unlink all contribution items from the given model menu.
 *
 * @param renderer
 *        the renderer that is holding the links
 * @param menu
 *        the model menu whose children should have its items unlinked
 *        from their corresponding contribution items
 */
private void unlink(MenuManagerRenderer renderer, MMenu menu) {
    for (MMenuElement menuElement : menu.getChildren()) {
        if (OpaqueElementUtil.isOpaqueMenuItem(menuElement)
                || OpaqueElementUtil.isOpaqueMenuSeparator(menuElement)) {
            Object item = OpaqueElementUtil.getOpaqueItem(menuElement);
            if (item instanceof IContributionItem) {
                renderer.clearModelToContribution(menuElement, (IContributionItem) item);
                OpaqueElementUtil.clearOpaqueItem(menuElement);
            }
        } else if (menuElement instanceof MMenu) {
            MMenu subMenu = (MMenu) menuElement;
            unlink(renderer, subMenu);
            MenuManager manager = renderer.getManager(subMenu);
            if (manager != null) {
                renderer.clearModelToManager(subMenu, manager);
            }
        } else {
            IContributionItem contribution = renderer.getContribution(menuElement);
            if (contribution != null) {
                renderer.clearModelToContribution(menuElement, contribution);
            }
        }
    }
}
 
Example #22
Source File: ThemeContribution.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected IContributionItem[] getContributionItems() {
	List<IContributionItem> items = new ArrayList<IContributionItem>();
	if (handlerService != null) {
		IEditorPart editorPart = getActivePart(handlerService.getCurrentState());
		if (editorPart != null) {
			IThemeManager manager = TMUIPlugin.getThemeManager();
			boolean dark = manager.isDarkEclipseTheme();
			ITheme[] themes = manager.getThemes();
			TMPresentationReconciler presentationReconciler = TMPresentationReconciler.getTMPresentationReconciler(editorPart);
			if (themes != null && presentationReconciler != null) {
				String scopeName = presentationReconciler.getGrammar().getScopeName();
				ITheme selectedTheme = manager.getThemeForScope(scopeName, dark);
				for (ITheme theme : themes) {
					IAction action = createAction(scopeName, theme, dark);
					if (theme.equals(selectedTheme)) {
						action.setChecked(true);
					}
					IContributionItem item = new ActionContributionItem(action);
					items.add(item);
				}
			}

		}
	}
	return items.toArray(new IContributionItem[items.size()]);
}
 
Example #23
Source File: ReminderView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private List<IContributionItem> createActionList(){
	Action labelFilter = new Action("Anzeige filtern") {};
	labelFilter.setEnabled(false);
	
	MenuManager timeFilterSubMenu = new MenuManager("Zeitraum Anzeige");
	FilterTimeAction action30 = new FilterTimeAction(30);
	FilterTimeAction action60 = new FilterTimeAction(60);
	FilterTimeAction action90 = new FilterTimeAction(90);
	action30.setOthers(Arrays.asList(action60, action90));
	action60.setOthers(Arrays.asList(action30, action90));
	action90.setOthers(Arrays.asList(action30, action60));
	timeFilterSubMenu.add(action30);
	timeFilterSubMenu.add(action60);
	timeFilterSubMenu.add(action90);
	
	Action labelResponsibility = new Action("Anzeige erweitern") {};
	labelResponsibility.setEnabled(false);
	
	Action labelSorter = new Action("Anzeige sortieren") {};
	labelSorter.setEnabled(false);
	
	MenuManager typeFilterSubMenu = new MenuManager("Nach Aktionstyp");
	List<IContributionItem> ca =
		ViewMenus.convertActionsToContributionItems((filterActionType));
	for (IContributionItem iContributionItem : ca) {
		typeFilterSubMenu.add(iContributionItem);
	}
	return Arrays.asList(new ActionContributionItem(newReminderAction), null,
		new ActionContributionItem(labelSorter), new ActionContributionItem(sortByDueDate),
		null, new ActionContributionItem(labelFilter), timeFilterSubMenu,
		new ActionContributionItem(showOnlyOwnDueReminderToggleAction), typeFilterSubMenu, null,
		new ActionContributionItem(labelResponsibility),
		new ActionContributionItem(showSelfCreatedReminderAction),
		new ActionContributionItem(showOthersRemindersAction), null);
}
 
Example #24
Source File: PackagesView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void fillActionBars(IActionBars actionBars) {
	//create new layout group
	IMenuManager manager= actionBars.getMenuManager();
	final IContributionItem groupMarker= new GroupMarker("layout"); //$NON-NLS-1$
	manager.add(groupMarker);
	IMenuManager newManager= new MenuManager(JavaBrowsingMessages.PackagesView_LayoutActionGroup_layout_label);
	manager.appendToGroup("layout", newManager); //$NON-NLS-1$
	super.addActions(newManager);
}
 
Example #25
Source File: ConfigurationActionBarContributor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager ( IContributionManager manager, Collection<? extends IAction> actions )
{
    if ( actions != null )
    {
        IContributionItem[] items = manager.getItems ();
        for ( int i = 0; i < items.length; i++ )
        {
            // Look into SubContributionItems
            //
            IContributionItem contributionItem = items[i];
            while ( contributionItem instanceof SubContributionItem )
            {
                contributionItem = ( (SubContributionItem)contributionItem ).getInnerItem ();
            }

            // Delete the ActionContributionItems with matching action.
            //
            if ( contributionItem instanceof ActionContributionItem )
            {
                IAction action = ( (ActionContributionItem)contributionItem ).getAction ();
                if ( actions.contains ( action ) )
                {
                    manager.remove ( contributionItem );
                }
            }
        }
    }
}
 
Example #26
Source File: SelectElementTypeContributionItem.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void addContributionItem(List<IContributionItem> list,
        String traceTypeId, String label, boolean selected, MenuManager subMenu) {
    Map<String, String> params = new HashMap<>();
    params.put(TYPE_PARAMETER, traceTypeId);

    ImageDescriptor icon = null;
    if (selected) {
        icon = SELECTED_ICON;
    }

    CommandContributionItemParameter param = new CommandContributionItemParameter(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow(), // serviceLocator
            "my.parameterid", // id //$NON-NLS-1$
            getContributionItemCommandId(), // commandId
            CommandContributionItem.STYLE_PUSH // style
    );
    param.parameters = params;
    param.icon = icon;
    param.disabledIcon = icon;
    param.hoverIcon = icon;
    param.label = label;
    param.visibleEnabled = true;

    if (subMenu != null) {
        CommandContributionItem item = new CommandContributionItem(param);
        int i = Collections.binarySearch(Arrays.asList(subMenu.getItems()), item, ITEM_COMPARATOR);
        i = (i >= 0) ? i : -i - 1;
        subMenu.insert(i, item);
    } else {
        list.add(new CommandContributionItem(param));
    }
}
 
Example #27
Source File: ProfilesContribution.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void addFromFileResource ( final List<IContributionItem> defs, final ISelection sel )
{
    final ModelLoader<Definition> loader = new ModelLoader<> ( Definition.class );

    for ( final IFile res : SelectionHelper.iterable ( sel, IFile.class ) )
    {
        try
        {
            if ( res == null || res.getContentDescription () == null || res.getContentDescription ().getContentType () == null )
            {
                continue;
            }
            if ( !CONTENT_TYPE_ID.equals ( res.getContentDescription ().getContentType ().getId () ) )
            {
                continue;
            }
        }
        catch ( final CoreException e1 )
        {
            continue;
        }
        try
        {
            final Definition def = loader.load ( res.getLocationURI () );
            if ( def != null )
            {
                addDefinition ( defs, res.getParent (), def );
            }

        }
        catch ( final Exception e )
        {
            // ignore
            StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.LOG );
        }
    }
}
 
Example #28
Source File: SecurityActionBarContributor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
 * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager ( IContributionManager manager, Collection<? extends IAction> actions )
{
    if ( actions != null )
    {
        IContributionItem[] items = manager.getItems ();
        for ( int i = 0; i < items.length; i++ )
        {
            // Look into SubContributionItems
            //
            IContributionItem contributionItem = items[i];
            while ( contributionItem instanceof SubContributionItem )
            {
                contributionItem = ( (SubContributionItem)contributionItem ).getInnerItem ();
            }

            // Delete the ActionContributionItems with matching action.
            //
            if ( contributionItem instanceof ActionContributionItem )
            {
                IAction action = ( (ActionContributionItem)contributionItem ).getAction ();
                if ( actions.contains ( action ) )
                {
                    manager.remove ( contributionItem );
                }
            }
        }
    }
}
 
Example #29
Source File: AbstractSegmentStoreTableViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
    final ISegment segment = (ISegment) sel.getFirstElement();
    if (segment != null) {
        IAction gotoStartTime = new Action(Messages.SegmentStoreTableViewer_goToStartEvent) {
            @Override
            public void run() {
                broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, TmfTimestamp.fromNanos(segment.getStart()), TmfTimestamp.fromNanos(segment.getStart()), fTrace));
            }
        };

        IAction gotoEndTime = new Action(Messages.SegmentStoreTableViewer_goToEndEvent) {
            @Override
            public void run() {
                broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, TmfTimestamp.fromNanos(segment.getEnd()), TmfTimestamp.fromNanos(segment.getEnd()), fTrace));
            }
        };

        manager.add(gotoStartTime);
        manager.add(gotoEndTime);
        if (segment instanceof ITmfSourceLookup) {
            IContributionItem openCallsiteAction = OpenSourceCodeAction.create(Messages.SegmentStoreTableViewer_lookup, (ITmfSourceLookup) segment, getTableViewer().getTable().getShell());
            if (openCallsiteAction != null) {
                manager.add(openCallsiteAction);
            }
        }
    }
}
 
Example #30
Source File: SelectElementTypeContributionItem.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected IContributionItem[] getContributionItems() {

    /*
     * Fill the selected trace types and verify if selection applies only to
     * either traces or experiments
     */
    Set<String> selectedTraceTypes = new HashSet<>();
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page = window.getActivePage();
    ISelection selection = page.getSelection();
    boolean forTraces = false, forExperiments = false;
    if (selection instanceof StructuredSelection) {
        for (Object element : ((StructuredSelection) selection).toList()) {
            if (element instanceof TmfTraceElement) {
                TmfTraceElement trace = (TmfTraceElement) element;
                selectedTraceTypes.add(trace.getTraceType());
                forTraces = true;
            } else if (element instanceof TmfExperimentElement) {
                TmfExperimentElement exp = (TmfExperimentElement) element;
                selectedTraceTypes.add(exp.getTraceType());
                forExperiments = true;
            }
        }
    }

    if (forTraces && forExperiments) {
        /* This should never happen anyways */
        throw new RuntimeException("You must select only experiments or only traces to set the element type"); //$NON-NLS-1$
    }

    return getContributionItems(selectedTraceTypes, forExperiments);
}