Program: 149165
Project: 149165
Buggy source:
protected Control createDialogArea(Composite parent){
  parent.getShell().setText(this.title);
  Composite composite=(Composite)super.createDialogArea(parent);
  GridLayout layout=(GridLayout)composite.getLayout();
  layout.numColumns=3;
  layout.makeColumnsEqualWidth=false;
  if (actionType == AnnotationWrite_ActionType || actionType == AnnotationHidden_ActionType) {
    textControl=new CCombo(composite,SWT.BORDER | SWT.READ_ONLY);
    roles=Util.getCachedXObjectsNameSet(this.xObject,TreeObject.ROLE);
    ((CCombo)textControl).setItems(roles.toArray(new String[roles.size()]));
  }
 else {
    textControl=new Text(composite,SWT.BORDER | SWT.SINGLE);
  }
  if (actionType == AnnotationOrderedListsDialog.AnnotationForeignKeyInfo_ActionType) {
    textControl.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,1,1));
  }
 else {
    textControl.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,2,1));
  }
  ((GridData)textControl.getLayoutData()).minimumWidth=400;
  textControl.addKeyListener(new KeyListener(){
    public void keyPressed(    KeyEvent e){
    }
    public void keyReleased(    KeyEvent e){
      if ((e.stateMask == 0) && (e.character == SWT.CR)) {
        xPaths.add(AnnotationOrderedListsDialog.getControlText(textControl));
        viewer.refresh();
      }
    }
  }
);
  if (actionType == AnnotationOrderedListsDialog.AnnotationForeignKeyInfo_ActionType) {
    Button xpathButton=new Button(composite,SWT.PUSH | SWT.CENTER);
    xpathButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
    xpathButton.setText("String_Node_Str");
    xpathButton.setToolTipText("String_Node_Str");
    xpathButton.addSelectionListener(new SelectionListener(){
      public void widgetDefaultSelected(      SelectionEvent e){
      }
      public void widgetSelected(      SelectionEvent e){
        XpathSelectDialog dlg=new XpathSelectDialog(parentPage.getSite().getShell(),xObject.getParent(),"String_Node_Str",parentPage.getSite(),false,dataModelName);
        dlg.setBlockOnOpen(true);
        dlg.open();
        if (dlg.getReturnCode() == Window.OK) {
          ((Text)textControl).setText(dlg.getXpath());
          dlg.close();
        }
      }
    }
);
  }
  Button addLabelButton=new Button(composite,SWT.PUSH | SWT.CENTER);
  addLabelButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
  addLabelButton.setText("String_Node_Str");
  addLabelButton.addSelectionListener(new SelectionListener(){
    public void widgetDefaultSelected(    org.eclipse.swt.events.SelectionEvent e){
    }
    public void widgetSelected(    org.eclipse.swt.events.SelectionEvent e){
      boolean exist=false;
      for (Iterator it=xPaths.iterator(); it.hasNext(); ) {
        if (((String)it.next()).equals(getControlText(textControl)))         exist=true;
      }
      if (!exist && getControlText(textControl) != null && getControlText(textControl) != "String_Node_Str")       xPaths.add(getControlText(textControl));
      viewer.refresh();
    }
  }
);
  final String COLUMN=columnName;
  viewer=new TableViewer(composite,SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL| SWT.BORDER| SWT.FULL_SELECTION);
  viewer.getControl().setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,2,1));
  ((GridData)viewer.getControl().getLayoutData()).heightHint=100;
  Table table=viewer.getTable();
  new TableColumn(table,SWT.CENTER).setText(COLUMN);
  table.getColumn(0).setWidth(500);
  for (int i=1, n=table.getColumnCount(); i < n; i++) {
    table.getColumn(i).pack();
  }
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  CellEditor[] editors=new CellEditor[1];
  if (actionType == AnnotationOrderedListsDialog.AnnotationWrite_ActionType || actionType == AnnotationOrderedListsDialog.AnnotationHidden_ActionType) {
    editors[0]=new ComboBoxCellEditor(table,roles.toArray(new String[]{}),SWT.READ_ONLY);
  }
 else {
    editors[0]=new TextCellEditor(table);
  }
  viewer.setCellEditors(editors);
  viewer.setContentProvider(new IStructuredContentProvider(){
    public void dispose(){
    }
    public void inputChanged(    Viewer viewer,    Object oldInput,    Object newInput){
    }
    public Object[] getElements(    Object inputElement){
      ArrayList<String> xPaths=(ArrayList<String>)inputElement;
      ArrayList<DescriptionLine> lines=new ArrayList<DescriptionLine>();
      for (Iterator iter=xPaths.iterator(); iter.hasNext(); ) {
        String xPath=((String)iter.next());
        DescriptionLine line=new DescriptionLine(xPath);
        lines.add(line);
      }
      return lines.toArray(new DescriptionLine[lines.size()]);
    }
  }
);
  viewer.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){
      DescriptionLine line=(DescriptionLine)element;
switch (columnIndex) {
case 0:
        return line.getLabel();
    }
    return "String_Node_Str";
  }
  public Image getColumnImage(  Object element,  int columnIndex){
    return null;
  }
}
);
viewer.setColumnProperties(new String[]{COLUMN});
viewer.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;
    DescriptionLine line=(DescriptionLine)item.getData();
    String orgValue=line.getLabel();
    if (actionType != AnnotationWrite_ActionType && actionType != AnnotationHidden_ActionType) {
      int targetPos=xPaths.indexOf(value.toString());
      if (targetPos < 0) {
        line.setLabel(value.toString());
        xPaths.add(value.toString());
        viewer.update(line,null);
      }
 else       if (targetPos >= 0 && !value.toString().equals(orgValue)) {
        MessageDialog.openInformation(null,"String_Node_Str","String_Node_Str");
      }
      return;
    }
 else {
      String[] attrs=roles.toArray(new String[]{});
      value=attrs[Integer.parseInt(value.toString())];
      int pos=xPaths.indexOf(value.toString());
      if (pos >= 0 && !(orgValue.equals(value))) {
        MessageDialog.openInformation(null,"String_Node_Str","String_Node_Str");
        return;
      }
 else       if (pos < 0) {
        line.setLabel(value.toString());
        xPaths.set(xPaths.indexOf(orgValue),value.toString());
        viewer.update(line,null);
      }
    }
  }
  public Object getValue(  Object element,  String property){
    DescriptionLine line=(DescriptionLine)element;
    String value=line.getLabel();
    if (actionType == AnnotationWrite_ActionType || actionType == AnnotationHidden_ActionType) {
      String[] attrs=roles.toArray(new String[]{});
      return Arrays.asList(attrs).indexOf(value);
    }
 else {
      return value;
    }
  }
}
);
viewer.addSelectionChangedListener(new ISelectionChangedListener(){
  public void selectionChanged(  SelectionChangedEvent event){
    DescriptionLine line=(DescriptionLine)((IStructuredSelection)viewer.getSelection()).getFirstElement();
    if (line != null)     ((Text)textControl).setText(line.getLabel());
  }
}
);
viewer.getTable().addKeyListener(new KeyListener(){
  public void keyPressed(  KeyEvent e){
  }
  public void keyReleased(  KeyEvent e){
    if ((e.stateMask == 0) && (e.character == SWT.DEL) && (viewer.getSelection() != null)) {
      DescriptionLine line=(DescriptionLine)((IStructuredSelection)viewer.getSelection()).getFirstElement();
      ArrayList<String> xPaths=(ArrayList<String>)viewer.getInput();
      xPaths.remove(line.getLabel());
      viewer.refresh();
    }
  }
}
);
viewer.setInput(xPaths);
viewer.refresh();
Composite rightButtonsComposite=new Composite(composite,SWT.NULL);
rightButtonsComposite.setLayout(new GridLayout(1,true));
rightButtonsComposite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
Button upButton=new Button(rightButtonsComposite,SWT.PUSH | SWT.CENTER);
upButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
upButton.setText("String_Node_Str");
upButton.addSelectionListener(new SelectionListener(){
  public void widgetDefaultSelected(  org.eclipse.swt.events.SelectionEvent e){
  }
  public void widgetSelected(  org.eclipse.swt.events.SelectionEvent e){
    DescriptionLine line=(DescriptionLine)((IStructuredSelection)viewer.getSelection()).getFirstElement();
    if (line == null)     return;
    int i=0;
    for (Iterator iter=xPaths.iterator(); iter.hasNext(); ) {
      String xPath=(String)iter.next();
      if (xPath.equals(line.getLabel())) {
        if (i > 0) {
          xPaths.remove(i);
          xPaths.add(i - 1,xPath);
          viewer.refresh();
          viewer.getTable().setSelection(i - 1);
          viewer.getTable().showSelection();
        }
        return;
      }
      i++;
    }
  }
}
);
Button downButton=new Button(rightButtonsComposite,SWT.PUSH | SWT.CENTER);
downButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
downButton.setText("String_Node_Str");
downButton.addSelectionListener(new SelectionListener(){
  public void widgetDefaultSelected(  org.eclipse.swt.events.SelectionEvent e){
  }
  public void widgetSelected(  org.eclipse.swt.events.SelectionEvent e){
    DescriptionLine line=(DescriptionLine)((IStructuredSelection)viewer.getSelection()).getFirstElement();
    if (line == null)     return;
    int i=0;
    for (Iterator iter=xPaths.iterator(); iter.hasNext(); ) {
      String xPath=(String)iter.next();
      if (xPath.equals(line.getLabel())) {
        if (i < xPaths.size() - 1) {
          xPaths.remove(i);
          xPaths.add(i + 1,xPath);
          viewer.refresh();
          viewer.getTable().setSelection(i + 1);
          viewer.getTable().showSelection();
        }
        return;
      }
      i++;
    }
  }
}
);
Button delButton=new Button(rightButtonsComposite,SWT.PUSH | SWT.CENTER);
delButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
delButton.setText("String_Node_Str");
delButton.addSelectionListener(new SelectionListener(){
  public void widgetDefaultSelected(  org.eclipse.swt.events.SelectionEvent e){
  }
  public void widgetSelected(  org.eclipse.swt.events.SelectionEvent e){
    DescriptionLine line=(DescriptionLine)((IStructuredSelection)viewer.getSelection()).getFirstElement();
    if (line != null) {
      ArrayList<String> xPaths=(ArrayList<String>)viewer.getInput();
      xPaths.remove(line.getLabel());
      viewer.refresh();
    }
  }
}
);
textControl.setFocus();
if (actionType != AnnotationOrderedListsDialog.AnnotationForeignKeyInfo_ActionType && actionType != AnnotationOrderedListsDialog.AnnotationTargetSystems_ActionType) {
  checkBox=new Button(composite,SWT.CHECK);
  checkBox.setLayoutData(new GridData(SWT.LEFT,SWT.FILL,false,true,2,1));
  checkBox.addSelectionListener(new SelectionListener(){
    public void widgetDefaultSelected(    org.eclipse.swt.events.SelectionEvent e){
    }
    public void widgetSelected(    org.eclipse.swt.events.SelectionEvent e){
      recursive=checkBox.getSelection();
    }
  }
);
  checkBox.setSelection(recursive);
  checkBox.setText("String_Node_Str");
}
return composite;
}

Fixed version (ground truth):
protected Control createDialogArea(Composite parent){
  parent.getShell().setText(this.title);
  Composite composite=(Composite)super.createDialogArea(parent);
  GridLayout layout=(GridLayout)composite.getLayout();
  layout.numColumns=3;
  layout.makeColumnsEqualWidth=false;
  if (actionType == AnnotationWrite_ActionType || actionType == AnnotationHidden_ActionType) {
    textControl=new CCombo(composite,SWT.BORDER | SWT.READ_ONLY);
    roles=Util.getChildren(this.xObject.getServerRoot(),TreeObject.ROLE);
    ((CCombo)textControl).setItems(roles.toArray(new String[roles.size()]));
  }
 else {
    textControl=new Text(composite,SWT.BORDER | SWT.SINGLE);
  }
  if (actionType == AnnotationOrderedListsDialog.AnnotationForeignKeyInfo_ActionType) {
    textControl.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,1,1));
  }
 else {
    textControl.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,2,1));
  }
  ((GridData)textControl.getLayoutData()).minimumWidth=400;
  textControl.addKeyListener(new KeyListener(){
    public void keyPressed(    KeyEvent e){
    }
    public void keyReleased(    KeyEvent e){
      if ((e.stateMask == 0) && (e.character == SWT.CR)) {
        xPaths.add(AnnotationOrderedListsDialog.getControlText(textControl));
        viewer.refresh();
      }
    }
  }
);
  if (actionType == AnnotationOrderedListsDialog.AnnotationForeignKeyInfo_ActionType) {
    Button xpathButton=new Button(composite,SWT.PUSH | SWT.CENTER);
    xpathButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
    xpathButton.setText("String_Node_Str");
    xpathButton.setToolTipText("String_Node_Str");
    xpathButton.addSelectionListener(new SelectionListener(){
      public void widgetDefaultSelected(      SelectionEvent e){
      }
      public void widgetSelected(      SelectionEvent e){
        XpathSelectDialog dlg=new XpathSelectDialog(parentPage.getSite().getShell(),xObject.getParent(),"String_Node_Str",parentPage.getSite(),false,dataModelName);
        dlg.setBlockOnOpen(true);
        dlg.open();
        if (dlg.getReturnCode() == Window.OK) {
          ((Text)textControl).setText(dlg.getXpath());
          dlg.close();
        }
      }
    }
);
  }
  Button addLabelButton=new Button(composite,SWT.PUSH | SWT.CENTER);
  addLabelButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
  addLabelButton.setText("String_Node_Str");
  addLabelButton.addSelectionListener(new SelectionListener(){
    public void widgetDefaultSelected(    org.eclipse.swt.events.SelectionEvent e){
    }
    public void widgetSelected(    org.eclipse.swt.events.SelectionEvent e){
      boolean exist=false;
      for (Iterator it=xPaths.iterator(); it.hasNext(); ) {
        if (((String)it.next()).equals(getControlText(textControl)))         exist=true;
      }
      if (!exist && getControlText(textControl) != null && getControlText(textControl) != "String_Node_Str")       xPaths.add(getControlText(textControl));
      viewer.refresh();
    }
  }
);
  final String COLUMN=columnName;
  viewer=new TableViewer(composite,SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL| SWT.BORDER| SWT.FULL_SELECTION);
  viewer.getControl().setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,2,1));
  ((GridData)viewer.getControl().getLayoutData()).heightHint=100;
  Table table=viewer.getTable();
  new TableColumn(table,SWT.CENTER).setText(COLUMN);
  table.getColumn(0).setWidth(500);
  for (int i=1, n=table.getColumnCount(); i < n; i++) {
    table.getColumn(i).pack();
  }
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  CellEditor[] editors=new CellEditor[1];
  if (actionType == AnnotationOrderedListsDialog.AnnotationWrite_ActionType || actionType == AnnotationOrderedListsDialog.AnnotationHidden_ActionType) {
    editors[0]=new ComboBoxCellEditor(table,roles.toArray(new String[]{}),SWT.READ_ONLY);
  }
 else {
    editors[0]=new TextCellEditor(table);
  }
  viewer.setCellEditors(editors);
  viewer.setContentProvider(new IStructuredContentProvider(){
    public void dispose(){
    }
    public void inputChanged(    Viewer viewer,    Object oldInput,    Object newInput){
    }
    public Object[] getElements(    Object inputElement){
      ArrayList<String> xPaths=(ArrayList<String>)inputElement;
      ArrayList<DescriptionLine> lines=new ArrayList<DescriptionLine>();
      for (Iterator iter=xPaths.iterator(); iter.hasNext(); ) {
        String xPath=((String)iter.next());
        DescriptionLine line=new DescriptionLine(xPath);
        lines.add(line);
      }
      return lines.toArray(new DescriptionLine[lines.size()]);
    }
  }
);
  viewer.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){
      DescriptionLine line=(DescriptionLine)element;
switch (columnIndex) {
case 0:
        return line.getLabel();
    }
    return "String_Node_Str";
  }
  public Image getColumnImage(  Object element,  int columnIndex){
    return null;
  }
}
);
viewer.setColumnProperties(new String[]{COLUMN});
viewer.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;
    DescriptionLine line=(DescriptionLine)item.getData();
    String orgValue=line.getLabel();
    if (actionType != AnnotationWrite_ActionType && actionType != AnnotationHidden_ActionType) {
      int targetPos=xPaths.indexOf(value.toString());
      if (targetPos < 0) {
        line.setLabel(value.toString());
        xPaths.add(value.toString());
        viewer.update(line,null);
      }
 else       if (targetPos >= 0 && !value.toString().equals(orgValue)) {
        MessageDialog.openInformation(null,"String_Node_Str","String_Node_Str");
      }
      return;
    }
 else {
      String[] attrs=roles.toArray(new String[]{});
      value=attrs[Integer.parseInt(value.toString())];
      int pos=xPaths.indexOf(value.toString());
      if (pos >= 0 && !(orgValue.equals(value))) {
        MessageDialog.openInformation(null,"String_Node_Str","String_Node_Str");
        return;
      }
 else       if (pos < 0) {
        line.setLabel(value.toString());
        xPaths.set(xPaths.indexOf(orgValue),value.toString());
        viewer.update(line,null);
      }
    }
  }
  public Object getValue(  Object element,  String property){
    DescriptionLine line=(DescriptionLine)element;
    String value=line.getLabel();
    if (actionType == AnnotationWrite_ActionType || actionType == AnnotationHidden_ActionType) {
      String[] attrs=roles.toArray(new String[]{});
      return Arrays.asList(attrs).indexOf(value);
    }
 else {
      return value;
    }
  }
}
);
viewer.addSelectionChangedListener(new ISelectionChangedListener(){
  public void selectionChanged(  SelectionChangedEvent event){
    DescriptionLine line=(DescriptionLine)((IStructuredSelection)viewer.getSelection()).getFirstElement();
    if (line != null)     ((Text)textControl).setText(line.getLabel());
  }
}
);
viewer.getTable().addKeyListener(new KeyListener(){
  public void keyPressed(  KeyEvent e){
  }
  public void keyReleased(  KeyEvent e){
    if ((e.stateMask == 0) && (e.character == SWT.DEL) && (viewer.getSelection() != null)) {
      DescriptionLine line=(DescriptionLine)((IStructuredSelection)viewer.getSelection()).getFirstElement();
      ArrayList<String> xPaths=(ArrayList<String>)viewer.getInput();
      xPaths.remove(line.getLabel());
      viewer.refresh();
    }
  }
}
);
viewer.setInput(xPaths);
viewer.refresh();
Composite rightButtonsComposite=new Composite(composite,SWT.NULL);
rightButtonsComposite.setLayout(new GridLayout(1,true));
rightButtonsComposite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
Button upButton=new Button(rightButtonsComposite,SWT.PUSH | SWT.CENTER);
upButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
upButton.setText("String_Node_Str");
upButton.addSelectionListener(new SelectionListener(){
  public void widgetDefaultSelected(  org.eclipse.swt.events.SelectionEvent e){
  }
  public void widgetSelected(  org.eclipse.swt.events.SelectionEvent e){
    DescriptionLine line=(DescriptionLine)((IStructuredSelection)viewer.getSelection()).getFirstElement();
    if (line == null)     return;
    int i=0;
    for (Iterator iter=xPaths.iterator(); iter.hasNext(); ) {
      String xPath=(String)iter.next();
      if (xPath.equals(line.getLabel())) {
        if (i > 0) {
          xPaths.remove(i);
          xPaths.add(i - 1,xPath);
          viewer.refresh();
          viewer.getTable().setSelection(i - 1);
          viewer.getTable().showSelection();
        }
        return;
      }
      i++;
    }
  }
}
);
Button downButton=new Button(rightButtonsComposite,SWT.PUSH | SWT.CENTER);
downButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
downButton.setText("String_Node_Str");
downButton.addSelectionListener(new SelectionListener(){
  public void widgetDefaultSelected(  org.eclipse.swt.events.SelectionEvent e){
  }
  public void widgetSelected(  org.eclipse.swt.events.SelectionEvent e){
    DescriptionLine line=(DescriptionLine)((IStructuredSelection)viewer.getSelection()).getFirstElement();
    if (line == null)     return;
    int i=0;
    for (Iterator iter=xPaths.iterator(); iter.hasNext(); ) {
      String xPath=(String)iter.next();
      if (xPath.equals(line.getLabel())) {
        if (i < xPaths.size() - 1) {
          xPaths.remove(i);
          xPaths.add(i + 1,xPath);
          viewer.refresh();
          viewer.getTable().setSelection(i + 1);
          viewer.getTable().showSelection();
        }
        return;
      }
      i++;
    }
  }
}
);
Button delButton=new Button(rightButtonsComposite,SWT.PUSH | SWT.CENTER);
delButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,true,1,1));
delButton.setText("String_Node_Str");
delButton.addSelectionListener(new SelectionListener(){
  public void widgetDefaultSelected(  org.eclipse.swt.events.SelectionEvent e){
  }
  public void widgetSelected(  org.eclipse.swt.events.SelectionEvent e){
    DescriptionLine line=(DescriptionLine)((IStructuredSelection)viewer.getSelection()).getFirstElement();
    if (line != null) {
      ArrayList<String> xPaths=(ArrayList<String>)viewer.getInput();
      xPaths.remove(line.getLabel());
      viewer.refresh();
    }
  }
}
);
textControl.setFocus();
if (actionType != AnnotationOrderedListsDialog.AnnotationForeignKeyInfo_ActionType && actionType != AnnotationOrderedListsDialog.AnnotationTargetSystems_ActionType) {
  checkBox=new Button(composite,SWT.CHECK);
  checkBox.setLayoutData(new GridData(SWT.LEFT,SWT.FILL,false,true,2,1));
  checkBox.addSelectionListener(new SelectionListener(){
    public void widgetDefaultSelected(    org.eclipse.swt.events.SelectionEvent e){
    }
    public void widgetSelected(    org.eclipse.swt.events.SelectionEvent e){
      recursive=checkBox.getSelection();
    }
  }
);
  checkBox.setSelection(recursive);
  checkBox.setText("String_Node_Str");
}
return composite;
}