Program: 147823
Project: 147823
Buggy source:
public void createControl(Composite parent){
  Composite composite=new Composite(parent,SWT.BORDER);
  composite.setLayout(new GridLayout(1,false));
  browseViewer=new TableViewer(composite,SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL);
  GridData gd=new GridData(SWT.FILL,SWT.FILL,true,true,1,1);
  gd.widthHint=600;
  browseViewer.getControl().setLayoutData(gd);
  ((GridData)browseViewer.getControl().getLayoutData()).heightHint=100;
  Table table=browseViewer.getTable();
  TableColumn column=new TableColumn(table,SWT.CENTER);
  column.setText(INSTANCE_NAME);
  column.setWidth(615);
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  CellEditor[] editors=new CellEditor[1];
  editors[0]=new TextCellEditor(table);
  browseViewer.setCellEditors(editors);
  browseViewer.setContentProvider(new IStructuredContentProvider(){
    public void dispose(){
    }
    public void inputChanged(    Viewer viewer,    Object oldInput,    Object newInput){
    }
    public Object[] getElements(    Object inputElement){
      ArrayList<XSDElementDeclaration> values=(ArrayList<XSDElementDeclaration>)inputElement;
      return values.toArray(new XSDElementDeclaration[values.size()]);
    }
  }
);
  browseViewer.setLabelProvider(new ITableLabelProvider(){
    public boolean isLabelProperty(    Object element,    String property){
      return false;
    }
    public void dispose(){
    }
    public void addListener(    ILabelProviderListener listener){
    }
    public void removeListener(    ILabelProviderListener listener){
    }
    public String getColumnText(    Object element,    int columnIndex){
      return BROWSE_ITEMS + ((XSDElementDeclaration)element).getName();
    }
    public Image getColumnImage(    Object element,    int columnIndex){
      return null;
    }
  }
);
  browseViewer.setCellModifier(new ICellModifier(){
    public boolean canModify(    Object element,    String property){
      return true;
    }
    public void modify(    Object element,    String property,    Object value){
      TableItem item=(TableItem)element;
      String tValue=value.toString().trim();
      if (Pattern.compile("String_Node_Str").matcher(value.toString()).matches() || tValue.replaceAll("String_Node_Str","String_Node_Str").length() != tValue.length()) {
        MessageDialog.openInformation(null,"String_Node_Str","String_Node_Str");
        return;
      }
      XSDElementDeclaration elem=(XSDElementDeclaration)item.getData();
      if (!(BROWSE_ITEMS + elem.getName()).equals(tValue)) {
        for (        XSDElementDeclaration theElem : declList) {
          if (theElem == elem)           continue;
          if ((BROWSE_ITEMS + theElem.getName()).equals(tValue)) {
            MessageDialog.openInformation(null,"String_Node_Str","String_Node_Str");
            return;
          }
        }
        List<Line> lines=browseItemToRoles.get(BROWSE_ITEMS + elem.getName());
        browseItemToRoles.remove(BROWSE_ITEMS + elem.getName());
        int prex=tValue.indexOf(BROWSE_ITEMS);
        if (prex != -1 && (prex + BROWSE_ITEMS.length()) <= tValue.length()) {
          elem.setName(tValue.substring(prex + BROWSE_ITEMS.length()));
        }
        browseItemToRoles.put(tValue,lines);
        refreshRoleView(BROWSE_ITEMS + elem.getName());
        browseViewer.update(elem,null);
      }
    }
    public Object getValue(    Object element,    String property){
      XSDElementDeclaration elem=(XSDElementDeclaration)element;
      return BROWSE_ITEMS + elem.getName();
    }
  }
);
  browseViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      applyChangeToRoles();
      IStructuredSelection selection=(IStructuredSelection)event.getSelection();
      if (selection.size() > 1) {
        List selectObjs=selection.toList();
        refreshRoleView(selectObjs);
        UpdateComplexViewButton(true);
      }
 else       if (selection.size() == 1) {
        XSDElementDeclaration decl=(XSDElementDeclaration)selection.getFirstElement();
        refreshRoleView(BROWSE_ITEMS + decl.getName());
        UpdateComplexViewButton(true);
      }
    }
  }
);
  browseViewer.setInput(declList);
  browseViewer.setColumnProperties(new String[]{INSTANCE_NAME});
  browseViewer.refresh();
  if (Util.IsEnterPrise()) {
    Label infoLabel=new Label(composite,SWT.NONE);
    infoLabel.setText("String_Node_Str");
    ComplexTableViewerColumn ruleColumn=roleConfigurationColumns[0];
    ruleColumn.setColumnWidth(250);
    List<String> roles=getAllRoleNames();
    ruleColumn.setComboValues(roles.toArray(new String[]{}));
    ComplexTableViewerColumn acsColumn=roleConfigurationColumns[1];
    acsColumn.setColumnWidth(250);
    acsColumn.setComboValues(new String[]{"String_Node_Str","String_Node_Str"});
    complexTableViewer=new ComplexTableViewer(Arrays.asList(roleConfigurationColumns),WidgetFactory.getWidgetFactory(),composite);
    complexTableViewer.setKeyColumns(new ComplexTableViewerColumn[]{roleConfigurationColumns[0]});
    complexTableViewer.create();
    complexTableViewer.getViewer().setInput(new ArrayList<Line>());
    UpdateComplexViewButton(false);
  }
  setControl(composite);
}

Fixed version (ground truth):
public void createControl(Composite parent){
  Composite composite=new Composite(parent,SWT.BORDER);
  composite.setLayout(new GridLayout(1,false));
  browseViewer=new TableViewer(composite,SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL);
  GridData gd=new GridData(SWT.FILL,SWT.FILL,true,true,1,1);
  gd.widthHint=600;
  browseViewer.getControl().setLayoutData(gd);
  ((GridData)browseViewer.getControl().getLayoutData()).heightHint=100;
  Table table=browseViewer.getTable();
  TableColumn column=new TableColumn(table,SWT.CENTER);
  column.setText(INSTANCE_NAME);
  column.setWidth(615);
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  CellEditor[] editors=new CellEditor[1];
  editors[0]=new TextCellEditor(table);
  browseViewer.setCellEditors(editors);
  browseViewer.setContentProvider(new IStructuredContentProvider(){
    public void dispose(){
    }
    public void inputChanged(    Viewer viewer,    Object oldInput,    Object newInput){
    }
    public Object[] getElements(    Object inputElement){
      ArrayList<XSDElementDeclaration> values=(ArrayList<XSDElementDeclaration>)inputElement;
      return values.toArray(new XSDElementDeclaration[values.size()]);
    }
  }
);
  browseViewer.setLabelProvider(new ITableLabelProvider(){
    public boolean isLabelProperty(    Object element,    String property){
      return false;
    }
    public void dispose(){
    }
    public void addListener(    ILabelProviderListener listener){
    }
    public void removeListener(    ILabelProviderListener listener){
    }
    public String getColumnText(    Object element,    int columnIndex){
      return BROWSE_ITEMS + ((XSDElementDeclaration)element).getName();
    }
    public Image getColumnImage(    Object element,    int columnIndex){
      return null;
    }
  }
);
  browseViewer.setCellModifier(new ICellModifier(){
    public boolean canModify(    Object element,    String property){
      return true;
    }
    public void modify(    Object element,    String property,    Object value){
      TableItem item=(TableItem)element;
      String tValue=value.toString().trim();
      if (Pattern.compile("String_Node_Str").matcher(value.toString()).matches() || tValue.replaceAll("String_Node_Str","String_Node_Str").length() != tValue.length()) {
        MessageDialog.openInformation(null,Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
        return;
      }
      if (!value.toString().startsWith(BROWSE_ITEMS)) {
        MessageDialog.openInformation(null,Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str") + BROWSE_ITEMS);
        return;
      }
      XSDElementDeclaration elem=(XSDElementDeclaration)item.getData();
      if (!(BROWSE_ITEMS + elem.getName()).equals(tValue)) {
        for (        XSDElementDeclaration theElem : declList) {
          if (theElem == elem)           continue;
          if ((BROWSE_ITEMS + theElem.getName()).equals(tValue)) {
            MessageDialog.openInformation(null,Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
            return;
          }
        }
        List<Line> lines=browseItemToRoles.get(BROWSE_ITEMS + elem.getName());
        browseItemToRoles.remove(BROWSE_ITEMS + elem.getName());
        int prex=tValue.indexOf(BROWSE_ITEMS);
        if (prex != -1 && (prex + BROWSE_ITEMS.length()) <= tValue.length()) {
          elem.setName(tValue.substring(prex + BROWSE_ITEMS.length()));
        }
        browseItemToRoles.put(tValue,lines);
        refreshRoleView(BROWSE_ITEMS + elem.getName());
        browseViewer.update(elem,null);
      }
    }
    public Object getValue(    Object element,    String property){
      XSDElementDeclaration elem=(XSDElementDeclaration)element;
      return BROWSE_ITEMS + elem.getName();
    }
  }
);
  browseViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      applyChangeToRoles();
      IStructuredSelection selection=(IStructuredSelection)event.getSelection();
      if (selection.size() > 1) {
        List selectObjs=selection.toList();
        refreshRoleView(selectObjs);
        UpdateComplexViewButton(true);
      }
 else       if (selection.size() == 1) {
        XSDElementDeclaration decl=(XSDElementDeclaration)selection.getFirstElement();
        refreshRoleView(BROWSE_ITEMS + decl.getName());
        UpdateComplexViewButton(true);
      }
    }
  }
);
  browseViewer.setInput(declList);
  browseViewer.setColumnProperties(new String[]{INSTANCE_NAME});
  browseViewer.refresh();
  if (Util.IsEnterPrise()) {
    Label infoLabel=new Label(composite,SWT.NONE);
    infoLabel.setText(Messages.getString("String_Node_Str"));
    ComplexTableViewerColumn ruleColumn=roleConfigurationColumns[0];
    ruleColumn.setColumnWidth(250);
    List<String> roles=getAllRoleNames();
    ruleColumn.setComboValues(roles.toArray(new String[]{}));
    ComplexTableViewerColumn acsColumn=roleConfigurationColumns[1];
    acsColumn.setColumnWidth(250);
    acsColumn.setComboValues(new String[]{Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str")});
    complexTableViewer=new ComplexTableViewer(Arrays.asList(roleConfigurationColumns),WidgetFactory.getWidgetFactory(),composite);
    complexTableViewer.setKeyColumns(new ComplexTableViewerColumn[]{roleConfigurationColumns[0]});
    complexTableViewer.create();
    complexTableViewer.getViewer().setInput(new ArrayList<Line>());
    UpdateComplexViewButton(false);
  }
  setControl(composite);
}