Program: 72929
Project: 72929
Buggy source:
public void buildContextMenu(IMenuManager menuManager){
  if (proxy != null) {
    proxy.menuAboutToShow(menuManager);
    proxy=null;
    return;
  }
  GEFActionConstants.addStandardActionGroups(menuManager);
  Object firstSelectedElement=getFirstElement();
  Object selectedElements=getSelectedElement();
  Object multiSelection=getMultiSelectedElement();
  boolean isExtended=false;
  if (firstSelectedElement instanceof IAdaptable) {
    if (((IAdaptable)firstSelectedElement).getAdapter(DesignElementHandle.class) instanceof ExtendedItemHandle)     isExtended=true;
  }
  if (isMutilSelection(multiSelection)) {
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.UNDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.REDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CutAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CopyAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new PasteAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,getAction(ActionFactory.DELETE.getId()));
    if (isRootElementHandleClass(multiSelection)) {
      Action action=new RefreshModuleHandleAction(selectedElements);
      menuManager.add(action);
      createInsertElementMenu(menuManager,GEFActionConstants.GROUP_EDIT);
      createThemeMenu(menuManager,GEFActionConstants.GROUP_REST);
    }
    if (isListHandleCalss(multiSelection)) {
      IAction action=getAction(CreatePlaceHolderPartAction.ID);
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,action);
    }
    createStyleMenu(menuManager,GEFActionConstants.GROUP_REST);
    if (Policy.TRACING_MENU_SHOW) {
      System.out.println("String_Node_Str");
    }
  }
 else   if (firstSelectedElement instanceof DesignElementHandle || isExtended) {
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.UNDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.REDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CutAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CopyAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new PasteAction(selectedElements));
    createStyleMenu(menuManager,GEFActionConstants.GROUP_REST);
    if (((IStructuredSelection)getSelection()).size() == 1) {
      Object element=((IStructuredSelection)getSelection()).getFirstElement();
      if (element instanceof LabelEditPart || element instanceof ImageEditPart) {
        if (element instanceof DataEditPart) {
          IAction action=getAction(ChangeDataColumnPartAction.ID);
          menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,action);
        }
        IAction action=getAction(GEFActionConstants.DIRECT_EDIT);
        action.setAccelerator(SWT.F2);
        if (element instanceof DataEditPart) {
          action.setText(Messages.getString("String_Node_Str"));
        }
 else {
          action.setText(Messages.getString("String_Node_Str"));
        }
        menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,action);
      }
      if (firstSelectedElement instanceof ReportItemHandle) {
        IAction action=getAction(CreatePlaceHolderPartAction.ID);
        menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,action);
      }
      if (firstSelectedElement instanceof TemplateReportItemHandle) {
        IAction action=getAction(RevertToReportItemPartAction.ID);
        menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,action);
      }
      Object[] objs=ElementAdapterManager.getAdapters(firstSelectedElement,IReportItemViewProvider.class);
      if (objs != null && objs.length == 1) {
        IAction action=getAction(CreateChartAction.ID);
        menuManager.appendToGroup(GEFActionConstants.GROUP_VIEW,action);
      }
    }
    if (firstSelectedElement instanceof RowHandle) {
      if (getRowHandles().size() != 0) {
        MenuManager insertMenu=new MenuManager(INSERT_MENU_ITEM_TEXT);
        MenuManager rowMenu=new MenuManager(INSERT_ROW_MENU_ITEM_TEXT);
        rowMenu.add(getAction(InsertRowAboveAction.ID));
        rowMenu.add(getAction(InsertRowBelowAction.ID));
        RowHandle row=(RowHandle)getRowHandles().get(0);
        if (!(row.getContainer() instanceof GridHandle)) {
          insertMenu.add(getAction(IncludeHeaderAction.ID));
          insertMenu.add(getAction(IncludeDetailAction.ID));
          insertMenu.add(getAction(IncludeFooterAction.ID));
        }
        insertMenu.add(rowMenu);
        menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,insertMenu);
      }
      menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,getAction(DeleteRowAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(MergeAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(SplitAction.ID));
    }
 else     if (firstSelectedElement instanceof ColumnHandle) {
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,new InsertPasteColumnAction(selectedElements));
      if (getColumnHandles().size() != 0) {
        MenuManager subMenu=new MenuManager(INSERT_MENU_ITEM_TEXT);
        subMenu.add(getAction(InsertColumnRightAction.ID));
        subMenu.add(getAction(InsertColumnLeftAction.ID));
        menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,subMenu);
      }
      menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,getAction(DeleteColumnAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(MergeAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(SplitAction.ID));
    }
 else     if (firstSelectedElement instanceof CellHandle) {
      createInsertElementMenu(menuManager,GEFActionConstants.GROUP_EDIT);
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(CopyCellContentsContextAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(MergeAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(SplitAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new DeleteAction(selectedElements));
    }
 else {
      menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,getAction(ActionFactory.DELETE.getId()));
    }
    if (Policy.TRACING_MENU_SHOW) {
      System.out.println("String_Node_Str" + ((DesignElementHandle)firstSelectedElement).getDefn().getDisplayName());
    }
  }
 else   if (firstSelectedElement instanceof SlotHandle) {
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.UNDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.REDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CutAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CopyAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new PasteAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new DeleteAction(selectedElements));
    createInsertElementMenu(menuManager,GEFActionConstants.GROUP_EDIT);
    if (Policy.TRACING_MENU_SHOW) {
      System.out.println("String_Node_Str" + ((SlotHandle)firstSelectedElement).getSlotID() + "String_Node_Str"+ ((SlotHandle)firstSelectedElement).getElementHandle().getDefn().getDisplayName());
    }
  }
 else {
  }
  if (!getTableEditParts().isEmpty() || !getTableMultipleEditParts().isEmpty()) {
    createInsertGroupMenu(menuManager,GEFActionConstants.GROUP_ADD);
    if (getTableEditParts().size() == 1 || getTableMultipleEditParts().size() == 1) {
      createDeleteGroupMenus(menuManager,GEFActionConstants.GROUP_ADD);
      createEditGroupMenu(menuManager,GEFActionConstants.GROUP_ADD);
      createInsertGroupHeaderFooter(menuManager,GEFActionConstants.GROUP_ADD);
      Separator separator=new Separator(EditBindingAction.ID);
      menuManager.add(separator);
      menuManager.appendToGroup(EditBindingAction.ID,getAction(EditBindingAction.ID));
    }
  }
  if (!getListEditParts().isEmpty()) {
    createInsertGroupMenu(menuManager,GEFActionConstants.GROUP_ADD);
    if (getListEditParts().size() == 1) {
      createDeleteGroupMenus(menuManager,GEFActionConstants.GROUP_ADD);
      createEditGroupMenu(menuManager,GEFActionConstants.GROUP_ADD);
      Separator separator=new Separator(EditBindingAction.ID);
      menuManager.add(separator);
      menuManager.appendToGroup(EditBindingAction.ID,getAction(EditBindingAction.ID));
    }
  }
  if (getElements().size() == 1 || isMutilSelection(multiSelection)) {
    if (firstSelectedElement instanceof DesignElementHandle) {
      String elementName=((DesignElementHandle)firstSelectedElement).getDefn().getName();
      IMenuBuilder menuBuilder=ExtensionPointManager.getInstance().getMenuBuilder(elementName);
      if (menuBuilder != null) {
        menuBuilder.buildMenu(menuManager,getElements());
      }
    }
    Object menuAdapter=Platform.getAdapterManager().getAdapter(firstSelectedElement,IMenuListener.class);
    if (menuAdapter != null) {
      if (menuAdapter instanceof ISchematicMenuListener) {
        ((ISchematicMenuListener)menuAdapter).setActionRegistry(getActionRegistry());
      }
      ((IMenuListener)menuAdapter).menuAboutToShow(menuManager);
    }
  }
}

Fixed version (ground truth):
public void buildContextMenu(IMenuManager menuManager){
  if (proxy != null) {
    proxy.menuAboutToShow(menuManager);
    proxy=null;
    return;
  }
  GEFActionConstants.addStandardActionGroups(menuManager);
  Object firstSelectedElement=getFirstElement();
  Object selectedElements=getSelectedElement();
  Object multiSelection=getMultiSelectedElement();
  boolean isExtended=false;
  if (firstSelectedElement instanceof IAdaptable) {
    if (((IAdaptable)firstSelectedElement).getAdapter(DesignElementHandle.class) instanceof ExtendedItemHandle)     isExtended=true;
  }
  if (isMutilSelection(multiSelection)) {
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.UNDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.REDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CutAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CopyAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new PasteAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,getAction(ActionFactory.DELETE.getId()));
    if (isRootElementHandleClass(multiSelection)) {
      Action action=new RefreshModuleHandleAction(selectedElements);
      menuManager.add(action);
      createInsertElementMenu(menuManager,GEFActionConstants.GROUP_EDIT);
      createThemeMenu(menuManager,GEFActionConstants.GROUP_REST);
    }
    if (isListHandleCalss(multiSelection)) {
      IAction action=getAction(CreatePlaceHolderPartAction.ID);
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,action);
    }
    createStyleMenu(menuManager,GEFActionConstants.GROUP_REST);
    if (Policy.TRACING_MENU_SHOW) {
      System.out.println("String_Node_Str");
    }
  }
 else   if (firstSelectedElement instanceof DesignElementHandle || isExtended) {
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.UNDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.REDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CutAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CopyAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new PasteAction(selectedElements));
    createStyleMenu(menuManager,GEFActionConstants.GROUP_REST);
    if (((IStructuredSelection)getSelection()).size() == 1) {
      Object element=((IStructuredSelection)getSelection()).getFirstElement();
      if (element instanceof LabelEditPart || element instanceof ImageEditPart) {
        if (element instanceof DataEditPart) {
          IAction action=getAction(ChangeDataColumnPartAction.ID);
          menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,action);
        }
        IAction action=getAction(GEFActionConstants.DIRECT_EDIT);
        action.setAccelerator(SWT.F2);
        if (element instanceof DataEditPart) {
          action.setText(Messages.getString("String_Node_Str"));
        }
 else {
          action.setText(Messages.getString("String_Node_Str"));
        }
        menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,action);
      }
      if (firstSelectedElement instanceof ReportItemHandle) {
        IAction action=getAction(CreatePlaceHolderPartAction.ID);
        menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,action);
      }
      if (firstSelectedElement instanceof TemplateReportItemHandle) {
        IAction action=getAction(RevertToReportItemPartAction.ID);
        menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,action);
      }
      Object[] objs=ElementAdapterManager.getAdapters(firstSelectedElement,IReportItemViewProvider.class);
      if (objs != null && objs.length == 1) {
        IAction action=getAction(CreateChartAction.ID);
        menuManager.appendToGroup(GEFActionConstants.GROUP_VIEW,action);
      }
    }
    if (firstSelectedElement instanceof RowHandle) {
      if (getRowHandles().size() != 0) {
        MenuManager insertMenu=new MenuManager(INSERT_MENU_ITEM_TEXT);
        MenuManager rowMenu=new MenuManager(INSERT_ROW_MENU_ITEM_TEXT);
        rowMenu.add(getAction(InsertRowAboveAction.ID));
        rowMenu.add(getAction(InsertRowBelowAction.ID));
        RowHandle row=(RowHandle)getRowHandles().get(0);
        if (!(row.getContainer() instanceof GridHandle)) {
          insertMenu.add(getAction(IncludeHeaderAction.ID));
          insertMenu.add(getAction(IncludeDetailAction.ID));
          insertMenu.add(getAction(IncludeFooterAction.ID));
        }
        insertMenu.add(rowMenu);
        menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,insertMenu);
      }
      menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,getAction(DeleteRowAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(MergeAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(SplitAction.ID));
    }
 else     if (firstSelectedElement instanceof ColumnHandle) {
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,new InsertPasteColumnAction(selectedElements));
      if (getColumnHandles().size() != 0) {
        MenuManager subMenu=new MenuManager(INSERT_MENU_ITEM_TEXT);
        subMenu.add(getAction(InsertColumnRightAction.ID));
        subMenu.add(getAction(InsertColumnLeftAction.ID));
        menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,subMenu);
      }
      menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,getAction(DeleteColumnAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(MergeAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(SplitAction.ID));
    }
 else     if (firstSelectedElement instanceof CellHandle) {
      createInsertElementMenu(menuManager,GEFActionConstants.GROUP_EDIT);
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(CopyCellContentsContextAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(MergeAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT,getAction(SplitAction.ID));
      menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new DeleteAction(selectedElements));
    }
 else {
      menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,getAction(ActionFactory.DELETE.getId()));
    }
    if (Policy.TRACING_MENU_SHOW) {
      System.out.println("String_Node_Str" + ((DesignElementHandle)firstSelectedElement).getDefn().getDisplayName());
    }
  }
 else   if (firstSelectedElement instanceof SlotHandle) {
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.UNDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_UNDO,getAction(ActionFactory.REDO.getId()));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CutAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new CopyAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new PasteAction(selectedElements));
    menuManager.appendToGroup(GEFActionConstants.GROUP_COPY,new DeleteAction(selectedElements));
    createInsertElementMenu(menuManager,GEFActionConstants.GROUP_EDIT);
    if (Policy.TRACING_MENU_SHOW) {
      System.out.println("String_Node_Str" + ((SlotHandle)firstSelectedElement).getSlotID() + "String_Node_Str"+ ((SlotHandle)firstSelectedElement).getElementHandle().getDefn().getDisplayName());
    }
  }
 else {
  }
  if (!getTableEditParts().isEmpty() || !getTableMultipleEditParts().isEmpty()) {
    createInsertGroupMenu(menuManager,GEFActionConstants.GROUP_ADD);
    if (getTableEditParts().size() == 1 || getTableMultipleEditParts().size() == 1) {
      createDeleteGroupMenus(menuManager,GEFActionConstants.GROUP_ADD);
      createEditGroupMenu(menuManager,GEFActionConstants.GROUP_ADD);
      createInsertGroupHeaderFooter(menuManager,GEFActionConstants.GROUP_ADD);
      Separator separator=new Separator(EditBindingAction.ID);
      menuManager.add(separator);
      menuManager.appendToGroup(EditBindingAction.ID,getAction(EditBindingAction.ID));
    }
  }
  if (!getListEditParts().isEmpty()) {
    createInsertGroupMenu(menuManager,GEFActionConstants.GROUP_ADD);
    if (getListEditParts().size() == 1) {
      createDeleteGroupMenus(menuManager,GEFActionConstants.GROUP_ADD);
      createEditGroupMenu(menuManager,GEFActionConstants.GROUP_ADD);
      Separator separator=new Separator(EditBindingAction.ID);
      menuManager.add(separator);
      menuManager.appendToGroup(EditBindingAction.ID,getAction(EditBindingAction.ID));
    }
  }
  if (getElements().size() == 1 || isMutilSelection(multiSelection)) {
    if (firstSelectedElement instanceof DesignElementHandle) {
      String elementName=((DesignElementHandle)firstSelectedElement).getDefn().getName();
      IMenuBuilder menuBuilder=ExtensionPointManager.getInstance().getMenuBuilder(elementName);
      if (menuBuilder != null) {
        menuBuilder.buildMenu(menuManager,getElements());
      }
    }
    Object[] menuAdapters=ElementAdapterManager.getAdapters(firstSelectedElement,IMenuListener.class);
    if (menuAdapters != null && menuAdapters.length > 0) {
      for (int i=0; i < menuAdapters.length; i++) {
        if (menuAdapters[i] instanceof ISchematicMenuListener) {
          ((ISchematicMenuListener)menuAdapters[i]).setActionRegistry(getActionRegistry());
        }
        ((IMenuListener)menuAdapters[i]).menuAboutToShow(menuManager);
      }
    }
  }
}