nus-yam/ex-repair huggingface dataset:
Program: 142943
Project: 142943
Buggy source:
private DataTableTopComponent(){
  dynamicFiltering=NbPreferences.forModule(DataTableTopComponent.class).getBoolean(DATA_LABORATORY_DYNAMIC_FILTERING,true);
  taskExecutor=new ThreadPoolExecutor(0,1,10L,TimeUnit.SECONDS,new LinkedBlockingDeque<Runnable>(20),new ThreadFactory(){
    public Thread newThread(    Runnable r){
      return new Thread(r,"String_Node_Str");
    }
  }
);
  initComponents();
  setName(NbBundle.getMessage(DataTableTopComponent.class,"String_Node_Str"));
  setIcon(ImageUtilities.loadImage(ICON_PATH));
  Border b=(Border)UIManager.get("String_Node_Str");
  controlToolbar.setBorder(b);
  if (UIUtils.isAquaLookAndFeel()) {
    controlToolbar.setBackground(UIManager.getColor("String_Node_Str"));
  }
  initEvents();
  nodeTable=new NodeDataTable();
  edgeTable=new EdgeDataTable();
  ProjectController pc=Lookup.getDefault().lookup(ProjectController.class);
  if (pc.getCurrentWorkspace() == null) {
    nodesButton.setEnabled(false);
    edgesButton.setEnabled(false);
    filterTextField.setEnabled(false);
    labelFilter.setEnabled(false);
    bannerPanel.setVisible(false);
    visibleGraphCheckbox.setEnabled(false);
  }
  bannerPanel.setVisible(false);
}

Fixed version (ground truth):
private DataTableTopComponent(){
  dynamicFiltering=NbPreferences.forModule(DataTableTopComponent.class).getBoolean(DATA_LABORATORY_DYNAMIC_FILTERING,true);
  taskExecutor=new ThreadPoolExecutor(0,1,10L,TimeUnit.SECONDS,new LinkedBlockingDeque<Runnable>(20),new ThreadFactory(){
    public Thread newThread(    Runnable r){
      return new Thread(r,"String_Node_Str");
    }
  }
);
  initComponents();
  setName(NbBundle.getMessage(DataTableTopComponent.class,"String_Node_Str"));
  setIcon(ImageUtilities.loadImage(ICON_PATH));
  Border b=(Border)UIManager.get("String_Node_Str");
  controlToolbar.setBorder(b);
  if (UIUtils.isAquaLookAndFeel()) {
    controlToolbar.setBackground(UIManager.getColor("String_Node_Str"));
  }
  initEvents();
  nodeTable=new NodeDataTable();
  edgeTable=new EdgeDataTable();
  ProjectController pc=Lookup.getDefault().lookup(ProjectController.class);
  if (pc.getCurrentWorkspace() == null) {
    nodesButton.setEnabled(false);
    edgesButton.setEnabled(false);
    filterTextField.setEnabled(false);
    labelFilter.setEnabled(false);
    bannerPanel.setVisible(false);
    visibleGraphCheckbox.setEnabled(false);
  }
 else {
    refresh();
  }
  bannerPanel.setVisible(false);
}
Program: 142945
Project: 142945
Buggy source:
public void disable(){
  elementGroup.clearSelection();
  nodesButton.setEnabled(false);
  edgesButton.setEnabled(false);
  filterTextField.setEnabled(false);
  labelFilter.setEnabled(false);
  bannerPanel.setVisible(false);
  visibleGraphCheckbox.setEnabled(false);
}

Fixed version (ground truth):
public void disable(){
  elementGroup.clearSelection();
  nodesButton.setEnabled(false);
  edgesButton.setEnabled(false);
  filterTextField.setEnabled(false);
  labelFilter.setEnabled(false);
  bannerPanel.setVisible(false);
  visibleGraphCheckbox.setEnabled(false);
  clear();
}
Program: 142946
Project: 142946
Buggy source:
public void initialize(Workspace workspace){
  workspace.add(new DataTablesModel());
}

Fixed version (ground truth):
public void initialize(Workspace workspace){
  workspace.add(new DataTablesModel());
  refresh();
}
Program: 142947
Project: 142947
Buggy source:
private JMenuItem createMenuItemFromEdgesManipulator(final EdgesManipulator em){
  JMenuItem menuItem=new JMenuItem();
  menuItem.setText(em.getName());
  menuItem.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      em.execute();
    }
  }
);
  return menuItem;
}

Fixed version (ground truth):
private JMenuItem createMenuItemFromEdgesManipulator(final EdgesManipulator em){
  JMenuItem menuItem=new JMenuItem();
  menuItem.setText(em.getName());
  menuItem.setIcon(em.getIcon());
  menuItem.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      em.execute();
    }
  }
);
  return menuItem;
}
Program: 142948
Project: 142948
Buggy source:
private JMenuItem createMenuItemFromNodesManipulator(final NodesManipulator nm){
  JMenuItem menuItem=new JMenuItem();
  menuItem.setText(nm.getName());
  menuItem.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      nm.execute();
    }
  }
);
  return menuItem;
}

Fixed version (ground truth):
private JMenuItem createMenuItemFromNodesManipulator(final NodesManipulator nm){
  JMenuItem menuItem=new JMenuItem();
  menuItem.setText(nm.getName());
  menuItem.setIcon(nm.getIcon());
  menuItem.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      nm.execute();
    }
  }
);
  return menuItem;
}
Program: 142951
Project: 142951
Buggy source:
@Override public void run(){
  neo4jImporter.importLocal(neo4jDirectory);
}

Fixed version (ground truth):
@Override public void run(){
  neo4jImporter.importRemote("String_Node_Str");
}
Program: 142952
Project: 142952
Buggy source:
protected void setSelectedLayout(Layout selectedLayout){
  Layout oldValue=this.selectedLayout;
  this.selectedLayout=selectedLayout;
  if (oldValue != null) {
    saveProperties(oldValue);
  }
  if (selectedLayout != null) {
    loadProperties(selectedLayout);
  }
  firePropertyChangeEvent(SELECTED_LAYOUT,oldValue,selectedLayout);
}

Fixed version (ground truth):
protected void setSelectedLayout(Layout selectedLayout){
  Layout oldValue=this.selectedLayout;
  this.selectedLayout=selectedLayout;
  this.selectedBuilder=selectedLayout.getBuilder();
  if (oldValue != null) {
    saveProperties(oldValue);
  }
  if (selectedLayout != null) {
    loadProperties(selectedLayout);
  }
  firePropertyChangeEvent(SELECTED_LAYOUT,oldValue,selectedLayout);
}
Program: 142953
Project: 142953
Buggy source:
public void setRunning(boolean running){
  this.running=running;
}

Fixed version (ground truth):
public void setRunning(boolean running){
  this.running=running;
synchronized (this.lock) {
    lock.notify();
  }
}
Program: 142954
Project: 142954
Buggy source:
@Override public void run(){
  while (running) {
    AbstractQueryImpl q;
    while ((q=rootQuery.getAndSet(null)) == null) {
      try {
synchronized (this.lock) {
          lock.wait();
        }
      }
 catch (      InterruptedException ex) {
        Exceptions.printStackTrace(ex);
      }
    }
    Query modifiedQuery=null;
    for (Iterator<PropertyModifier> itr=modifiersMap.values().iterator(); itr.hasNext(); ) {
      PropertyModifier pm=itr.next();
      itr.remove();
      pm.callback.setValue(pm.value);
      modifiedQuery=pm.query;
    }
    if (modifiedQuery != null) {
      model.updateParameters(modifiedQuery);
    }
    ProgressTicket progressTicket=null;
    ProgressTicketProvider progressTicketProvider=Lookup.getDefault().lookup(ProgressTicketProvider.class);
    if (progressTicketProvider != null) {
      progressTicket=progressTicketProvider.createTicket("String_Node_Str",null);
      Progress.start(progressTicket);
    }
    if (filtering) {
      filter(q);
    }
 else {
      select(q);
    }
    Progress.finish(progressTicket);
  }
  Query q=null;
  for (Iterator<PropertyModifier> itr=modifiersMap.values().iterator(); itr.hasNext(); ) {
    PropertyModifier pm=itr.next();
    pm.callback.setValue(pm.value);
    q=pm.query;
  }
  modifiersMap.clear();
  if (q != null) {
    model.updateParameters(q);
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (running) {
    AbstractQueryImpl q;
    while ((q=rootQuery.getAndSet(null)) == null && running) {
      try {
synchronized (this.lock) {
          lock.wait();
        }
      }
 catch (      InterruptedException ex) {
        Exceptions.printStackTrace(ex);
      }
    }
    if (!running) {
      return;
    }
    Query modifiedQuery=null;
    for (Iterator<PropertyModifier> itr=modifiersMap.values().iterator(); itr.hasNext(); ) {
      PropertyModifier pm=itr.next();
      itr.remove();
      pm.callback.setValue(pm.value);
      modifiedQuery=pm.query;
    }
    if (modifiedQuery != null) {
      model.updateParameters(modifiedQuery);
    }
    ProgressTicket progressTicket=null;
    ProgressTicketProvider progressTicketProvider=Lookup.getDefault().lookup(ProgressTicketProvider.class);
    if (progressTicketProvider != null) {
      progressTicket=progressTicketProvider.createTicket("String_Node_Str",null);
      Progress.start(progressTicket);
    }
    if (filtering) {
      filter(q);
    }
 else {
      select(q);
    }
    Progress.finish(progressTicket);
  }
  Query q=null;
  for (Iterator<PropertyModifier> itr=modifiersMap.values().iterator(); itr.hasNext(); ) {
    PropertyModifier pm=itr.next();
    pm.callback.setValue(pm.value);
    q=pm.query;
  }
  modifiersMap.clear();
  if (q != null) {
    model.updateParameters(q);
  }
}
Program: 142955
Project: 142955
Buggy source:
private void importXML(InputStream stream,Importer importer,final Container container){
  final Document document=getDocument(stream);
  final XMLImporter xmlImporter=(XMLImporter)importer;
  final Report report=container.getReport();
  LongTask task=null;
  if (importer instanceof LongTask) {
    task=(LongTask)importer;
  }
  final LongTaskErrorHandler errorHandler=new LongTaskErrorHandler(){
    public void fatalError(    Throwable t){
      if (t instanceof OutOfMemoryError) {
        return;
      }
      Logger.getLogger("String_Node_Str").log(Level.WARNING,"String_Node_Str",t.getCause());
    }
  }
;
  executor.execute(task,new Runnable(){
    public void run(){
      try {
        if (xmlImporter.importData(document,container.getLoader(),report)) {
          finishImport(container);
        }
      }
 catch (      Exception ex) {
        throw new RuntimeException(ex);
      }
    }
  }
,"String_Node_Str" + container.getSource(),errorHandler);
}

Fixed version (ground truth):
private void importXML(final InputStream stream,Importer importer,final Container container){
  final XMLImporter xmlImporter=(XMLImporter)importer;
  final Report report=container.getReport();
  LongTask task=null;
  if (importer instanceof LongTask) {
    task=(LongTask)importer;
  }
  final LongTaskErrorHandler errorHandler=new LongTaskErrorHandler(){
    public void fatalError(    Throwable t){
      if (t instanceof OutOfMemoryError) {
        return;
      }
      t.printStackTrace();
      NotifyDescriptor.Message msg=new NotifyDescriptor.Message(t.getCause().getMessage(),NotifyDescriptor.WARNING_MESSAGE);
      DialogDisplayer.getDefault().notify(msg);
    }
  }
;
  executor.execute(task,new Runnable(){
    public void run(){
      try {
        final Document document=getDocument(stream);
        if (xmlImporter.importData(document,container.getLoader(),report)) {
          finishImport(container);
        }
      }
 catch (      Exception ex) {
        throw new RuntimeException(ex);
      }
    }
  }
,"String_Node_Str" + container.getSource(),errorHandler);
}
Program: 142956
Project: 142956
Buggy source:
private void importText(InputStream stream,Importer importer,final Container container){
  final LineNumberReader reader=getTextReader(stream);
  final TextImporter textImporter=(TextImporter)importer;
  final Report report=container.getReport();
  LongTask task=null;
  if (importer instanceof LongTask) {
    task=(LongTask)importer;
  }
  final LongTaskErrorHandler errorHandler=new LongTaskErrorHandler(){
    public void fatalError(    Throwable t){
      Logger.getLogger("String_Node_Str").log(Level.WARNING,"String_Node_Str",t.getCause());
    }
  }
;
  executor.execute(task,new Runnable(){
    public void run(){
      try {
        if (textImporter.importData(reader,container.getLoader(),report)) {
          finishImport(container);
        }
      }
 catch (      Exception ex) {
        throw new RuntimeException(ex);
      }
    }
  }
,"String_Node_Str" + container.getSource(),errorHandler);
}

Fixed version (ground truth):
private void importText(InputStream stream,Importer importer,final Container container){
  final LineNumberReader reader=getTextReader(stream);
  final TextImporter textImporter=(TextImporter)importer;
  final Report report=container.getReport();
  LongTask task=null;
  if (importer instanceof LongTask) {
    task=(LongTask)importer;
  }
  final LongTaskErrorHandler errorHandler=new LongTaskErrorHandler(){
    public void fatalError(    Throwable t){
      t.printStackTrace();
      NotifyDescriptor.Message msg=new NotifyDescriptor.Message(t.getCause().getMessage(),NotifyDescriptor.WARNING_MESSAGE);
      DialogDisplayer.getDefault().notify(msg);
    }
  }
;
  executor.execute(task,new Runnable(){
    public void run(){
      try {
        if (textImporter.importData(reader,container.getLoader(),report)) {
          finishImport(container);
        }
      }
 catch (      Exception ex) {
        throw new RuntimeException(ex);
      }
    }
  }
,"String_Node_Str" + container.getSource(),errorHandler);
}
Program: 142957
Project: 142957
Buggy source:
public void addStatistics(Statistics statistics){
  statisticsList.add(statistics);
  fireChangeEvent();
}

Fixed version (ground truth):
public void addStatistics(Statistics statistics){
  if (!statisticsList.contains(statistics)) {
    statisticsList.add(statistics);
    fireChangeEvent();
  }
}
Program: 142958
Project: 142958
Buggy source:
/** 
 * @param graphModel
 */
public void execute(GraphModel graphModel,AttributeModel attributeModel){
  mIsCanceled=false;
  AttributeTable nodeTable=attributeModel.getNodeTable();
  AttributeColumn inCol=nodeTable.getColumn("String_Node_Str");
  AttributeColumn outCol=nodeTable.getColumn("String_Node_Str");
  if (inCol == null) {
    inCol=nodeTable.addColumn("String_Node_Str","String_Node_Str",AttributeType.INT,AttributeOrigin.COMPUTED,0);
  }
  if (outCol == null) {
    outCol=nodeTable.addColumn("String_Node_Str","String_Node_Str",AttributeType.INT,AttributeOrigin.COMPUTED,0);
  }
  DirectedGraph graph=graphModel.getDirectedGraphVisible();
  int i=0;
  graph.readLock();
  this.mGraphRevision="String_Node_Str" + graph.getNodeVersion() + "String_Node_Str"+ graph.getEdgeVersion()+ "String_Node_Str";
  Progress.start(mProgress,graph.getNodeCount());
  for (  Node n : graph.getNodes()) {
    AttributeRow row=(AttributeRow)n.getNodeData().getAttributes();
    row.setValue(inCol,graph.getInDegree(n));
    row.setValue(outCol,graph.getOutDegree(n));
    mAvgInDegree+=graph.getInDegree(n);
    mAvgOutDegree+=graph.getOutDegree(n);
    if (mIsCanceled) {
      break;
    }
    i++;
    mProgress.progress(i);
  }
  mAvgDegree+=mAvgInDegree + mAvgOutDegree;
  mAvgInDegree/=graph.getNodeCount();
  mAvgOutDegree/=graph.getNodeCount();
  mAvgDegree/=graph.getNodeCount();
  graph.readUnlockAll();
}

Fixed version (ground truth):
/** 
 * @param graphModel
 */
public void execute(GraphModel graphModel,AttributeModel attributeModel){
  mIsCanceled=false;
  mAvgInDegree=mAvgOutDegree=0.0;
  AttributeTable nodeTable=attributeModel.getNodeTable();
  AttributeColumn inCol=nodeTable.getColumn("String_Node_Str");
  AttributeColumn outCol=nodeTable.getColumn("String_Node_Str");
  if (inCol == null) {
    inCol=nodeTable.addColumn("String_Node_Str","String_Node_Str",AttributeType.INT,AttributeOrigin.COMPUTED,0);
  }
  if (outCol == null) {
    outCol=nodeTable.addColumn("String_Node_Str","String_Node_Str",AttributeType.INT,AttributeOrigin.COMPUTED,0);
  }
  DirectedGraph graph=graphModel.getDirectedGraphVisible();
  int i=0;
  graph.readLock();
  this.mGraphRevision="String_Node_Str" + graph.getNodeVersion() + "String_Node_Str"+ graph.getEdgeVersion()+ "String_Node_Str";
  Progress.start(mProgress,graph.getNodeCount());
  for (  Node n : graph.getNodes()) {
    AttributeRow row=(AttributeRow)n.getNodeData().getAttributes();
    row.setValue(inCol,graph.getInDegree(n));
    row.setValue(outCol,graph.getOutDegree(n));
    mAvgInDegree+=graph.getInDegree(n);
    mAvgOutDegree+=graph.getOutDegree(n);
    if (mIsCanceled) {
      break;
    }
    i++;
    mProgress.progress(i);
  }
  mAvgDegree=mAvgInDegree + mAvgOutDegree;
  mAvgInDegree/=graph.getNodeCount();
  mAvgOutDegree/=graph.getNodeCount();
  mAvgDegree/=graph.getNodeCount();
  graph.readUnlockAll();
}
Program: 142959
Project: 142959
Buggy source:
public void goAlgo(){
  graph=graphModel.getHierarchicalGraphVisible();
  Node[] nodes=graph.getNodes().toArray();
  for (  Node n : nodes) {
    if (n.getNodeData().getLayoutData() == null || !(n.getNodeData().getLayoutData() instanceof ForceVector)) {
      n.getNodeData().setLayoutData(new ForceVector());
    }
  }
  QuadTree tree=QuadTree.buildTree(graph,getQuadTreeMaxLevel());
  BarnesHut barnes=new BarnesHut(getNodeForce());
  barnes.setTheta(getBarnesHutTheta());
  for (  Node node : nodes) {
    NodeData data=node.getNodeData();
    ForceVector layoutData=data.getLayoutData();
    ForceVector f=barnes.calculateForce(data,tree);
    layoutData.add(f);
  }
  for (  Edge e : graph.getEdgesAndMetaEdges()) {
    NodeData n1=e.getSource().getNodeData();
    NodeData n2=e.getTarget().getNodeData();
    ForceVector f1=n1.getLayoutData();
    ForceVector f2=n2.getLayoutData();
    ForceVector f=getEdgeForce().calculateForce(n1,n2);
    f1.add(f);
    f2.subtract(f);
  }
  energy0=energy;
  energy=0;
  double maxForce=1;
  for (  Node n : nodes) {
    NodeData data=n.getNodeData();
    ForceVector force=data.getLayoutData();
    energy+=force.getNorm();
    maxForce=Math.max(maxForce,force.getNorm());
  }
  for (  Node n : nodes) {
    NodeData data=n.getNodeData();
    ForceVector force=data.getLayoutData();
    force.multiply((float)(1.0 / maxForce));
    getDisplacement().moveNode(data,force);
  }
  postAlgo();
}

Fixed version (ground truth):
public void goAlgo(){
  graph=graphModel.getHierarchicalGraphVisible();
  Node[] nodes=graph.getNodes().toArray();
  for (  Node n : nodes) {
    if (n.getNodeData().getLayoutData() == null || !(n.getNodeData().getLayoutData() instanceof ForceVector)) {
      n.getNodeData().setLayoutData(new ForceVector());
    }
  }
  QuadTree tree=QuadTree.buildTree(graph,getQuadTreeMaxLevel());
  BarnesHut barnes=new BarnesHut(getNodeForce());
  barnes.setTheta(getBarnesHutTheta());
  for (  Node node : nodes) {
    NodeData data=node.getNodeData();
    ForceVector layoutData=data.getLayoutData();
    ForceVector f=barnes.calculateForce(data,tree);
    layoutData.add(f);
  }
  for (  Edge e : graph.getEdgesAndMetaEdges()) {
    NodeData n1=e.getSource().getNodeData();
    NodeData n2=e.getTarget().getNodeData();
    ForceVector f1=n1.getLayoutData();
    ForceVector f2=n2.getLayoutData();
    ForceVector f=getEdgeForce().calculateForce(n1,n2);
    f1.add(f);
    f2.subtract(f);
  }
  energy0=energy;
  energy=0;
  double maxForce=1;
  for (  Node n : nodes) {
    NodeData data=n.getNodeData();
    ForceVector force=data.getLayoutData();
    energy+=force.getNorm();
    maxForce=Math.max(maxForce,force.getNorm());
  }
  for (  Node n : nodes) {
    NodeData data=n.getNodeData();
    if (!data.isFixed()) {
      ForceVector force=data.getLayoutData();
      force.multiply((float)(1.0 / maxForce));
      getDisplacement().moveNode(data,force);
    }
  }
  postAlgo();
}
Program: 142961
Project: 142961
Buggy source:
public TextLine(String text){
  this.text=text;
}

Fixed version (ground truth):
public TextLine(String text,Rectangle2D bounds){
  this.text=text;
  this.bounds=bounds;
}
Program: 142962
Project: 142962
Buggy source:
public void setLine(String line){
  this.line=new TextLine(line);
}

Fixed version (ground truth):
public void setLine(String line){
  this.line=new TextLine(line,this.line.bounds);
}
Program: 142963
Project: 142963
Buggy source:
private void deleteNode(AbstractNode node){
  for (DescendantAndSelfIterator itr=new DescendantAndSelfIterator(treeStructure,node,Tautology.instance); itr.hasNext(); ) {
    AbstractNode descendant=itr.next();
    if (descendant.isEnabled()) {
      edgeProcessor.clearMetaEdges(descendant);
      view.decNodesEnabled(1);
    }
    edgeProcessor.clearEdges(descendant);
    dhns.getGraphStructure().getNodeDictionnary().remove(descendant);
  }
  treeStructure.deleteDescendantAndSelf(node);
}

Fixed version (ground truth):
private void deleteNode(AbstractNode node){
  for (DescendantAndSelfIterator itr=new DescendantAndSelfIterator(treeStructure,node,Tautology.instance); itr.hasNext(); ) {
    AbstractNode descendant=itr.next();
    if (descendant.isEnabled()) {
      edgeProcessor.clearMetaEdges(descendant);
      view.decNodesEnabled(1);
    }
    edgeProcessor.clearEdges(descendant);
    if (node.countInViews() == 1) {
      dhns.getGraphStructure().getNodeDictionnary().remove(descendant);
    }
  }
  treeStructure.deleteDescendantAndSelf(node);
}
Program: 142964
Project: 142964
Buggy source:
protected void setSyntax(StreamTokenizer tk){
  tk.resetSyntax();
  tk.eolIsSignificant(false);
  tk.slashStarComments(true);
  tk.slashSlashComments(true);
  tk.whitespaceChars(0,' ');
  tk.wordChars(' ' + 1,'\u00ff');
  tk.ordinaryChar('[');
  tk.ordinaryChar(']');
  tk.ordinaryChar('{');
  tk.ordinaryChar('}');
  tk.ordinaryChar('-');
  tk.ordinaryChar('>');
  tk.ordinaryChar('/');
  tk.ordinaryChar('*');
  tk.quoteChar('"');
  tk.whitespaceChars(';',';');
  tk.ordinaryChar('=');
}

Fixed version (ground truth):
protected void setSyntax(StreamTokenizer tk){
  tk.resetSyntax();
  tk.eolIsSignificant(false);
  tk.slashStarComments(true);
  tk.slashSlashComments(true);
  tk.whitespaceChars(0,' ');
  tk.wordChars(' ' + 1,'\u00ff');
  tk.ordinaryChar('[');
  tk.ordinaryChar(']');
  tk.ordinaryChar('{');
  tk.ordinaryChar('}');
  tk.ordinaryChar('-');
  tk.ordinaryChar('>');
  tk.ordinaryChar('/');
  tk.ordinaryChar('*');
  tk.ordinaryChar(',');
  tk.quoteChar('"');
  tk.whitespaceChars(';',';');
  tk.ordinaryChar('=');
}
Program: 142965
Project: 142965
Buggy source:
public Node getPredecessor(Node node){
  return predecessors.get(node).getSource();
}

Fixed version (ground truth):
public Node getPredecessor(Node node){
  Edge edge=predecessors.get(node);
  if (edge != null) {
    if (edge.getSource() != node) {
      return edge.getSource();
    }
 else {
      return edge.getTarget();
    }
  }
  return null;
}
Program: 142966
Project: 142966
Buggy source:
public void compute(){
  graph.readLock();
  Set<Node> nodes=new HashSet<Node>();
  int nodeCount=0;
  for (  Node node : graph.getNodes()) {
    distances.put(node,Double.POSITIVE_INFINITY);
    nodes.add(node);
    nodeCount++;
  }
  distances.put(sourceNode,0d);
  while (!nodes.isEmpty()) {
    Double minDistance=Double.POSITIVE_INFINITY;
    Node minDistanceNode=null;
    for (    Node k : nodes) {
      Double dist=distances.get(k);
      if (dist.compareTo(minDistance) < 0) {
        minDistance=dist;
        minDistanceNode=k;
      }
    }
    Node currentNode=minDistanceNode;
    nodes.remove(currentNode);
    for (    Edge edge : graph.getEdges(currentNode)) {
      Node neighbor=graph.getOpposite(currentNode,edge);
      if (distances.get(neighbor).equals(Double.POSITIVE_INFINITY)) {
        double dist=edgeWeight(edge) + distances.get(currentNode);
        distances.put(neighbor,dist);
        maxDistance=Math.max(maxDistance,dist);
      }
 else {
        double testDistance=distances.get(currentNode) + edgeWeight(edge);
        if (testDistance < distances.get(neighbor)) {
          distances.put(neighbor,testDistance);
          maxDistance=Math.max(maxDistance,testDistance);
        }
      }
    }
  }
  graph.readUnlock();
}

Fixed version (ground truth):
public void compute(){
  graph.readLock();
  Set<Node> nodes=new HashSet<Node>();
  int nodeCount=0;
  for (  Node node : graph.getNodes()) {
    distances.put(node,Double.POSITIVE_INFINITY);
    nodes.add(node);
    nodeCount++;
  }
  distances.put(sourceNode,0d);
  while (!nodes.isEmpty()) {
    Double minDistance=Double.POSITIVE_INFINITY;
    Node minDistanceNode=null;
    for (    Node k : nodes) {
      Double dist=distances.get(k);
      if (dist.compareTo(minDistance) < 0) {
        minDistance=dist;
        minDistanceNode=k;
      }
    }
    Node currentNode=minDistanceNode;
    nodes.remove(currentNode);
    for (    Edge edge : graph.getEdges(currentNode)) {
      Node neighbor=graph.getOpposite(currentNode,edge);
      double dist=edgeWeight(edge) + distances.get(currentNode);
      if (distances.get(neighbor).equals(Double.POSITIVE_INFINITY)) {
        distances.put(neighbor,dist);
        maxDistance=Math.max(maxDistance,dist);
        predecessors.put(neighbor,edge);
      }
 else {
        if (dist < distances.get(neighbor)) {
          distances.put(neighbor,dist);
          maxDistance=Math.max(maxDistance,dist);
          predecessors.put(neighbor,edge);
        }
      }
    }
  }
  graph.readUnlock();
}
Program: 142967
Project: 142967
Buggy source:
public DijkstraShortestPathAlgorithm(Graph graph,Node sourceNode){
  super(sourceNode);
  this.graph=graph;
}

Fixed version (ground truth):
public DijkstraShortestPathAlgorithm(Graph graph,Node sourceNode){
  super(sourceNode);
  this.graph=graph;
  predecessors=new HashMap<Node,Edge>();
}
Program: 142968
Project: 142968
Buggy source:
public Node getOpposite(Node node,Edge edge){
  checkNode(node);
  AbstractEdge absEdge=checkEdge(edge);
  if (absEdge.getSource(view.getViewId()) == node) {
    return absEdge.getTarget();
  }
 else   if (absEdge.getTarget(view.getViewId()) == node) {
    return absEdge.getSource(view.getViewId());
  }
  throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
public Node getOpposite(Node node,Edge edge){
  checkNode(node);
  AbstractEdge absEdge=checkEdge(edge);
  if (absEdge.getSource(view.getViewId()) == node) {
    return absEdge.getTarget(view.getViewId());
  }
 else   if (absEdge.getTarget(view.getViewId()) == node) {
    return absEdge.getSource(view.getViewId());
  }
  throw new IllegalArgumentException("String_Node_Str");
}
Program: 142969
Project: 142969
Buggy source:
public void applyPreset(PreviewPreset preset){
  Map<String,String> propertiesMap=preset.getProperties();
  for (  Property p : getPropertiesMap().values()) {
    try {
      PropertyEditor editor=p.getPropertyEditor();
      if (editor == null) {
        editor=PropertyEditorManager.findEditor(p.getValueType());
      }
      if (editor != null) {
        String valueStr=propertiesMap.get(p.getName());
        if (valueStr != null && !valueStr.isEmpty()) {
          editor.setAsText(valueStr);
          Object value=editor.getValue();
          if (value != null) {
            p.setValue(value);
          }
        }
      }
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
public void applyPreset(PreviewPreset preset){
  Map<String,String> propertiesMap=preset.getProperties();
  for (  Property p : getPropertiesMap().values()) {
    try {
      PropertyEditor editor=p.getPropertyEditor();
      if (editor == null) {
        editor=PropertyEditorManager.findEditor(p.getValueType());
      }
      if (editor != null) {
        String valueStr=propertiesMap.get(p.getName());
        if (valueStr != null && !valueStr.isEmpty()) {
          editor.setAsText(valueStr);
          if (p.getValueType().equals(Font.class)) {
            editor.setValue(Font.decode(valueStr));
          }
          Object value=editor.getValue();
          if (value != null) {
            p.setValue(value);
          }
        }
      }
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}
Program: 142970
Project: 142970
Buggy source:
/** 
 * Returns the Processing font related to the given classic font.
 * @param font  a classic font
 * @return      the related Processing font
 */
private PFont getPFont(Font font){
  if (fontMap.containsKey(font)) {
    return fontMap.get(font);
  }
  PFont pFont=createFont(font);
  fontMap.put(font,pFont);
  return pFont;
}

Fixed version (ground truth):
/** 
 * Returns the Processing font related to the given classic font.
 * @param font  a classic font
 * @return      the related Processing font
 */
private PFont getPFont(Font font){
  String fontName=font.getName();
  if (fontMap.containsKey(fontName)) {
    return fontMap.get(fontName);
  }
  PFont pFont=createFont(font);
  fontMap.put(fontName,pFont);
  return pFont;
}
Program: 142971
Project: 142971
Buggy source:
public void renderEdgeLabel(EdgeLabel label){
  textFont(getPFont(label.getFont()));
  textAlign(CENTER,BASELINE);
  pushMatrix();
  fill(label.getColor().getRed(),label.getColor().getGreen(),label.getColor().getBlue());
  translate(label.getPosition().getX(),label.getPosition().getY());
  rotate(label.getAngle());
  text(label.getValue(),0,0);
  popMatrix();
}

Fixed version (ground truth):
public void renderEdgeLabel(EdgeLabel label){
  textFont(label.getFont());
  textAlign(CENTER,BASELINE);
  pushMatrix();
  fill(label.getColor().getRed(),label.getColor().getGreen(),label.getColor().getBlue());
  translate(label.getPosition().getX(),label.getPosition().getY());
  rotate(label.getAngle());
  text(label.getValue(),0,0);
  popMatrix();
}
Program: 142972
Project: 142972
Buggy source:
/** 
 * Refreshes the preview using the current graph from the preview controller.
 */
public void refresh(){
  PreviewController controller=Lookup.getDefault().lookup(PreviewController.class);
  PreviewModel model=controller.getModel();
  fontMap.clear();
  if (model != null) {
    uniEdgeMiniLabelFont=getPFont(model.getUniEdgeSupervisor().getMiniLabelFont());
    biEdgeMiniLabelFont=getPFont(model.getBiEdgeSupervisor().getMiniLabelFont());
  }
  redraw();
}

Fixed version (ground truth):
/** 
 * Refreshes the preview using the current graph from the preview controller.
 */
public void refresh(){
  PreviewController controller=Lookup.getDefault().lookup(PreviewController.class);
  PreviewModel model=controller.getModel();
  if (model != null) {
    uniEdgeMiniLabelFont=getPFont(model.getUniEdgeSupervisor().getMiniLabelFont());
    biEdgeMiniLabelFont=getPFont(model.getBiEdgeSupervisor().getMiniLabelFont());
  }
  redraw();
}
Program: 142973
Project: 142973
Buggy source:
public void renderNodeLabel(NodeLabel label){
  textFont(getPFont(label.getFont()));
  textAlign(CENTER,CENTER);
  fill(label.getColor().getRed(),label.getColor().getGreen(),label.getColor().getBlue());
  text(label.getValue(),label.getPosition().getX(),label.getPosition().getY() - (textAscent() + textDescent()) * 0.1f);
}

Fixed version (ground truth):
public void renderNodeLabel(NodeLabel label){
  textFont(label.getFont());
  textAlign(CENTER,CENTER);
  fill(label.getColor().getRed(),label.getColor().getGreen(),label.getColor().getBlue());
  text(label.getValue(),label.getPosition().getX(),label.getPosition().getY() - (textAscent() + textDescent()) * 0.1f);
}
Program: 142974
Project: 142974
Buggy source:
/** 
 * Creates a Processing font from a classic font.
 * @param font  a font to transform
 * @return      a Processing font
 */
private PFont createFont(Font font){
  return createFont(font.getName(),font.getSize());
}

Fixed version (ground truth):
/** 
 * Creates a Processing font from a classic font.
 * @param font  a font to transform
 * @return      a Processing font
 */
private PFont createFont(Font font){
  return createFont(font.getName(),1);
}
Program: 142975
Project: 142975
Buggy source:
public void actionPerformed(ActionEvent e){
  select(tool);
  propertiesBar.select(toolUI.getPropertiesBar(tool));
}

Fixed version (ground truth):
public void actionPerformed(ActionEvent e){
  if (tool == currentTool) {
    toolbar.clearSelection();
    unselect();
  }
 else {
    select(tool);
    propertiesBar.select(toolUI.getPropertiesBar(tool));
  }
}
Program: 142976
Project: 142976
Buggy source:
public void stateChanged(ChangeEvent e){
  SelectionManager selectionManager=VizController.getInstance().getSelectionManager();
  if (selectionManager.isRectangleSelection() && currentTool != null) {
    toolbar.clearSelection();
    unselect();
  }
 else   if (selectionManager.isSelectionEnabled() && currentTool != null && currentTool.getSelectionType() == ToolSelectionType.NONE) {
    toolbar.clearSelection();
    unselect();
  }
}

Fixed version (ground truth):
public void stateChanged(ChangeEvent e){
  SelectionManager selectionManager=VizController.getInstance().getSelectionManager();
  if (selectionManager.isRectangleSelection() && currentTool != null) {
    toolbar.clearSelection();
    unselect();
  }
 else   if (selectionManager.isSelectionEnabled() && currentTool != null && currentTool.getSelectionType() == ToolSelectionType.NONE) {
    toolbar.clearSelection();
    unselect();
  }
 else   if (selectionManager.isDraggingEnabled() && currentTool != null) {
    toolbar.clearSelection();
    unselect();
  }
}
Program: 142978
Project: 142978
Buggy source:
public void setDraggingMouseSelection(){
  engine.setRectangleSelection(false);
  vizConfig.setDraggingEnable(true);
  vizConfig.setSelectionEnable(true);
  vizConfig.setCustomSelection(false);
  this.blocked=false;
  fireChangeEvent();
}

Fixed version (ground truth):
public void setDraggingMouseSelection(){
  engine.setRectangleSelection(false);
  vizConfig.setDraggingEnable(true);
  vizConfig.setMouseSelectionUpdateWhileDragging(false);
  vizConfig.setSelectionEnable(true);
  vizConfig.setCustomSelection(false);
  this.blocked=false;
  fireChangeEvent();
}
Program: 142980
Project: 142980
Buggy source:
public boolean requireUpdate(){
  if (graph == null) {
    GraphModel graphModel=controller.getModel();
    if (graphModel != null) {
      if (!graphModel.isDirected() && !graphModel.isUndirected() && !graphModel.isMixed()) {
        return false;
      }
 else {
        graph=graphModel.getHierarchicalGraphVisible();
      }
    }
  }
  if (graph != null) {
    if (graph.getGraphModel().getVisibleView().getViewId() != graphView) {
      reset();
    }
    return graph.getNodeVersion() > nodeVersion || graph.getEdgeVersion() > edgeVersion;
  }
  return false;
}

Fixed version (ground truth):
public boolean requireUpdate(){
  if (graph == null) {
    GraphModel graphModel=controller.getModel();
    if (graphModel != null) {
      graph=graphModel.getHierarchicalGraphVisible();
    }
  }
  if (graph != null) {
    if (graph.getGraphModel().getVisibleView().getViewId() != graphView) {
      reset();
    }
    return graph.getNodeVersion() > nodeVersion || graph.getEdgeVersion() > edgeVersion;
  }
  return false;
}
Program: 142981
Project: 142981
Buggy source:
public void renameProject(Project project,final String name){
  project.getLookup().lookup(ProjectInformationImpl.class);
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      JFrame frame=(JFrame)WindowManager.getDefault().getMainWindow();
      String title=frame.getTitle();
      title=title.substring(0,title.indexOf('-') - 1);
      title+="String_Node_Str" + name;
      frame.setTitle(title);
    }
  }
);
}

Fixed version (ground truth):
public void renameProject(Project project,final String name){
  project.getLookup().lookup(ProjectInformationImpl.class).setName(name);
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      JFrame frame=(JFrame)WindowManager.getDefault().getMainWindow();
      String title=frame.getTitle();
      title=title.substring(0,title.indexOf('-') - 1);
      title+="String_Node_Str" + name;
      frame.setTitle(title);
    }
  }
);
}
Program: 142982
Project: 142982
Buggy source:
public void save(Project project){
  ProjectInformation info=project.getLookup().lookup(ProjectInformation.class);
  if (info != null) {
    if (!titleTextField.getText().isEmpty() && !titleTextField.getText().equals(info.getName())) {
      ProjectController pc=Lookup.getDefault().lookup(ProjectController.class);
      pc.renameProject(project,titleTextField.getText());
    }
  }
  ProjectMetaData metaData=project.getLookup().lookup(ProjectMetaData.class);
  if (metaData != null) {
    metaData.setTitle(nameTextField.getText());
    metaData.setAuthor(authorTextField.getText());
    metaData.setKeywords(keywordsTextField.getText());
    metaData.setDescription(descriptionTextArea.getText());
  }
}

Fixed version (ground truth):
public void save(Project project){
  ProjectInformation info=project.getLookup().lookup(ProjectInformation.class);
  if (info != null) {
    if (!nameTextField.getText().isEmpty() && !nameTextField.getText().equals(info.getName())) {
      ProjectController pc=Lookup.getDefault().lookup(ProjectController.class);
      pc.renameProject(project,nameTextField.getText());
    }
  }
  ProjectMetaData metaData=project.getLookup().lookup(ProjectMetaData.class);
  if (metaData != null) {
    metaData.setTitle(titleTextField.getText());
    metaData.setAuthor(authorTextField.getText());
    metaData.setKeywords(keywordsTextField.getText());
    metaData.setDescription(descriptionTextArea.getText());
  }
}
Program: 142983
Project: 142983
Buggy source:
public boolean init(Graph graph){
  values=new ArrayList<Object>();
  return true;
}

Fixed version (ground truth):
public boolean init(Graph graph){
  if (range == null) {
    getValues();
    refreshRange();
  }
  values=new ArrayList<Object>();
  return true;
}
Program: 142984
Project: 142984
Buggy source:
public boolean init(Graph graph){
  values=new ArrayList<Float>(graph.getEdgeCount());
  min=Float.POSITIVE_INFINITY;
  max=Float.NEGATIVE_INFINITY;
  return true;
}

Fixed version (ground truth):
public boolean init(Graph graph){
  if (range == null) {
    getValues();
    refreshRange();
  }
  values=new ArrayList<Float>(graph.getEdgeCount());
  min=Float.POSITIVE_INFINITY;
  max=Float.NEGATIVE_INFINITY;
  return true;
}
Program: 142985
Project: 142985
Buggy source:
private void refreshRange(){
  Float lowerBound=range.getLowerFloat();
  Float upperBound=range.getUpperFloat();
  if ((Float)min > lowerBound || (Float)max < lowerBound || lowerBound.equals(upperBound)) {
    lowerBound=(Float)min;
  }
  if ((Float)min > upperBound || (Float)max < upperBound || lowerBound.equals(upperBound)) {
    upperBound=(Float)max;
  }
  range=new Range(lowerBound,upperBound);
}

Fixed version (ground truth):
private void refreshRange(){
  if (range == null) {
    range=new Range(min,max);
  }
 else {
    range.trimBounds(min,max);
  }
}
Program: 142986
Project: 142986
Buggy source:
public boolean init(Graph graph){
  values=new ArrayList<Integer>(graph.getNodeCount());
  min=Integer.MAX_VALUE;
  max=Integer.MIN_VALUE;
  return true;
}

Fixed version (ground truth):
public boolean init(Graph graph){
  if (range == null) {
    getValues();
    refreshRange();
  }
  values=new ArrayList<Integer>(graph.getNodeCount());
  min=Integer.MAX_VALUE;
  max=Integer.MIN_VALUE;
  return true;
}
Program: 142987
Project: 142987
Buggy source:
private void refreshRange(){
  Integer lowerBound=range.getLowerInteger();
  Integer upperBound=range.getUpperInteger();
  if ((Integer)min > lowerBound || (Integer)max < lowerBound || lowerBound.equals(upperBound)) {
    lowerBound=(Integer)min;
  }
  if ((Integer)min > upperBound || (Integer)max < upperBound || lowerBound.equals(upperBound)) {
    upperBound=(Integer)max;
  }
  range=new Range(lowerBound,upperBound);
}

Fixed version (ground truth):
private void refreshRange(){
  if (range == null) {
    range=new Range(min,max);
  }
 else {
    range.trimBounds(min,max);
  }
}
Program: 142988
Project: 142988
Buggy source:
public boolean init(Graph graph){
  if (!(graph instanceof DirectedGraph)) {
    return false;
  }
  values=new ArrayList<Integer>(graph.getNodeCount());
  min=Integer.MAX_VALUE;
  max=Integer.MIN_VALUE;
  return true;
}

Fixed version (ground truth):
public boolean init(Graph graph){
  if (!(graph instanceof DirectedGraph)) {
    return false;
  }
  if (range == null) {
    getValues();
    refreshRange();
  }
  values=new ArrayList<Integer>(graph.getNodeCount());
  min=Integer.MAX_VALUE;
  max=Integer.MIN_VALUE;
  return true;
}
Program: 142989
Project: 142989
Buggy source:
private void refreshRange(){
  Integer lowerBound=range.getLowerInteger();
  Integer upperBound=range.getUpperInteger();
  if ((Integer)min > lowerBound || (Integer)max < lowerBound || lowerBound.equals(upperBound)) {
    lowerBound=(Integer)min;
  }
  if ((Integer)min > upperBound || (Integer)max < upperBound || lowerBound.equals(upperBound)) {
    upperBound=(Integer)max;
  }
  range=new Range(lowerBound,upperBound);
}

Fixed version (ground truth):
private void refreshRange(){
  if (range == null) {
    range=new Range(min,max);
  }
 else {
    range.trimBounds(min,max);
  }
}
Program: 142990
Project: 142990
Buggy source:
public boolean init(Graph graph){
  if (!(graph instanceof DirectedGraph)) {
    return false;
  }
  values=new ArrayList<Integer>(graph.getNodeCount());
  min=Integer.MAX_VALUE;
  max=Integer.MIN_VALUE;
  return true;
}

Fixed version (ground truth):
public boolean init(Graph graph){
  if (!(graph instanceof DirectedGraph)) {
    return false;
  }
  if (range == null) {
    getValues();
    refreshRange();
  }
  values=new ArrayList<Integer>(graph.getNodeCount());
  min=Integer.MAX_VALUE;
  max=Integer.MIN_VALUE;
  return true;
}
Program: 142991
Project: 142991
Buggy source:
private void refreshRange(){
  Integer lowerBound=range.getLowerInteger();
  Integer upperBound=range.getUpperInteger();
  if ((Integer)min > lowerBound || (Integer)max < lowerBound || lowerBound.equals(upperBound)) {
    lowerBound=(Integer)min;
  }
  if ((Integer)min > upperBound || (Integer)max < upperBound || lowerBound.equals(upperBound)) {
    upperBound=(Integer)max;
  }
  range=new Range(lowerBound,upperBound);
}

Fixed version (ground truth):
private void refreshRange(){
  if (range == null) {
    range=new Range(min,max);
  }
 else {
    range.trimBounds(min,max);
  }
}
Program: 142992
Project: 142992
Buggy source:
public boolean init(Graph graph){
  if (!(graph instanceof DirectedGraph)) {
    return false;
  }
  values=new ArrayList<Integer>(graph.getNodeCount());
  min=Integer.MAX_VALUE;
  max=Integer.MIN_VALUE;
  return true;
}

Fixed version (ground truth):
public boolean init(Graph graph){
  if (!(graph instanceof DirectedGraph)) {
    return false;
  }
  if (range == null) {
    getValues();
    refreshRange();
  }
  values=new ArrayList<Integer>(graph.getNodeCount());
  min=Integer.MAX_VALUE;
  max=Integer.MIN_VALUE;
  return true;
}
Program: 142993
Project: 142993
Buggy source:
private void refreshRange(){
  Integer lowerBound=range.getLowerInteger();
  Integer upperBound=range.getUpperInteger();
  if ((Integer)min > lowerBound || (Integer)max < lowerBound || lowerBound.equals(upperBound)) {
    lowerBound=(Integer)min;
  }
  if ((Integer)min > upperBound || (Integer)max < upperBound || lowerBound.equals(upperBound)) {
    upperBound=(Integer)max;
  }
  range=new Range(lowerBound,upperBound);
}

Fixed version (ground truth):
private void refreshRange(){
  if (range == null) {
    range=new Range(min,max);
  }
 else {
    range.trimBounds(min,max);
  }
}
Program: 142997
Project: 142997
Buggy source:
public Element writeXML(Document document,Workspace workspace){
  Dhns dhns=workspace.getLookup().lookup(Dhns.class);
  DHNSSerializer serializer=new DHNSSerializer();
  return serializer.writeDhns(document,dhns);
}

Fixed version (ground truth):
public Element writeXML(Document document,Workspace workspace){
  DhnsGraphController graphController=Lookup.getDefault().lookup(DhnsGraphController.class);
  Dhns dhns=(Dhns)graphController.getModel(workspace);
  DHNSSerializer serializer=new DHNSSerializer();
  return serializer.writeDhns(document,dhns);
}
Program: 142999
Project: 142999
Buggy source:
private void initEvents(){
  model=new RankingUIModel();
  final ProjectController pc=Lookup.getDefault().lookup(ProjectController.class);
  pc.addWorkspaceListener(new WorkspaceListener(){
    public void initialize(    Workspace workspace){
      workspace.add(new RankingUIModel());
    }
    public void select(    Workspace workspace){
      enabled=true;
      RankingUIModel newModel=workspace.getLookup().lookup(RankingUIModel.class);
      if (newModel != null) {
        model.loadModel(newModel);
      }
      refreshModel();
    }
    public void unselect(    Workspace workspace){
      RankingUIModel oldModel=workspace.getLookup().lookup(RankingUIModel.class);
      if (oldModel != null) {
        workspace.remove(oldModel);
      }
      workspace.add(model.saveModel());
    }
    public void close(    Workspace workspace){
    }
    public void disable(){
      enabled=false;
      refreshModel();
    }
  }
);
  if (pc.getCurrentWorkspace() != null) {
    RankingUIModel newModel=pc.getCurrentWorkspace().getLookup().lookup(RankingUIModel.class);
    if (newModel != null) {
      model.loadModel(newModel);
    }
  }
}

Fixed version (ground truth):
private void initEvents(){
  model=new RankingUIModel();
  final ProjectController pc=Lookup.getDefault().lookup(ProjectController.class);
  pc.addWorkspaceListener(new WorkspaceListener(){
    public void initialize(    Workspace workspace){
      workspace.add(new RankingUIModel());
    }
    public void select(    Workspace workspace){
      enabled=true;
      RankingUIModel newModel=workspace.getLookup().lookup(RankingUIModel.class);
      if (newModel != null) {
        model.loadModel(newModel);
      }
      refreshModel();
    }
    public void unselect(    Workspace workspace){
      RankingUIModel oldModel=workspace.getLookup().lookup(RankingUIModel.class);
      if (oldModel != null) {
        workspace.remove(oldModel);
      }
      workspace.add(model.saveModel());
    }
    public void close(    Workspace workspace){
    }
    public void disable(){
      enabled=false;
      refreshModel();
    }
  }
);
  if (pc.getCurrentWorkspace() != null) {
    enabled=true;
    RankingUIModel newModel=pc.getCurrentWorkspace().getLookup().lookup(RankingUIModel.class);
    if (newModel != null) {
      model.loadModel(newModel);
    }
  }
}
Program: 143000
Project: 143000
Buggy source:
private RankingTopComponent(){
  setName(NbBundle.getMessage(RankingTopComponent.class,"String_Node_Str"));
  setToolTipText(NbBundle.getMessage(RankingTopComponent.class,"String_Node_Str"));
  setIcon(ImageUtilities.loadImage(ICON_PATH));
  RankingController rankingController=Lookup.getDefault().lookup(RankingController.class);
  rankingModel=rankingController.getRankingModel();
  initEvents();
  initComponents();
  initSouth();
  if (UIUtils.isAquaLookAndFeel()) {
    mainPanel.setBackground(UIManager.getColor("String_Node_Str"));
  }
  refreshModel();
}

Fixed version (ground truth):
private RankingTopComponent(){
  setName(NbBundle.getMessage(RankingTopComponent.class,"String_Node_Str"));
  setToolTipText(NbBundle.getMessage(RankingTopComponent.class,"String_Node_Str"));
  setIcon(ImageUtilities.loadImage(ICON_PATH));
  RankingController rankingController=Lookup.getDefault().lookup(RankingController.class);
  rankingModel=rankingController.getRankingModel();
  initEvents();
  initComponents();
  initSouth();
  if (UIUtils.isAquaLookAndFeel()) {
    mainPanel.setBackground(UIManager.getColor("String_Node_Str"));
  }
  refreshModel();
  final ProjectController pc=Lookup.getDefault().lookup(ProjectController.class);
  if (pc.getCurrentWorkspace() != null) {
    ((RankingChooser)rankingChooser).refreshModel();
  }
}