Program: 188022
Project: 188022
Buggy source:
public void handleClick(MouseEvent ev){
  if (ev.getButton() == 1) {
    if (Repository.getSuiteNr() == 0)     return;
    if (keypress == 0) {
      deselectAll();
      getClickedItem(ev.getX(),ev.getY());
      if (selected.size() > 0) {
        selectItem(selected);
        if (getItem(selected,false).getType() == 2) {
          Item temp=getItem(selected,false);
          int userDefNr=temp.getUserDefNr();
          boolean root=false;
          Repository.window.mainpanel.p1.suitaDetails.setParent(temp);
          if (temp.getPos().size() == 1) {
            root=true;
            if (userDefNr != Repository.window.mainpanel.p1.suitaDetails.getDefsNr()) {
              System.out.println("String_Node_Str" + temp.getName() + "String_Node_Str"+ userDefNr+ "String_Node_Str"+ Repository.window.mainpanel.p1.suitaDetails.getDefsNr()+ "String_Node_Str");
              if (Repository.window.mainpanel.p1.suitaDetails.getDefsNr() < userDefNr) {
                temp.getUserDefs().subList(Repository.window.mainpanel.p1.suitaDetails.getDefsNr(),userDefNr).clear();
              }
            }
            try {
              for (int i=0; i < Repository.window.mainpanel.p1.suitaDetails.getDefsNr(); i++) {
                if (temp.getUserDefNr() == i)                 break;
                Repository.window.mainpanel.p1.suitaDetails.getDefPanel(i).setDescription(temp.getUserDef(i)[1]);
              }
            }
 catch (            Exception e) {
              e.printStackTrace();
            }
          }
          Repository.window.mainpanel.p1.suitaDetails.setSuiteDetails(root);
        }
        if (getItem(selected,false).getType() == 1) {
          Item temp=getItem(selected,false);
          Repository.window.mainpanel.p1.suitaDetails.setParent(temp);
          Repository.window.mainpanel.p1.suitaDetails.setTCDetails();
        }
        if (getItem(selected,false).getCheckRectangle().intersects(new Rectangle(ev.getX() - 1,ev.getY() - 1,2,2))) {
          getItem(selected,false).setCheck(!getItem(selected,false).getCheck());
        }
 else         if (getItem(selected,false).getSubItemsNr() > 0 && ev.getClickCount() == 2 && getItem(selected,false).getType() != 1) {
          if (getItem(selected,false).getType() == 2 && !itemIsExpanded(getItem(selected,false))) {
            if (!onlyOptionals)             getItem(selected,false).setVisibleTC();
 else {
              Item parent=getItem(selected,false);
              for (              Item i : parent.getSubItems()) {
                if (i.isOptional()) {
                  i.setSubItemVisible(true);
                  i.setSubItemVisible(true);
                  i.setVisible(false);
                }
              }
            }
          }
 else           getItem(selected,false).setVisible(!itemIsExpanded(getItem(selected,false)));
        }
        updateLocations(getItem(selected,false));
      }
 else {
        Repository.window.mainpanel.p1.suitaDetails.setGlobalDetails();
      }
      repaint();
    }
 else     if (keypress == 2) {
      getClickedItem(ev.getX(),ev.getY());
      if (selected.size() > 0) {
        int[] theone=new int[selected.size()];
        for (int i=0; i < selected.size(); i++) {
          theone[i]=selected.get(i).intValue();
        }
        Item theone1=getItem(selected,false);
        theone1.select(!theone1.isSelected());
        if (theone1.isSelected())         selectedcollection.add(theone);
 else {
          for (int m=0; m < selectedcollection.size(); m++) {
            if (Arrays.equals(selectedcollection.get(m),theone)) {
              selectedcollection.remove(m);
              break;
            }
          }
        }
        if (selectedcollection.size() == 0) {
          Repository.window.mainpanel.p1.remove.setEnabled(false);
        }
        repaint();
      }
    }
 else {
      if (selected.size() > 0) {
        deselectAll();
        int[] theone1=new int[selected.size()];
        for (int i=0; i < selected.size(); i++) {
          theone1[i]=selected.get(i).intValue();
        }
        getClickedItem(ev.getX(),ev.getY());
        int[] theone2=new int[selected.size()];
        for (int i=0; i < selected.size(); i++) {
          theone2[i]=selected.get(i).intValue();
        }
        if (theone1.length == theone2.length) {
          if (theone1.length > 1) {
            int[] temp1, temp2;
            temp1=Arrays.copyOfRange(theone1,0,theone1.length - 1);
            temp2=Arrays.copyOfRange(theone2,0,theone2.length - 1);
            if (Arrays.equals(temp1,temp2)) {
              int[] first, second;
              if (theone2[theone2.length - 1] >= theone1[theone1.length - 1]) {
                first=theone2;
                second=theone1;
              }
 else {
                first=theone1;
                second=theone2;
              }
              ArrayList<Integer> temp11=new ArrayList<Integer>();
              for (int i=0; i < temp1.length; i++)               temp11.add(new Integer(temp1[i]));
              Item parent=getItem(temp11,false);
              for (int i=second[second.length - 1]; i < first[first.length - 1] + 1; i++) {
                parent.getSubItem(i).select(true);
                int[] temporary=new int[parent.getSubItem(i).getPos().size()];
                for (int m=0; m < temporary.length; m++) {
                  temporary[m]=parent.getSubItem(i).getPos().get(m).intValue();
                }
                selectedcollection.add(temporary);
              }
            }
          }
 else {
            int first, second;
            if (theone1[0] >= theone2[0]) {
              first=theone1[0];
              second=theone2[0];
            }
 else {
              second=theone1[0];
              first=theone2[0];
            }
            for (int m=second; m < first + 1; m++) {
              Repository.getSuita(m).select(true);
              selectedcollection.add(new int[]{m});
            }
          }
        }
        repaint();
      }
    }
  }
  if (ev.getButton() == 3) {
    getClickedItem(ev.getX(),ev.getY());
    if ((selected.size() == 0)) {
      if (Repository.getSuiteNr() > 0) {
        deselectAll();
        repaint();
      }
      noSelectionPopUp(ev);
    }
 else {
      if (!getItem(selected,false).isSelected()) {
        deselectAll();
        selectItem(selected);
        repaint();
        Item temp=getItem(selected,false);
        if (temp.getType() == 0)         propertyPopUp(ev,getItem(selected,false));
 else         if (temp.getType() == 1) {
          Repository.window.mainpanel.p1.suitaDetails.setParent(temp);
          Repository.window.mainpanel.p1.suitaDetails.setTCDetails();
          tcPopUp(ev,getItem(selected,false));
        }
 else {
          boolean root=false;
          Repository.window.mainpanel.p1.suitaDetails.setParent(temp);
          if (temp.getPos().size() == 1) {
            root=true;
            int userDefNr=temp.getUserDefNr();
            if (userDefNr != Repository.window.mainpanel.p1.suitaDetails.getDefsNr()) {
              System.out.println("String_Node_Str" + temp.getName() + "String_Node_Str"+ userDefNr+ "String_Node_Str"+ Repository.window.mainpanel.p1.suitaDetails.getDefsNr()+ "String_Node_Str");
              if (Repository.window.mainpanel.p1.suitaDetails.getDefsNr() < userDefNr) {
                temp.getUserDefs().subList(Repository.window.mainpanel.p1.suitaDetails.getDefsNr(),userDefNr).clear();
              }
            }
            try {
              for (int i=0; i < Repository.window.mainpanel.p1.suitaDetails.getDefsNr(); i++) {
                if (temp.getUserDefNr() == i)                 break;
                Repository.window.mainpanel.p1.suitaDetails.getDefPanel(i).setDescription(temp.getUserDef(i)[1]);
              }
            }
 catch (            Exception e) {
              e.printStackTrace();
            }
          }
          Repository.window.mainpanel.p1.suitaDetails.setSuiteDetails(root);
          suitaPopUp(ev,temp);
        }
      }
 else {
        if (selectedcollection.size() == 1) {
          if (getItem(selected,false).getType() == 0)           propertyPopUp(ev,getItem(selected,false));
 else           if (getItem(selected,false).getType() == 1)           tcPopUp(ev,getItem(selected,false));
 else {
            System.out.println("String_Node_Str");
            Item temp=getItem(selected,false);
            boolean root=false;
            Repository.window.mainpanel.p1.suitaDetails.setParent(temp);
            if (temp.getPos().size() == 1) {
              root=true;
              int userDefNr=temp.getUserDefNr();
              if (userDefNr != Repository.window.mainpanel.p1.suitaDetails.getDefsNr()) {
                System.out.println("String_Node_Str" + temp.getName() + "String_Node_Str"+ userDefNr+ "String_Node_Str"+ Repository.window.mainpanel.p1.suitaDetails.getDefsNr()+ "String_Node_Str");
                if (Repository.window.mainpanel.p1.suitaDetails.getDefsNr() < userDefNr) {
                  temp.getUserDefs().subList(Repository.window.mainpanel.p1.suitaDetails.getDefsNr(),userDefNr).clear();
                }
              }
              try {
                for (int i=0; i < Repository.window.mainpanel.p1.suitaDetails.getDefsNr(); i++) {
                  if (temp.getUserDefNr() == i)                   break;
                  Repository.window.mainpanel.p1.suitaDetails.getDefPanel(i).setDescription(temp.getUserDef(i)[1]);
                }
              }
 catch (              Exception e) {
                e.printStackTrace();
              }
            }
            Repository.window.mainpanel.p1.suitaDetails.setSuiteDetails(root);
            suitaPopUp(ev,getItem(selected,false));
          }
        }
 else {
          multipleSelectionPopUp(ev);
        }
      }
    }
  }
  if (selectedcollection.size() > 0)   Repository.window.mainpanel.p1.remove.setEnabled(true);
}

Fixed version (ground truth):
public void handleClick(MouseEvent ev){
  if (ev.getButton() == 1) {
    if (Repository.getSuiteNr() == 0)     return;
    if (keypress == 0) {
      deselectAll();
      getClickedItem(ev.getX(),ev.getY());
      if (selected.size() > 0) {
        selectItem(selected);
        if (getItem(selected,false).getType() == 2) {
          Item temp=getItem(selected,false);
          int userDefNr=temp.getUserDefNr();
          boolean root=false;
          Repository.window.mainpanel.p1.suitaDetails.setParent(temp);
          if (temp.getPos().size() == 1) {
            root=true;
            if (userDefNr != Repository.window.mainpanel.p1.suitaDetails.getDefsNr()) {
              System.out.println("String_Node_Str" + temp.getName() + "String_Node_Str"+ userDefNr+ "String_Node_Str"+ Repository.window.mainpanel.p1.suitaDetails.getDefsNr()+ "String_Node_Str");
              if (Repository.window.mainpanel.p1.suitaDetails.getDefsNr() < userDefNr) {
                temp.getUserDefs().subList(Repository.window.mainpanel.p1.suitaDetails.getDefsNr(),userDefNr).clear();
              }
            }
            try {
              for (int i=0; i < Repository.window.mainpanel.p1.suitaDetails.getDefsNr(); i++) {
                if (temp.getUserDefNr() == i)                 break;
                Repository.window.mainpanel.p1.suitaDetails.getDefPanel(i).setDescription(temp.getUserDef(i)[1],true);
              }
            }
 catch (            Exception e) {
              e.printStackTrace();
            }
          }
          Repository.window.mainpanel.p1.suitaDetails.setSuiteDetails(root);
        }
        if (getItem(selected,false).getType() == 1) {
          Item temp=getItem(selected,false);
          Repository.window.mainpanel.p1.suitaDetails.setParent(temp);
          Repository.window.mainpanel.p1.suitaDetails.setTCDetails();
        }
        if (getItem(selected,false).getCheckRectangle().intersects(new Rectangle(ev.getX() - 1,ev.getY() - 1,2,2))) {
          getItem(selected,false).setCheck(!getItem(selected,false).getCheck());
        }
 else         if (getItem(selected,false).getSubItemsNr() > 0 && ev.getClickCount() == 2 && getItem(selected,false).getType() != 1) {
          if (getItem(selected,false).getType() == 2 && !itemIsExpanded(getItem(selected,false))) {
            if (!onlyOptionals)             getItem(selected,false).setVisibleTC();
 else {
              Item parent=getItem(selected,false);
              for (              Item i : parent.getSubItems()) {
                if (i.isOptional()) {
                  i.setSubItemVisible(true);
                  i.setSubItemVisible(true);
                  i.setVisible(false);
                }
              }
            }
          }
 else           getItem(selected,false).setVisible(!itemIsExpanded(getItem(selected,false)));
        }
        updateLocations(getItem(selected,false));
      }
 else {
        Repository.window.mainpanel.p1.suitaDetails.setGlobalDetails();
      }
      repaint();
    }
 else     if (keypress == 2) {
      getClickedItem(ev.getX(),ev.getY());
      if (selected.size() > 0) {
        int[] theone=new int[selected.size()];
        for (int i=0; i < selected.size(); i++) {
          theone[i]=selected.get(i).intValue();
        }
        Item theone1=getItem(selected,false);
        theone1.select(!theone1.isSelected());
        if (theone1.isSelected())         selectedcollection.add(theone);
 else {
          for (int m=0; m < selectedcollection.size(); m++) {
            if (Arrays.equals(selectedcollection.get(m),theone)) {
              selectedcollection.remove(m);
              break;
            }
          }
        }
        if (selectedcollection.size() == 0) {
          Repository.window.mainpanel.p1.remove.setEnabled(false);
        }
        repaint();
      }
    }
 else {
      if (selected.size() > 0) {
        deselectAll();
        int[] theone1=new int[selected.size()];
        for (int i=0; i < selected.size(); i++) {
          theone1[i]=selected.get(i).intValue();
        }
        getClickedItem(ev.getX(),ev.getY());
        int[] theone2=new int[selected.size()];
        for (int i=0; i < selected.size(); i++) {
          theone2[i]=selected.get(i).intValue();
        }
        if (theone1.length == theone2.length) {
          if (theone1.length > 1) {
            int[] temp1, temp2;
            temp1=Arrays.copyOfRange(theone1,0,theone1.length - 1);
            temp2=Arrays.copyOfRange(theone2,0,theone2.length - 1);
            if (Arrays.equals(temp1,temp2)) {
              int[] first, second;
              if (theone2[theone2.length - 1] >= theone1[theone1.length - 1]) {
                first=theone2;
                second=theone1;
              }
 else {
                first=theone1;
                second=theone2;
              }
              ArrayList<Integer> temp11=new ArrayList<Integer>();
              for (int i=0; i < temp1.length; i++)               temp11.add(new Integer(temp1[i]));
              Item parent=getItem(temp11,false);
              for (int i=second[second.length - 1]; i < first[first.length - 1] + 1; i++) {
                parent.getSubItem(i).select(true);
                int[] temporary=new int[parent.getSubItem(i).getPos().size()];
                for (int m=0; m < temporary.length; m++) {
                  temporary[m]=parent.getSubItem(i).getPos().get(m).intValue();
                }
                selectedcollection.add(temporary);
              }
            }
          }
 else {
            int first, second;
            if (theone1[0] >= theone2[0]) {
              first=theone1[0];
              second=theone2[0];
            }
 else {
              second=theone1[0];
              first=theone2[0];
            }
            for (int m=second; m < first + 1; m++) {
              Repository.getSuita(m).select(true);
              selectedcollection.add(new int[]{m});
            }
          }
        }
        repaint();
      }
    }
  }
  if (ev.getButton() == 3) {
    getClickedItem(ev.getX(),ev.getY());
    if ((selected.size() == 0)) {
      if (Repository.getSuiteNr() > 0) {
        deselectAll();
        repaint();
      }
      noSelectionPopUp(ev);
    }
 else {
      if (!getItem(selected,false).isSelected()) {
        deselectAll();
        selectItem(selected);
        repaint();
        Item temp=getItem(selected,false);
        if (temp.getType() == 0)         propertyPopUp(ev,getItem(selected,false));
 else         if (temp.getType() == 1) {
          Repository.window.mainpanel.p1.suitaDetails.setParent(temp);
          Repository.window.mainpanel.p1.suitaDetails.setTCDetails();
          tcPopUp(ev,getItem(selected,false));
        }
 else {
          boolean root=false;
          Repository.window.mainpanel.p1.suitaDetails.setParent(temp);
          if (temp.getPos().size() == 1) {
            root=true;
            int userDefNr=temp.getUserDefNr();
            if (userDefNr != Repository.window.mainpanel.p1.suitaDetails.getDefsNr()) {
              System.out.println("String_Node_Str" + temp.getName() + "String_Node_Str"+ userDefNr+ "String_Node_Str"+ Repository.window.mainpanel.p1.suitaDetails.getDefsNr()+ "String_Node_Str");
              if (Repository.window.mainpanel.p1.suitaDetails.getDefsNr() < userDefNr) {
                temp.getUserDefs().subList(Repository.window.mainpanel.p1.suitaDetails.getDefsNr(),userDefNr).clear();
              }
            }
            try {
              for (int i=0; i < Repository.window.mainpanel.p1.suitaDetails.getDefsNr(); i++) {
                if (temp.getUserDefNr() == i)                 break;
                Repository.window.mainpanel.p1.suitaDetails.getDefPanel(i).setDescription(temp.getUserDef(i)[1],true);
              }
            }
 catch (            Exception e) {
              e.printStackTrace();
            }
          }
          Repository.window.mainpanel.p1.suitaDetails.setSuiteDetails(root);
          suitaPopUp(ev,temp);
        }
      }
 else {
        if (selectedcollection.size() == 1) {
          if (getItem(selected,false).getType() == 0)           propertyPopUp(ev,getItem(selected,false));
 else           if (getItem(selected,false).getType() == 1)           tcPopUp(ev,getItem(selected,false));
 else {
            System.out.println("String_Node_Str");
            Item temp=getItem(selected,false);
            boolean root=false;
            Repository.window.mainpanel.p1.suitaDetails.setParent(temp);
            if (temp.getPos().size() == 1) {
              root=true;
              int userDefNr=temp.getUserDefNr();
              if (userDefNr != Repository.window.mainpanel.p1.suitaDetails.getDefsNr()) {
                System.out.println("String_Node_Str" + temp.getName() + "String_Node_Str"+ userDefNr+ "String_Node_Str"+ Repository.window.mainpanel.p1.suitaDetails.getDefsNr()+ "String_Node_Str");
                if (Repository.window.mainpanel.p1.suitaDetails.getDefsNr() < userDefNr) {
                  temp.getUserDefs().subList(Repository.window.mainpanel.p1.suitaDetails.getDefsNr(),userDefNr).clear();
                }
              }
              try {
                for (int i=0; i < Repository.window.mainpanel.p1.suitaDetails.getDefsNr(); i++) {
                  if (temp.getUserDefNr() == i)                   break;
                  Repository.window.mainpanel.p1.suitaDetails.getDefPanel(i).setDescription(temp.getUserDef(i)[1],true);
                }
              }
 catch (              Exception e) {
                e.printStackTrace();
              }
            }
            Repository.window.mainpanel.p1.suitaDetails.setSuiteDetails(root);
            suitaPopUp(ev,getItem(selected,false));
          }
        }
 else {
          multipleSelectionPopUp(ev);
        }
      }
    }
  }
  if (selectedcollection.size() > 0)   Repository.window.mainpanel.p1.remove.setEnabled(true);
}