private void createModelFor(String id) {
   if (id == null) {
     id = getClass().getName() + '.' + System.identityHashCode(this);
   }
   menuModel = null;
   for (MMenu item : modelPart.getMenus()) {
     if (id.equals(item.getElementId())
         && item instanceof MPopupMenu
         && item.getTags().contains(ContributionsAnalyzer.MC_POPUP)) {
       menuModel = (MPopupMenu) item;
       break;
     }
   }
   if (menuModel == null) {
     menuModel = MenuFactoryImpl.eINSTANCE.createPopupMenu();
     menuModel.setElementId(id);
     menuModel.getTags().add(ContributionsAnalyzer.MC_POPUP);
     modelPart.getMenus().add(menuModel);
   }
   IRendererFactory factory = modelPart.getContext().get(IRendererFactory.class);
   AbstractPartRenderer obj = factory.getRenderer(menuModel, null);
   if (obj instanceof MenuManagerRenderer) {
     ((MenuManagerRenderer) obj).linkModelToManager(menuModel, menu);
   }
   registerE4Support();
   cleanUpContributionCache();
 }
 static boolean isFiltered(
     MMenu menuModel, MMenuContribution menuContribution, boolean includePopups) {
   if (includePopups || menuModel.getTags().contains(ContributionsAnalyzer.MC_POPUP)) {
     return !menuContribution.getTags().contains(ContributionsAnalyzer.MC_POPUP)
         && menuContribution.getTags().contains(ContributionsAnalyzer.MC_MENU);
   }
   if (menuModel.getTags().contains(ContributionsAnalyzer.MC_MENU)) {
     return !menuContribution.getTags().contains(ContributionsAnalyzer.MC_MENU)
         && menuContribution.getTags().contains(ContributionsAnalyzer.MC_POPUP);
   }
   if (!includePopups) {
     // not including popups, so filter out popup menu contributions if the menu is a regular
     // menu
     return menuContribution.getTags().contains(ContributionsAnalyzer.MC_POPUP);
   }
   return false;
 }
 public static void XXXgatherMenuContributions(
     final MMenu menuModel,
     final List<MMenuContribution> menuContributionList,
     final String id,
     final ArrayList<MMenuContribution> toContribute,
     final ExpressionContext eContext,
     boolean includePopups) {
   if (id == null || id.length() == 0) {
     return;
   }
   ArrayList<String> popupIds = new ArrayList<String>();
   if (includePopups) {
     popupIds.add(id);
     for (String tag : menuModel.getTags()) {
       if (tag.startsWith("popup:")) { // $NON-NLS-1$
         String tmp = tag.substring("popup:".length()); // $NON-NLS-1$
         if (!popupIds.contains(tmp)) {
           popupIds.add(tmp);
         }
       }
     }
   }
   for (MMenuContribution menuContribution : menuContributionList) {
     String parentID = menuContribution.getParentId();
     if (parentID == null) {
       // it doesn't make sense for this to be null, temporary workaround for bug 320790
       continue;
     }
     boolean popupTarget = includePopups && popupIds.contains(parentID);
     boolean popupAny =
         includePopups && menuModel instanceof MPopupMenu && POPUP_PARENT_ID.equals(parentID);
     boolean filtered = isFiltered(menuModel, menuContribution, includePopups);
     if (filtered
         || (!popupAny && !popupTarget && !parentID.equals(id))
         || !menuContribution.isToBeRendered()) {
       continue;
     }
     toContribute.add(menuContribution);
   }
 }