nus-yam/ex-repair huggingface dataset:
Program: 79050
Project: 79050
Buggy source:
public Collection getSelectionChoice(String name){
  usingParameterValues();
  ReportDesignHandle report=(ReportDesignHandle)this.runnable.getDesignHandle();
  ScalarParameterHandle parameter=(ScalarParameterHandle)report.findParameter(name);
  if (parameter == null) {
    return null;
  }
  String selectionType=parameter.getValueType();
  String dataType=parameter.getDataType();
  if (DesignChoiceConstants.PARAM_VALUE_TYPE_DYNAMIC.equals(selectionType)) {
    String dataSetName=parameter.getDataSetName();
    String valueExpr=parameter.getValueExpr();
    String labelExpr=parameter.getLabelExpr();
    if (labelExpr == null) {
      labelExpr=valueExpr;
    }
    return createDynamicSelectionChoices(dataSetName,labelExpr,valueExpr,dataType);
  }
 else   if (DesignChoiceConstants.PARAM_VALUE_TYPE_STATIC.equals(selectionType)) {
    Iterator iter=parameter.choiceIterator();
    ArrayList choices=new ArrayList();
    while (iter.hasNext()) {
      SelectionChoiceHandle choice=(SelectionChoiceHandle)iter.next();
      String label=report.getMessage(choice.getLabelKey(),locale);
      if (label != null) {
        label=choice.getLabel();
      }
      Object value=getStringValue(choice.getValue(),dataType);
      choices.add(new SelectionChoice(label,value));
    }
    return choices;
  }
  return null;
}

Fixed version (ground truth):
public Collection getSelectionChoice(String name){
  usingParameterValues();
  ReportDesignHandle report=(ReportDesignHandle)this.runnable.getDesignHandle();
  ScalarParameterHandle parameter=(ScalarParameterHandle)report.findParameter(name);
  if (parameter == null) {
    return null;
  }
  String selectionType=parameter.getValueType();
  String dataType=parameter.getDataType();
  boolean fixedOrder=parameter.isFixedOrder();
  if (DesignChoiceConstants.PARAM_VALUE_TYPE_DYNAMIC.equals(selectionType)) {
    String dataSetName=parameter.getDataSetName();
    String valueExpr=parameter.getValueExpr();
    String labelExpr=parameter.getLabelExpr();
    int limit=parameter.getListlimit();
    return createDynamicSelectionChoices(dataSetName,labelExpr,valueExpr,dataType,limit,fixedOrder);
  }
 else   if (DesignChoiceConstants.PARAM_VALUE_TYPE_STATIC.equals(selectionType)) {
    Iterator iter=parameter.choiceIterator();
    ArrayList choices=new ArrayList();
    while (iter.hasNext()) {
      SelectionChoiceHandle choice=(SelectionChoiceHandle)iter.next();
      String label=report.getMessage(choice.getLabelKey(),locale);
      if (label != null) {
        label=choice.getLabel();
      }
      Object value=getStringValue(choice.getValue(),dataType);
      choices.add(new SelectionChoice(label,value));
    }
    if (!fixedOrder)     Collections.sort(choices,new SelectionChoiceComparator(true));
    return choices;
  }
  return null;
}
Program: 79052
Project: 79052
Buggy source:
/** 
 * creates the static selection list 
 */
public void evaluateSelectionList(){
  if (selectionListType == IScalarParameterDefn.SELECTION_LIST_STATIC) {
    boolean sortDisplayValue=true;
    for (int i=0; i < selectionList.size(); i++) {
      ParameterSelectionChoice choice=(ParameterSelectionChoice)selectionList.get(i);
      choice.setLocale(locale);
      if (choice.getLabel() == null) {
        sortDisplayValue=false;
        break;
      }
    }
    if (!fixedOrder)     Collections.sort(selectionList,new SelectionChoiceCompartor(sortDisplayValue));
  }
}

Fixed version (ground truth):
/** 
 * creates the static selection list 
 */
public void evaluateSelectionList(){
  if (selectionListType == IScalarParameterDefn.SELECTION_LIST_STATIC) {
    boolean sortDisplayValue=true;
    for (int i=0; i < selectionList.size(); i++) {
      ParameterSelectionChoice choice=(ParameterSelectionChoice)selectionList.get(i);
      choice.setLocale(locale);
      if (choice.getLabel() == null) {
        sortDisplayValue=false;
        break;
      }
    }
    if (!fixedOrder)     Collections.sort(selectionList,new SelectionChoiceComparator(sortDisplayValue));
  }
}
Program: 79053
Project: 79053
Buggy source:
/** 
 * Returns the qualified name of this element. The qualified name is the name of this element if this element is in module user is editing.
 * @return the qualified name of thie element.
 */
public String getQualifiedName(){
  if (getElement().getName() == null)   return null;
  if (module instanceof Library) {
    String namespace=((Library)module).getNamespace();
    return StringUtil.buildQualifiedReference(namespace,getElement().getName());
  }
  return getElement().getName();
}

Fixed version (ground truth):
/** 
 * Gets the name of this element. The returned element name will be the same as <CODE>getName()</CODE>, plus the namespace of the module that the elment is contained, if any. If the element is existed in the current module,this method and <CODE>getName()</CODE> will return identical results.
 * @return the qualified name of thie element.
 */
public String getQualifiedName(){
  if (getElement().getName() == null)   return null;
  if (module instanceof Library) {
    String namespace=((Library)module).getNamespace();
    return StringUtil.buildQualifiedReference(namespace,getElement().getName());
  }
  return getElement().getName();
}
Program: 79054
Project: 79054
Buggy source:
/** 
 * Constructs the record for adding with container element, slot id, content element, and position in container.
 * @param containerObj The container element.
 * @param theSlot The slotID in which to put the content.
 * @param contentObj The content object to add or remove.
 * @param newPos The position index where to insert the content.
 */
public ContentRecord(DesignElement containerObj,int theSlot,DesignElement contentObj,int newPos){
  init(containerObj,theSlot,contentObj,newPos,true);
}

Fixed version (ground truth):
/** 
 * Constructs the record for adding with container element, slot id, content element, and position in container.
 * @param module the module in which this record executes
 * @param containerObj The container element.
 * @param theSlot The slotID in which to put the content.
 * @param contentObj The content object to add or remove.
 * @param newPos The position index where to insert the content.
 */
public ContentRecord(Module module,DesignElement containerObj,int theSlot,DesignElement contentObj,int newPos){
}
Program: 79055
Project: 79055
Buggy source:
protected void perform(boolean undo){
  ContainerSlot slot=container.getSlot(slotID);
  if (add && !undo || !add && undo) {
    slot.insert(content,oldPosn);
    content.setContainer(container,slotID);
    if (content.getRoot() != null)     manageId(content,true);
  }
 else {
    slot.remove(content);
    if (content.getRoot() != null)     manageId(content,false);
    content.setContainer(null,DesignElement.NO_SLOT);
  }
}

Fixed version (ground truth):
protected void perform(boolean undo){
  ContainerSlot slot=container.getSlot(slotID);
  if (add && !undo || !add && undo) {
    slot.insert(content,oldPosn);
    content.setContainer(container,slotID);
    if (content.getRoot() != null)     module.manageId(content,true,true);
  }
 else {
    slot.remove(content);
    if (content.getRoot() != null)     module.manageId(content,false,false);
    content.setContainer(null,DesignElement.NO_SLOT);
  }
}
Program: 79056
Project: 79056
Buggy source:
/** 
 * Creates a new library.
 * @return the created library.
 */
public Library createLibrary(){
  Library library=new Library(this);
  Theme theme=new Theme(ModelMessages.getMessage(Theme.DEFAULT_THEME_NAME));
  library.getSlot(ILibraryModel.THEMES_SLOT).add(theme);
  library.setProperty(Module.THEME_PROP,new ElementRefValue(null,theme));
  library.setValid(true);
  libraries.add(library);
  return library;
}

Fixed version (ground truth):
/** 
 * Creates a new library.
 * @return the created library.
 */
public Library createLibrary(){
  Library library=new Library(this);
  Theme theme=new Theme(ModelMessages.getMessage(Theme.DEFAULT_THEME_NAME));
  library.setProperty(Module.THEME_PROP,new ElementRefValue(null,theme));
  ModelUtil.insertCompatibleThemeToLibrary(library,theme);
  theme.setID(library.getNextID());
  library.addElementID(theme);
  library.setValid(true);
  libraries.add(library);
  return library;
}
Program: 79057
Project: 79057
Buggy source:
public void parseAttrs(Attributes attrs) throws XMLParserException {
  element=new Cell();
  if (!addToSlot(container,slotID,element))   return;
}

Fixed version (ground truth):
public void parseAttrs(Attributes attrs) throws XMLParserException {
  element=new Cell();
  try {
    String theID=attrs.getValue(DesignSchemaConstants.ID_ATTRIB);
    if (!StringUtil.isBlank(theID)) {
      long id=Long.parseLong(theID);
      element.setID(id);
    }
  }
 catch (  NumberFormatException e) {
    handler.getErrorHandler().semanticError(new DesignParserException(new String[]{element.getIdentifier(),attrs.getValue(DesignSchemaConstants.ID_ATTRIB)},DesignParserException.DESIGN_EXCEPTION_INVALID_ELEMENT_ID));
  }
  if (!addToSlot(container,slotID,element))   return;
}
Program: 79058
Project: 79058
Buggy source:
public void parseAttrs(Attributes attrs) throws XMLParserException {
  if (!addToSlot(container,slotID,group))   return;
}

Fixed version (ground truth):
public void parseAttrs(Attributes attrs) throws XMLParserException {
  try {
    String theID=attrs.getValue(DesignSchemaConstants.ID_ATTRIB);
    if (!StringUtil.isBlank(theID)) {
      long id=Long.parseLong(theID);
      getElement().setID(id);
    }
  }
 catch (  NumberFormatException e) {
    handler.getErrorHandler().semanticError(new DesignParserException(new String[]{getElement().getIdentifier(),attrs.getValue(DesignSchemaConstants.ID_ATTRIB)},DesignParserException.DESIGN_EXCEPTION_INVALID_ELEMENT_ID));
  }
  if (!addToSlot(container,slotID,group))   return;
}
Program: 79059
Project: 79059
Buggy source:
public void parseAttrs(Attributes attrs) throws XMLParserException {
  element=new TableColumn();
  if (!addToSlot(container,slotID,element))   return;
}

Fixed version (ground truth):
public void parseAttrs(Attributes attrs) throws XMLParserException {
  element=new TableColumn();
  try {
    String theID=attrs.getValue(DesignSchemaConstants.ID_ATTRIB);
    if (!StringUtil.isBlank(theID)) {
      long id=Long.parseLong(theID);
      element.setID(id);
    }
  }
 catch (  NumberFormatException e) {
    handler.getErrorHandler().semanticError(new DesignParserException(new String[]{element.getIdentifier(),attrs.getValue(DesignSchemaConstants.ID_ATTRIB)},DesignParserException.DESIGN_EXCEPTION_INVALID_ELEMENT_ID));
  }
  if (!addToSlot(container,slotID,element))   return;
}
Program: 79060
Project: 79060
Buggy source:
public void parseAttrs(Attributes attrs) throws XMLParserException {
  element=new TableRow();
  if (!addToSlot(container,slotID,element))   return;
}

Fixed version (ground truth):
public void parseAttrs(Attributes attrs) throws XMLParserException {
  element=new TableRow();
  try {
    String theID=attrs.getValue(DesignSchemaConstants.ID_ATTRIB);
    if (!StringUtil.isBlank(theID)) {
      long id=Long.parseLong(theID);
      element.setID(id);
    }
  }
 catch (  NumberFormatException e) {
    handler.getErrorHandler().semanticError(new DesignParserException(new String[]{element.getIdentifier(),attrs.getValue(DesignSchemaConstants.ID_ATTRIB)},DesignParserException.DESIGN_EXCEPTION_INVALID_ELEMENT_ID));
  }
  if (!addToSlot(container,slotID,element))   return;
}
Program: 79062
Project: 79062
Buggy source:
public final void setProperty(String sProperty,Object oValue){
  super.setProperty(sProperty,oValue);
  if (sProperty.equals(IDeviceRenderer.EXPECTED_BOUNDS)) {
    final Bounds bo=(Bounds)oValue;
    try {
      dom=createSvgDocument(bo.getWidth(),bo.getHeight());
      svggc=new SVGGraphics2D(dom);
      hotspotLayer=createHotspotLayer(dom);
      super.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT,svggc);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
 else   if (sProperty.equals(IDeviceRenderer.FILE_IDENTIFIER)) {
    oOutputIdentifier=oValue;
  }
}

Fixed version (ground truth):
public final void setProperty(String sProperty,Object oValue){
  super.setProperty(sProperty,oValue);
  if (sProperty.equals(IDeviceRenderer.UPDATE_NOTIFIER)) {
    _iun=(IUpdateNotifier)oValue;
  }
 else   if (sProperty.equals(IDeviceRenderer.EXPECTED_BOUNDS)) {
    final Bounds bo=(Bounds)oValue;
    try {
      dom=createSvgDocument(bo.getWidth(),bo.getHeight());
      svggc=new SVGGraphics2D(dom);
      hotspotLayer=createHotspotLayer(dom);
      super.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT,svggc);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
 else   if (sProperty.equals(IDeviceRenderer.FILE_IDENTIFIER)) {
    oOutputIdentifier=oValue;
  }
}
Program: 79063
Project: 79063
Buggy source:
/** 
 * Gets the proper expression for the given model
 * @param model the given model
 * @return Returns the proper expression for the given model, or null if noproper one exists
 */
public static String getExpression(Object model){
  if (model instanceof ParameterHandle) {
    return IReportElementConstants.PARAMETER_PREFIX + "String_Node_Str" + ((ParameterHandle)model).getName()+ "String_Node_Str";
  }
  if (model instanceof DataSetItemModel) {
    String colName=((DataSetItemModel)model).getAlias();
    if (colName == null || colName.trim().length() == 0) {
      colName=((DataSetItemModel)model).getName();
    }
    return IReportElementConstants.DATA_COLUMN_PREFIX + "String_Node_Str" + DEUtil.escape(colName)+ "String_Node_Str";
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Gets the proper expression for the given model
 * @param model the given model
 * @return Returns the proper expression for the given model, or null if noproper one exists
 */
public static String getExpression(Object model){
  if (model instanceof ParameterHandle) {
    return IReportElementConstants.PARAMETER_PREFIX + "String_Node_Str" + ((ParameterHandle)model).getName()+ "String_Node_Str";
  }
  if (model instanceof DataSetItemModel) {
    String colName=((DataSetItemModel)model).getAlias();
    if (colName == null || colName.trim().length() == 0) {
      colName=((DataSetItemModel)model).getName();
    }
    return getColumnExpression(colName);
  }
  return null;
}
Program: 79064
Project: 79064
Buggy source:
boolean visitParametersInGroup(ParameterGroupHandle group){
  SlotHandle parameters=group.getParameters();
  Iterator iter=parameters.iterator();
  while (iter.hasNext()) {
    Object param=iter.next();
    if (param instanceof ParameterGroupHandle) {
      if (!visitParameterGroup((ParameterGroupHandle)param)) {
        return false;
      }
    }
 else     if (param instanceof ScalarParameterHandle) {
      if (!visitParameterGroup((ParameterGroupHandle)param)) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
boolean visitParametersInGroup(ParameterGroupHandle group){
  SlotHandle parameters=group.getParameters();
  Iterator iter=parameters.iterator();
  while (iter.hasNext()) {
    Object param=iter.next();
    if (param instanceof ParameterGroupHandle) {
      if (!visitParameterGroup((ParameterGroupHandle)param)) {
        return false;
      }
    }
 else     if (param instanceof ScalarParameterHandle) {
      if (!visitScalarParameter((ScalarParameterHandle)param)) {
        return false;
      }
    }
  }
  return true;
}
Program: 79066
Project: 79066
Buggy source:
protected List getModelChildren(){
  return HandleAdapterFactory.getInstance().getLibraryHandleAdapter().getChildren();
}

Fixed version (ground truth):
protected List getModelChildren(){
  return HandleAdapterFactory.getInstance().getLibraryHandleAdapter(getModel()).getChildren();
}
Program: 79067
Project: 79067
Buggy source:
public void elementChanged(DesignElementHandle focus,NotificationEvent ev){
}

Fixed version (ground truth):
public void elementChanged(DesignElementHandle focus,NotificationEvent ev){
  if (!isModelInModuleHandle()) {
    SetCurrentEditModelCommand command=new SetCurrentEditModelCommand(null);
    command.execute();
  }
}
Program: 79068
Project: 79068
Buggy source:
public void propertyChange(PropertyChangeEvent evt){
  if (evt.getPropertyName().equals(LibraryHandleAdapt.CURRENTMODEL)) {
    refresh();
    Display.getCurrent().asyncExec(new Runnable(){
      public void run(){
        List mediatorSelection=SessionHandleAdapter.getInstance().getMediator().getCurrentState().getSelectionObject();
        if (mediatorSelection.size() == 1 && mediatorSelection.get(0) instanceof LibraryHandle) {
          return;
        }
        List list=getChildren();
        EditPartViewer viewer=getViewer();
        if (viewer instanceof DeferredGraphicalViewer) {
          ((DeferredGraphicalViewer)viewer).setSelection(new StructuredSelection(list),false);
        }
      }
    }
);
  }
}

Fixed version (ground truth):
public void propertyChange(PropertyChangeEvent evt){
  if (evt.getPropertyName().equals(LibraryHandleAdapt.CURRENTMODEL)) {
    refresh();
    Display.getCurrent().asyncExec(new Runnable(){
      public void run(){
        final List mediatorSelection=SessionHandleAdapter.getInstance().getMediator().getCurrentState().getSelectionObject();
        if (mediatorSelection.size() == 1 && mediatorSelection.get(0) instanceof LibraryHandle) {
          return;
        }
        List list=getChildren();
        EditPartViewer viewer=getViewer();
        if (viewer instanceof DeferredGraphicalViewer) {
          ((DeferredGraphicalViewer)viewer).setSelection(new StructuredSelection(list),false);
        }
      }
    }
);
  }
}
Program: 79069
Project: 79069
Buggy source:
public void run(){
  List mediatorSelection=SessionHandleAdapter.getInstance().getMediator().getCurrentState().getSelectionObject();
  if (mediatorSelection.size() == 1 && mediatorSelection.get(0) instanceof LibraryHandle) {
    return;
  }
  List list=getChildren();
  EditPartViewer viewer=getViewer();
  if (viewer instanceof DeferredGraphicalViewer) {
    ((DeferredGraphicalViewer)viewer).setSelection(new StructuredSelection(list),false);
  }
}

Fixed version (ground truth):
public void run(){
  final List mediatorSelection=SessionHandleAdapter.getInstance().getMediator().getCurrentState().getSelectionObject();
  if (mediatorSelection.size() == 1 && mediatorSelection.get(0) instanceof LibraryHandle) {
    return;
  }
  List list=getChildren();
  EditPartViewer viewer=getViewer();
  if (viewer instanceof DeferredGraphicalViewer) {
    ((DeferredGraphicalViewer)viewer).setSelection(new StructuredSelection(list),false);
  }
}
Program: 79070
Project: 79070
Buggy source:
/** 
 * Gets the object selected
 * @return Returns the object selected.<p> If object number is more than one, class type is <code>StructuredSelection</code>
 */
public Object getSelection(){
  if (selection instanceof Object[]) {
    return new StructuredSelection((Object[])selection);
  }
  return selection;
}

Fixed version (ground truth):
/** 
 * Gets the object selected
 * @return Returns the object selected.<p> If object number is more than one, class type is <code>StructuredSelection</code>
 */
public Object getSelection(){
  if (selection instanceof Object[]) {
    return new StructuredSelection((Object[])selection);
  }
 else   if (selection == null) {
    return new StructuredSelection();
  }
  return selection;
}
Program: 79071
Project: 79071
Buggy source:
/** 
 * Gets models of selected elements
 */
protected List getElementHandles(){
  if (selectionHandles == null)   selectionHandles=InsertInLayoutUtil.editPart2Model(getSelection()).toList();
  return selectionHandles;
}

Fixed version (ground truth):
/** 
 * Gets models of selected elements
 */
protected List getElementHandles(){
  if (selectionHandles == null) {
    selectionHandles=InsertInLayoutUtil.editPart2Model(TableUtil.filletCellInSelectionEditorpart(getSelection())).toList();
  }
  return selectionHandles;
}
Program: 79072
Project: 79072
Buggy source:
protected boolean handleMove(){
  if (isCreating) {
    return true;
  }
  boolean validateTrue=false;
  updateTargetUnderMouse();
  if (getTargetEditPart() != null) {
    validateTrue=handleValidatePalette(getFactory().getObjectType(),getTargetEditPart());
  }
  if (validateTrue) {
    updateTargetRequest();
    setCurrentCommand(getCommand());
    showTargetFeedback();
  }
 else {
    setCurrentCommand(null);
  }
  return validateTrue;
}

Fixed version (ground truth):
protected boolean handleMove(){
  if (isCreating || SessionHandleAdapter.getInstance().getReportDesignHandle() instanceof LibraryHandle) {
    return true;
  }
  boolean validateTrue=false;
  updateTargetUnderMouse();
  if (getTargetEditPart() != null) {
    validateTrue=handleValidatePalette(getFactory().getObjectType(),getTargetEditPart());
  }
  if (validateTrue) {
    updateTargetRequest();
    setCurrentCommand(getCommand());
    showTargetFeedback();
  }
 else {
    setCurrentCommand(null);
  }
  return validateTrue;
}
Program: 79073
Project: 79073
Buggy source:
/** 
 * Perform direct edit.
 */
public void performDirectEdit(){
  CommandStack stack=SessionHandleAdapter.getInstance().getCommandStack();
  stack.startTrans(TEXT_TRANS_MSG);
  TextEditDialog dialog=new TextEditDialog(DLG_TITLE_TEXT,((TextItemHandle)getModel()));
  if (dialog.open() == Dialog.OK) {
    stack.commit();
    refreshVisuals();
  }
 else {
    stack.rollback();
  }
}

Fixed version (ground truth):
/** 
 * Perform direct edit.
 */
public void performDirectEdit(){
  CommandStack stack=SessionHandleAdapter.getInstance().getCommandStack();
  stack.startTrans(TEXT_TRANS_MSG);
  TextEditDialog dialog=new TextEditDialog(UIUtil.getDefaultShell(),DLG_TITLE_TEXT,((TextItemHandle)getModel()));
  if (dialog.open() == Dialog.OK) {
    stack.commit();
    refreshVisuals();
  }
 else {
    stack.rollback();
  }
}
Program: 79074
Project: 79074
Buggy source:
public void run(){
  CommandStack stack=SessionHandleAdapter.getInstance().getReportDesignHandle().getCommandStack();
  IElementProcessor processor=ElementProcessorFactory.createProcessor(dataType);
  stack.startTrans(processor.getCreateTransactionLabel());
  DesignElementHandle handle=processor.createElement(null);
  if (handle == null) {
    stack.rollback();
  }
 else {
    try {
      getContainer().add(handle);
    }
 catch (    Exception e) {
      stack.rollback();
      ExceptionHandler.handle(e);
    }
    stack.commit();
  }
  super.run();
}

Fixed version (ground truth):
public void run(){
  CommandStack stack=SessionHandleAdapter.getInstance().getReportDesignHandle().getCommandStack();
  IElementProcessor processor=ElementProcessorFactory.createProcessor(dataType);
  stack.startTrans(processor.getCreateTransactionLabel());
  DesignElementHandle handle=processor.createElement(null);
  if (handle == null) {
    stack.rollback();
  }
 else {
    try {
      getContainer().add(handle);
    }
 catch (    Exception e) {
      stack.rollback();
      ExceptionHandler.handle(e);
    }
    stack.commit();
    synWithMediator(handle);
  }
  super.run();
}
Program: 79075
Project: 79075
Buggy source:
/** 
 * Creates a new image item.
 * @param name the optional image name. Can be <code>null</code>.
 * @return a handle to the image
 */
public ImageHandle newImage(String name){
  ImageItem element=new ImageItem(name);
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new image item.
 * @param name the optional image name. Can be <code>null</code>.
 * @return a handle to the image
 */
public ImageHandle newImage(String name){
  ImageItem element=new ImageItem(name);
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79076
Project: 79076
Buggy source:
/** 
 * Creates a new cell element. Cells cannot have a name.
 * @return a handle to the cell
 */
public CellHandle newCell(){
  Cell element=new Cell();
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new cell element. Cells cannot have a name.
 * @return a handle to the cell
 */
public CellHandle newCell(){
  Cell element=new Cell();
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79077
Project: 79077
Buggy source:
/** 
 * Creates a new table group element. Table groups cannot have a name.
 * @return a handle to the table group
 */
public TableGroupHandle newTableGroup(){
  TableGroup element=new TableGroup();
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new table group element. Table groups cannot have a name.
 * @return a handle to the table group
 */
public TableGroupHandle newTableGroup(){
  TableGroup element=new TableGroup();
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79078
Project: 79078
Buggy source:
/** 
 * Creates a new rectangle.
 * @param name the optional rectangle name. Can be <code>null</code>.
 * @return a handle to rectangle
 */
public RectangleHandle newRectangle(String name){
  RectangleItem element=new RectangleItem(name);
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new rectangle.
 * @param name the optional rectangle name. Can be <code>null</code>.
 * @return a handle to rectangle
 */
public RectangleHandle newRectangle(String name){
  RectangleItem element=new RectangleItem(name);
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79079
Project: 79079
Buggy source:
/** 
 * Creates a new data item.
 * @param name the optional data item name. Can be <code>null</code>.
 * @return a handle to the data item
 */
public DataItemHandle newDataItem(String name){
  DataItem element=new DataItem(name);
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new data item.
 * @param name the optional data item name. Can be <code>null</code>.
 * @return a handle to the data item
 */
public DataItemHandle newDataItem(String name){
  DataItem element=new DataItem(name);
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79080
Project: 79080
Buggy source:
/** 
 * Creates a new line item.
 * @param name the optional line item name. Can be <code>null</code>.
 * @return a handle to the line item
 */
public LineHandle newLineItem(String name){
  LineItem element=new LineItem(name);
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new line item.
 * @param name the optional line item name. Can be <code>null</code>.
 * @return a handle to the line item
 */
public LineHandle newLineItem(String name){
  LineItem element=new LineItem(name);
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79081
Project: 79081
Buggy source:
/** 
 * Creates a new list group element. List groups cannot have a name.
 * @return a handle to the list group
 */
public ListGroupHandle newListGroup(){
  ListGroup element=new ListGroup();
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new list group element. List groups cannot have a name.
 * @return a handle to the list group
 */
public ListGroupHandle newListGroup(){
  ListGroup element=new ListGroup();
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79082
Project: 79082
Buggy source:
/** 
 * Creates a new column element. Columns cannot have a name.
 * @return a handle to the column
 */
public ColumnHandle newTableColumn(){
  TableColumn element=new TableColumn();
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new column element. Columns cannot have a name.
 * @return a handle to the column
 */
public ColumnHandle newTableColumn(){
  TableColumn element=new TableColumn();
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79083
Project: 79083
Buggy source:
/** 
 * Creates a new free-form item.
 * @param name the optional free-form name. Can be <code>null</code>.
 * @return a handle to the free-form
 */
public FreeFormHandle newFreeForm(String name){
  FreeForm element=new FreeForm(name);
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new free-form item.
 * @param name the optional free-form name. Can be <code>null</code>.
 * @return a handle to the free-form
 */
public FreeFormHandle newFreeForm(String name){
  FreeForm element=new FreeForm(name);
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79084
Project: 79084
Buggy source:
/** 
 * Creates a new list item.
 * @param name the optional list name. Can be <code>null</code>.
 * @return a handle to the list
 */
public ListHandle newList(String name){
  ListItem element=new ListItem(name);
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new list item.
 * @param name the optional list name. Can be <code>null</code>.
 * @return a handle to the list
 */
public ListHandle newList(String name){
  ListItem element=new ListItem(name);
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79085
Project: 79085
Buggy source:
/** 
 * Creates a new text item.
 * @param name the optional text item name. Can be <code>null</code>.
 * @return a handle to the text item
 */
public TextItemHandle newTextItem(String name){
  TextItem element=new TextItem(name);
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new text item.
 * @param name the optional text item name. Can be <code>null</code>.
 * @return a handle to the text item
 */
public TextItemHandle newTextItem(String name){
  TextItem element=new TextItem(name);
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79086
Project: 79086
Buggy source:
/** 
 * Creates a new label item.
 * @param name the optional label name. Can be <code>null</code>.
 * @return a handle to the label
 */
public LabelHandle newLabel(String name){
  Label element=new Label(name);
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new label item.
 * @param name the optional label name. Can be <code>null</code>.
 * @return a handle to the label
 */
public LabelHandle newLabel(String name){
  Label element=new Label(name);
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79087
Project: 79087
Buggy source:
/** 
 * Creates a new multi line data item.
 * @param name the optional multi line data name. Can be <code>null</code>.
 * @return a handle to multi line data item
 */
public TextDataHandle newTextData(String name){
  TextDataItem element=new TextDataItem(name);
  return element.handle(module);
}

Fixed version (ground truth):
/** 
 * Creates a new multi line data item.
 * @param name the optional multi line data name. Can be <code>null</code>.
 * @return a handle to multi line data item
 */
public TextDataHandle newTextData(String name){
  TextDataItem element=new TextDataItem(name);
  module.makeUniqueName(element);
  return element.handle(module);
}
Program: 79088
Project: 79088
Buggy source:
protected void populateAvailableDbObjects(){
  if ((cachedSearchTxt == searchTxt.getText() || (cachedSearchTxt != null && cachedSearchTxt.equals(searchTxt.getText()))) && (cachedDbType == getSelectedDbType() || (cachedDbType != null && cachedDbType.equals(getSelectedDbType())))) {
    if (schemaList != null && schemaList.size() > 0) {
      if (cachedSchemaComboIndex == schemaCombo.getSelectionIndex()) {
        return;
      }
    }
 else     return;
  }
  RemoveAllAvailableDbObjects();
  setRootElement();
  setRefreshInfo();
  if (isSchemaSupported) {
    getAvailableSchema();
    if (schemaCombo.getItemCount() < 1) {
      schemaCombo.add(JdbcPlugin.getResourceString("String_Node_Str"));
      schemaCombo.select(0);
      Iterator it=schemaList.iterator();
      while (it.hasNext())       schemaCombo.add(it.next().toString());
    }
    populateTableList();
  }
 else {
    populateTableList();
  }
  if (rootNode != null) {
    selectNode(rootNode);
  }
}

Fixed version (ground truth):
protected void populateAvailableDbObjects(){
  if ((cachedSearchTxt == searchTxt.getText() || (cachedSearchTxt != null && cachedSearchTxt.equals(searchTxt.getText()))) && (cachedDbType == getSelectedDbType() || (cachedDbType != null && cachedDbType.equals(getSelectedDbType())))) {
    if (schemaList != null && schemaList.size() > 0) {
      if (cachedSchemaComboIndex == schemaCombo.getSelectionIndex()) {
        return;
      }
    }
 else     return;
  }
  RemoveAllAvailableDbObjects();
  setRootElement();
  setRefreshInfo();
  if (isSchemaSupported) {
    getAvailableSchema();
    if (schemaCombo.getItemCount() < 1) {
      schemaCombo.add(JdbcPlugin.getResourceString("String_Node_Str"));
      schemaCombo.select(0);
      if (schemaList != null) {
        Iterator it=schemaList.iterator();
        while (it.hasNext())         schemaCombo.add(it.next().toString());
      }
    }
    populateTableList();
  }
 else {
    populateTableList();
  }
  if (rootNode != null) {
    selectNode(rootNode);
  }
}
Program: 79089
Project: 79089
Buggy source:
/** 
 * @param namePattern
 * @return
 */
private String getTailoredSearchText(String namePattern){
  if (searchTxt.getText().length() > 0) {
    namePattern=searchTxt.getText();
    if (namePattern != null) {
      if (namePattern.lastIndexOf('%') == -1) {
        namePattern=namePattern + "String_Node_Str";
      }
    }
  }
  return namePattern;
}

Fixed version (ground truth):
/** 
 * @param namePattern
 * @return
 */
private String getTailoredSearchText(String namePattern){
  if (namePattern != null) {
    if (namePattern.lastIndexOf('%') == -1) {
      namePattern=namePattern + "String_Node_Str";
    }
  }
 else   namePattern="String_Node_Str";
  return namePattern;
}
Program: 79093
Project: 79093
Buggy source:
public void dragStart(DragSourceEvent event){
  TreeItem[] selection=availableDbObjectsTree.getSelection();
  if (selection.length > 0 && selection[0].getData() instanceof DbObject) {
    if (((DbObject)selection[0].getData()).getType() == DbObject.PROCEDURE_TYPE) {
      event.doit=false;
      return;
    }
    ;
  }
 else   if (selection.length <= 0 || selection[0].getData() == null) {
    event.doit=false;
    return;
  }
}

Fixed version (ground truth):
public void dragStart(DragSourceEvent event){
  TreeItem[] selection=availableDbObjectsTree.getSelection();
  if (selection.length > 0) {
    if (selection[0].getData() instanceof DbObject) {
      if (((DbObject)selection[0].getData()).getType() == DbObject.PROCEDURE_TYPE) {
        event.doit=false;
        return;
      }
    }
 else     if (selection[0].getData() instanceof ProcedureParameter) {
      event.doit=false;
      return;
    }
  }
 else   if (selection.length <= 0 || selection[0].getData() == null) {
    event.doit=false;
    return;
  }
}
Program: 79094
Project: 79094
Buggy source:
/** 
 * Adds drag support to tree..Must set tree before execution.
 */
public void addDragSupportToTree(){
  DragSource dragSource=new DragSource(availableDbObjectsTree,DND.DROP_COPY);
  dragSource.setTransfer(new Transfer[]{TextTransfer.getInstance()});
  dragSource.addDragListener(new DragSourceAdapter(){
    public void dragStart(    DragSourceEvent event){
      TreeItem[] selection=availableDbObjectsTree.getSelection();
      if (selection.length > 0 && selection[0].getData() instanceof DbObject) {
        if (((DbObject)selection[0].getData()).getType() == DbObject.PROCEDURE_TYPE) {
          event.doit=false;
          return;
        }
        ;
      }
 else       if (selection.length <= 0 || selection[0].getData() == null) {
        event.doit=false;
        return;
      }
    }
    public void dragSetData(    DragSourceEvent event){
      if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
        TreeItem[] selection=availableDbObjectsTree.getSelection();
        if (selection.length > 0) {
          Object obj=selection[0].getData();
          if (obj instanceof DbObject) {
            event.data=((DbObject)obj).getName();
          }
 else           if (obj instanceof Procedure) {
            event.data=((Procedure)obj).getProcedureName();
          }
 else           event.data=selection[0].getData();
        }
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Adds drag support to tree..Must set tree before execution.
 */
public void addDragSupportToTree(){
  DragSource dragSource=new DragSource(availableDbObjectsTree,DND.DROP_COPY);
  dragSource.setTransfer(new Transfer[]{TextTransfer.getInstance()});
  dragSource.addDragListener(new DragSourceAdapter(){
    public void dragStart(    DragSourceEvent event){
      TreeItem[] selection=availableDbObjectsTree.getSelection();
      if (selection.length > 0) {
        if (selection[0].getData() instanceof DbObject) {
          if (((DbObject)selection[0].getData()).getType() == DbObject.PROCEDURE_TYPE) {
            event.doit=false;
            return;
          }
        }
 else         if (selection[0].getData() instanceof ProcedureParameter) {
          event.doit=false;
          return;
        }
      }
 else       if (selection.length <= 0 || selection[0].getData() == null) {
        event.doit=false;
        return;
      }
    }
    public void dragSetData(    DragSourceEvent event){
      if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
        TreeItem[] selection=availableDbObjectsTree.getSelection();
        if (selection.length > 0) {
          Object obj=selection[0].getData();
          if (obj instanceof DbObject) {
            event.data=((DbObject)obj).getName();
          }
 else           if (obj instanceof Procedure) {
            event.data=((Procedure)obj).getProcedureName();
          }
 else           event.data=selection[0].getData();
        }
      }
    }
  }
);
}
Program: 79095
Project: 79095
Buggy source:
/** 
 * Return pre-defined query text pattern with every element in a cell in an Array
 * @return pre-defined query text in an Array
 */
private String[] getQueryPresetTextArray(){
  final String[] lines=new String[]{"String_Node_Str","String_Node_Str"};
  return lines;
}

Fixed version (ground truth):
/** 
 * Return pre-defined query text pattern with every element in a cell in an Array
 * @return pre-defined query text in an Array
 */
private String[] getQueryPresetTextArray(){
  final String[] lines;
  if (((OdaDataSetHandle)getContainer().getModel()).getExtensionID().equals("String_Node_Str"))   lines=new String[]{"String_Node_Str"};
 else   lines=new String[]{"String_Node_Str","String_Node_Str"};
  return lines;
}
Program: 79099
Project: 79099
Buggy source:
public void dragStart(DragSourceEvent event){
  TreeItem[] selection=availableDbObjectsTree.getSelection();
  if (selection.length <= 0 || selection[0].getData() == null) {
    event.doit=false;
    return;
  }
}

Fixed version (ground truth):
public void dragStart(DragSourceEvent event){
  TreeItem[] selection=availableDbObjectsTree.getSelection();
  if (selection.length > 0 && selection[0].getData() instanceof DbObject) {
    if (((DbObject)selection[0].getData()).getType() == DbObject.PROCEDURE_TYPE) {
      event.doit=false;
      return;
    }
    ;
  }
 else   if (selection.length <= 0 || selection[0].getData() == null) {
    event.doit=false;
    return;
  }
}
Program: 79100
Project: 79100
Buggy source:
public void dragSetData(DragSourceEvent event){
  if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
    TreeItem[] selection=availableDbObjectsTree.getSelection();
    if (selection.length > 0) {
      Object obj=selection[0].getData();
      if (obj instanceof DbObject) {
        event.data=((DbObject)obj).getName();
      }
 else       event.data=selection[0].getData();
    }
  }
}

Fixed version (ground truth):
public void dragSetData(DragSourceEvent event){
  if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
    TreeItem[] selection=availableDbObjectsTree.getSelection();
    if (selection.length > 0) {
      Object obj=selection[0].getData();
      if (obj instanceof DbObject) {
        event.data=((DbObject)obj).getName();
      }
 else       if (obj instanceof Procedure) {
        event.data=((Procedure)obj).getProcedureName();
      }
 else       event.data=selection[0].getData();
    }
  }
}
Program: 79101
Project: 79101
Buggy source:
/** 
 * Adds drag support to tree..Must set tree before execution.
 */
public void addDragSupportToTree(){
  DragSource dragSource=new DragSource(availableDbObjectsTree,DND.DROP_COPY);
  dragSource.setTransfer(new Transfer[]{TextTransfer.getInstance()});
  dragSource.addDragListener(new DragSourceAdapter(){
    public void dragStart(    DragSourceEvent event){
      TreeItem[] selection=availableDbObjectsTree.getSelection();
      if (selection.length <= 0 || selection[0].getData() == null) {
        event.doit=false;
        return;
      }
    }
    public void dragSetData(    DragSourceEvent event){
      if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
        TreeItem[] selection=availableDbObjectsTree.getSelection();
        if (selection.length > 0) {
          Object obj=selection[0].getData();
          if (obj instanceof DbObject) {
            event.data=((DbObject)obj).getName();
          }
 else           event.data=selection[0].getData();
        }
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Adds drag support to tree..Must set tree before execution.
 */
public void addDragSupportToTree(){
  DragSource dragSource=new DragSource(availableDbObjectsTree,DND.DROP_COPY);
  dragSource.setTransfer(new Transfer[]{TextTransfer.getInstance()});
  dragSource.addDragListener(new DragSourceAdapter(){
    public void dragStart(    DragSourceEvent event){
      TreeItem[] selection=availableDbObjectsTree.getSelection();
      if (selection.length > 0 && selection[0].getData() instanceof DbObject) {
        if (((DbObject)selection[0].getData()).getType() == DbObject.PROCEDURE_TYPE) {
          event.doit=false;
          return;
        }
        ;
      }
 else       if (selection.length <= 0 || selection[0].getData() == null) {
        event.doit=false;
        return;
      }
    }
    public void dragSetData(    DragSourceEvent event){
      if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
        TreeItem[] selection=availableDbObjectsTree.getSelection();
        if (selection.length > 0) {
          Object obj=selection[0].getData();
          if (obj instanceof DbObject) {
            event.data=((DbObject)obj).getName();
          }
 else           if (obj instanceof Procedure) {
            event.data=((Procedure)obj).getProcedureName();
          }
 else           event.data=selection[0].getData();
        }
      }
    }
  }
);
}
Program: 79102
Project: 79102
Buggy source:
/** 
 * get all procedure from special catalog,schemaPattern,and namePattern
 */
public ResultSet getAllProcedure(String cataLog,String schemaPattern,String namePattern){
  if (metaData == null) {
    metaData=getMetaData();
  }
  ResultSet resultSet=null;
  if (cataLog != null && cataLog.trim().length() == 0) {
    cataLog=null;
  }
  if (metaData != null) {
    try {
      resultSet=metaData.getProcedures(cataLog,schemaPattern,namePattern);
    }
 catch (    SQLException e) {
    }
  }
  return resultSet;
}

Fixed version (ground truth):
/** 
 * get all procedure from special catalog,schemaPattern,and namePattern
 */
public ArrayList getAllProcedure(String cataLog,String schemaPattern,String namePattern){
  ArrayList procedureList=new ArrayList();
  if (metaData == null) {
    metaData=getMetaData();
  }
  ResultSet procedureRs=null;
  if (cataLog != null && cataLog.trim().length() == 0) {
    cataLog=null;
  }
  if (metaData != null) {
    try {
      procedureRs=metaData.getProcedures(cataLog,schemaPattern,namePattern);
      boolean isSame;
      while (procedureRs.next()) {
        isSame=false;
        Procedure procedure=new Procedure();
        procedure.setProcedureName(procedureRs.getString("String_Node_Str"));
        procedure.setSchema(procedureRs.getString("String_Node_Str"));
        procedure.setCatalog(procedureRs.getString("String_Node_Str"));
        for (int i=0; i < procedureList.size(); i++) {
          if (((Procedure)(procedureList.get(i))).isEqualWith(procedure))           isSame=true;
        }
        if (!isSame)         procedureList.add(procedure);
      }
    }
 catch (    SQLException e) {
    }
  }
  return procedureList;
}
Program: 79103
Project: 79103
Buggy source:
/** 
 * Get procedure's columns information
 */
public ArrayList getProcedureColumns(String cataLog,String schemaPattern,String procedureNamePattern,String columnNamePattern){
  ArrayList columnList=new ArrayList();
  if (metaData == null) {
    metaData=getMetaData();
  }
  ResultSet columnsRs=null;
  if (cataLog != null && cataLog.trim().length() == 0) {
    cataLog=null;
  }
  if (metaData != null) {
    try {
      columnsRs=metaData.getProcedureColumns(cataLog,schemaPattern,procedureNamePattern,columnNamePattern);
      int n=0;
      while (columnsRs.next()) {
        ProcedureParameter column=new ProcedureParameter();
        if (columnsRs.getString("String_Node_Str") != null)         column.setName(columnsRs.getString("String_Node_Str"));
 else {
          n++;
          column.setName("String_Node_Str" + n);
        }
        column.setModeType(columnsRs.getInt("String_Node_Str"));
        column.setDataTypeName(columnsRs.getString("String_Node_Str"));
        column.setDataType(columnsRs.getInt("String_Node_Str"));
        column.setProcedureName(columnsRs.getString("String_Node_Str"));
        columnList.add(column);
      }
    }
 catch (    SQLException e) {
    }
  }
  return columnList;
}

Fixed version (ground truth):
/** 
 * Get procedure's columns information
 */
public ArrayList getProcedureColumns(String cataLog,String schemaPattern,String procedureNamePattern,String columnNamePattern){
  ArrayList columnList=new ArrayList();
  if (metaData == null) {
    metaData=getMetaData();
  }
  ResultSet columnsRs=null;
  if (cataLog != null && cataLog.trim().length() == 0) {
    cataLog=null;
  }
  if (metaData != null) {
    try {
      columnsRs=metaData.getProcedureColumns(cataLog,schemaPattern,procedureNamePattern,columnNamePattern);
      int n=0;
      while (columnsRs.next()) {
        ProcedureParameter column=new ProcedureParameter();
        column.setSchema(schemaPattern);
        if (columnsRs.getString("String_Node_Str") != null)         column.setName(columnsRs.getString("String_Node_Str"));
 else {
          n++;
          column.setName("String_Node_Str" + n);
        }
        column.setModeType(columnsRs.getInt("String_Node_Str"));
        column.setDataTypeName(columnsRs.getString("String_Node_Str"));
        column.setDataType(columnsRs.getInt("String_Node_Str"));
        column.setProcedureName(columnsRs.getString("String_Node_Str"));
        columnList.add(column);
      }
    }
 catch (    SQLException e) {
    }
  }
  return columnList;
}