public Menu getMenu(Menu parent) {
    dispose();

    menu = new Menu(parent);
    fillMenu(menu, concernModelProvider.getModel().getRoot().getChildren());
    return menu;
  }
  /*
   * Refresh menu when concerns and links change
   */
  @Override
  public void modelChanged(ConcernEvent events) {
    if (events.isChangedDomainName()) return;

    if (events.isChangedActiveConcernModel()) {
      concernModelProvider.getModel().removeListener(this);
      concernModelProvider = ConcernModelFactory.singleton();

      // We want to be notified when any concerns or links are
      // changed in the active concern model
      concernModelProvider.getModel().addListener(this);
    }

    boolean hasLinkOrUnlink = false;

    for (ConcernEvent event : events) {
      if (event.isLinked() || event.isUnlinked()) {
        hasLinkOrUnlink = true;
        break;
      }
    }

    if (hasLinkOrUnlink) Display.getDefault().asyncExec(new UpdateDropDownMenusRunner(events));
  }
  public UnlinkElementsAction() {

    setImageDescriptor(
        AbstractUIPlugin.imageDescriptorFromPlugin(FLATTT.ID_PLUGIN, "icons/link_break.png"));

    setText(FLATTT.getResourceString("actions.UnlinkElementsAction.ToolTip"));

    // We want to be notified when the active concern model changes
    ConcernModelFactory.singleton().addListener(this);

    concernModelProvider = ConcernModelFactory.singleton();

    // We want to be notified when any concerns or links are
    // changed in the active concern model
    concernModelProvider.getModel().addListener(this);
  }
  /** Populate the dynamic menu */
  protected void fillMenu(Menu parent, List<Concern> concerns) {
    assert parent != null;
    assert !parent.isDisposed();

    //	if (!selectedJavaElements.isEmpty())
    // {
    parent.setEnabled(true);

    fillMenuRecursive(parent, concerns, selectedJavaElements, concernModelProvider.getLinkType());

    String linkAllLabel = getNewConcernMenuItemText();

    for (MenuItem menuItem : parent.getItems()) {
      String text = menuItem.getText();

      if (text.isEmpty()) {
        menuItem.dispose();
      } else if (text.equals(linkAllLabel)) {
        menuItem.dispose();
        break;
      }
    }

    // If there were concerns in the model, add a separator before
    // the New Concern item

    boolean hasItemsToLink = parent.getItemCount() > 0;

    /*if (hasItemsToLink)
    {
    	new MenuItem(parent, SWT.SEPARATOR);
    }*/

    // Add the "New concern..." item
    /*MenuItem lNewConcernItem = new MenuItem(parent, SWT.PUSH);
    lNewConcernItem.addSelectionListener(clickListener);
    lNewConcernItem.setText(linkAllLabel);*/
    /*	}
    else
    {
    	parent.setEnabled(false);
    }*/
  }
 private void refresh(ConcernEvent events) {
   if (menu != null) {
     fillMenu(menu, concernModelProvider.getModel().getRoot().getChildren());
   }
 }
 public Menu getMenu(MenuManager mng) {
   dispose();
   menu = mng.getMenu();
   fillMenu(menu, concernModelProvider.getModel().getRoot().getChildren());
   return menu;
 }