public void cleanUpCopy(ContributionRecord record, MMenuElement copy) { modelContributionToRecord.remove(copy); if (copy instanceof MMenu) { MMenu menuCopy = (MMenu) copy; cleanUp(menuCopy); MenuManager copyManager = getManager(menuCopy); clearModelToManager(menuCopy, copyManager); if (copyManager != null) { record.getManagerForModel().remove(copyManager); copyManager.dispose(); } } else { IContributionItem ici = getContribution(copy); clearModelToContribution(copy, ici); if (ici != null) { record.getManagerForModel().remove(ici); } } }
/** * @param parentManager * @param itemModel * @param id */ void processDirectItem(MenuManager parentManager, MDirectMenuItem itemModel, String id) { IContributionItem ici = getContribution(itemModel); if (ici != null) { return; } final IEclipseContext lclContext = getContext(itemModel); DirectContributionItem ci = ContextInjectionFactory.make( DirectContributionItem.class, lclContext); ci.setModel(itemModel); ci.setVisible(itemModel.isVisible()); addToManager(parentManager, itemModel, ci); linkModelToContribution(itemModel, ci); }
/** * @param parentManager * @param menuModel */ private void processMenu(MenuManager parentManager, MMenu menuModel) { MenuManager menuManager = getManager(menuModel); if (menuManager == null) { String menuText = getText(menuModel); ImageDescriptor desc = getImageDescriptor(menuModel); menuManager = new MenuManager(menuText, desc, menuModel.getElementId()); linkModelToManager(menuModel, menuManager); menuManager.setVisible(menuModel.isVisible()); addToManager(parentManager, menuModel, menuManager); } // processContributions(menuModel, false); List<MMenuElement> parts = menuModel.getChildren(); if (parts != null) { MMenuElement[] plist = parts .toArray(new MMenuElement[parts.size()]); for (int i = 0; i < plist.length; i++) { MMenuElement childME = plist[i]; modelProcessSwitch(menuManager, childME); } } }
private void unlinkMenu(MMenu menu) { List<MMenuElement> children = menu.getChildren(); for (MMenuElement child : children) { if (child instanceof MMenu) unlinkMenu((MMenu) child); else { IContributionItem contribution = getContribution(child); clearModelToContribution(child, contribution); } } MenuManager mm = getManager(menu); clearModelToManager(menu, mm); }
/** * @param menuManager * @param itemModel */ private void processDynamicMenuContribution(MenuManager menuManager, MDynamicMenuContribution itemModel) { IContributionItem ici = getContribution(itemModel); if (ici != null) { return; } DynamicContributionContributionItem ci = new DynamicContributionContributionItem( itemModel); addToManager(menuManager, itemModel, ci); linkModelToContribution(itemModel, ci); }
@Override public void processContents(MElementContainer<MUIElement> container) { // I can either simply stop processing, or we can walk the model // ourselves like the "old" days // EMF gives us null lists if empty if (container == null) return; // this is in direct violation of good programming MenuManager parentManager = getManager((MMenu) ((Object) container)); if (parentManager == null) { return; } // Process any contents of the newly created ME List<MUIElement> parts = container.getChildren(); if (parts != null) { MUIElement[] plist = parts.toArray(new MUIElement[parts.size()]); for (MUIElement childME : plist) { modelProcessSwitch(parentManager, (MMenuElement) childME); } } scheduleManagerUpdate(parentManager); }
if (item instanceof MenuManager) { MenuManager childManager = (MenuManager) item; MMenu childModel = getMenuModel(childManager); if (childModel == null) { MMenu legacyModel = MenuFactoryImpl.eINSTANCE legacyModel.setElementId(childManager.getId()); legacyModel.setVisible(childManager.isVisible()); linkModelToManager(legacyModel, childManager); if (modelChildren.size() > dest) { modelChildren.add(dest, legacyModel); reconcileManagerToModel(childManager, legacyModel); } else { if (childModel instanceof MOpaqueMenu) { IEclipseContext lclContext = getContext(menuModel); if (lclContext != null) { ((MPopupMenu) childModel) MMenuElement menuElement = getMenuElement(item); if (menuElement == null) { MOpaqueMenuSeparator legacySep = MenuFactoryImpl.eINSTANCE legacySep.setVisible(item.isVisible()); legacySep.setOpaqueItem(item); linkModelToContribution(legacySep, item); if (modelChildren.size() > dest) { modelChildren.add(dest, legacySep);
MUIElement container = modelService.getContainer(element); if (container instanceof MWindow) { menuManager = getManager(menuModel); if (menuManager == null) { menuManager = new MenuManager(NO_LABEL, menuModel.getElementId()); linkModelToManager(menuModel, menuManager); menuBar = true; } else { menuManager = getManager(menuModel); if (menuManager == null) { menuManager = new MenuManager(NO_LABEL, menuModel.getElementId()); linkModelToManager(menuModel, menuManager); menuManager = getManager(menuModel); if (menuManager == null) { menuManager = new MenuManager(NO_LABEL, menuModel.getElementId()); linkModelToManager(menuModel, menuManager); Object data = getUIContainer(element); if (data instanceof Control && parent.equals(data)) { ((Control) parent).setMenu(newMenu); processContributions(menuModel, menuModel.getElementId(), menuBar, menuModel instanceof MPopupMenu); cleanUp(menuModel); MenuManager manager = getManager(menuModel); if (manager != null) { manager.markDirty();
MenuManager parent = getManager((MMenu) obj); if (itemModel.isToBeRendered()) { if (parent != null) { modelProcessSwitch(parent, itemModel); IContributionItem ici = getContribution(itemModel); clearModelToContribution(itemModel, ici); if (ici != null && parent != null) { parent.remove(ici); for (MMenu menu : menus) { if (menu instanceof MPopupMenu) unlinkMenu(menu); if (element instanceof MMenu) { MMenu menuModel = (MMenu) element; MenuManager manager = getManager(menuModel); if (manager == null) { return; if (manager.getParent() != null) { manager.getParent().markDirty(); scheduleManagerUpdate(manager.getParent()); Object obj = getContribution(itemModel); if (!(obj instanceof ContributionItem)) { return; if (item.getParent() != null) {
return; MenuManager parent = getManager((MMenu) obj); if (itemModel.isToBeRendered()) { if (parent != null) { modelProcessSwitch(parent, itemModel); IContributionItem ici = getContribution(itemModel); clearModelToContribution(itemModel, ici); if (ici != null && parent != null) { parent.remove(ici); if (element instanceof MMenu) { MMenu menuModel = (MMenu) element; MenuManager manager = getManager(menuModel); if (manager == null) { return; Object obj = getContribution(itemModel); if (!(obj instanceof ContributionItem)) { return;
/** * well, this goes to the renderer. * * @param mgr */ private void addMenuContributions(IMenuManager mgr) { IRendererFactory factory = modelPart.getContext().get(IRendererFactory.class); AbstractPartRenderer obj = factory.getRenderer(menuModel, null); if (obj instanceof MenuManagerRenderer) { MenuManagerRenderer renderer = (MenuManagerRenderer) obj; renderer.reconcileManagerToModel(menu, menuModel); renderer.processContributions(menuModel, menuModel.getElementId(), false, true); // double cast because we're bad people renderer.processContents((MElementContainer<MUIElement>) ((Object) menuModel)); } }
.eContainer(); if (container instanceof MWindow) { menuManager = getManager(menuModel); if (menuManager == null) { menuManager = new MenuManager(NO_LABEL, menuModel.getElementId()); linkModelToManager(menuModel, menuManager); menuBar = true; } else { menuManager = getManager(menuModel); if (menuManager == null) { menuManager = new MenuManager(NO_LABEL, menuModel.getElementId()); linkModelToManager(menuModel, menuManager); menuManager = getManager(menuModel); if (menuManager == null) { menuManager = new MenuManager(NO_LABEL, menuModel.getElementId()); linkModelToManager(menuModel, menuManager); processContributions(menuModel, menuModel.getElementId(), menuBar, menuModel instanceof MPopupMenu);
HashSet<ContributionRecord> records = new HashSet<>(); for (MMenuElement element : menuModel.getChildren()) { ContributionRecord record = renderer.getContributionRecord(element); if (record != null) { if (records.add(record)) { MenuManagerRenderer.updateVisibility(menuManager, element, exprContext); && element instanceof MMenu) { MMenu childMenu = (MMenu) element; MenuManager childManager = renderer.getManager(childMenu); if (childManager != null) { updateElementVisibility(childMenu, renderer, childManager,
/** * @param event */ private void updateLabelOfMenu(Event event) { String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME); MMenu model = (MMenu) event.getProperty(UIEvents.EventTags.ELEMENT); MenuManager manager = getManager(model); if ((manager == null)) { return; } if (UIEvents.UILabel.LABEL.equals(attName) || UIEvents.UILabel.LOCALIZED_LABEL.equals(attName)) { manager.setMenuText(getText(model)); manager.update(IAction.TEXT); } if (UIEvents.UILabel.ICONURI.equals(attName)) { manager.setImageDescriptor(getImageDescriptor(model)); manager.update(IAction.IMAGE); } }
public void clearModelToContribution(MMenuElement model, IContributionItem item) { if (model instanceof MMenu) { for (MMenuElement element : ((MMenu) model).getChildren()) { IContributionItem ici = getContribution(element); clearModelToContribution(element, ici); } } modelToContribution.remove(model); contributionToModel.remove(item); if (Policy.DEBUG_RENDERER) { logger.debug( "\nMMR:clearModelToContribution: modelToContribution size = {0}, contributionToModel size = {1}", //$NON-NLS-1$ modelToContribution.size(), contributionToModel.size()); } }
public void menuAboutToHide(IMenuManager manager) { if (!(manager instanceof MenuManager)) { return; } MenuManager menuManager = (MenuManager) manager; final MMenu menuModel = renderer.getMenuModel(menuManager); final Menu menu = menuManager.getMenu(); if (menuModel != null) { processDynamicElements(menuModel, menuManager); showMenu(menu, menuModel, menuManager); } }
/** * @param menuModel * @param isMenuBar * @param isPopup */ public void processContributions(MMenu menuModel, String elementId, boolean isMenuBar, boolean isPopup) { if (elementId == null) { return; } final ArrayList<MMenuContribution> toContribute = new ArrayList<>(); ContributionsAnalyzer.XXXgatherMenuContributions(menuModel, application.getMenuContributions(), elementId, toContribute, null, isPopup); generateContributions(menuModel, toContribute, isMenuBar); for (MMenuElement element : menuModel.getChildren()) { if (element instanceof MMenu) { processContributions((MMenu) element, element.getElementId(), false, isPopup); } } }
public void menuAboutToShow(IMenuManager manager) { if (!(manager instanceof MenuManager)) { return; } MenuManager menuManager = (MenuManager) manager; final MMenu menuModel = renderer.getMenuModel(menuManager); final Menu menu = menuManager.getMenu(); if (menuModel != null && menuManager != null) { cleanUp(menu, menuModel, menuManager); } if (menuModel instanceof MPopupMenu) { showPopup(menu, (MPopupMenu) menuModel, menuManager); } AbstractPartRenderer obj = rendererFactory.getRenderer(menuModel, menu.getParent()); if (!(obj instanceof MenuManagerRenderer)) { trace("Not the correct renderer: " + obj, menu, menuModel); //$NON-NLS-1$ return; } MenuManagerRenderer renderer = (MenuManagerRenderer) obj; if (menuModel.getWidget() == null) { renderer.bindWidget(menuModel, menuManager.getMenu()); } }
MenuManager manager = getManager(menuModel); boolean done = toContribute.isEmpty(); while (!done) { if (!processAddition(menuModel, manager, menuContribution, existingMenuIds, existingSeparatorNames, menuBar)) { toContribute.add(menuContribution);
/** * @param event * @param element */ private void handleLabelOfMenuItem(Event event, Object element) { String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME); MMenuItem itemModel = (MMenuItem) element; IContributionItem ici = getContribution(itemModel); if (ici == null) { return; } 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(); } }