Program: 148700
Project: 148700
Buggy source:
protected void fillContextMenu(IMenuManager manager){
  IStructuredSelection selection=((IStructuredSelection)viewer.getSelection());
  if ((selection == null) || (selection.getFirstElement() == null)) {
    manager.add(new XSDNewConceptAction(this));
    manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    String title="String_Node_Str";
    if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() == 1)     title="String_Node_Str";
 else     if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() > 1)     title="String_Node_Str";
    XSDPasteConceptAction pasteConceptAction=new XSDPasteConceptAction(this,title);
    if (pasteConceptAction.checkInPasteType()) {
      manager.add(new Separator());
      manager.add(pasteConceptAction);
    }
    return;
  }
  Object[] selectedObjs=selection.toArray();
  Object obj=selection.getFirstElement();
  if (obj instanceof XSDElementDeclaration && selectedObjs.length == 1) {
    XSDElementDeclaration decl=(XSDElementDeclaration)obj;
    boolean isConcept=Util.checkConcept(decl);
    if (decl.getTargetNamespace() == null && !Util.IsAImporedElement(decl,xsdSchema)) {
      if (isConcept) {
        manager.add(editConceptAction);
        manager.add(deleteConceptAction);
        manager.add(newBrowseItemAction);
      }
 else {
        manager.add(editElementAction);
        manager.add(deleteElementAction);
      }
      XSDCopyConceptAction copyConceptAction=new XSDCopyConceptAction(this,"String_Node_Str");
      if (Util.checkInCopy(selectedObjs)) {
        manager.add(new Separator());
        manager.add(copyConceptAction);
      }
      String title="String_Node_Str";
      if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() > 1)       title="String_Node_Str";
 else       if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() == 1)       title="String_Node_Str";
 else       if (WorkbenchClipboard.getWorkbenchClipboard().getParticles().size() > 1)       title="String_Node_Str";
 else       if (WorkbenchClipboard.getWorkbenchClipboard().getParticles().size() == 1)       title="String_Node_Str";
      XSDPasteConceptAction pasteConceptAction=new XSDPasteConceptAction(this,title);
      if (pasteConceptAction.checkInPasteType())       manager.add(pasteConceptAction);
      manager.add(new Separator());
      manager.add(new XSDNewConceptAction(this));
      manager.add(newElementAction);
      manager.add(new Separator());
      manager.add(changeToComplexTypeAction);
      manager.add(changeToSimpleTypeAction);
      if (((XSDElementDeclaration)obj).getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
        manager.add(setFacetMsgAction);
      }
      manager.add(new Separator());
      manager.add(newIdentityConstraintAction);
    }
 else {
      if (isConcept) {
        manager.add(newBrowseItemAction);
      }
      manager.add(new XSDNewConceptAction(this));
      manager.add(newElementAction);
    }
    if (decl.getTargetNamespace() == null && !Util.IsAImporedElement(decl,xsdSchema) || !Util.IsAImporedElement(decl.getTypeDefinition(),xsdSchema))     setAnnotationActions2(obj,manager);
  }
  if (obj instanceof XSDModelGroup && !Util.IsAImporedElement((XSDModelGroup)obj,xsdSchema)) {
    manager.add(changeSubElementGroupAction);
  }
  if (obj instanceof XSDParticle && selectedObjs.length == 1) {
    XSDTerm term=((XSDParticle)obj).getTerm();
    if (!(term instanceof XSDWildcard)) {
      if (term instanceof XSDElementDeclaration) {
        if (!Util.IsAImporedElement(term,xsdSchema) || term.getContainer() instanceof XSDSchema) {
          manager.add(editParticleAction);
          manager.add(newParticleFromParticleAction);
          if (term instanceof XSDModelGroup) {
            manager.add(newParticleFromTypeAction);
            manager.add(newGroupFromTypeAction);
          }
          manager.add(deleteParticleAction);
          XSDCopyConceptAction copyConceptAction=new XSDCopyConceptAction(this,"String_Node_Str");
          manager.add(copyConceptAction);
          manager.add(new Separator());
          manager.add(changeToComplexTypeAction);
          manager.add(changeToSimpleTypeAction);
          manager.add(new Separator());
          if (term instanceof XSDElementDeclaration) {
            XSDTypeDefinition type=((XSDElementDeclaration)term).getTypeDefinition();
            setAnnotationActions(obj,manager);
            if (((XSDElementDeclaration)term).getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
              manager.add(setFacetMsgAction);
            }
            manager.add(new Separator());
            manager.add(getXPathAction);
          }
        }
      }
    }
  }
  if (obj instanceof XSDComplexTypeDefinition && selectedObjs.length == 1 && ((XSDComplexTypeDefinition)obj).getTargetNamespace() == null && !Util.IsAImporedElement((XSDParticle)obj,xsdSchema)) {
    manager.add(newParticleFromTypeAction);
    manager.add(newGroupFromTypeAction);
  }
  if (obj instanceof XSDIdentityConstraintDefinition && selectedObjs.length == 1 && ((XSDIdentityConstraintDefinition)obj).getTargetNamespace() == null && !Util.IsAImporedElement((XSDIdentityConstraintDefinition)obj,xsdSchema)) {
    manager.add(editIdentityConstraintAction);
    manager.add(deleteIdentityConstraintAction);
    manager.add(newIdentityConstraintAction);
    manager.add(new Separator());
    manager.add(newXPathAction);
  }
  if (obj instanceof XSDXPathDefinition && selectedObjs.length == 1 && ((XSDXPathDefinition)obj).getSchema().getTargetNamespace() == null && !Util.IsAImporedElement((XSDXPathDefinition)obj,xsdSchema)) {
    manager.add(editXPathAction);
    manager.add(newXPathAction);
    XSDXPathDefinition xpath=(XSDXPathDefinition)obj;
    if (xpath.getVariety().equals(XSDXPathVariety.FIELD_LITERAL))     manager.add(deleteXPathAction);
  }
  if (obj instanceof XSDSimpleTypeDefinition && selectedObjs.length == 1 && (!Util.IsAImporedElement((XSDSimpleTypeDefinition)obj,xsdSchema) || ((XSDSimpleTypeDefinition)obj).getName() == null)) {
    XSDSimpleTypeDefinition typedef=(XSDSimpleTypeDefinition)obj;
    manager.add(changeBaseTypeAction);
    manager.add(new Separator());
    EList list=typedef.getBaseTypeDefinition().getValidFacets();
    for (Iterator iter=list.iterator(); iter.hasNext(); ) {
      String element=(String)iter.next();
      manager.add(new XSDEditFacetAction(this,element));
    }
  }
  if (selectedObjs.length > 1 && deleteConceptWrapAction.checkInDeletableType(selectedObjs)) {
    deleteConceptWrapAction.prepareToDelSelectedItems(selection,viewer);
  }
  if (selectedObjs.length > 1 && deleteConceptWrapAction.checkInAllElementType(selectedObjs)) {
    manager.add(newBrowseItemAction);
  }
  if (selectedObjs.length > 1 && deleteConceptWrapAction.outPutDeleteActions() != null) {
    manager.add(deleteConceptWrapAction.outPutDeleteActions());
    String title="String_Node_Str";
    if (Util.checkInCopyTypeElement(selectedObjs))     title="String_Node_Str";
 else     if (Util.checkInCOpyTypeParticle(selectedObjs))     title="String_Node_Str";
    XSDCopyConceptAction copyConceptAction=new XSDCopyConceptAction(this,title);
    if (Util.checkInCopy(selectedObjs)) {
      manager.add(new Separator());
      manager.add(copyConceptAction);
    }
  }
  if (Util.IsEnterPrise()) {
    if (selectedObjs.length > 1 && setAnnotationWrapWriteAction.checkInWriteType(selectedObjs)) {
      manager.add(new Separator());
      manager.add(setAnnotationWrapWriteAction);
      manager.add(setAnnotationWrapNoAction);
    }
  }
  java.util.List<IAvailableModel> availablemodels=AvailableModelUtil.getAvailableModels();
  for (  IAvailableModel model : availablemodels) {
    model.fillContextMenu(obj,manager,this,dataModelName);
  }
  manager.add(new Separator());
  drillDownAdapter.addNavigationActions(manager);
  manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}

Fixed version (ground truth):
protected void fillContextMenu(IMenuManager manager){
  IStructuredSelection selection=((IStructuredSelection)viewer.getSelection());
  manager.add(new XSDNewConceptAction(this));
  if ((selection == null) || (selection.getFirstElement() == null)) {
    manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    String title="String_Node_Str";
    if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() == 1)     title="String_Node_Str";
 else     if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() > 1)     title="String_Node_Str";
    XSDPasteConceptAction pasteConceptAction=new XSDPasteConceptAction(this,title);
    if (pasteConceptAction.checkInPasteType()) {
      manager.add(new Separator());
      manager.add(pasteConceptAction);
    }
    return;
  }
  Object[] selectedObjs=selection.toArray();
  Object obj=selection.getFirstElement();
  if (obj instanceof XSDElementDeclaration && selectedObjs.length == 1) {
    XSDElementDeclaration decl=(XSDElementDeclaration)obj;
    boolean isConcept=Util.checkConcept(decl);
    if (decl.getTargetNamespace() == null && !Util.IsAImporedElement(decl,xsdSchema)) {
      if (isConcept) {
        manager.add(editConceptAction);
        manager.add(deleteConceptAction);
        manager.add(newBrowseItemAction);
      }
 else {
        manager.add(editElementAction);
        manager.add(deleteElementAction);
      }
      XSDCopyConceptAction copyConceptAction=new XSDCopyConceptAction(this,"String_Node_Str");
      if (Util.checkInCopy(selectedObjs)) {
        manager.add(new Separator());
        manager.add(copyConceptAction);
      }
      String title="String_Node_Str";
      if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() > 1)       title="String_Node_Str";
 else       if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() == 1)       title="String_Node_Str";
 else       if (WorkbenchClipboard.getWorkbenchClipboard().getParticles().size() > 1)       title="String_Node_Str";
 else       if (WorkbenchClipboard.getWorkbenchClipboard().getParticles().size() == 1)       title="String_Node_Str";
      XSDPasteConceptAction pasteConceptAction=new XSDPasteConceptAction(this,title);
      if (pasteConceptAction.checkInPasteType())       manager.add(pasteConceptAction);
      manager.add(new Separator());
      manager.add(newElementAction);
      manager.add(new Separator());
      manager.add(changeToComplexTypeAction);
      manager.add(changeToSimpleTypeAction);
      if (((XSDElementDeclaration)obj).getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
        manager.add(setFacetMsgAction);
      }
      manager.add(new Separator());
      manager.add(newIdentityConstraintAction);
    }
 else {
      if (isConcept) {
        manager.add(newBrowseItemAction);
      }
      manager.add(newElementAction);
    }
    if (decl.getTargetNamespace() == null && !Util.IsAImporedElement(decl,xsdSchema) || !Util.IsAImporedElement(decl.getTypeDefinition(),xsdSchema))     setAnnotationActions2(obj,manager);
  }
  if (obj instanceof XSDModelGroup && !Util.IsAImporedElement((XSDModelGroup)obj,xsdSchema)) {
    manager.add(changeSubElementGroupAction);
  }
  if (obj instanceof XSDParticle && selectedObjs.length == 1) {
    XSDTerm term=((XSDParticle)obj).getTerm();
    if (!(term instanceof XSDWildcard)) {
      if (term instanceof XSDElementDeclaration) {
        if (!Util.IsAImporedElement(term,xsdSchema) || term.getContainer() instanceof XSDSchema) {
          manager.add(editParticleAction);
          manager.add(newParticleFromParticleAction);
          if (term instanceof XSDModelGroup) {
            manager.add(newParticleFromTypeAction);
            manager.add(newGroupFromTypeAction);
          }
          manager.add(deleteParticleAction);
          XSDCopyConceptAction copyConceptAction=new XSDCopyConceptAction(this,"String_Node_Str");
          manager.add(copyConceptAction);
          manager.add(new Separator());
          manager.add(changeToComplexTypeAction);
          manager.add(changeToSimpleTypeAction);
          manager.add(new Separator());
          if (term instanceof XSDElementDeclaration) {
            XSDTypeDefinition type=((XSDElementDeclaration)term).getTypeDefinition();
            setAnnotationActions(obj,manager);
            if (((XSDElementDeclaration)term).getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
              manager.add(setFacetMsgAction);
            }
            manager.add(new Separator());
            manager.add(getXPathAction);
          }
        }
      }
    }
  }
  if (obj instanceof XSDComplexTypeDefinition && selectedObjs.length == 1 && ((XSDComplexTypeDefinition)obj).getTargetNamespace() == null && !Util.IsAImporedElement((XSDParticle)obj,xsdSchema)) {
    manager.add(newParticleFromTypeAction);
    manager.add(newGroupFromTypeAction);
  }
  if (obj instanceof XSDIdentityConstraintDefinition && selectedObjs.length == 1 && ((XSDIdentityConstraintDefinition)obj).getTargetNamespace() == null && !Util.IsAImporedElement((XSDIdentityConstraintDefinition)obj,xsdSchema)) {
    manager.add(editIdentityConstraintAction);
    manager.add(deleteIdentityConstraintAction);
    manager.add(newIdentityConstraintAction);
    manager.add(new Separator());
    manager.add(newXPathAction);
  }
  if (obj instanceof XSDXPathDefinition && selectedObjs.length == 1 && ((XSDXPathDefinition)obj).getSchema().getTargetNamespace() == null && !Util.IsAImporedElement((XSDXPathDefinition)obj,xsdSchema)) {
    manager.add(editXPathAction);
    manager.add(newXPathAction);
    XSDXPathDefinition xpath=(XSDXPathDefinition)obj;
    if (xpath.getVariety().equals(XSDXPathVariety.FIELD_LITERAL))     manager.add(deleteXPathAction);
  }
  if (obj instanceof XSDSimpleTypeDefinition && selectedObjs.length == 1 && (!Util.IsAImporedElement((XSDSimpleTypeDefinition)obj,xsdSchema) || ((XSDSimpleTypeDefinition)obj).getName() == null)) {
    XSDSimpleTypeDefinition typedef=(XSDSimpleTypeDefinition)obj;
    manager.add(changeBaseTypeAction);
    manager.add(new Separator());
    EList list=typedef.getBaseTypeDefinition().getValidFacets();
    for (Iterator iter=list.iterator(); iter.hasNext(); ) {
      String element=(String)iter.next();
      manager.add(new XSDEditFacetAction(this,element));
    }
  }
  if (selectedObjs.length > 1 && deleteConceptWrapAction.checkInDeletableType(selectedObjs)) {
    deleteConceptWrapAction.prepareToDelSelectedItems(selection,viewer);
  }
  if (selectedObjs.length > 1 && deleteConceptWrapAction.checkInAllElementType(selectedObjs)) {
    manager.add(newBrowseItemAction);
  }
  if (selectedObjs.length > 1 && deleteConceptWrapAction.outPutDeleteActions() != null) {
    manager.add(deleteConceptWrapAction.outPutDeleteActions());
    String title="String_Node_Str";
    if (Util.checkInCopyTypeElement(selectedObjs))     title="String_Node_Str";
 else     if (Util.checkInCOpyTypeParticle(selectedObjs))     title="String_Node_Str";
    XSDCopyConceptAction copyConceptAction=new XSDCopyConceptAction(this,title);
    if (Util.checkInCopy(selectedObjs)) {
      manager.add(new Separator());
      manager.add(copyConceptAction);
    }
  }
  if (Util.IsEnterPrise()) {
    if (selectedObjs.length > 1 && setAnnotationWrapWriteAction.checkInWriteType(selectedObjs)) {
      manager.add(new Separator());
      manager.add(setAnnotationWrapWriteAction);
      manager.add(setAnnotationWrapNoAction);
    }
  }
  java.util.List<IAvailableModel> availablemodels=AvailableModelUtil.getAvailableModels();
  for (  IAvailableModel model : availablemodels) {
    model.fillContextMenu(obj,manager,this,dataModelName);
  }
  manager.add(new Separator());
  drillDownAdapter.addNavigationActions(manager);
  manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}