Program: 123173
Project: 123173
Buggy source:
/** 
 * DOC nrousseau Comment method "getSubjobContainerRectangle".
 * @return
 */
public Rectangle getSubjobContainerRectangle(){
  Rectangle totalRectangle=null;
  boolean collapsed=isCollapsed();
  for (  NodeContainer container : nodeContainers) {
    Rectangle curRect=null;
    if (container instanceof JobletContainer) {
      curRect=((JobletContainer)container).getJobletContainerRectangle();
    }
 else {
      curRect=container.getNodeContainerRectangle();
    }
    if (curRect.y == container.getNode().getPosY()) {
      curRect.setLocation(curRect.getLocation().x,curRect.getLocation().y - TalendEditor.GRID_SIZE);
      curRect.setSize(curRect.getSize().width,curRect.getSize().height + TalendEditor.GRID_SIZE);
    }
    if (collapsed && totalRectangle == null) {
      totalRectangle=curRect.getCopy();
    }
 else     if (!collapsed) {
      if (totalRectangle == null) {
        totalRectangle=curRect.getCopy();
      }
 else {
        totalRectangle=totalRectangle.getUnion(curRect);
      }
    }
  }
  if (totalRectangle == null) {
    return null;
  }
  Point location=totalRectangle.getLocation();
  Point newLocation=new Point();
  newLocation.x=(location.x / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
  newLocation.y=(location.y / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
  if (newLocation.y <= 0) {
    newLocation.y=newLocation.y - TalendEditor.GRID_SIZE;
  }
  if (newLocation.x <= 0) {
    newLocation.x=newLocation.x - TalendEditor.GRID_SIZE;
  }
  totalRectangle.setLocation(newLocation);
  Dimension diff=location.getDifference(newLocation);
  Dimension size=totalRectangle.getSize().expand(diff);
  if ((size.height % TalendEditor.GRID_SIZE) == 0) {
    size.height=(size.height / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
  }
 else {
    size.height=((size.height / TalendEditor.GRID_SIZE) + 1) * TalendEditor.GRID_SIZE;
  }
  if ((size.width % TalendEditor.GRID_SIZE) == 0) {
    size.width=(size.width / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
  }
 else {
    size.width=((size.width / TalendEditor.GRID_SIZE) + 1) * TalendEditor.GRID_SIZE;
  }
  totalRectangle.setSize(size);
  return totalRectangle;
}

Fixed version (ground truth):
/** 
 * DOC nrousseau Comment method "getSubjobContainerRectangle".
 * @return
 */
public Rectangle getSubjobContainerRectangle(){
  Rectangle totalRectangle=null;
  boolean collapsed=isCollapsed();
  for (  NodeContainer container : nodeContainers) {
    Rectangle curRect=null;
    if (container instanceof JobletContainer) {
      curRect=((JobletContainer)container).getJobletContainerRectangle();
    }
 else {
      curRect=container.getNodeContainerRectangle();
    }
    if ((curRect.x + curRect.width) == (container.getNode().getPosX() + container.getNode().getSize().width)) {
      curRect.setSize(curRect.getSize().width + TalendEditor.GRID_SIZE,curRect.getSize().height);
    }
    if ((curRect.y + curRect.height) == (container.getNode().getPosY() + container.getNode().getSize().height)) {
      curRect.setSize(curRect.getSize().width,curRect.getSize().height + TalendEditor.GRID_SIZE);
    }
    if (curRect.y == container.getNode().getPosY()) {
      curRect.setLocation(curRect.getLocation().x,curRect.getLocation().y - TalendEditor.GRID_SIZE);
      curRect.setSize(curRect.getSize().width,curRect.getSize().height + TalendEditor.GRID_SIZE);
    }
    if (curRect.x == container.getNode().getPosX()) {
      curRect.setLocation(curRect.getLocation().x - TalendEditor.GRID_SIZE,curRect.getLocation().y);
      curRect.setSize(curRect.getSize().width + TalendEditor.GRID_SIZE,curRect.getSize().height);
    }
    if (collapsed && totalRectangle == null) {
      totalRectangle=curRect.getCopy();
    }
 else     if (!collapsed) {
      if (totalRectangle == null) {
        totalRectangle=curRect.getCopy();
      }
 else {
        totalRectangle=totalRectangle.getUnion(curRect);
      }
    }
  }
  if (totalRectangle == null) {
    return null;
  }
  Point location=totalRectangle.getLocation();
  Point newLocation=new Point();
  newLocation.x=(location.x / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
  newLocation.y=(location.y / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
  if (newLocation.y <= 0) {
    newLocation.y=newLocation.y - TalendEditor.GRID_SIZE;
  }
  if (newLocation.x <= 0) {
    newLocation.x=newLocation.x - TalendEditor.GRID_SIZE;
  }
  totalRectangle.setLocation(newLocation);
  Dimension diff=location.getDifference(newLocation);
  Dimension size=totalRectangle.getSize().expand(diff);
  if ((size.height % TalendEditor.GRID_SIZE) == 0) {
    size.height=(size.height / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
  }
 else {
    size.height=((size.height / TalendEditor.GRID_SIZE) + 1) * TalendEditor.GRID_SIZE;
  }
  if ((size.width % TalendEditor.GRID_SIZE) == 0) {
    size.width=(size.width / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
  }
 else {
    size.width=((size.width / TalendEditor.GRID_SIZE) + 1) * TalendEditor.GRID_SIZE;
  }
  totalRectangle.setSize(size);
  return totalRectangle;
}