Program: 133637
Project: 133637
Buggy source:
/** 
 * This operation creates the add and delete buttons that are used to add layers to the table. Also creates buttons for moving layers around. 
 */
private void createAddDeleteButtons(){
  Composite listButtonComposite=new Composite(sectionClient,SWT.NONE);
  listButtonComposite.setLayout(new GridLayout(1,false));
  listButtonComposite.setLayoutData(new GridData(SWT.RIGHT,SWT.FILL,false,true,1,1));
  Button addMaterialButton=new Button(listButtonComposite,SWT.PUSH);
  addMaterialButton.setText("String_Node_Str");
  addMaterialButton.addSelectionListener(new SelectionListener(){
    @Override public void widgetSelected(    SelectionEvent e){
      if (source == null) {
        int index=list.size() - 1;
        list.getReadWriteLock().writeLock().lock();
        try {
          list.add(list.get(index));
        }
  finally {
          list.getReadWriteLock().writeLock().unlock();
        }
      }
 else {
        ElementSourceDialog dialog=new ElementSourceDialog(shell,source);
        if (dialog.open() == Window.OK) {
          list.getReadWriteLock().writeLock().lock();
          try {
            list.add(dialog.getSelection());
          }
  finally {
            list.getReadWriteLock().writeLock().unlock();
          }
        }
      }
    }
    @Override public void widgetDefaultSelected(    SelectionEvent e){
    }
  }
);
  Button deleteMaterialButton=new Button(listButtonComposite,SWT.PUSH);
  deleteMaterialButton.setText("String_Node_Str");
  deleteMaterialButton.addSelectionListener(new SelectionListener(){
    @Override public void widgetDefaultSelected(    SelectionEvent arg0){
    }
    @Override public void widgetSelected(    SelectionEvent arg0){
      if (list.size() > 0) {
        ListComponent selected=table.getSelectedObjects();
        if (selected.size() > 0) {
          list.getReadWriteLock().writeLock().lock();
          try {
            for (            Object o : selected) {
              list.remove(o);
            }
          }
  finally {
            list.getReadWriteLock().writeLock().unlock();
          }
        }
      }
    }
  }
);
  Button moveUpButton=new Button(listButtonComposite,SWT.PUSH);
  moveUpButton.setText("String_Node_Str");
  moveUpButton.addSelectionListener(new SelectionListener(){
    @Override public void widgetDefaultSelected(    SelectionEvent arg0){
    }
    @SuppressWarnings("String_Node_Str") @Override public void widgetSelected(    SelectionEvent arg0){
      if (list.size() > 0) {
        ListComponent selected=table.getSelectedObjects();
        if (selected.size() > 0) {
          int numSelected=selected.size();
          if (!(selected.get(0).equals(list.get(0)))) {
            list.getReadWriteLock().writeLock().lock();
            int index=0;
            Object toMove=list.get(0);
            for (int i=0; i < numSelected; i++) {
              index=list.indexOf(selected.get(i)) - 1;
              toMove=list.get(index);
              list.set(index,selected.get(i));
              list.set(index + 1,toMove);
            }
            list.set(index + 1,toMove);
            list.getReadWriteLock().writeLock().unlock();
            table.setSelection(selected);
          }
        }
      }
    }
  }
);
  Button moveDownButton=new Button(listButtonComposite,SWT.PUSH);
  moveDownButton.setText("String_Node_Str");
  moveDownButton.addSelectionListener(new SelectionListener(){
    @Override public void widgetDefaultSelected(    SelectionEvent arg0){
    }
    @SuppressWarnings("String_Node_Str") @Override public void widgetSelected(    SelectionEvent arg0){
      if (list.size() > 0) {
        ListComponent selected=table.getSelectedObjects();
        if (selected.size() > 0) {
          int numSelected=selected.size();
          if (!(selected.get(numSelected - 1).equals(list.get(list.size() - 1)))) {
            list.getReadWriteLock().writeLock().lock();
            int index=0;
            Object toMove=list.get(0);
            for (int i=0; i < numSelected; i++) {
              index=list.indexOf(selected.get(i)) + 1;
              toMove=list.get(index);
              list.set(index,selected.get(i));
              list.set(index - 1,toMove);
            }
            list.set(index - 1,toMove);
            list.getReadWriteLock().writeLock().unlock();
            table.setSelection(selected);
          }
        }
      }
    }
  }
);
  return;
}

Fixed version (ground truth):
/** 
 * This operation creates the add and delete buttons that are used to add layers to the table. Also creates buttons for moving layers around. 
 */
private void createAddDeleteButtons(){
  Composite listButtonComposite=new Composite(sectionClient,SWT.NONE);
  listButtonComposite.setLayout(new GridLayout(1,false));
  listButtonComposite.setLayoutData(new GridData(SWT.RIGHT,SWT.FILL,false,true,1,1));
  Button addMaterialButton=new Button(listButtonComposite,SWT.PUSH);
  addMaterialButton.setText("String_Node_Str");
  addMaterialButton.addSelectionListener(new SelectionListener(){
    @Override public void widgetSelected(    SelectionEvent e){
      if (source == null) {
        int index=list.size() - 1;
        list.getReadWriteLock().writeLock().lock();
        try {
          list.add(list.get(index));
        }
  finally {
          list.getReadWriteLock().writeLock().unlock();
        }
      }
 else {
        ElementSourceDialog dialog=new ElementSourceDialog(shell,source);
        if (dialog.open() == Window.OK) {
          list.getReadWriteLock().writeLock().lock();
          try {
            list.add(dialog.getSelection());
          }
  finally {
            list.getReadWriteLock().writeLock().unlock();
          }
        }
      }
    }
    @Override public void widgetDefaultSelected(    SelectionEvent e){
    }
  }
);
  Button deleteMaterialButton=new Button(listButtonComposite,SWT.PUSH);
  deleteMaterialButton.setText("String_Node_Str");
  deleteMaterialButton.addSelectionListener(new SelectionListener(){
    @Override public void widgetDefaultSelected(    SelectionEvent arg0){
    }
    @Override public void widgetSelected(    SelectionEvent arg0){
      if (list.size() > 0) {
        ListComponent selected=table.getSelectedObjects();
        if (selected.size() > 0) {
          list.getReadWriteLock().writeLock().lock();
          try {
            for (            Object o : selected) {
              list.remove(o);
            }
          }
  finally {
            list.getReadWriteLock().writeLock().unlock();
          }
        }
      }
    }
  }
);
  Button moveUpButton=new Button(listButtonComposite,SWT.PUSH);
  moveUpButton.setText("String_Node_Str");
  moveUpButton.addSelectionListener(new SelectionListener(){
    @Override public void widgetDefaultSelected(    SelectionEvent arg0){
    }
    @SuppressWarnings("String_Node_Str") @Override public void widgetSelected(    SelectionEvent arg0){
      if (list.size() > 0) {
        ListComponent selected=table.getSelectedObjects();
        if (selected.size() > 0) {
          int numSelected=selected.size();
          if (!(selected.get(0).equals(list.get(0)))) {
            list.getReadWriteLock().writeLock().lock();
            int index=0;
            Object toMove=list.get(0);
            for (int i=0; i < numSelected; i++) {
              index=list.indexOf(selected.get(i)) - 1;
              toMove=list.get(index);
              list.set(index,selected.get(i));
              list.set(index + 1,toMove);
            }
            list.set(index + 1,toMove);
            list.getReadWriteLock().writeLock().unlock();
            table.setSelection(selected);
          }
        }
      }
    }
  }
);
  Button moveDownButton=new Button(listButtonComposite,SWT.PUSH);
  moveDownButton.setText("String_Node_Str");
  moveDownButton.addSelectionListener(new SelectionListener(){
    @Override public void widgetDefaultSelected(    SelectionEvent arg0){
    }
    @SuppressWarnings("String_Node_Str") @Override public void widgetSelected(    SelectionEvent arg0){
      if (list.size() > 0) {
        ListComponent selected=table.getSelectedObjects();
        if (selected.size() > 0) {
          int numSelected=selected.size();
          if (!(selected.get(numSelected - 1).equals(list.get(list.size() - 1)))) {
            list.getReadWriteLock().writeLock().lock();
            int index=0;
            Object toMove=list.get(0);
            for (int i=numSelected - 1; i >= 0; i--) {
              index=list.indexOf(selected.get(i)) + 1;
              toMove=list.get(index);
              list.set(index,selected.get(i));
              list.set(index - 1,toMove);
            }
            list.set(index - 1,toMove);
            list.getReadWriteLock().writeLock().unlock();
            table.setSelection(selected);
          }
        }
      }
    }
  }
);
  return;
}