List of usage examples for org.eclipse.jface.action IContributionItem update
void update();
From source file:ch.elexis.core.ui.util.ViewMenus.java
License:Open Source License
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(); }/* w ww.ja va2 s . c o m*/ } contributionItem.update(); manager.add(contributionItem); } }
From source file:ch.elexis.core.ui.views.KonsDetailView.java
License:Open Source License
@Override public void setUnlocked(boolean unlocked) { boolean hlMandantEnabled = actKons != null && actKons.isEditable(false) && CoreHub.acl.request(AccessControlDefaults.KONS_REASSIGN) && unlocked; hlMandant.setEnabled(hlMandantEnabled); boolean cbFallEnabled = actKons != null && actKons.isEditable(false) && unlocked; comboViewerFall.getCombo().setEnabled(cbFallEnabled); text.setEditable(unlocked);//from w w w.j av a2 s . c o m // update the UI IToolBarManager mgr = ((IViewSite) getSite()).getActionBars().getToolBarManager(); IContributionItem[] items = mgr.getItems(); for (IContributionItem iContributionItem : items) { iContributionItem.update(); } }
From source file:com.ecfeed.ui.editor.BasicDetailsPage.java
License:Open Source License
protected void refreshTextClient() { if (fSelectedNode == null && fImplementButton != null) { fImplementButton.setEnabled(false); } else if (fToolBarManager != null) { fToolBarManager.update(true);/*ww w . ja v a 2 s .c o m*/ for (IContributionItem item : fToolBarManager.getItems()) { item.update(); } } }
From source file:com.motorola.studio.android.emulator.ui.view.AbstractAndroidView.java
License:Apache License
/** * Updates the zoom action that needs to be checked. * This method must be called every time the focus changes to another * viewer/*from ww w .j av a 2s . co m*/ */ private void updateMenuAndToolbars() { IViewSite viewSite = getViewSite(); if (viewSite != null) { IActionBars actionBars = viewSite.getActionBars(); if (actionBars != null) { IMenuManager menuManager = actionBars.getMenuManager(); updateMenuManager(menuManager, viewSite); IToolBarManager toolbarManager = actionBars.getToolBarManager(); if (toolbarManager != null) { IContributionItem[] items = toolbarManager.getItems(); for (IContributionItem item : items) { item.update(); } } } refreshMenuElements(); } }
From source file:com.motorola.studio.android.emulator.ui.view.AbstractAndroidView.java
License:Apache License
/** * Recursive method to update items at menus. The recursion helps to update submenus * //from www. java2 s.c o m * @param manager The manager that holds a menu items * @param viewSite The current view site. */ private void updateMenuManager(IMenuManager manager, IViewSite viewSite) { // Update the items in menu manager if (manager != null) { IContributionItem[] items = manager.getItems(); for (IContributionItem item : items) { if (item instanceof IMenuManager) { updateMenuManager((IMenuManager) item, viewSite); } else { item.update(); } } } }
From source file:com.sap.dirigible.ide.ui.rap.managers.CoolBarManager.java
License:Open Source License
public void update(final boolean force) { if ((isDirty() || force) && getControl2() != null) { refresh();//from www .j av a 2s . co m boolean changed = false; /* * Make a list of items including only those items that are visible. * Separators are being removed. Because we use only one Toolbar all * ToolBarContributionItems will be extracted in their IContribution * Items. */ final IContributionItem[] items = getItems(); final List<IContributionItem> visibleItems = new ArrayList<IContributionItem>(items.length); for (int i = 0; i < items.length; i++) { final IContributionItem item = items[i]; if (item.isVisible()) { if (item instanceof IToolBarContributionItem) { IToolBarContributionItem toolbarItem = (IToolBarContributionItem) item; IToolBarManager toolBarManager = toolbarItem.getToolBarManager(); IContributionItem[] toolbarItems = toolBarManager.getItems(); for (int j = 0; j < toolbarItems.length; j++) { final IContributionItem toolItem = toolbarItems[j]; if (toolItem.isVisible() && !toolItem.isSeparator()) { visibleItems.add(toolItem); } } } } } /* * Make a list of ToolItem widgets in the tool bar for which there * is no current visible contribution item. These are the widgets to * be disposed. Dynamic items are also removed. */ ToolItem[] toolItems = toolbar.getItems(); final ArrayList<ToolItem> toolItemsToRemove = new ArrayList<ToolItem>(toolItems.length); for (int i = 0; i < toolItems.length; i++) { final Object data = toolItems[i].getData(); if ((data == null) || (!visibleItems.contains(data)) || ((data instanceof IContributionItem) && ((IContributionItem) data).isDynamic())) { toolItemsToRemove.add(toolItems[i]); } } // Dispose of any items in the list to be removed. for (int i = toolItemsToRemove.size() - 1; i >= 0; i--) { ToolItem toolItem = (ToolItem) toolItemsToRemove.get(i); if (!toolItem.isDisposed()) { Control control = toolItem.getControl(); if (control != null) { toolItem.setControl(null); control.dispose(); } toolItem.dispose(); } } // Add any new items by telling them to fill. toolItems = toolbar.getItems(); IContributionItem sourceItem; IContributionItem destinationItem; int sourceIndex = 0; int destinationIndex = 0; final Iterator<IContributionItem> visibleItemItr = visibleItems.iterator(); while (visibleItemItr.hasNext()) { sourceItem = visibleItemItr.next(); // Retrieve the corresponding contribution item from SWT's // data. if (sourceIndex < toolItems.length) { destinationItem = (IContributionItem) toolItems[sourceIndex].getData(); } else { destinationItem = null; } // The items match if they are equal or both separators. if (destinationItem != null) { if (sourceItem.equals(destinationItem)) { sourceIndex++; destinationIndex++; sourceItem.update(); continue; } else if ((destinationItem.isSeparator()) && (sourceItem.isSeparator())) { toolItems[sourceIndex].setData(sourceItem); sourceIndex++; destinationIndex++; sourceItem.update(); continue; } } // Otherwise, a new item has to be added. final int start = toolbar.getItemCount(); sourceItem.fill(toolbar, destinationIndex); final int newItems = toolbar.getItemCount() - start; // add the selection listener for the styling StylingSelectionAdapter listener = new StylingSelectionAdapter(HEADER_TOOLBAR_VARIANT); for (int i = 0; i < newItems; i++) { ToolItem item = toolbar.getItem(destinationIndex++); item.setData(sourceItem); item.addSelectionListener(listener); } changed = true; } // Remove any old widgets not accounted for. for (int i = toolItems.length - 1; i >= sourceIndex; i--) { final ToolItem item = toolItems[i]; if (!item.isDisposed()) { Control control = item.getControl(); if (control != null) { item.setControl(null); control.dispose(); } item.dispose(); changed = true; } } // Update wrap indices. only needed by a coolbar // updateWrapIndices(); // Update the sizes. for (int i = 0; i < items.length; i++) { IContributionItem item = items[i]; item.update(SIZE); } if (changed) { updateToolbarTabOrder(); } // We are no longer dirty. setDirty(false); styleToolItems(); toolbar.pack(); toolbar.layout(true, true); manageOverflow(); } }
From source file:net.sf.eclipsensis.editor.NSISActionContributor.java
License:Open Source License
private boolean showHideAction(IContributionManager manager, String id, boolean show) { IContributionItem item = manager.find(id); if (item != null) { if (item.isVisible() != show) { item.setVisible(show);/*from w ww . ja v a 2 s . c om*/ item.update(); return true; } } return false; }
From source file:net.yatomiya.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.java
License:Open Source License
@Inject @Optional//from w w w . j a v a2 s . com private void subscribeTopicUpdateItems(@UIEventTopic(UIEvents.UILabel.TOPIC_ALL) Event event) { // Ensure that this event is for a MToolBarElement if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MToolBarElement)) { return; } MToolBarElement itemModel = (MToolBarElement) event.getProperty(UIEvents.EventTags.ELEMENT); IContributionItem ici = getContribution(itemModel); if (ici == null) { return; } String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME); if (UIEvents.UILabel.LABEL.equals(attName) || UIEvents.UILabel.LOCALIZED_LABEL.equals(attName)) { ici.update(); } else if (UIEvents.UILabel.ICONURI.equals(attName)) { ici.update(); } else if (UIEvents.UILabel.TOOLTIP.equals(attName) || UIEvents.UILabel.LOCALIZED_TOOLTIP.equals(attName)) { ici.update(); } }
From source file:net.yatomiya.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.java
License:Open Source License
@Inject @Optional// www . j a va2 s .c o m private void subscribeTopicUpdateSelection(@UIEventTopic(UIEvents.Item.TOPIC_SELECTED) Event event) { // Ensure that this event is for a MToolBarElement if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MToolBarElement)) { return; } MToolBarElement itemModel = (MToolBarElement) event.getProperty(UIEvents.EventTags.ELEMENT); IContributionItem ici = getContribution(itemModel); if (ici != null) { ici.update(); } }
From source file:net.yatomiya.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.java
License:Open Source License
@Inject @Optional//from w w w . ja v a 2 s . com private void subscribeTopicUpdateEnablement(@UIEventTopic(UIEvents.Item.TOPIC_ENABLED) Event event) { // Ensure that this event is for a MMenuItem if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MToolBarElement)) { return; } MToolBarElement itemModel = (MToolBarElement) event.getProperty(UIEvents.EventTags.ELEMENT); IContributionItem ici = getContribution(itemModel); if (ici != null) { ici.update(); } }