/**
   * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, handling {@link
   * org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
   * that can be added to the selected object and updating the menus accordingly.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void selectionChanged(SelectionChangedEvent event) {
    // Remove any menu items for old selection.
    //
    if (createChildMenuManager != null) {
      depopulateManager(createChildMenuManager, createChildSubmenuActions);
      depopulateManager(createChildMenuManager, createChildActions);
    }
    if (createSiblingMenuManager != null) {
      depopulateManager(createSiblingMenuManager, createSiblingSubmenuActions);
      depopulateManager(createSiblingMenuManager, createSiblingActions);
    }

    // Query the new selection for appropriate new child/sibling descriptors
    //
    Collection<?> newChildDescriptors = null;
    Collection<?> newSiblingDescriptors = null;

    ISelection selection = event.getSelection();
    if (selection instanceof IStructuredSelection
        && ((IStructuredSelection) selection).size() == 1) {
      Object object = ((IStructuredSelection) selection).getFirstElement();

      EditingDomain domain = ((IEditingDomainProvider) activeEditorPart).getEditingDomain();

      newChildDescriptors = domain.getNewChildDescriptors(object, null);
      newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
    }

    // Generate actions for selection; populate and redraw the menus.
    //
    createChildActions = generateCreateChildActions(newChildDescriptors, selection);
    createChildSubmenuActions = extractSubmenuActions(createChildActions);
    createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
    createSiblingSubmenuActions = extractSubmenuActions(createSiblingActions);

    if (createChildMenuManager != null) {
      populateManager(createChildMenuManager, createChildSubmenuActions, null);
      populateManager(createChildMenuManager, createChildActions, null);
      createChildMenuManager.update(true);
    }
    if (createSiblingMenuManager != null) {
      populateManager(createSiblingMenuManager, createSiblingSubmenuActions, null);
      populateManager(createSiblingMenuManager, createSiblingActions, null);
      createSiblingMenuManager.update(true);
    }
  }
 public void addActionsToMenu() {
   for (Action action : additionalActions) {
     if (toolbarMM.getItems().length != additionalActions.size() + 2) {
       barMM.add(action);
       barMM.update(true);
       toolbarMM.add(action);
       toolbarMM.update(true);
     }
   }
   additionalActions.clear();
 }
  /** Updates the form menu. Sub-classes can extend if needed. */
  protected void updateFormMenuManager() {
    IMenuManager menuManager = mainForm.getMenuManager();
    menuManager.removeAll();

    for (CmrRepositoryDefinition cmrRepositoryDefinition :
        cmrRepositoryManager.getCmrRepositoryDefinitions()) {
      if (!Objects.equals(cmrRepositoryDefinition, displayedCmrRepositoryDefinition)) {
        menuManager.add(new SelectCmrAction(cmrRepositoryDefinition));
      }
    }
    menuManager.update(true);
    mainForm.getHead().layout();
  }
  private void cleanMenuBar() {
    String contribID = null;

    for (IContributionItem contribItem : myMenuBar.getItems()) {
      contribID = contribItem.getId();

      if ((contribID.startsWith("org.eclipse."))
          || (contribID.startsWith(IWorkbenchActionConstants.MB_ADDITIONS))
          || (contribID.startsWith(IWorkbenchActionConstants.M_NAVIGATE))) {
        myMenuBar.remove(contribItem);
      }
    }

    //
    //	myMenuBar.getgetParent().getParent().getParent().setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW));

    myMenuBar.update(true); // refresh the display of the menu bar
  }