Program: 58128
Project: 58128
Buggy source:
@Override protected void handlePickingEvents(EPickingType ePickingType,EPickingMode pickingMode,int iExternalID,Pick pick){
  if (detailLevel == DetailLevel.VERY_LOW) {
    return;
  }
switch (ePickingType) {
case GROUPER_GROUP_SELECTION:
    final GroupRepresentation groupRep=hashGroups.get(iExternalID);
switch (pickingMode) {
case CLICKED:
    iDraggedOverCollapseButtonID=-1;
  if (groupRep != null) {
    if (!bControlPressed && !selectionManager.checkStatus(SelectionType.SELECTION,groupRep.getID())) {
      dragAndDropController.clearDraggables();
      selectionManager.clearSelection(SelectionType.SELECTION);
      selectionManager.clearSelection(selectionTypeClicked);
    }
    if (!bControlPressed) {
      potentialNewSelectedGroup=groupRep;
      bPotentialNewSelection=true;
    }
    dragAndDropController.setDraggingStartPosition(pick.getPickedPoint());
    groupRep.addAsDraggable(dragAndDropController);
    groupRep.setSelectionTypeRec(SelectionType.SELECTION,selectionManager);
    selectionManager.addToType(selectionTypeClicked,groupRep.getID());
    rootGroup.updateSelections(selectionManager,drawingStrategyManager);
    triggerSelectionEvents();
    setDisplayListDirty();
  }
break;
case DRAGGED:
iDraggedOverCollapseButtonID=-1;
if (groupRep != null && dragAndDropController.hasDraggables()) {
if (!dragAndDropController.isDragging()) {
if (dragAndDropController.containsDraggable(groupRep)) {
  bPotentialNewSelection=false;
  dragAndDropController.startDragging();
}
}
if (groupRep.isLeaf()) {
GroupRepresentation parent=(GroupRepresentation)groupRep.getParent();
if (parent != null) dragAndDropController.setDropArea(parent);
}
 else {
dragAndDropController.setDropArea(groupRep);
}
}
break;
case MOUSE_OVER:
iDraggedOverCollapseButtonID=-1;
if (groupRep != null) {
if (selectionManager.checkStatus(SelectionType.MOUSE_OVER,groupRep.getID()) || selectionManager.checkStatus(SelectionType.SELECTION,groupRep.getID())) {
return;
}
selectionManager.clearSelection(SelectionType.MOUSE_OVER);
selectionManager.addToType(SelectionType.MOUSE_OVER,groupRep.getID());
rootGroup.updateSelections(selectionManager,drawingStrategyManager);
triggerSelectionEvents();
setDisplayListDirty();
}
break;
case RIGHT_CLICKED:
if (groupRep != null) {
boolean bContextMenueItemsAvailable=false;
if (selectionManager.checkStatus(SelectionType.SELECTION,groupRep.getID()) && groupRep != rootGroup) {
RenameGroupItem renameItem=new RenameGroupItem(iExternalID);
contextMenu.addContextMenueItem(renameItem);
Set<Integer> setSelectedGroups=new HashSet<Integer>(selectionManager.getElements(SelectionType.SELECTION));
CreateGroupItem createGroupItem=new CreateGroupItem(setSelectedGroups);
contextMenu.addContextMenueItem(createGroupItem);
CopyGroupsItem copyGroupsItem=new CopyGroupsItem(setSelectedGroups);
contextMenu.addContextMenueItem(copyGroupsItem);
DeleteGroupsItem deleteGroupsItem=new DeleteGroupsItem(setSelectedGroups);
contextMenu.addContextMenueItem(deleteGroupsItem);
Set<Integer> setClickedGroups=new HashSet<Integer>(selectionManager.getElements(selectionTypeClicked));
ArrayList<ICompositeGraphic> orderedComposites=getOrderedCompositeList(setClickedGroups,false);
ArrayList<ISet> selectedSets=new ArrayList<ISet>();
for (ICompositeGraphic composite : orderedComposites) {
selectedSets.add(((GroupRepresentation)composite).getClusterNode().getMetaSet());
}
if (Platform.getBundle("String_Node_Str") != null) {
contextMenu.addSeparator();
GeneralManager.get().getRStatisticsPerformer();
StatisticsPValueReductionItem pValueReductionItem=new StatisticsPValueReductionItem(selectedSets);
contextMenu.addContextMenueItem(pValueReductionItem);
if (orderedComposites.size() == 2) {
StatisticsFoldChangeReductionItem foldChangeReductionItem=new StatisticsFoldChangeReductionItem(selectedSets.get(0),selectedSets.get(1));
contextMenu.addContextMenueItem(foldChangeReductionItem);
StatisticsTwoSidedTTestReductionItem twoSidedTTestReductionItem=new StatisticsTwoSidedTTestReductionItem(selectedSets);
contextMenu.addContextMenueItem(twoSidedTTestReductionItem);
}
}
if (orderedComposites.size() >= 2) {
contextMenu.addSeparator();
CompareGroupsItem compareGroupsItem=new CompareGroupsItem(selectedSets);
contextMenu.addContextMenueItem(compareGroupsItem);
}
bContextMenueItemsAvailable=true;
}
if (setCopiedGroups != null && !setCopiedGroups.contains(groupRep.getID()) && !groupRep.isLeaf()) {
PasteGroupsItem pasteGroupItem=new PasteGroupsItem(groupRep.getID());
contextMenu.addContextMenueItem(pasteGroupItem);
bContextMenueItemsAvailable=true;
}
if (!isRenderedRemote() && bContextMenueItemsAvailable) {
contextMenu.setLocation(pick.getPickedPoint(),getParentGLCanvas().getWidth(),getParentGLCanvas().getHeight());
contextMenu.setMasterGLView(this);
}
}
break;
default :
return;
}
break;
case GROUPER_BACKGROUND_SELECTION:
switch (pickingMode) {
case CLICKED:
iDraggedOverCollapseButtonID=-1;
dragAndDropController.clearDraggables();
selectionManager.clearSelections();
rootGroup.updateSelections(selectionManager,drawingStrategyManager);
triggerSelectionEvents();
setDisplayListDirty();
break;
default :
return;
}
break;
case GROUPER_COLLAPSE_BUTTON_SELECTION:
GroupRepresentation group=hashGroups.get(iExternalID);
switch (pickingMode) {
case CLICKED:
iDraggedOverCollapseButtonID=-1;
if (group != null) {
group.setCollapsed(!group.isCollapsed());
setDisplayListDirty();
}
break;
case DRAGGED:
if (group != null && group.isCollapsed()) {
double dCurrentTimeStamp=Calendar.getInstance().getTimeInMillis();
if (dCurrentTimeStamp - dCollapseButtonDragOverTime > 500 && group.getID() == iDraggedOverCollapseButtonID) {
group.setCollapsed(false);
iDraggedOverCollapseButtonID=-1;
setDisplayListDirty();
return;
}
if (group.getID() != iDraggedOverCollapseButtonID) dCollapseButtonDragOverTime=dCurrentTimeStamp;
iDraggedOverCollapseButtonID=group.getID();
}
default :
return;
}
break;
}
}

Fixed version (ground truth):
@Override protected void handlePickingEvents(EPickingType ePickingType,EPickingMode pickingMode,int iExternalID,Pick pick){
  if (detailLevel == DetailLevel.VERY_LOW) {
    return;
  }
switch (ePickingType) {
case GROUPER_GROUP_SELECTION:
    final GroupRepresentation groupRep=hashGroups.get(iExternalID);
switch (pickingMode) {
case CLICKED:
    iDraggedOverCollapseButtonID=-1;
  if (groupRep != null) {
    if (!bControlPressed && !selectionManager.checkStatus(SelectionType.SELECTION,groupRep.getID())) {
      dragAndDropController.clearDraggables();
      selectionManager.clearSelection(SelectionType.SELECTION);
      selectionManager.clearSelection(selectionTypeClicked);
    }
    if (!bControlPressed) {
      potentialNewSelectedGroup=groupRep;
      bPotentialNewSelection=true;
    }
    dragAndDropController.setDraggingStartPosition(pick.getPickedPoint());
    groupRep.addAsDraggable(dragAndDropController);
    groupRep.setSelectionTypeRec(SelectionType.SELECTION,selectionManager);
    selectionManager.addToType(selectionTypeClicked,groupRep.getID());
    if (groupRep.isLeaf())     rootGroup.updateSelections(selectionManager,drawingStrategyManager);
    triggerSelectionEvents();
    setDisplayListDirty();
  }
break;
case DRAGGED:
iDraggedOverCollapseButtonID=-1;
if (groupRep != null && dragAndDropController.hasDraggables()) {
if (!dragAndDropController.isDragging()) {
if (dragAndDropController.containsDraggable(groupRep)) {
  bPotentialNewSelection=false;
  dragAndDropController.startDragging();
}
}
if (groupRep.isLeaf()) {
GroupRepresentation parent=(GroupRepresentation)groupRep.getParent();
if (parent != null) dragAndDropController.setDropArea(parent);
}
 else {
dragAndDropController.setDropArea(groupRep);
}
}
break;
case MOUSE_OVER:
iDraggedOverCollapseButtonID=-1;
if (groupRep != null) {
if (selectionManager.checkStatus(SelectionType.MOUSE_OVER,groupRep.getID()) || selectionManager.checkStatus(SelectionType.SELECTION,groupRep.getID())) {
return;
}
selectionManager.clearSelection(SelectionType.MOUSE_OVER);
selectionManager.addToType(SelectionType.MOUSE_OVER,groupRep.getID());
rootGroup.updateSelections(selectionManager,drawingStrategyManager);
triggerSelectionEvents();
setDisplayListDirty();
}
break;
case RIGHT_CLICKED:
if (groupRep != null) {
boolean bContextMenueItemsAvailable=false;
if (selectionManager.checkStatus(SelectionType.SELECTION,groupRep.getID()) && groupRep != rootGroup) {
RenameGroupItem renameItem=new RenameGroupItem(iExternalID);
contextMenu.addContextMenueItem(renameItem);
Set<Integer> setSelectedGroups=new HashSet<Integer>(selectionManager.getElements(SelectionType.SELECTION));
CreateGroupItem createGroupItem=new CreateGroupItem(setSelectedGroups);
contextMenu.addContextMenueItem(createGroupItem);
CopyGroupsItem copyGroupsItem=new CopyGroupsItem(setSelectedGroups);
contextMenu.addContextMenueItem(copyGroupsItem);
DeleteGroupsItem deleteGroupsItem=new DeleteGroupsItem(setSelectedGroups);
contextMenu.addContextMenueItem(deleteGroupsItem);
Set<Integer> setClickedGroups=new HashSet<Integer>(selectionManager.getElements(selectionTypeClicked));
ArrayList<ICompositeGraphic> orderedComposites=getOrderedCompositeList(setClickedGroups,false);
ArrayList<ISet> selectedSets=new ArrayList<ISet>();
for (ICompositeGraphic composite : orderedComposites) {
selectedSets.add(((GroupRepresentation)composite).getClusterNode().getMetaSet());
}
if (Platform.getBundle("String_Node_Str") != null) {
contextMenu.addSeparator();
GeneralManager.get().getRStatisticsPerformer();
StatisticsPValueReductionItem pValueReductionItem=new StatisticsPValueReductionItem(selectedSets);
contextMenu.addContextMenueItem(pValueReductionItem);
if (orderedComposites.size() == 2) {
StatisticsFoldChangeReductionItem foldChangeReductionItem=new StatisticsFoldChangeReductionItem(selectedSets.get(0),selectedSets.get(1));
contextMenu.addContextMenueItem(foldChangeReductionItem);
StatisticsTwoSidedTTestReductionItem twoSidedTTestReductionItem=new StatisticsTwoSidedTTestReductionItem(selectedSets);
contextMenu.addContextMenueItem(twoSidedTTestReductionItem);
}
}
if (orderedComposites.size() >= 2) {
contextMenu.addSeparator();
CompareGroupsItem compareGroupsItem=new CompareGroupsItem(selectedSets);
contextMenu.addContextMenueItem(compareGroupsItem);
}
bContextMenueItemsAvailable=true;
}
if (setCopiedGroups != null && !setCopiedGroups.contains(groupRep.getID()) && !groupRep.isLeaf()) {
PasteGroupsItem pasteGroupItem=new PasteGroupsItem(groupRep.getID());
contextMenu.addContextMenueItem(pasteGroupItem);
bContextMenueItemsAvailable=true;
}
if (!isRenderedRemote() && bContextMenueItemsAvailable) {
contextMenu.setLocation(pick.getPickedPoint(),getParentGLCanvas().getWidth(),getParentGLCanvas().getHeight());
contextMenu.setMasterGLView(this);
}
}
break;
default :
return;
}
break;
case GROUPER_BACKGROUND_SELECTION:
switch (pickingMode) {
case CLICKED:
iDraggedOverCollapseButtonID=-1;
dragAndDropController.clearDraggables();
selectionManager.clearSelections();
rootGroup.updateSelections(selectionManager,drawingStrategyManager);
triggerSelectionEvents();
setDisplayListDirty();
break;
default :
return;
}
break;
case GROUPER_COLLAPSE_BUTTON_SELECTION:
GroupRepresentation group=hashGroups.get(iExternalID);
switch (pickingMode) {
case CLICKED:
iDraggedOverCollapseButtonID=-1;
if (group != null) {
group.setCollapsed(!group.isCollapsed());
setDisplayListDirty();
}
break;
case DRAGGED:
if (group != null && group.isCollapsed()) {
double dCurrentTimeStamp=Calendar.getInstance().getTimeInMillis();
if (dCurrentTimeStamp - dCollapseButtonDragOverTime > 500 && group.getID() == iDraggedOverCollapseButtonID) {
group.setCollapsed(false);
iDraggedOverCollapseButtonID=-1;
setDisplayListDirty();
return;
}
if (group.getID() != iDraggedOverCollapseButtonID) dCollapseButtonDragOverTime=dCurrentTimeStamp;
iDraggedOverCollapseButtonID=group.getID();
}
default :
return;
}
break;
}
}