Program: 120336
Project: 120336
Buggy source:
@SuppressWarnings("String_Node_Str") public void updateLinksStyleAndControlsSelection(Control currentControl,Boolean flag){
  boolean selectedControlIsTable=false;
  if (currentControl instanceof Table) {
    selectedControlIsTable=true;
  }
 else   if (currentControl instanceof Tree) {
    selectedControlIsTable=false;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  HashSet selectedItems=new HashSet();
  Map itemsToSelect=new HashMap();
  if (selectedControlIsTable) {
    for (    Table table : getTables()) {
      if (table != currentControl) {
        table.deselectAll();
        if (isFieldsTable(table)) {
          fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
        }
      }
    }
    TableItem[] selection=((Table)currentControl).getSelection();
    for (int i=0; i < selection.length; i++) {
      TableItem tableItem=selection[i];
      selectedItems.add(tableItem.getData());
    }
  }
 else {
    TreeItem[] selection=getTree().getSelection();
    for (int i=0; i < selection.length; i++) {
      TreeItem treeItem=selection[i];
      selectedItems.add(treeItem.getData());
    }
  }
  List<LinkDescriptor<TreeItem,Object,Table,Object>> links=linksManager.getLinks();
  for (  LinkDescriptor<TreeItem,Object,Table,Object> link : links) {
    IStyleLink styleLink=null;
    IExtremityLink extremity=null;
    IExtremityLink otherExtremity=null;
    if (selectedControlIsTable) {
      extremity=link.getExtremity2();
      otherExtremity=link.getExtremity1();
    }
 else {
      extremity=link.getExtremity1();
      otherExtremity=link.getExtremity2();
    }
    boolean currentItemIsSelected=selectedItems.contains(extremity.getDataItem());
    if (extremity.getGraphicalObject() == loopTableEditorView.getTableViewerCreator().getTable() || otherExtremity.getGraphicalObject() == loopTableEditorView.getTableViewerCreator().getTable()) {
      styleLink=getSelectedLoopStyleLink();
    }
 else {
      if (currentItemIsSelected) {
        styleLink=getSelectedStyleLink();
        if (selectedControlIsTable) {
          itemsToSelect.put(otherExtremity.getGraphicalObject(),null);
        }
 else {
          Table currentTable=(Table)otherExtremity.getGraphicalObject();
          List<TableItem> tableItemsToSelect=(List<TableItem>)itemsToSelect.get(currentTable);
          if (tableItemsToSelect == null) {
            tableItemsToSelect=new ArrayList<TableItem>();
            itemsToSelect.put(currentTable,tableItemsToSelect);
          }
          TableItem tableItem=TableUtils.getTableItem(currentTable,otherExtremity.getDataItem());
          tableItemsToSelect.add(tableItem);
        }
      }
 else {
        styleLink=getUnselectedStyleLink();
      }
    }
    if (styleLink == null) {
      styleLink=getDefaultStyleLink();
    }
    link.setStyleLink(styleLink);
  }
  if (selectedControlIsTable) {
    (getTree()).setSelection((TreeItem[])itemsToSelect.keySet().toArray(new TreeItem[0]));
  }
 else {
    Set<Table> set=itemsToSelect.keySet();
    if (set.size() > 0) {
      for (      Table table : set) {
        ArrayList<TableItem> tableItemsToSelect=(ArrayList<TableItem>)itemsToSelect.get(table);
        table.deselectAll();
        TableItem[] tableItems=tableItemsToSelect.toArray(new TableItem[0]);
        table.setSelection(tableItems);
      }
    }
 else {
      loopTableEditorView.getTable().deselectAll();
      fieldsTableEditorView.getTable().deselectAll();
    }
    fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
  }
  if (flag) {
    getLinksManager().sortLinks(getDrawingLinksComparator());
    getBackgroundRefresher().refreshBackground();
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void updateLinksStyleAndControlsSelection(Control currentControl,Boolean flag){
  boolean selectedControlIsTable=false;
  if (currentControl instanceof Table) {
    selectedControlIsTable=true;
  }
 else   if (currentControl instanceof Tree) {
    selectedControlIsTable=false;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  HashSet selectedItems=new HashSet();
  Map itemsToSelect=new HashMap();
  if (selectedControlIsTable) {
    for (    Table table : getTables()) {
      if (table != currentControl) {
        table.deselectAll();
        if (isFieldsTable(table)) {
          fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
        }
      }
    }
    TableItem[] selection=((Table)currentControl).getSelection();
    for (int i=0; i < selection.length; i++) {
      TableItem tableItem=selection[i];
      selectedItems.add(tableItem.getData());
    }
  }
 else {
    TreeItem[] selection=getTree().getSelection();
    for (int i=0; i < selection.length; i++) {
      TreeItem treeItem=selection[i];
      selectedItems.add(treeItem.getData());
    }
  }
  List<LinkDescriptor<TreeItem,Object,Table,Object>> links=linksManager.getLinks();
  for (  LinkDescriptor<TreeItem,Object,Table,Object> link : links) {
    IStyleLink styleLink=null;
    IExtremityLink extremity=null;
    IExtremityLink otherExtremity=null;
    if (selectedControlIsTable) {
      extremity=link.getExtremity2();
      otherExtremity=link.getExtremity1();
    }
 else {
      extremity=link.getExtremity1();
      otherExtremity=link.getExtremity2();
    }
    boolean currentItemIsSelected=selectedItems.contains(extremity.getDataItem());
    if (extremity.getGraphicalObject() == loopTableEditorView.getTableViewerCreator().getTable() || otherExtremity.getGraphicalObject() == loopTableEditorView.getTableViewerCreator().getTable()) {
      styleLink=getSelectedLoopStyleLink();
    }
 else {
      if (currentItemIsSelected) {
        styleLink=getSelectedStyleLink();
        if (selectedControlIsTable) {
          itemsToSelect.put(otherExtremity.getGraphicalObject(),null);
        }
 else {
          Table currentTable=(Table)otherExtremity.getGraphicalObject();
          List<TableItem> tableItemsToSelect=(List<TableItem>)itemsToSelect.get(currentTable);
          if (tableItemsToSelect == null) {
            tableItemsToSelect=new ArrayList<TableItem>();
            itemsToSelect.put(currentTable,tableItemsToSelect);
          }
          TableItem tableItem=TableUtils.getTableItem(currentTable,otherExtremity.getDataItem());
          tableItemsToSelect.add(tableItem);
        }
      }
 else {
        styleLink=getUnselectedStyleLink();
      }
    }
    if (styleLink == null) {
      styleLink=getDefaultStyleLink();
    }
    link.setStyleLink(styleLink);
  }
  if (selectedControlIsTable) {
    TreeItem[] treeItems=(TreeItem[])itemsToSelect.keySet().toArray(new TreeItem[0]);
    if (treeItems.length > 0) {
      if (!treeItems[0].isDisposed()) {
        (getTree()).setSelection((TreeItem[])itemsToSelect.keySet().toArray(new TreeItem[0]));
      }
    }
  }
 else {
    Set<Table> set=itemsToSelect.keySet();
    if (set.size() > 0) {
      for (      Table table : set) {
        ArrayList<TableItem> tableItemsToSelect=(ArrayList<TableItem>)itemsToSelect.get(table);
        table.deselectAll();
        TableItem[] tableItems=tableItemsToSelect.toArray(new TableItem[0]);
        table.setSelection(tableItems);
      }
    }
 else {
      loopTableEditorView.getTable().deselectAll();
      fieldsTableEditorView.getTable().deselectAll();
    }
    fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
  }
  if (flag) {
    getLinksManager().sortLinks(getDrawingLinksComparator());
    getBackgroundRefresher().refreshBackground();
  }
}