public static boolean processAddition( final MMenu menuModel, final ArrayList<MMenuElement> menuContributionsToRemove, MMenuContribution menuContribution, final HashSet<String> existingMenuIds, HashSet<String> existingSeparatorNames) { int idx = getIndex(menuModel, menuContribution.getPositionInParent()); if (idx == -1) { return false; } for (MMenuElement item : menuContribution.getChildren()) { if (item instanceof MMenu && existingMenuIds.contains(item.getElementId())) { // skip this, it's already there continue; } else if (item instanceof MMenuSeparator && existingSeparatorNames.contains(item.getElementId())) { // skip this, it's already there continue; } MMenuElement copy = (MMenuElement) EcoreUtil.copy((EObject) item); if (DEBUG) { trace("addMenuContribution " + copy, menuModel.getWidget(), menuModel); // $NON-NLS-1$ } menuContributionsToRemove.add(copy); menuModel.getChildren().add(idx++, copy); if (copy instanceof MMenu && copy.getElementId() != null) { existingMenuIds.add(copy.getElementId()); } else if (copy instanceof MMenuSeparator && copy.getElementId() != null) { existingSeparatorNames.add(copy.getElementId()); } } return true; }
public MenuKey(MMenuContribution mc) { super( mc.getParentId(), mc.getPositionInParent(), mc.getTags(), (MCoreExpression) mc.getVisibleWhen(), mc.getTransientData().get(FACTORY)); this.contribution = mc; mc.setWidget(this); }