nus-yam/ex-repair huggingface dataset:
Program: 70740
Project: 70740
Buggy source:
private void execMemento(){
  if (!execMemento) {
    execMemento=true;
    Display.getDefault().asyncExec(new Runnable(){
      public void run(){
        if (!viewer.getTree().isDisposed()) {
          IMemento memento=viewerMemento.getChild(provider.getElementType());
          if (memento == null) {
            expandToDefaultLevel();
            if (viewer.getTree().getItemCount() > 0) {
              Memento elementMemento=(Memento)viewerMemento.createChild(provider.getElementType(),MementoElement.Type_Element);
              elementMemento.getMementoElement().setValue(new Integer(0));
            }
          }
 else           if (memento instanceof Memento) {
            expandToDefaultLevel();
            expandTreeFromMemento((Memento)memento);
          }
        }
        execMemento=false;
      }
    }
);
  }
}

Fixed version (ground truth):
private void execMemento(){
  if (!execMemento) {
    execMemento=true;
    Display.getDefault().asyncExec(new Runnable(){
      public void run(){
        if (!viewer.getTree().isDisposed()) {
          IMemento memento=viewerMemento.getChild(provider.getElementType());
          if (memento == null) {
            expandToDefaultLevel();
            if (viewer.getTree().getItemCount() > 0) {
              Memento elementMemento=(Memento)viewerMemento.createChild(provider.getElementType(),MementoElement.Type_Element);
              elementMemento.getMementoElement().setValue(Integer.valueOf(0));
            }
          }
 else           if (memento instanceof Memento) {
            expandToDefaultLevel();
            expandTreeFromMemento((Memento)memento);
          }
        }
        execMemento=false;
      }
    }
);
  }
}
Program: 70741
Project: 70741
Buggy source:
private boolean saveFile(String filePath){
  File f=new File(filePath);
  if (!(f.exists() && f.isFile())) {
    MessageDialog.openError(getShell(),Messages.getString("String_Node_Str"),Messages.getFormattedString("String_Node_Str",new Object[]{propFileName}));
    return false;
  }
 else   if (!f.canWrite()) {
    MessageDialog.openError(getShell(),Messages.getString("String_Node_Str"),Messages.getFormattedString("String_Node_Str",new Object[]{propFileName}));
    return false;
  }
  try {
    if (f.canWrite()) {
      FileOutputStream fos=new FileOutputStream(f);
      content.store(fos,"String_Node_Str");
      fos.close();
    }
    return true;
  }
 catch (  Exception e) {
    ExceptionHandler.handle(e);
  }
  return false;
}

Fixed version (ground truth):
private boolean saveFile(String filePath){
  File f=new File(filePath);
  if (!(f.exists() && f.isFile())) {
    MessageDialog.openError(getShell(),Messages.getString("String_Node_Str"),Messages.getFormattedString("String_Node_Str",new Object[]{propFileName}));
    return false;
  }
 else   if (!f.canWrite()) {
    MessageDialog.openError(getShell(),Messages.getString("String_Node_Str"),Messages.getFormattedString("String_Node_Str",new Object[]{propFileName}));
    return false;
  }
  FileOutputStream fos=null;
  try {
    if (f.canWrite()) {
      fos=new FileOutputStream(f);
      content.store(fos,"String_Node_Str");
    }
    return true;
  }
 catch (  Exception e) {
    ExceptionHandler.handle(e);
  }
 finally {
    if (fos != null) {
      try {
        fos.close();
      }
 catch (      IOException e) {
        ExceptionHandler.handle(e);
      }
    }
  }
  return false;
}
Program: 70742
Project: 70742
Buggy source:
/** 
 * Check if the name of a group/dimension level is allowed.
 * @return allowed
 */
public static boolean validateDimensionName(String name){
  DataRequestSession session=null;
  ICubeQueryUtil cubeQueryUtil=null;
  try {
    session=DataRequestSession.newSession(new DataSessionContext(DataSessionContext.MODE_DIRECT_PRESENTATION));
    cubeQueryUtil=session.getCubeQueryUtil();
  }
 catch (  Exception e) {
  }
  return cubeQueryUtil.isValidDimensionName(name);
}

Fixed version (ground truth):
/** 
 * Check if the name of a group/dimension level is allowed.
 * @return allowed
 */
public static boolean validateDimensionName(String name){
  DataRequestSession session=null;
  ICubeQueryUtil cubeQueryUtil=null;
  try {
    session=DataRequestSession.newSession(new DataSessionContext(DataSessionContext.MODE_DIRECT_PRESENTATION));
    cubeQueryUtil=session.getCubeQueryUtil();
  }
 catch (  Exception e) {
    ExceptionHandler.handle(e);
    return false;
  }
  if (cubeQueryUtil != null)   return cubeQueryUtil.isValidDimensionName(name);
 else   return false;
}
Program: 70743
Project: 70743
Buggy source:
public void run(){
  EditPartViewer viewer=getSourceEditPart().getViewer();
  EditPart parent=getSourceEditPart().getParent();
  if (activeHelper == this && getSourceEditPart().isActive() && viewer.getControl() != null && !viewer.getControl().isDisposed()) {
    if (viewer.getSelectedEditParts().size() == 1) {
      if (parent.getAdapter(IDelaySelectionDragTracker.class) != null) {
        proxy=(IDelaySelectionDragTracker)parent.getAdapter(IDelaySelectionDragTracker.class);
        if (viewer instanceof DeferredGraphicalViewer)         ((DeferredGraphicalViewer)viewer).setSelection(new StructuredSelection(proxy.getSourceEditPart()),true);
        if (getSourceEditPart() != getEditPartUnderMouse()) {
          IFigure figure=((GraphicalEditPart)getSourceEditPart()).getFigure();
          Rectangle center=figure.getBounds().getCopy();
          figure.translateToAbsolute(center);
          proxy.setStartLocation(center.getCenter());
        }
 else {
          proxy.setStartLocation(getStartLocation());
        }
        proxy.setState(STATE_DRAG_IN_PROGRESS);
      }
      setFlag(FLAG_DELAY_SELECTION,true);
    }
 else {
      setFlag(FLAG_DELAY_SELECTION,false);
    }
  }
 else {
    setFlag(FLAG_DELAY_SELECTION,false);
  }
  activeHelper=null;
}

Fixed version (ground truth):
public void run(){
  if (!getSourceEditPart().isActive()) {
    return;
  }
  EditPartViewer viewer=getSourceEditPart().getViewer();
  EditPart parent=getSourceEditPart().getParent();
  if (activeHelper == this && getSourceEditPart().isActive() && viewer.getControl() != null && !viewer.getControl().isDisposed()) {
    if (viewer.getSelectedEditParts().size() == 1) {
      if (parent.getAdapter(IDelaySelectionDragTracker.class) != null) {
        proxy=(IDelaySelectionDragTracker)parent.getAdapter(IDelaySelectionDragTracker.class);
        if (viewer instanceof DeferredGraphicalViewer)         ((DeferredGraphicalViewer)viewer).setSelection(new StructuredSelection(proxy.getSourceEditPart()),true);
        if (getSourceEditPart() != getEditPartUnderMouse()) {
          IFigure figure=((GraphicalEditPart)getSourceEditPart()).getFigure();
          Rectangle center=figure.getBounds().getCopy();
          figure.translateToAbsolute(center);
          proxy.setStartLocation(center.getCenter());
        }
 else {
          proxy.setStartLocation(getStartLocation());
        }
        proxy.setState(STATE_DRAG_IN_PROGRESS);
      }
      setFlag(FLAG_DELAY_SELECTION,true);
    }
 else {
      setFlag(FLAG_DELAY_SELECTION,false);
    }
  }
 else {
    setFlag(FLAG_DELAY_SELECTION,false);
  }
  activeHelper=null;
}
Program: 70746
Project: 70746
Buggy source:
/** 
 * Creates the palette viewer and its control.
 * @see Page#createControl(org.eclipse.swt.widgets.Composite)
 */
public void createControl(Composite parent){
  if (getViewer() == null) {
    return;
  }
  tree=new Tree(parent,SWT.NONE);
  treeCommon.setTree(tree);
  treeCommon.setExpressionViewer(getViewer());
  treeCommon.createDefaultExpressionTree(SessionHandleAdapter.getInstance().getReportDesignHandle().getVisibleDataSets());
  treeCommon.addMouseTrackListener();
  treeCommon.addMouseListener();
  treeCommon.addDragSupportToTree();
  treeCommon.addDropSupportToViewer();
  tree.setToolTipText("String_Node_Str");
  tree.addDisposeListener(new DisposeListener(){
    public void widgetDisposed(    DisposeEvent e){
      treeCommon.removeDropSupportToViewer();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Creates the palette viewer and its control.
 * @see Page#createControl(org.eclipse.swt.widgets.Composite)
 */
public void createControl(Composite parent){
  if (getViewer() == null) {
    return;
  }
  tree=new Tree(parent,SWT.NONE);
  treeCommon.setTree(tree);
  treeCommon.setExpressionViewer(getViewer());
  treeCommon.createDefaultExpressionTree();
  treeCommon.addMouseTrackListener();
  treeCommon.addMouseListener();
  treeCommon.addDragSupportToTree();
  treeCommon.addDropSupportToViewer();
  tree.setToolTipText("String_Node_Str");
  tree.addDisposeListener(new DisposeListener(){
    public void widgetDisposed(    DisposeEvent e){
      treeCommon.removeDropSupportToViewer();
    }
  }
);
}
Program: 70747
Project: 70747
Buggy source:
public void startImage(IImageContent image){
}

Fixed version (ground truth):
public void startImage(IImageContent image){
  IStyle style=image.getComputedStyle();
  HyperlinkDef url=parseHyperLink(image);
  BookmarkDef bookmark=getBookmark(image);
  engine.addImageData(image,style,url,bookmark);
}
Program: 70748
Project: 70748
Buggy source:
public void outputData(SheetData sheetData){
  Data d=(Data)sheetData;
  startCell(d.span.getCol(),d.span.getColSpan(),d.getRowSpan(),d.styleId,d.hyperLink,d.getLinkedBookmark());
  writeText(d);
  if (d.hyperLink != null && d.hyperLink.getToolTip() != null) {
    writeComments(d.hyperLink);
  }
  endCell();
}

Fixed version (ground truth):
public void outputData(SheetData sheetData){
  if (sheetData.getDatatype() == SheetData.IMAGE)   return;
  Data d=(Data)sheetData;
  startCell(d.span.getCol(),d.span.getColSpan(),d.getRowSpan(),d.styleId,d.hyperLink,d.getLinkedBookmark());
  writeText(d);
  if (d.hyperLink != null && d.hyperLink.getToolTip() != null) {
    writeComments(d.hyperLink);
  }
  endCell();
}
Program: 70749
Project: 70749
Buggy source:
/** 
 */
public void applyContainerBottomStyle(){
  XlsContainer container=engine.getCurrentContainer();
  ContainerSizeInfo rule=container.getSizeInfo();
  StyleEntry entry=container.getStyle();
  int start=rule.getStartCoordinate();
  int col=engine.getAxis().getColumnIndexByCoordinate(start);
  int span=engine.getAxis().getColumnIndexByCoordinate(rule.getEndCoordinate());
  for (int i=col; i < span; i++) {
    SheetData data=engine.getColumnLastData(i);
    if (data == null) {
      continue;
    }
    StyleBuilder.applyBottomBorder(entry,data.style);
  }
}

Fixed version (ground truth):
public void applyContainerBottomStyle(XlsContainer container){
  ContainerSizeInfo rule=container.getSizeInfo();
  StyleEntry entry=container.getStyle();
  int start=rule.getStartCoordinate();
  int col=engine.getAxis().getColumnIndexByCoordinate(start);
  int span=engine.getAxis().getColumnIndexByCoordinate(rule.getEndCoordinate());
  for (int i=col; i < span; i++) {
    SheetData data=engine.getColumnLastData(i);
    if (data == null) {
      continue;
    }
    StyleBuilder.applyBottomBorder(entry,data.style);
  }
}
Program: 70750
Project: 70750
Buggy source:
public void complete(){
  endNormalContainer();
  Iterator<SheetData[]> iterator=cache.getRowIterator();
  while (iterator.hasNext()) {
    SheetData[] rowData=iterator.next();
    for (int j=0; j < rowData.length; j++) {
      SheetData data=rowData[j];
      if (data == null || data.isBlank()) {
        continue;
      }
      int styleid=engine.getStyleID(data.getStyle());
      data.setStyleId(styleid);
      ContainerSizeInfo rule=data.getSizeInfo();
      int start=axis.getColumnIndexByCoordinate(rule.getStartCoordinate()) + 1;
      int end=axis.getColumnIndexByCoordinate(rule.getEndCoordinate()) + 1;
      end=Math.min(end,maxCol);
      int scount=Math.max(0,end - start - 1);
      Span span=new Span(start,scount);
      data.setSpan(span);
      HyperlinkDef hyperLink=data.getHyperlinkDef();
      if (hyperLink != null) {
        if (hyperLink.getType() == IHyperlinkAction.ACTION_BOOKMARK) {
          setLinkedBookmark(data,hyperLink);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void complete(){
  engine.applyContainerBottomStyle(containers.get(0));
  Iterator<SheetData[]> iterator=cache.getRowIterator();
  while (iterator.hasNext()) {
    SheetData[] rowData=iterator.next();
    for (int j=0; j < rowData.length; j++) {
      SheetData data=rowData[j];
      if (data == null || data.isBlank()) {
        continue;
      }
      int styleid=engine.getStyleID(data.getStyle());
      data.setStyleId(styleid);
      ContainerSizeInfo rule=data.getSizeInfo();
      int start=axis.getColumnIndexByCoordinate(rule.getStartCoordinate()) + 1;
      int end=axis.getColumnIndexByCoordinate(rule.getEndCoordinate()) + 1;
      end=Math.min(end,maxCol);
      int scount=Math.max(0,end - start - 1);
      Span span=new Span(start,scount);
      data.setSpan(span);
      HyperlinkDef hyperLink=data.getHyperlinkDef();
      if (hyperLink != null) {
        if (hyperLink.getType() == IHyperlinkAction.ACTION_BOOKMARK) {
          setLinkedBookmark(data,hyperLink);
        }
      }
    }
  }
}
Program: 70751
Project: 70751
Buggy source:
public void widgetSelected(SelectionEvent e){
  TableItem row=cursor.getRow();
  String value=row.getText(cursor.getColumn());
  int strValue=0;
  try {
    strValue=Integer.parseInt(value);
  }
 catch (  Exception ee) {
    setOriValue();
    return;
  }
  int oldValue=cale.get(Calendar.DAY_OF_MONTH);
  cale.set(Calendar.DAY_OF_MONTH,strValue);
  firePropertyListener(new PropertyChangeEvent(new Object(),"String_Node_Str",new Integer(oldValue),new Integer(strValue)));
}

Fixed version (ground truth):
public void widgetSelected(SelectionEvent e){
  TableItem row=cursor.getRow();
  String value=row.getText(cursor.getColumn());
  int strValue=0;
  try {
    strValue=Integer.parseInt(value);
  }
 catch (  Exception ee) {
    setOriValue();
    return;
  }
  int oldValue=cale.get(Calendar.DAY_OF_MONTH);
  cale.set(Calendar.DAY_OF_MONTH,strValue);
  firePropertyListener(new PropertyChangeEvent(new Object(),"String_Node_Str",Integer.valueOf(oldValue),Integer.valueOf(strValue)));
}
Program: 70752
Project: 70752
Buggy source:
/** 
 * Constructs a new instance of this class given its parent , a style and a calendar
 * @param composite
 * @param style
 * @param calendar
 */
public SpinnerTable(Composite composite,int style,Calendar calendar){
  super(composite,style);
  table=new TimeTable(this,SWT.HIDE_SELECTION | style | SWT.BORDER);
  createColumn(table);
  cursor=new TimeTableCursor(table,SWT.NONE);
  cursor.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
  cursor.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
  cursor.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      TableItem row=cursor.getRow();
      String value=row.getText(cursor.getColumn());
      int strValue=0;
      try {
        strValue=Integer.parseInt(value);
      }
 catch (      Exception ee) {
        setOriValue();
        return;
      }
      int oldValue=cale.get(Calendar.DAY_OF_MONTH);
      cale.set(Calendar.DAY_OF_MONTH,strValue);
      firePropertyListener(new PropertyChangeEvent(new Object(),"String_Node_Str",new Integer(oldValue),new Integer(strValue)));
    }
  }
);
  createItems();
  setCalendar(calendar);
}

Fixed version (ground truth):
/** 
 * Constructs a new instance of this class given its parent , a style and a calendar
 * @param composite
 * @param style
 * @param calendar
 */
public SpinnerTable(Composite composite,int style,Calendar calendar){
  super(composite,style);
  table=new TimeTable(this,SWT.HIDE_SELECTION | style | SWT.BORDER);
  createColumn(table);
  cursor=new TimeTableCursor(table,SWT.NONE);
  cursor.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
  cursor.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
  cursor.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      TableItem row=cursor.getRow();
      String value=row.getText(cursor.getColumn());
      int strValue=0;
      try {
        strValue=Integer.parseInt(value);
      }
 catch (      Exception ee) {
        setOriValue();
        return;
      }
      int oldValue=cale.get(Calendar.DAY_OF_MONTH);
      cale.set(Calendar.DAY_OF_MONTH,strValue);
      firePropertyListener(new PropertyChangeEvent(new Object(),"String_Node_Str",Integer.valueOf(oldValue),Integer.valueOf(strValue)));
    }
  }
);
  createItems();
  setCalendar(calendar);
}
Program: 70753
Project: 70753
Buggy source:
public void setValue(String va){
  int intValue;
  try {
    intValue=Integer.parseInt(va);
  }
 catch (  Exception e) {
    setText(value);
    return;
  }
  intValue=intValue % limit;
  if (intValue < 0) {
    intValue=intValue + limit;
  }
  PropertyChangeEvent event=new PropertyChangeEvent(new Object(),getChangeName(),new Integer(Integer.parseInt(value)),new Integer(intValue));
  firePropertyListener(event);
  value=String.valueOf(intValue);
  setText(value);
}

Fixed version (ground truth):
public void setValue(String va){
  int intValue;
  try {
    intValue=Integer.parseInt(va);
  }
 catch (  Exception e) {
    setText(value);
    return;
  }
  intValue=intValue % limit;
  if (intValue < 0) {
    intValue=intValue + limit;
  }
  PropertyChangeEvent event=new PropertyChangeEvent(new Object(),getChangeName(),Integer.valueOf(Integer.parseInt(value)),Integer.valueOf(intValue));
  firePropertyListener(event);
  value=String.valueOf(intValue);
  setText(value);
}
Program: 70754
Project: 70754
Buggy source:
private void setText(String text){
  int value;
  try {
    value=Integer.parseInt(text);
  }
 catch (  Exception e) {
    this.text.setText(textContend);
    return;
  }
  if (value < 0) {
    this.text.setText(textContend);
    return;
  }
  firePropertyListener(new PropertyChangeEvent(new Object(),IPropertyEventConstants.YEAR_CHANGE_EVENT,new Integer(Integer.parseInt(textContend)),new Integer(value)));
  this.textContend=text;
  this.text.setText(textContend);
}

Fixed version (ground truth):
private void setText(String text){
  int value;
  try {
    value=Integer.parseInt(text);
  }
 catch (  Exception e) {
    this.text.setText(textContend);
    return;
  }
  if (value < 0) {
    this.text.setText(textContend);
    return;
  }
  firePropertyListener(new PropertyChangeEvent(new Object(),IPropertyEventConstants.YEAR_CHANGE_EVENT,Integer.valueOf(Integer.parseInt(textContend)),Integer.valueOf(value)));
  this.textContend=text;
  this.text.setText(textContend);
}
Program: 70755
Project: 70755
Buggy source:
/** 
 * Convert the single string of preference into string array
 * @param preferenceValue The specified element name
 * @return String[] The array of strings
 */
public static String[] convert(String preferenceValue){
  String preferenceValueCopy=new String();
  preferenceValueCopy=new String(PREFERENCE_DELIMITER) + preferenceValue;
  String replaceString=new String(PREFERENCE_DELIMITER) + new String(PREFERENCE_DELIMITER);
  String regrex=new String(PREFERENCE_DELIMITER) + SPACE + new String(PREFERENCE_DELIMITER);
  while (preferenceValueCopy.indexOf(replaceString) != -1) {
    preferenceValueCopy=preferenceValueCopy.replaceFirst(replaceString,regrex);
  }
  StringTokenizer tokenizer=new StringTokenizer(preferenceValueCopy,PREFERENCE_DELIMITER);
  int tokenCount=tokenizer.countTokens();
  String[] elements=new String[tokenCount];
  int i;
  for (i=0; i < tokenCount; i++) {
    elements[i]=tokenizer.nextToken().trim();
  }
  return elements;
}

Fixed version (ground truth):
/** 
 * Convert the single string of preference into string array
 * @param preferenceValue The specified element name
 * @return String[] The array of strings
 */
public static String[] convert(String preferenceValue){
  String preferenceValueCopy=PREFERENCE_DELIMITER + preferenceValue;
  String replaceString=PREFERENCE_DELIMITER + PREFERENCE_DELIMITER;
  String regrex=PREFERENCE_DELIMITER + SPACE + PREFERENCE_DELIMITER;
  while (preferenceValueCopy.indexOf(replaceString) != -1) {
    preferenceValueCopy=preferenceValueCopy.replaceFirst(replaceString,regrex);
  }
  StringTokenizer tokenizer=new StringTokenizer(preferenceValueCopy,PREFERENCE_DELIMITER);
  int tokenCount=tokenizer.countTokens();
  String[] elements=new String[tokenCount];
  int i;
  for (i=0; i < tokenCount; i++) {
    elements[i]=tokenizer.nextToken().trim();
  }
  return elements;
}
Program: 70756
Project: 70756
Buggy source:
/** 
 * set default template preference
 */
public void setDefaultTemplatePreference(){
  String defaultDir=new String(UIUtil.getHomeDirectory());
  PreferenceFactory.getInstance().getPreferences(this).setDefault(TEMPLATE_PREFERENCE,defaultDir);
}

Fixed version (ground truth):
/** 
 * set default template preference
 */
public void setDefaultTemplatePreference(){
  String defaultDir=UIUtil.getHomeDirectory();
  PreferenceFactory.getInstance().getPreferences(this).setDefault(TEMPLATE_PREFERENCE,defaultDir);
}
Program: 70757
Project: 70757
Buggy source:
/** 
 * Get the custom name preference of specified element name
 * @param defaultName The specified element name
 * @return String The custom name gotten
 */
public String getCustomName(String defaultName){
  int i;
  String[] defaultNameArray=getDefaultNamePreference();
  String[] customNameArray=getCustomNamePreference();
  if (defaultNameArray.length != customNameArray.length) {
    return null;
  }
  for (i=0; i < defaultNameArray.length; i++) {
    if (defaultNameArray[i].trim().equals(defaultName)) {
      if (customNameArray[i].equals("String_Node_Str")) {
        return null;
      }
      return new String(customNameArray[i]);
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Get the custom name preference of specified element name
 * @param defaultName The specified element name
 * @return String The custom name gotten
 */
public String getCustomName(String defaultName){
  int i;
  String[] defaultNameArray=getDefaultNamePreference();
  String[] customNameArray=getCustomNamePreference();
  if (defaultNameArray.length != customNameArray.length) {
    return null;
  }
  for (i=0; i < defaultNameArray.length; i++) {
    if (defaultNameArray[i].trim().equals(defaultName)) {
      if (customNameArray[i].equals("String_Node_Str")) {
        return null;
      }
      return customNameArray[i];
    }
  }
  return null;
}
Program: 70758
Project: 70758
Buggy source:
/** 
 * @see org.eclipse.jface.action.IAction#run()
 */
public void run(){
  if (Policy.TRACING_ACTIONS) {
    System.out.println("String_Node_Str");
  }
  diagramViewer.setProperty(DeferredGraphicalViewer.PROPERTY_MARGIN_VISIBILITY,new Boolean(!isChecked()));
}

Fixed version (ground truth):
/** 
 * @see org.eclipse.jface.action.IAction#run()
 */
public void run(){
  if (Policy.TRACING_ACTIONS) {
    System.out.println("String_Node_Str");
  }
  diagramViewer.setProperty(DeferredGraphicalViewer.PROPERTY_MARGIN_VISIBILITY,Boolean.valueOf(!isChecked()));
}
Program: 70762
Project: 70762
Buggy source:
public void setValue(String name,boolean value){
  boolean oldValue=getBoolean(name);
  if (this.preferenceType == SPECIAL_TYPE && project != null) {
    Preferences preference=prefs.getReportPreference(project);
    if (preference != null) {
      if (preference.isDefault(name) || oldValue != value) {
        preference.setValue(name,value);
        firePreferenceChangeEvent(name,new Boolean(oldValue),new Boolean(value));
      }
      return;
    }
  }
  if (oldValue != value) {
    prefsStore.setValue(name,value);
    firePreferenceChangeEvent(name,new Boolean(oldValue),new Boolean(value));
  }
}

Fixed version (ground truth):
public void setValue(String name,boolean value){
  boolean oldValue=getBoolean(name);
  if (this.preferenceType == SPECIAL_TYPE && project != null) {
    Preferences preference=prefs.getReportPreference(project);
    if (preference != null) {
      if (preference.isDefault(name) || oldValue != value) {
        preference.setValue(name,value);
        firePreferenceChangeEvent(name,Boolean.valueOf(oldValue),Boolean.valueOf(value));
      }
      return;
    }
  }
  if (oldValue != value) {
    prefsStore.setValue(name,value);
    firePreferenceChangeEvent(name,Boolean.valueOf(oldValue),Boolean.valueOf(value));
  }
}
Program: 70763
Project: 70763
Buggy source:
public void dialogFieldChanged(DialogField field){
  enableProjectSpecificSettings(((SelectionButtonDialogField)field).isSelected());
}

Fixed version (ground truth):
public void dialogFieldChanged(DialogField field){
  if (field instanceof SelectionButtonDialogField)   enableProjectSpecificSettings(((SelectionButtonDialogField)field).isSelected());
}
Program: 70765
Project: 70765
Buggy source:
private int getMaxStringWidth(){
  GC gc=new GC(shell);
  String[] items=list.getItems();
  ArrayList separatorIndexes=new ArrayList(5);
  int maxChars=0;
  int maxWidth=0;
  Point pt=null;
  for (int n=0; n < items.length; n++) {
    pt=gc.textExtent(items[n]);
    if (pt.x > maxWidth) {
      maxWidth=pt.x;
    }
    int len=items[n].length();
    if (len > maxChars) {
      maxChars=len;
    }
    if (items[n].equals("String_Node_Str")) {
      separatorIndexes.add(new Integer(n));
    }
  }
  gc.dispose();
  String separator=getSeparator(maxChars);
  Iterator iter=separatorIndexes.iterator();
  while (iter.hasNext()) {
    list.setItem(((Integer)iter.next()).intValue(),separator);
  }
  return maxWidth + 5;
}

Fixed version (ground truth):
private int getMaxStringWidth(){
  GC gc=new GC(shell);
  String[] items=list.getItems();
  ArrayList separatorIndexes=new ArrayList(5);
  int maxChars=0;
  int maxWidth=0;
  Point pt=null;
  for (int n=0; n < items.length; n++) {
    pt=gc.textExtent(items[n]);
    if (pt.x > maxWidth) {
      maxWidth=pt.x;
    }
    int len=items[n].length();
    if (len > maxChars) {
      maxChars=len;
    }
    if (items[n].equals("String_Node_Str")) {
      separatorIndexes.add(Integer.valueOf(n));
    }
  }
  gc.dispose();
  String separator=getSeparator(maxChars);
  Iterator iter=separatorIndexes.iterator();
  while (iter.hasNext()) {
    list.setItem(((Integer)iter.next()).intValue(),separator);
  }
  return maxWidth + 5;
}
Program: 70766
Project: 70766
Buggy source:
/** 
 * @throws IOException
 */
public void outputCacheData() throws IOException {
  writer.startSheet(engine.getCoordinates());
  Iterator<RowData> it=engine.getIterator();
  while (it.hasNext()) {
    outputRowData(it.next());
  }
  writer.endSheet();
}

Fixed version (ground truth):
/** 
 * @throws IOException
 */
public void outputCacheData() throws IOException {
  writer.startSheet(engine.getCoordinates(),pageHeader,pageFooter);
  Iterator<RowData> it=engine.getIterator();
  while (it.hasNext()) {
    outputRowData(it.next());
  }
  writer.endSheet(orientation);
}
Program: 70767
Project: 70767
Buggy source:
protected void createWriter(){
  writer=new ExcelWriter(out,context,isRTLSheet,pageHeader,pageFooter,orientation);
}

Fixed version (ground truth):
protected void createWriter(){
  writer=new ExcelWriter(out,context,isRTLSheet);
}
Program: 70768
Project: 70768
Buggy source:
public void startSheet(int[] coordinates) throws IOException {
  if (writer == null) {
    initializeWriterAsTempWriter();
  }
  writer.startSheet(coordinates);
  sheetIndex++;
}

Fixed version (ground truth):
public void startSheet(int[] coordinates,String pageHeader,String pageFooter) throws IOException {
  if (writer == null) {
    initializeWriterAsTempWriter();
  }
  writer.startSheet(coordinates,pageHeader,pageFooter);
  sheetIndex++;
}
Program: 70769
Project: 70769
Buggy source:
/** 
 * @param out
 * @param context
 * @param isRtlSheet
 * @param pageHeader
 * @param pageFooter
 * @param orientation
 */
public ExcelWriter(OutputStream out,ExcelContext context,boolean isRtlSheet,String pageHeader,String pageFooter,String orientation){
  this.out=out;
  this.context=context;
  this.isRTLSheet=isRtlSheet;
  this.pageHeader=pageHeader;
  this.pageFooter=pageFooter;
  this.orientation=orientation;
}

Fixed version (ground truth):
/** 
 * @param out
 * @param context
 * @param isRtlSheet
 * @param pageHeader
 * @param pageFooter
 * @param orientation
 */
public ExcelWriter(OutputStream out,ExcelContext context,boolean isRtlSheet){
  this.out=out;
  this.context=context;
  this.isRTLSheet=isRtlSheet;
}
Program: 70770
Project: 70770
Buggy source:
public void start(IReportContent report,Map<StyleEntry,Integer> styles,HashMap<String,BookmarkDef> bookmarkList) throws IOException {
  writer=new ExcelXmlWriter(out,context,isRTLSheet,pageHeader,pageFooter,orientation);
  writer.setSheetIndex(sheetIndex);
  writer.start(report,styles,bookmarkList);
  copyOutputData();
}

Fixed version (ground truth):
public void start(IReportContent report,Map<StyleEntry,Integer> styles,HashMap<String,BookmarkDef> bookmarkList) throws IOException {
  writer=new ExcelXmlWriter(out,context,isRTLSheet);
  writer.setSheetIndex(sheetIndex);
  writer.start(report,styles,bookmarkList);
  copyOutputData();
}
Program: 70771
Project: 70771
Buggy source:
/** 
 * @throws FileNotFoundException
 */
private void initializeWriterAsTempWriter() throws FileNotFoundException {
  tempFilePath=context.getTempFileDir() + "String_Node_Str" + Thread.currentThread().getId();
  FileOutputStream out=new FileOutputStream(tempFilePath);
  tempWriter=new ExcelXmlWriter(out,context,isRTLSheet,pageHeader,pageFooter,orientation);
  writer=tempWriter;
}

Fixed version (ground truth):
/** 
 * @throws FileNotFoundException
 */
private void initializeWriterAsTempWriter() throws FileNotFoundException {
  tempFilePath=context.getTempFileDir() + "String_Node_Str" + Thread.currentThread().getId();
  FileOutputStream out=new FileOutputStream(tempFilePath);
  tempWriter=new ExcelXmlWriter(out,context,isRTLSheet);
  writer=tempWriter;
}
Program: 70772
Project: 70772
Buggy source:
public void endSheet(){
  writer.endSheet();
}

Fixed version (ground truth):
public void endSheet(String oritentation){
  writer.endSheet(oritentation);
}
Program: 70773
Project: 70773
Buggy source:
public void startSheet(int[] coordinates){
  startSheet(sheetIndex);
  ouputColumns(coordinates);
  sheetIndex+=1;
}

Fixed version (ground truth):
public void startSheet(int[] coordinates,String pageHeader,String pageFooter){
  this.pageHeader=pageHeader;
  this.pageFooter=pageFooter;
  startSheet(sheetIndex);
  ouputColumns(coordinates);
  sheetIndex+=1;
}
Program: 70774
Project: 70774
Buggy source:
public void endSheet(){
  endTable();
  declareWorkSheetOptions(orientation,pageHeader,pageFooter);
  closeSheet();
}

Fixed version (ground truth):
public void endSheet(String orientaion){
  endTable();
  declareWorkSheetOptions(orientation,pageHeader,pageFooter);
  closeSheet();
}
Program: 70775
Project: 70775
Buggy source:
public void startSheet(int[] coordinates) throws IOException ;

Fixed version (ground truth):
public void startSheet(int[] coordinates,String pageHeader,String pageFooter) throws IOException ;
Program: 70776
Project: 70776
Buggy source:
public void endSheet();

Fixed version (ground truth):
public void endSheet(String orientation);
Program: 70777
Project: 70777
Buggy source:
boolean finalLaunchCheck(final ILaunchConfiguration configuration,String mode,IProgressMonitor monitor) throws CoreException {
  paramValues=new HashMap();
  LauncherEngineConfig engineConfig=new LauncherEngineConfig();
  IReportEngineFactory factory=(IReportEngineFactory)Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
  final IReportEngine engine=factory.createReportEngine(engineConfig);
  engine.changeLogLevel(Level.WARNING);
  final String fileName=covertVariables(configuration.getAttribute(ATTR_REPORT_FILE_NAME,"String_Node_Str"));
  final int taskType=configuration.getAttribute(ATTR_TASK_TYPE,DEFAULT_TASK_TYPE);
  Display display=DebugUI.getStandardDisplay();
  if (display.getThread().equals(Thread.currentThread())) {
    return getParameterValues(getInputParameters(fileName,taskType,engine),paramValues);
  }
  final Object[] result=new Object[]{Boolean.FALSE};
  Runnable r=new Runnable(){
    public void run(){
      result[0]=new Boolean(getParameterValues(getInputParameters(fileName,taskType,engine),paramValues));
    }
  }
;
  DebugUI.getStandardDisplay().syncExec(r);
  return ((Boolean)result[0]).booleanValue();
}

Fixed version (ground truth):
boolean finalLaunchCheck(final ILaunchConfiguration configuration,String mode,IProgressMonitor monitor) throws CoreException {
  paramValues=new HashMap();
  LauncherEngineConfig engineConfig=new LauncherEngineConfig();
  IReportEngineFactory factory=(IReportEngineFactory)Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
  final IReportEngine engine=factory.createReportEngine(engineConfig);
  engine.changeLogLevel(Level.WARNING);
  final String fileName=covertVariables(configuration.getAttribute(ATTR_REPORT_FILE_NAME,"String_Node_Str"));
  final int taskType=configuration.getAttribute(ATTR_TASK_TYPE,DEFAULT_TASK_TYPE);
  Display display=DebugUI.getStandardDisplay();
  if (display.getThread().equals(Thread.currentThread())) {
    return getParameterValues(getInputParameters(fileName,taskType,engine),paramValues);
  }
  final Object[] result=new Object[]{Boolean.FALSE};
  Runnable r=new Runnable(){
    public void run(){
      result[0]=Boolean.valueOf(getParameterValues(getInputParameters(fileName,taskType,engine),paramValues));
    }
  }
;
  DebugUI.getStandardDisplay().syncExec(r);
  return ((Boolean)result[0]).booleanValue();
}
Program: 70788
Project: 70788
Buggy source:
public void relocate(IFigure target){
  Rectangle bounds;
  if (getReference() instanceof HandleBounds)   bounds=((HandleBounds)getReference()).getHandleBounds();
 else   bounds=getReference().getBounds();
  bounds=new PrecisionRectangle(new Rectangle(bounds.x,bounds.y + bounds.height,DEFAULT_VALUE.width,DEFAULT_VALUE.height));
  getReference().translateToAbsolute(bounds);
  target.translateToRelative(bounds);
  if (target.getBounds().width < bounds.width || target.getBounds().height < bounds.height) {
    target.setBounds(bounds);
  }
}

Fixed version (ground truth):
public void relocate(IFigure target){
  Rectangle bounds;
  if (getReference() instanceof HandleBounds)   bounds=((HandleBounds)getReference()).getHandleBounds();
 else   bounds=getReference().getBounds();
  bounds=new PrecisionRectangle(new Rectangle(bounds.x,bounds.y + bounds.height,DEFAULT_VALUE.width,DEFAULT_VALUE.height));
  getReference().translateToAbsolute(bounds);
  target.translateToRelative(bounds);
  target.setLocation(bounds.getLocation());
  if (target.getBounds().width < bounds.width || target.getBounds().height < bounds.height) {
    target.setSize(bounds.getSize());
  }
}
Program: 70789
Project: 70789
Buggy source:
@Override protected void propertyChange(Map info){
  boolean invalidate=false;
  if (info.get(ReportDesignHandle.BIDI_ORIENTATION_PROP) instanceof ReportDesignHandle) {
    String newOrientation=((ReportDesignHandle)info.get(ReportDesignHandle.BIDI_ORIENTATION_PROP)).getBidiOrientation();
    UIUtil.processOrientationChange(newOrientation,getViewer());
    invalidate=true;
  }
  super.propertyChange(info);
  if (invalidate) {
    getFigure().invalidateTree();
    getFigure().revalidate();
  }
}

Fixed version (ground truth):
@Override protected void propertyChange(Map info){
  boolean invalidate=false;
  if (info.get(ReportDesignHandle.BIDI_ORIENTATION_PROP) instanceof ReportDesignHandle) {
    String newOrientation=((ReportDesignHandle)info.get(ReportDesignHandle.BIDI_ORIENTATION_PROP)).getBidiOrientation();
    UIUtil.processOrientationChange(newOrientation,getViewer());
    invalidate=true;
  }
  super.propertyChange(info);
  if (info.get(MasterPageHandle.WIDTH_PROP) instanceof MasterPageHandle || info.get(MasterPageHandle.HEIGHT_PROP) instanceof MasterPageHandle) {
    Display.getCurrent().asyncExec(new Runnable(){
      public void run(){
        List list=getChildren();
        int size=list.size();
        for (int i=0; i < size; i++) {
          ((ReportElementEditPart)list.get(i)).refreshVisuals();
        }
      }
    }
);
  }
  if (invalidate) {
    getFigure().invalidateTree();
    getFigure().revalidate();
  }
}
Program: 70790
Project: 70790
Buggy source:
public void relocate(IFigure target){
  Rectangle bounds;
  if (getReference() instanceof HandleBounds)   bounds=((HandleBounds)getReference()).getHandleBounds();
 else   bounds=getReference().getBounds();
  bounds=new PrecisionRectangle(new Rectangle(bounds.x,bounds.y + bounds.height,DEFAULT_VALUE.width,DEFAULT_VALUE.height));
  getReference().translateToAbsolute(bounds);
  target.translateToRelative(bounds);
  target.setBounds(bounds);
}

Fixed version (ground truth):
public void relocate(IFigure target){
  Rectangle bounds;
  if (getReference() instanceof HandleBounds)   bounds=((HandleBounds)getReference()).getHandleBounds();
 else   bounds=getReference().getBounds();
  bounds=new PrecisionRectangle(new Rectangle(bounds.x,bounds.y + bounds.height,DEFAULT_VALUE.width,DEFAULT_VALUE.height));
  getReference().translateToAbsolute(bounds);
  target.translateToRelative(bounds);
  if (target.getBounds().width < bounds.width || target.getBounds().height < bounds.height) {
    target.setBounds(bounds);
  }
}
Program: 70791
Project: 70791
Buggy source:
/** 
 * Get the parent (container) of this element
 * @throws BirtException
 */
IReportElementInstance getParent() throws BirtException ;

Fixed version (ground truth):
/** 
 * Get the parent (container) of this element
 * @throws ScriptException 
 * @throws BirtException
 */
IReportElementInstance getParent() throws ScriptException ;
Program: 70792
Project: 70792
Buggy source:
/** 
 * Get the row data used to create the instance. The row data is defined by the column binding.
 * @throws BirtException
 */
IRowData getRowData() throws BirtException ;

Fixed version (ground truth):
/** 
 * Get the row data used to create the instance. The row data is defined by the column binding.
 * @throws ScriptException 
 * @throws BirtException
 */
IRowData getRowData() throws ScriptException ;
Program: 70793
Project: 70793
Buggy source:
public IReportElementInstance getParent() throws BirtException {
  return ElementUtil.getInstance(content.getParent(),context);
}

Fixed version (ground truth):
public IReportElementInstance getParent() throws ScriptException {
  try {
    return ElementUtil.getInstance(content.getParent(),context);
  }
 catch (  BirtException e) {
    ScriptException scriptException=new ScriptException(e.getLocalizedMessage());
    scriptException.initCause(e);
    throw scriptException;
  }
}
Program: 70794
Project: 70794
Buggy source:
public IRowData getRowData() throws BirtException {
  if (rowData != null) {
    return rowData;
  }
  Object objGen=content.getGenerateBy();
  if (objGen instanceof ReportItemDesign) {
    ReportItemDesign design=(ReportItemDesign)objGen;
    if (design.getQuery() != null) {
      DesignElementHandle handle=design.getHandle();
      if (handle instanceof ReportItemHandle) {
        IBaseResultSet rset=context.getResultSet();
        rowData=new RowData(rset,(ReportItemHandle)handle);
        return rowData;
      }
    }
  }
  IReportElementInstance parent=this.getParent();
  if (parent != null) {
    return parent.getRowData();
  }
  return null;
}

Fixed version (ground truth):
public IRowData getRowData() throws ScriptException {
  if (rowData != null) {
    return rowData;
  }
  Object objGen=content.getGenerateBy();
  if (objGen instanceof ReportItemDesign) {
    ReportItemDesign design=(ReportItemDesign)objGen;
    if (design.getQuery() != null) {
      DesignElementHandle handle=design.getHandle();
      if (handle instanceof ReportItemHandle) {
        IBaseResultSet rset=context.getResultSet();
        rowData=new RowData(rset,(ReportItemHandle)handle);
        return rowData;
      }
    }
  }
  IReportElementInstance parent=this.getParent();
  if (parent != null) {
    return parent.getRowData();
  }
  return null;
}
Program: 70798
Project: 70798
Buggy source:
public void widgetSelected(SelectionEvent e){
  ThumbnailBuilder dialog=new ThumbnailBuilder();
  dialog.setImageName(prvImageSection.getTextControl().getText());
  ReportDesignHandle handle=(ReportDesignHandle)SessionHandleAdapter.getInstance().getReportDesignHandle();
  dialog.setReportDesignHandle(handle);
  if (dialog.open() != Dialog.OK) {
    Image image=dialog.getImage();
    if (image != null) {
      image.dispose();
      image=null;
    }
    return;
  }
  if (dialog.shouldSetThumbnail()) {
    Image image=dialog.getImage();
    ImageData imageData=image.getImageData();
    ImageLoader imageLoader=new ImageLoader();
    imageLoader.data=new ImageData[1];
    imageLoader.data[0]=imageData;
    ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
    imageLoader.save(outputStream,SWT.IMAGE_PNG);
    try {
      handle.setThumbnail(outputStream.toByteArray());
    }
 catch (    SemanticException e1) {
      ExceptionHandler.handle(e1);
    }
    if (image != null) {
      image.dispose();
      image=null;
    }
    prvImageSection.setStringValue(dialog.getImageName());
    prvImageSection.forceFocus();
  }
 else {
    if (handle.getThumbnail() != null && handle.getThumbnail().length != 0) {
      try {
        handle.deleteThumbnail();
      }
 catch (      SemanticException e1) {
        ExceptionHandler.handle(e1);
      }
    }
    prvImageSection.setStringValue("String_Node_Str");
    prvImageSection.forceFocus();
  }
}

Fixed version (ground truth):
public void widgetSelected(SelectionEvent e){
  ThumbnailBuilder dialog=new ThumbnailBuilder();
  dialog.setImageName(prvImageSection.getTextControl().getText());
  ReportDesignHandle handle=(ReportDesignHandle)SessionHandleAdapter.getInstance().getReportDesignHandle();
  dialog.setReportDesignHandle(handle);
  if (dialog.open() != Dialog.OK) {
    Image image=dialog.getImage();
    if (image != null) {
      image.dispose();
      image=null;
    }
    return;
  }
  if (dialog.shouldSetThumbnail()) {
    Image image=dialog.getImage();
    if (image != null) {
      ImageData imageData=image.getImageData();
      ImageLoader imageLoader=new ImageLoader();
      imageLoader.data=new ImageData[1];
      imageLoader.data[0]=imageData;
      ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
      imageLoader.save(outputStream,SWT.IMAGE_PNG);
      try {
        handle.setThumbnail(outputStream.toByteArray());
      }
 catch (      SemanticException e1) {
        ExceptionHandler.handle(e1);
      }
      image.dispose();
      image=null;
    }
    prvImageSection.setStringValue(dialog.getImageName());
    prvImageSection.forceFocus();
  }
 else {
    if (handle.getThumbnail() != null && handle.getThumbnail().length != 0) {
      try {
        handle.deleteThumbnail();
      }
 catch (      SemanticException e1) {
        ExceptionHandler.handle(e1);
      }
    }
    prvImageSection.setStringValue("String_Node_Str");
    prvImageSection.forceFocus();
  }
}
Program: 70799
Project: 70799
Buggy source:
/** 
 * Creates provider's array for font style controls.
 * @return the provider's array(elements are instances of<code>IDescriptorProvider</code>).
 */
private IDescriptorProvider[] createFontStyleProviders(){
  PropertyDescriptorProvider[] providers=new PropertyDescriptorProvider[]{new FontStylePropertyDescriptorProvider(StyleHandle.FONT_WEIGHT_PROP,ReportDesignConstants.STYLE_ELEMENT),new FontStylePropertyDescriptorProvider(StyleHandle.FONT_STYLE_PROP,ReportDesignConstants.STYLE_ELEMENT),new FontStylePropertyDescriptorProvider(StyleHandle.TEXT_UNDERLINE_PROP,ReportDesignConstants.STYLE_ELEMENT),new FontStylePropertyDescriptorProvider(StyleHandle.TEXT_LINE_THROUGH_PROP,ReportDesignConstants.STYLE_ELEMENT),new PropertyDescriptorProvider(StyleHandle.TEXT_ALIGN_PROP,ReportDesignConstants.STYLE_ELEMENT)};
  for (int i=0; i < providers.length; i++) {
    if (providers[i] instanceof PropertyDescriptorProvider)     ((PropertyDescriptorProvider)providers[i]).enableReset(true);
  }
  return providers;
}

Fixed version (ground truth):
/** 
 * Creates provider's array for font style controls.
 * @return the provider's array(elements are instances of<code>IDescriptorProvider</code>).
 */
private IDescriptorProvider[] createFontStyleProviders(){
  PropertyDescriptorProvider[] providers=new PropertyDescriptorProvider[]{new FontStylePropertyDescriptorProvider(StyleHandle.FONT_WEIGHT_PROP,ReportDesignConstants.STYLE_ELEMENT),new FontStylePropertyDescriptorProvider(StyleHandle.FONT_STYLE_PROP,ReportDesignConstants.STYLE_ELEMENT),new FontStylePropertyDescriptorProvider(StyleHandle.TEXT_UNDERLINE_PROP,ReportDesignConstants.STYLE_ELEMENT),new FontStylePropertyDescriptorProvider(StyleHandle.TEXT_LINE_THROUGH_PROP,ReportDesignConstants.STYLE_ELEMENT),new PropertyDescriptorProvider(StyleHandle.TEXT_ALIGN_PROP,ReportDesignConstants.STYLE_ELEMENT)};
  for (int i=0; i < providers.length; i++) {
    ((PropertyDescriptorProvider)providers[i]).enableReset(true);
  }
  return providers;
}
Program: 70800
Project: 70800
Buggy source:
private boolean updateHideRule(DesignElementHandle element,String format,boolean checked,String expression) throws Exception {
  if (checked) {
    HideRuleHandle hideHandle=getHideRuleHandle(element,format);
    if (hideHandle == null) {
      try {
        hideHandle=createHideRuleHandle(element,format,expression);
      }
 catch (      SemanticException e) {
        throw e;
      }
    }
 else {
      if (!expression.equals(hideHandle.getExpression()) && (!expression.equals("String_Node_Str") || hideHandle.getExpression() != null)) {
        hideHandle.setExpression(expression);
      }
    }
  }
 else {
    Iterator visibilities=visibilityRulesIterator(element);
    if (visibilities == null) {
      return true;
    }
    while (visibilities.hasNext()) {
      HideRuleHandle handle=(HideRuleHandle)visibilities.next();
      if (format.equalsIgnoreCase(handle.getFormat())) {
        try {
          getVisibilityPropertyHandle(element).removeItem(handle.getStructure());
        }
 catch (        PropertyValueException e) {
          throw e;
        }
        return true;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean updateHideRule(DesignElementHandle element,String format,boolean checked,String expression) throws Exception {
  if (checked) {
    HideRuleHandle hideHandle=getHideRuleHandle(element,format);
    if (hideHandle == null) {
      try {
        createHideRuleHandle(element,format,expression);
      }
 catch (      SemanticException e) {
        throw e;
      }
    }
 else {
      if (!expression.equals(hideHandle.getExpression()) && (!expression.equals("String_Node_Str") || hideHandle.getExpression() != null)) {
        hideHandle.setExpression(expression);
      }
    }
  }
 else {
    Iterator visibilities=visibilityRulesIterator(element);
    if (visibilities == null) {
      return true;
    }
    while (visibilities.hasNext()) {
      HideRuleHandle handle=(HideRuleHandle)visibilities.next();
      if (format.equalsIgnoreCase(handle.getFormat())) {
        try {
          getVisibilityPropertyHandle(element).removeItem(handle.getStructure());
        }
 catch (        PropertyValueException e) {
          throw e;
        }
        return true;
      }
    }
  }
  return true;
}