List of usage examples for org.eclipse.jface.action MenuManager fill
@Override
public void fill(ToolBar parent, int index)
From source file:com.aptana.ide.server.ui.views.actions.GenericAddServerAction.java
License:Open Source License
/** * // www . j a v a 2 s . com */ public GenericAddServerAction() { super(Messages.GenericAddServerActionTITLE, Action.AS_DROP_DOWN_MENU); this.setImageDescriptor(ServerUIPlugin.getImageDescriptor("/icons/server/add_server.gif")); //$NON-NLS-1$ this.setMenuCreator(new IMenuCreator() { public void dispose() { } public Menu getMenu(Control parent) { MenuManager mn = new MenuManager(); fillManager(mn); return mn.createContextMenu(parent); } public Menu getMenu(Menu parent) { MenuManager mn = new MenuManager(); fillManager(mn); Menu menu = new Menu(parent); mn.fill(menu, 0); return menu; } }); }
From source file:com.aptana.ide.server.ui.views.actions.OpenLogAction.java
License:Open Source License
/** * @param provider/* w ww . j a va2 s . com*/ * @param style */ public OpenLogAction(ISelectionProvider provider, int style) { super("", style); //$NON-NLS-1$ this.setImageDescriptor(ServerUIPlugin.getImageDescriptor("/icons/windowlist.png")); //$NON-NLS-1$ this.setToolTipText(Messages.OpenLogAction_Title0); this.provider = provider; provider.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { OpenLogAction.this.selectionChanged(event); } }); this.setMenuCreator(new IMenuCreator() { public void dispose() { } public Menu getMenu(Control parent) { MenuManager mn = new MenuManager(); fillManager(mn); return mn.createContextMenu(parent); } public Menu getMenu(Menu parent) { MenuManager mn = new MenuManager(); fillManager(mn); Menu menu = new Menu(parent); mn.fill(menu, 0); return menu; } }); }
From source file:com.aptana.ruby.internal.rake.actions.RakeTasksContributionItem.java
License:Open Source License
@Override public void fill(Menu menu, int index) { IProject project = getProject();/*from ww w . ja v a 2 s. c o m*/ if (project == null) { return; } Map<String, String> tasks = getRakeHelper().getTasks(project, new NullProgressMonitor()); fNamespaces = new HashMap<String, MenuManager>(); // Please note that tehre's a lot of code mixed up in here to ensure that the menus, items and sub-menus all // appear alphabetically List<String> values = new ArrayList<String>(tasks.keySet()); Collections.sort(values); for (String task : values) { String[] paths = task.split(RAKE_NAMESPACE_DELIMETER); if (paths.length == 1) { IAction action = new RunRakeAction(project, task, tasks.get(task)); ActionContributionItem item = new ActionContributionItem(action); item.fill(menu, -1); } else { MenuManager manager = getOrCreate(paths); manager.add(new RunRakeAction(project, task, tasks.get(task))); } } values = new ArrayList<String>(fNamespaces.keySet()); Collections.sort(values); Collections.reverse(values); for (String path : values) { MenuManager manager = fNamespaces.get(path); String[] parts = path.split(RAKE_NAMESPACE_DELIMETER); if (parts.length == 1) { int index2 = getInsertIndex(menu, manager); manager.fill(menu, index2); } else { MenuManager parent = getParent(parts); if (parent != null) { int index2 = getInsertIndex(parent, manager); parent.insert(index2, manager); } else { int index2 = getInsertIndex(menu, manager); manager.fill(menu, index2); } } } }
From source file:fede.workspace.tool.view.menu.MenuActionContributionItem.java
License:Apache License
@Override public void fill(Menu menu, int index) { int style = SWT.PUSH; widget = new MenuItem[dy.length]; boolean appendsepartor = false; for (int i = 0; i < dy.length; i++) { final IMenuAction aMenuAction = dy[i]; if (aMenuAction.isMenu()) { IMenuAction[] menuChildren = aMenuAction.getChildren(); if (menuChildren.length != 0) { MenuManager subMenuManager = new MenuManager(aMenuAction.getLabel(), aMenuAction.getId()); subMenuManager.add(/*from w w w . j a v a 2 s.com*/ new MenuActionContributionItem(this.workbenchWindow, this.selection, menuChildren)); subMenuManager.fill(menu, index); if (index >= 0) { index++; } appendsepartor = true; } continue; } if (aMenuAction.isSeparator()) { if (appendsepartor) { if (index >= 0) { new MenuItem(menu, SWT.SEPARATOR, index++); } else { new MenuItem(menu, SWT.SEPARATOR); } appendsepartor = false; } continue; } if (aMenuAction.isGroup()) { continue; } MenuItem mi; if (index >= 0) { mi = new MenuItem(menu, style, index++); } else { mi = new MenuItem(menu, style); } mi.setText(aMenuAction.getLabel()); mi.setData(aMenuAction); appendsepartor = true; try { String url = aMenuAction.getImage(); if (url != null && url.length() > 0) { Image image = WSPlugin.getDefault().getImageFromURL(url); ; if (image != null) { mi.setImage(image); } } else { ImageDescriptor desc = (ImageDescriptor) aMenuAction.getImageDescriptor(); if (desc != null) { Image image = desc.createImage(); if (image != null) { mi.setImage(image); } } } } catch (Throwable e) { e.printStackTrace(); } widget[i] = mi; mi.setData(REF, aMenuAction); mi.addListener(SWT.Dispose, this); mi.addListener(SWT.Selection, this); } super.fill(menu, index + dy.length); }
From source file:gov.nasa.arc.spife.ui.timeline.action.TimelineBuilderContributionItem.java
License:Open Source License
@Override public void fill(Menu menu, int index) { ImageDescriptor imageTimelineDescriptor = TimelineBuilder.IMAGE_TIMELINE_DESCRIPTOR; MenuManager addSectionItem = new MenuManager("Add timeline Section", imageTimelineDescriptor, getId()); List<TimelineBuilder> builders = TimelineBuilderRegistry.getInstance().getAllTimelineBuilders(); for (final TimelineBuilder builder : builders) { String text = builder.getName(); ImageDescriptor imageDescriptor = builder.getActionImageDescriptor(); if (imageDescriptor == null) { imageDescriptor = imageTimelineDescriptor; }//from www.j a v a 2s.c om Action action = new Action(text, imageDescriptor) { @Override public void runWithEvent(Event event) { IEditorPart activeEditor = EditorPartUtils.getCurrent(); Timeline timeline = TimelineUtils.getTimeline(activeEditor); if (timeline == null) { return; } EObject section = builder.createTimelineSection(); final ETimeline timelineModel = timeline.getTimelineModel(); TransactionalEditingDomain domain = gov.nasa.ensemble.emf.transaction.TransactionUtils .getDomain(timelineModel); Command command = AddCommand.create(domain, timelineModel, TimelinePackage.Literals.ETIMELINE__CONTENTS, Collections.singleton(section)); EMFUtils.executeCommand(domain, command); } }; addSectionItem.add(action); } addSectionItem.fill(menu, index); }
From source file:org.jboss.tools.vpe.editor.menu.InsertContributionItem.java
License:Open Source License
@Override public void fill(Menu menu, int index) { /*// w w w. jav a 2 s . c om * Setting each InsertType to correct position in the menu */ for (final InsertType insertItem : InsertType.values()) { /* * Use MenuManager to create submenu. */ final MenuManager paletteManuManager = new MenuManager(insertItem.getMessage()); final XModelObject model = ModelUtilities.getPreferenceModel().getByPath("%Palette%"); //$NON-NLS-1$ paletteManuManager.addMenuListener(new InsertMenuListener(model, insertItem)); paletteManuManager.setRemoveAllWhenShown(true); paletteManuManager.fill(menu, index); index++; } }