private static boolean containsMatching(List<MMenuElement> children, MMenuElement me) { for (MMenuElement element : children) { if (Util.equals(me.getElementId(), element.getElementId()) && element.getClass().isInstance(me) && (element instanceof MMenuSeparator || element instanceof MMenu)) { return true; } } return false; }
@Override protected boolean isShowing(MMenuElement item) { return this.currentVisibleMenus.contains(item.getParent()); }
@Override public void handleChildrenAddition(MMenu parent, Collection<MMenuElement> elements) { Iterator<MMenuElement> iterator = elements.iterator(); while (iterator.hasNext()) { MMenuElement element = iterator.next(); if (element.isToBeRendered() && isChildElementAllowed(element)) { if (element.getWidget() == null) { engineCreateWidget(element); } else { childRendered(parent, element); } } } }
private MMenuElement createMenuSeparatorAddition(final IConfigurationElement sepAddition) { String name = MenuHelper.getName(sepAddition); MMenuElement element = MenuFactoryImpl.eINSTANCE.createMenuSeparator(); element.setElementId(name); if (!MenuHelper.isSeparatorVisible(sepAddition)) { element.setVisible(false); element.getTags().add(MenuManagerRenderer.GROUP_MARKER); } return element; }
/** * @param menuManager * @param element * @param evalContext */ public static void updateVisibility(MenuManager menuManager, MMenuElement element, ExpressionContext evalContext) { boolean current = element.isVisible(); boolean visible = true; boolean evaluated = false; if (element.getPersistedState().get(VISIBILITY_IDENTIFIER) != null) { evaluated = true; String identifier = element.getPersistedState().get(VISIBILITY_IDENTIFIER); Object rc = evalContext.eclipseContext.get(identifier); if (rc instanceof Boolean) { visible = ((Boolean) rc).booleanValue(); } } if (visible && element.getVisibleWhen() != null) { evaluated = true; visible = ContributionsAnalyzer.isVisible(element.getVisibleWhen(), evalContext); } if (evaluated && visible != current) { element.setVisible(visible); menuManager.markDirty(); } }
.getTransientData(); @SuppressWarnings("unchecked") ArrayList<MMenuElement> dump = (ArrayList<MMenuElement>) storageMap if (menuElement.getElementId() == null || menuElement.getElementId().length() < 1) { menuElement.setElementId(currentMenuElement .getElementId() + "." + j); //$NON-NLS-1$
/** * Determines if the menu provided or any one of its children should be * rendered. * * @param menu * the menu to determine if it should be displayed in the tab * folder * @return <tt>true</tt> if the menu should be drawn in the tab folder, * <tt>false</tt> otherwise */ private boolean isMenuVisible(MMenu menu) { if (menu.isToBeRendered() && menu.isVisible()) { for (MMenuElement element : menu.getChildren()) { if (element.isToBeRendered() && element.isVisible()) { return true; } else if (element instanceof MMenu && isMenuVisible((MMenu) element)) { return true; } } } return false; }
if (currentMenuElement instanceof MDynamicMenuContribution) { final Map<String, Object> storageMap = currentMenuElement.getTransientData(); @SuppressWarnings("unchecked") ArrayList<MMenuElement> mel = (ArrayList<MMenuElement>) storageMap item.setVisible(false);
@Override public void doProcessContent(MPopupMenu element) { // TODO Should we do this creation lazy???? WPopupMenu<N> menu = getWidget(element); if( menu == null ) { getLogger().error("No widget found for '"+element+"'"); //$NON-NLS-1$//$NON-NLS-2$ return; } for (MMenuElement e : element.getChildren()) { if (e.isToBeRendered()) { WMenuElement<MMenuElement> widget = engineCreateWidget(e); if (widget != null && isChildRenderedAndVisible(e)) { menu.addElement(widget); } } } }
boolean currentVisibility = computeVisibility(recentlyUpdated, item, exprContext); if (item.isVisible() != currentVisibility) { changed = true; item.setVisible(currentVisibility); boolean currentVisibility = computeVisibility(recentlyUpdated, item, exprContext); if (item.isVisible() != currentVisibility) { changed = true; item.setVisible(currentVisibility);
MMenu shared = findExistingMenu(copy.getElementId()); if (shared == null) { shared = (MMenu) copy; menuModel.getChildren().add(idx++, copy); } else { shared.setVisibleWhen(merge(copy.getVisibleWhen(), shared.getVisibleWhen())); copy = shared; } else if (copy instanceof MMenuSeparator) { MMenuSeparator shared = findExistingSeparator(copy .getElementId()); if (shared == null) { shared = (MMenuSeparator) copy;
private DynamicContributionItem createMenuEntry(DisplayItem parent, Map<IContributionItem, IContributionItem> findDynamics, DynamicContributionItem dynamicEntry, MMenuElement menuItem) { String text = menuItem.getLocalizedLabel(); if (text == null || text.length() == 0) { text = menuItem.getLabel(); || (menuItem instanceof MHandledMenuItem) || menuItem.getWidget() != null) { IContributionItem contributionItem; if (menuItem instanceof MMenu) { dynamicEntry.addCurrentItem((MenuItem) menuItem.getWidget()); String iconURI = menuItem.getIconURI(); if (iconURI != null && iconURI.length() > 0) { iconDescriptor = resUtils.imageDescriptorFromURI(URI.createURI(iconURI)); if (menuItem.getWidget() instanceof MenuItem) { MenuItem item = (MenuItem) menuItem.getWidget(); if (text == null) { if ("".equals(item.getText())) { //$NON-NLS-1$
workbenchWindow, commandId, commandId, CommandContributionItem.STYLE_PUSH); String label = menuElement.getLabel(); if (label != null && label.length() > 0) { ccip.label = label; String mnemonics = menuElement.getMnemonics(); if (mnemonics != null && mnemonics.length() == 1) { ccip.mnemonic = mnemonics; String iconURI = menuElement.getIconURI(); try { if (iconURI != null && !iconURI.isEmpty()) {
&& item.getPersistedState().get( MenuManagerRenderer.VISIBILITY_IDENTIFIER) != null) { String identifier = item.getPersistedState().get( MenuManagerRenderer.VISIBILITY_IDENTIFIER); Object rc = exprContext.eclipseContext.get(identifier); if (currentVisibility && item.getVisibleWhen() != null) { boolean val = ContributionsAnalyzer.isVisible(item.getVisibleWhen(), exprContext); currentVisibility = val;
.getTransientData().get(MenuManagerShowProcessor.DYNAMIC_ELEMENT_STORAGE_KEY);
String mnemonics = ((MMenuElement) model).getMnemonics(); if (mnemonics != null) { int idx = text.indexOf(mnemonics);
public void collectInfo(ExpressionInfo info) { ContributionsAnalyzer.collectInfo(info, menuContribution.getVisibleWhen()); for (MMenuElement item : generatedElements) { ContributionsAnalyzer.collectInfo(info, item.getVisibleWhen()); } for (MMenuElement item : sharedElements) { ContributionsAnalyzer.collectInfo(info, item.getVisibleWhen()); } }
@Override public void handleChildrenRemove(MMenu parent, Collection<MMenuElement> elements) { Iterator<MMenuElement> iterator = elements.iterator(); while (iterator.hasNext()) { MMenuElement element = iterator.next(); if (element.getWidget() != null) { hideChild(parent, element); } } } }
/** * @param menuManager * @param element * @param evalContext */ public static void updateVisibility(MenuManager menuManager, MMenuElement element, ExpressionContext evalContext) { boolean current = element.isVisible(); boolean visible = true; boolean evaluated = false; if (element.getPersistedState().get(VISIBILITY_IDENTIFIER) != null) { evaluated = true; String identifier = element.getPersistedState().get( VISIBILITY_IDENTIFIER); Object rc = evalContext.eclipseContext.get(identifier); if (rc instanceof Boolean) { visible = ((Boolean) rc).booleanValue(); } } if (visible && (element.getVisibleWhen() instanceof MCoreExpression)) { evaluated = true; visible = ContributionsAnalyzer.isVisible( (MCoreExpression) element.getVisibleWhen(), evalContext); } if (evaluated && visible != current) { element.setVisible(visible); menuManager.markDirty(); } }
if (menuElement.getElementId() == null || menuElement.getElementId().length() < 1) { menuElement.setElementId(currentMenuElement .getElementId() + "." + j); //$NON-NLS-1$ currentMenuElement.getTransientData().put(DYNAMIC_ELEMENT_STORAGE_KEY, mel);