@Override public Menu getMenu(Control parent) { if (fMenu == null) { fMenu = new Menu(parent); OpenNewPHPInterfaceWizardAction interfaceAction = new OpenNewPHPInterfaceWizardAction(); interfaceAction.init(window); ActionContributionItem item = new ActionContributionItem(interfaceAction); item.fill(fMenu, -1); item = new ActionContributionItem(this); item.fill(fMenu, -1); } return fMenu; }
protected void populateSubMenus( Menu subMenu, final Object node, ITreeContentProvider provider, final boolean isRunTo) { if (provider.hasChildren(node)) { /* * this is a submenu mark */ MenuItem header = new MenuItem(subMenu, SWT.CASCADE); header.setText(node.toString()); Menu newSubMenu = new Menu(header); header.setMenu(newSubMenu); for (Object child : provider.getChildren(node)) populateSubMenus(newSubMenu, child, provider, isRunTo); } else { /** lone item, this is a runner. */ ITimeBasedAction action = new TimeBasedAction(this, node, isRunTo); action.setText( String.format("%s %s", isRunTo ? "Skip to " : "Run for ", _labelProvider.getText(node))); _allActions.add(action); ActionContributionItem aci = new ActionContributionItem(action); aci.fill(subMenu, -1); } }
public Menu getMenu(Control parent) { Menu menu = new Menu(parent); for (ActionContributionItem action : getActions()) { action.fill(menu, -1); } return menu; }
private void addActions(Menu menu) { // add repository action Presentation selectedPresentation = view.getContentProvider().getPresentation(); for (final Presentation presentation : Presentation.values()) { Action action = new Action() { @Override public void run() { view.getContentProvider().setPresentation(presentation); } }; action.setText(presentation.toString()); action.setChecked(presentation == selectedPresentation); ActionContributionItem item = new ActionContributionItem(action); item.fill(menu, -1); } }
/** * The menu to show in the workbench menu * * @param menu the menu to fill entries into it */ protected void fillMenu(Menu menu) { IWorkbenchPart activePart = JavaPlugin.getActivePage().getActivePart(); if (!(activePart instanceof CompilationUnitEditor)) { ActionContributionItem item = new ActionContributionItem(NONE_APPLICABLE_ACTION); item.fill(menu, -1); return; } CompilationUnitEditor editor = (CompilationUnitEditor) activePart; if (editor.isBreadcrumbActive()) { ActionContributionItem item = new ActionContributionItem(NONE_APPLICABLE_ACTION); item.fill(menu, -1); return; } IAction[] actions = getTemplateActions(editor); boolean addSurroundWith = !isInJavadoc(editor); if (addSurroundWith) { SurroundWithTryCatchAction surroundAction = createSurroundWithTryCatchAction(editor); ActionContributionItem surroundItem = new ActionContributionItem(surroundAction); surroundItem.fill(menu, -1); } boolean hasTemplateActions = actions != null && actions.length > 0; if (!hasTemplateActions && !addSurroundWith) { ActionContributionItem item = new ActionContributionItem(NONE_APPLICABLE_ACTION); item.fill(menu, -1); } else if (hasTemplateActions) { if (addSurroundWith) { Separator templateGroup = new Separator(TEMPLATE_GROUP); templateGroup.fill(menu, -1); } for (int i = 0; i < actions.length; i++) { ActionContributionItem item = new ActionContributionItem(actions[i]); item.fill(menu, -1); } } Separator configGroup = new Separator(CONFIG_GROUP); configGroup.fill(menu, -1); ActionContributionItem configAction = new ActionContributionItem(new ConfigureTemplatesAction()); configAction.fill(menu, -1); }
protected void addActionToMenu(Menu parent, Action action) { ActionContributionItem item = new ActionContributionItem(action); item.fill(parent, -1); }
protected Control createContents(Composite parent) { getShell().setText("Action/Contribution Example"); parent.setSize(290, 150); aci.fill(parent); return parent; }
/** * Fills the menu with build configurations which are common for all selected projects * * @param menu The menu to fill */ protected void fillMenu(Menu menu) { // This should not happen if (menu == null) return; MenuItem[] items = menu.getItems(); for (MenuItem item2 : items) item2.dispose(); SortedSet<String> configNames = new TreeSet<String>(); String sCurrentConfig = null; boolean bCurrentConfig = true; for (IProject prj : fProjects) { ICConfigurationDescription[] cfgDescs = getCfgs(prj); String sActiveConfig = null; // Store names and detect active configuration for (ICConfigurationDescription cfgDesc : cfgDescs) { String s = cfgDesc.getName(); if (!configNames.contains(s)) configNames.add(s); if (cfgDesc.isActive()) sActiveConfig = s; } // Check whether all projects have the same active configuration if (bCurrentConfig) { if (sCurrentConfig == null) sCurrentConfig = sActiveConfig; else { if (!sCurrentConfig.equals(sActiveConfig)) bCurrentConfig = false; } } } int accel = 0; for (String sName : configNames) { String sDesc = null; boolean commonName = true; boolean commonDesc = true; boolean firstProj = true; for (IProject prj : fProjects) { ICConfigurationDescription[] cfgDescs = getCfgs(prj); int i = 0; for (; i < cfgDescs.length; i++) { if (cfgDescs[i].getName().equals(sName)) { String sNewDesc = cfgDescs[i].getDescription(); if (sNewDesc != null && sNewDesc.length() == 0) { sNewDesc = null; } if (commonDesc) { if (firstProj) { sDesc = sNewDesc; firstProj = false; } else if (sNewDesc == null && sDesc != null || sNewDesc != null && !sNewDesc.equals(sDesc)) { commonDesc = false; } } break; } } if (i == cfgDescs.length) { commonName = false; break; } } if (commonName) { StringBuffer builder = new StringBuffer(sName); if (commonDesc) { if (sDesc != null) { builder.append(" ("); // $NON-NLS-1$ builder.append(sDesc); builder.append(")"); // $NON-NLS-1$ } } else { builder.append(" (...)"); // $NON-NLS-1$ } IAction action = makeAction(sName, builder, accel); if (bCurrentConfig && sCurrentConfig != null && sCurrentConfig.equals(sName)) { action.setChecked(true); } ActionContributionItem item = new ActionContributionItem(action); item.fill(menu, -1); accel++; } } }