org.eclipse.jface.action.ContributionItem Java Examples
The following examples show how to use
org.eclipse.jface.action.ContributionItem.
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: GroupResultTable.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public String getColumnText(Object element, int column) { if (!(element instanceof ContributionItem)) return null; Contribution<ProcessGrouping> resultItem = (Contribution<ProcessGrouping>) element; switch (column) { case GROUP_COL: return getName(resultItem); case AMOUNT_COL: return Double.toString(resultItem.amount); case UNIT_COL: return unit; default: return null; } }
Example #2
Source File: NwResultPage.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public String getColumnText(Object o, int col) { if (!(o instanceof ContributionItem)) return null; Contribution<ImpactResult> item = Contribution.class.cast(o); switch (col) { case 0: return Labels.name(item.item.impactCategory); case 1: return Numbers.format(item.amount); case 2: if (setup.nwSet != null) return setup.nwSet.weightedScoreUnit; default: return null; } }
Example #3
Source File: OpenDropDownMenuHandler.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * Retrieve the menu id to show from the contribution item's ID (following the documented approach * for DROP_DOWN items). */ private static String getMenuId(ToolItem toolItem) throws ExecutionException { if (toolItem.getData() instanceof ContributionItem) { ContributionItem data = (ContributionItem) toolItem.getData(); if (!Strings.isNullOrEmpty(data.getId())) { return data.getId(); } } throw new ExecutionException("Unable to determine menu ID"); }
Example #4
Source File: DynamicViewMenu.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Gets the menu items. This is expected to be called from within the UI thread. If not it will throw exceptions * based on invalid thread access. * * @param items * the menu items to search through * @param menuPath * the menu path without the menu item to find. * @param recursive * if set to <code>true</code>, will find sub-menus as well. * @return The list of SWTBotMenu items which match the menu path. */ @SuppressWarnings("PMD.CyclomaticComplexity") private static List<SWTBotMenu> getMenuItemsInternal(final IContributionItem[] items, final List<String> menuPath, final boolean recursive) { final List<SWTBotMenu> l = new ArrayList<SWTBotMenu>(); final boolean findAnything = (menuPath == null) || menuPath.isEmpty(); for (final IContributionItem item : items) { try { if ((item instanceof MenuManager) && recursive) { // Sub menus final MenuManager menuManager = (MenuManager) item; if (findAnything || menuManager.getMenuText().equals(menuPath.get(0))) { List<String> subList = null; if (menuPath.size() > 1) { subList = menuPath.subList(1, menuPath.size()); } l.addAll(getMenuItemsInternal(menuManager.getItems(), subList, recursive)); } } else if (item instanceof ContributionItem) { final ContributionItem dynItem = (ContributionItem) item; dynItem.fill(originalMenu, 0); final MenuItem[] items2 = originalMenu.getItems(); for (final MenuItem item2 : items2) { l.add(new SWTBotMenu(item2)); } } } catch (final WidgetNotFoundException widgetNotFoundException) { continue; // Do nothing } } return l; }
Example #5
Source File: ListProcessContributionItem.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private IContributionItem createContributionItem(AbstractProcess process) { return new ContributionItem() { @Override public void fill(Menu menu, int index) { MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText(String.format("%s (%s)", process.getName(), process.getVersion())); item.addListener(SWT.Selection, createSelectionListener(process)); } }; }
Example #6
Source File: GroupResultTable.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override @SuppressWarnings("rawtypes") public Image getColumnImage(Object element, int column) { if (!(element instanceof ContributionItem) || column != 0) return null; Contribution<?> item = (Contribution) element; return image.getForTable(item.share); }
Example #7
Source File: NwResultPage.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public Image getColumnImage(Object o, int col) { if (col != 0 || !(o instanceof ContributionItem)) return null; Contribution<ImpactResult> item = Contribution.class.cast(o); return image.getForTable(item.share); }
Example #8
Source File: LapseMultiActionGroup.java From lapse-plus with GNU General Public License v3.0 | 4 votes |
/** * Add the actions to the given menu manager. */ protected void addActions(IMenuManager viewMenu) { viewMenu.add(new Separator());//we begin adding a Separator fItems = new MenuItem[fActions.length]; fStatus = new boolean[fActions.length]; //We go all over the actions for (int i = 0; i < fActions.length; i++) { final int j = i; //We create the menu viewMenu.add(new ContributionItem() {//Contribution item in a menu is a button or a separator. A contribution item in a menu bar is a menu public void fill(Menu menu, int index) { // System.err.println("Filling the menu"); int style = SWT.CHECK; if ((fActions[j].getStyle() & IAction.AS_RADIO_BUTTON) != 0) style = SWT.RADIO; //Initializing the menu and the images //The MenuItem receives a menu, the style of check or radio button MenuItem mi = new MenuItem(menu, style, index); ImageDescriptor d = fActions[j].getImageDescriptor(); mi.setImage(JavaPlugin.getImageDescriptorRegistry().get(d)); fItems[j] = mi; mi.setEnabled(true); mi.setText(fActions[j].getText()); mi.setSelection(fCurrentSelection == j); fStatus[j] = (fCurrentSelection == j); //To know if the menu is selected mi.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (fCurrentSelection == j) { // already selected fItems[fCurrentSelection].setSelection(true); fStatus[fCurrentSelection] = true; return; } fActions[j].run(); // Update checked state fItems[fCurrentSelection].setSelection(false); fStatus[fCurrentSelection] = false; fCurrentSelection = j; fItems[fCurrentSelection].setSelection(true); fStatus[fCurrentSelection] = true; } }); } }); } }
Example #9
Source File: LapseMultiActionGroup.java From lapse-plus with GNU General Public License v3.0 | 4 votes |
/** * Add the actions to the given menu manager. */ protected void addActions(IMenuManager viewMenu) { viewMenu.add(new Separator()); fItems = new MenuItem[fActions.length]; fStatus = new boolean[fActions.length]; for (int i = 0; i < fActions.length; i++) { final int j = i; if ((fInitial != null) && fInitial[j]) { fActions[j].run(); } viewMenu.add(new ContributionItem() { public void fill(Menu menu, int index) { // System.err.println("Filling the menu"); int style = SWT.CHECK; MenuItem mi = new MenuItem(menu, style, index); ImageDescriptor d = fActions[j].getImageDescriptor(); mi.setImage(JavaPlugin.getImageDescriptorRegistry().get(d)); fItems[j] = mi; mi.setEnabled(true); mi.setText(fActions[j].getText()); mi.setSelection((fInitial != null) && fInitial[j]); fStatus[j] = (fInitial != null) && fInitial[j]; mi.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { MenuItem item = fItems[j]; // System.err.println("Old value: " + // item.getSelection()); item.setSelection(!fStatus[j]); fStatus[j] = !fStatus[j]; // System.err.println("New value: " + // item.getSelection()); fActions[j].run(); } }); } }); } }
Example #10
Source File: MultiActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Adds the actions to the given menu manager. */ protected void addActions(IMenuManager viewMenu) { viewMenu.add(new Separator()); fItems= new MenuItem[fActions.length]; for (int i= 0; i < fActions.length; i++) { final int j= i; viewMenu.add(new ContributionItem() { @Override public void fill(Menu menu, int index) { int style= SWT.CHECK; if ((fActions[j].getStyle() & IAction.AS_RADIO_BUTTON) != 0) style= SWT.RADIO; MenuItem mi= new MenuItem(menu, style, index); ImageDescriptor d= fActions[j].getImageDescriptor(); mi.setImage(JavaPlugin.getImageDescriptorRegistry().get(d)); fItems[j]= mi; mi.setText(fActions[j].getText()); mi.setSelection(fCurrentSelection == j); mi.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (fCurrentSelection == j) { fItems[fCurrentSelection].setSelection(true); return; } fActions[j].run(); // Update checked state fItems[fCurrentSelection].setSelection(false); fCurrentSelection= j; fItems[fCurrentSelection].setSelection(true); } }); } @Override public boolean isDynamic() { return false; } }); } }
Example #11
Source File: WorkingSetRootModeActionGroup.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * Adds the actions to the given menu manager. */ protected void addActions(IMenuManager viewMenu) { if (actions == null) actions = createActions(); viewMenu.add(new Separator()); items = new MenuItem[actions.length]; for (int i = 0; i < actions.length; i++) { final int j = i; viewMenu.add(new ContributionItem() { public void fill(Menu menu, int index) { int style = SWT.CHECK; if ((actions[j].getStyle() & IAction.AS_RADIO_BUTTON) != 0) style = SWT.RADIO; final MenuItem mi = new MenuItem(menu, style, index); items[j] = mi; mi.setText(actions[j].getText()); mi.setSelection(currentSelection == j); mi.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (currentSelection == j) { items[currentSelection].setSelection(true); return; } actions[j].run(); // Update checked state items[currentSelection].setSelection(false); currentSelection = j; items[currentSelection].setSelection(true); } }); } public boolean isDynamic() { return false; } }); } }
Example #12
Source File: Designer.java From Rel with Apache License 2.0 | 4 votes |
protected void init() { dataProvider = new DataProvider(); headingProvider = new HeadingProvider(); gridLayer = new DefaultGridLayer(dataProvider, headingProvider); // CellLabelAccumulator determines how cells will be displayed class CellLabelAccumulator implements IConfigLabelAccumulator { @Override public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { configLabels.addLabel("column" + columnPosition); if (dataProvider.isEditableNonscalarDefinition(rowPosition) && columnPosition == Attr.HEADING_COLUMN) configLabels.addLabel("nonscalareditor"); } } DataLayer bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer(); CellLabelAccumulator cellLabelAccumulator = new CellLabelAccumulator(); bodyDataLayer.setConfigLabelAccumulator(cellLabelAccumulator); table = new NatTable(parent, gridLayer, false); editorConfiguration = new EditorConfiguration(); DefaultNatTableStyleConfiguration defaultStyle = new DefaultNatTableStyleConfiguration(); table.addConfiguration(defaultStyle); table.addConfiguration(editorConfiguration); ContributionItem rowMenuItems = new ContributionItem() { @Override public void fill(Menu menu, int index) { new IconMenuItem(menu, "Delete", "table_row_delete", SWT.PUSH, e -> askDeleteSelected()); } }; table.addConfiguration(new MenuConfiguration(GridRegion.ROW_HEADER, new PopupMenuBuilder(table).withContributionItem(rowMenuItems))); // Tabbing wraps and moves up/down gridLayer.registerCommandHandler(new MoveCellSelectionCommandHandler( gridLayer.getBodyLayer().getSelectionLayer(), ITraversalStrategy.TABLE_CYCLE_TRAVERSAL_STRATEGY)); table.configure(); // Tooltip for row/column headings new NatTableContentTooltip(table, GridRegion.ROW_HEADER) { protected String getText(Event event) { return "Right-click for options."; } }; }
Example #13
Source File: WorkingSetRootModeActionGroup.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * Adds the actions to the given menu manager. */ protected void addActions(IMenuManager viewMenu) { if (actions == null) actions = createActions(); viewMenu.add(new Separator()); items = new MenuItem[actions.length]; for (int i = 0; i < actions.length; i++) { final int j = i; viewMenu.add(new ContributionItem() { public void fill(Menu menu, int index) { int style = SWT.CHECK; if ((actions[j].getStyle() & IAction.AS_RADIO_BUTTON) != 0) style = SWT.RADIO; final MenuItem mi = new MenuItem(menu, style, index); items[j] = mi; mi.setText(actions[j].getText()); mi.setSelection(currentSelection == j); mi.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (currentSelection == j) { items[currentSelection].setSelection(true); return; } actions[j].run(); // Update checked state items[currentSelection].setSelection(false); currentSelection = j; items[currentSelection].setSelection(true); } }); } public boolean isDynamic() { return false; } }); } }