Program: 76674
Project: 76674
Buggy source:
public Control createControl(Composite parent){
  content=new Composite(parent,SWT.NONE);
  GridLayout layout=UIUtil.createGridLayoutWithoutMargin(2,false);
  layout.marginHeight=1;
  layout.marginWidth=1;
  layout.horizontalSpacing=10;
  content.setLayout(layout);
  content.setLayoutData(new GridData(GridData.FILL_BOTH));
  Composite choices=new Composite(content,SWT.NONE);
  GridData data=new GridData(GridData.FILL_BOTH);
  choices.setLayoutData(data);
  layout=WidgetUtil.createGridLayout(2);
  layout.marginHeight=1;
  layout.marginWidth=2;
  choices.setLayout(layout);
  Label styleLabel=FormWidgetFactory.getInstance().createLabel(choices,SWT.LEFT,isFormStyle);
  styleLabel.setText(styleProvider.getDisplayName());
  styleLabel.setLayoutData(new GridData());
  if (isFormStyle) {
    styleCombo=FormWidgetFactory.getInstance().createStyleCombo(choices,(IComboProvider)styleProvider);
  }
 else {
    styleCombo=new StyleCombo(choices,style,(IComboProvider)styleProvider);
  }
  data=new GridData();
  data.widthHint=200;
  styleCombo.setLayoutData(data);
  styleCombo.setItems(((IComboProvider)styleProvider).getItems());
  Label colorLabel=FormWidgetFactory.getInstance().createLabel(choices,SWT.LEFT,isFormStyle);
  colorLabel.setText(colorProvider.getDisplayName());
  colorLabel.setLayoutData(new GridData());
  builder=new ColorBuilder(choices,SWT.NONE,isFormStyle);
  builder.setChoiceSet(colorProvider.getElementChoiceSet());
  colorProvider.setIndex(IColorConstants.BLACK);
  data=new GridData();
  data.widthHint=200;
  data.heightHint=builder.computeSize(SWT.DEFAULT,SWT.DEFAULT).y;
  builder.setLayoutData(data);
  Label widthLabel=FormWidgetFactory.getInstance().createLabel(choices,SWT.LEFT,isFormStyle);
  widthLabel.setText(widthProvider.getDisplayName());
  widthLabel.setLayoutData(new GridData());
  if (isFormStyle) {
    widthCombo=FormWidgetFactory.getInstance().createStyleCombo(choices,(IComboProvider)widthProvider);
  }
 else {
    widthCombo=new StyleCombo(choices,style,(IComboProvider)widthProvider);
  }
  widthProvider.setIndex(widthProvider.getItems()[1].toString());
  data=new GridData();
  data.widthHint=200;
  widthCombo.setLayoutData(data);
  widthCombo.setItems(((IComboProvider)widthProvider).getItems());
  Composite composite=new Composite(choices,SWT.NONE);
  layout=new GridLayout();
  layout.horizontalSpacing=7;
  layout.numColumns=toggleProviders.length + 1;
  composite.setLayout(layout);
  data=new GridData();
  data.horizontalSpan=2;
  composite.setLayoutData(data);
  toggles=new Button[toggleProviders.length];
  for (int i=0; i < toggleProviders.length; i++) {
    Button button=new Button(composite,SWT.TOGGLE);
    toggles[i]=button;
    button.setLayoutData(new GridData());
    button.setToolTipText(toggleProviders[i].getTooltipText());
    button.setImage(ReportPlatformUIImages.getImage(toggleProviders[i].getImageName()));
    final BorderToggleDescriptorProvider provider=toggleProviders[i];
    button.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent e){
        if (((Button)e.widget).getSelection()) {
          SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
          BorderInfomation information=new BorderInfomation();
          information.setPosition(provider.getPosition());
          information.setColor(builder.getRGB());
          information.setStyle((String)styleCombo.getSelectedItem());
          information.setWidth((String)widthCombo.getSelectedItem());
          previewCanvas.setBorderInfomation(information);
          restoreInfo=information;
          try {
            provider.save(information);
          }
 catch (          Exception e1) {
            ExceptionHandler.handle(e1);
          }
          checkToggleButtons();
          SessionHandleAdapter.getInstance().getCommandStack().commit();
        }
 else {
          BorderInfomation oldInfo=(BorderInfomation)provider.load();
          RGB oldColor=oldInfo.getColor();
          if (oldColor == null) {
            oldColor=autoColor;
          }
          if (!(oldInfo.getStyle().equals((String)styleCombo.getSelectedItem())) || !(oldColor.equals(builder.getRGB())) || !(oldInfo.getWidth().equals((String)widthCombo.getSelectedItem()))) {
            SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
            BorderInfomation information=new BorderInfomation();
            information.setPosition(provider.getPosition());
            information.setColor(builder.getRGB());
            information.setStyle((String)styleCombo.getSelectedItem());
            information.setWidth((String)widthCombo.getSelectedItem());
            previewCanvas.setBorderInfomation(information);
            restoreInfo=information;
            try {
              provider.save(information);
            }
 catch (            Exception e1) {
              ExceptionHandler.handle(e1);
            }
            ((Button)e.widget).setSelection(true);
            SessionHandleAdapter.getInstance().getCommandStack().commit();
          }
 else {
            SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
            previewCanvas.removeBorderInfomation(provider.getPosition());
            if (allButton.getSelection())             allButton.setSelection(false);
            try {
              provider.reset();
            }
 catch (            Exception e1) {
              ExceptionHandler.handle(e1);
            }
            SessionHandleAdapter.getInstance().getCommandStack().commit();
          }
        }
        previewCanvas.redraw();
      }
    }
);
  }
  allButton=new Button(composite,SWT.TOGGLE);
  allButton.setImage(ReportPlatformUIImages.getImage(IReportGraphicConstants.ICON_ATTRIBUTE_BORDER_FRAME));
  allButton.setToolTipText(Messages.getString("String_Node_Str"));
  allButton.setLayoutData(new GridData());
  allButton.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      if (((Button)e.widget).getSelection()) {
        SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
        for (int i=0; i < toggleProviders.length; i++) {
          BorderInfomation information=new BorderInfomation();
          information.setPosition(toggleProviders[i].getPosition());
          information.setColor(builder.getRGB());
          information.setStyle((String)styleCombo.getSelectedItem());
          information.setWidth((String)widthCombo.getSelectedItem());
          toggles[i].setSelection(true);
          previewCanvas.setBorderInfomation(information);
          try {
            toggleProviders[i].save(information);
          }
 catch (          Exception e1) {
            ExceptionHandler.handle(e1);
          }
        }
        restoreInfo=(BorderInfomation)toggleProviders[toggleProviders.length - 1].load();
        SessionHandleAdapter.getInstance().getCommandStack().commit();
      }
 else {
        boolean reset=true;
        RGB oldColor=null;
        for (int i=0; i < toggleProviders.length; i++) {
          BorderInfomation info=(BorderInfomation)toggleProviders[i].load();
          oldColor=info.getColor();
          if (oldColor == null) {
            oldColor=autoColor;
          }
          if (!(info.getStyle().equals((String)styleCombo.getSelectedItem())) || !(oldColor.equals(builder.getRGB())) || !(info.getWidth().equals((String)widthCombo.getSelectedItem()))) {
            reset=false;
            break;
          }
        }
        if (reset) {
          SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
          for (int i=0; i < toggleProviders.length; i++) {
            previewCanvas.removeBorderInfomation(toggleProviders[i].getPosition());
            toggles[i].setSelection(false);
            try {
              toggleProviders[i].reset();
            }
 catch (            Exception e1) {
              ExceptionHandler.handle(e1);
            }
          }
          SessionHandleAdapter.getInstance().getCommandStack().commit();
        }
 else {
          SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
          for (int i=0; i < toggleProviders.length; i++) {
            BorderInfomation information=new BorderInfomation();
            information.setPosition(toggleProviders[i].getPosition());
            information.setColor(builder.getRGB());
            information.setStyle((String)styleCombo.getSelectedItem());
            information.setWidth((String)widthCombo.getSelectedItem());
            previewCanvas.setBorderInfomation(information);
            restoreInfo=information;
            try {
              toggleProviders[i].save(information);
            }
 catch (            Exception e1) {
              ExceptionHandler.handle(e1);
            }
          }
          ((Button)e.widget).setSelection(true);
          SessionHandleAdapter.getInstance().getCommandStack().commit();
        }
      }
      previewCanvas.redraw();
    }
  }
);
  Composite previewContainer=new Composite(content,SWT.NONE);
  data=new GridData(GridData.FILL_BOTH);
  previewContainer.setLayoutData(data);
  layout=new GridLayout();
  layout.numColumns=2;
  layout.marginHeight=1;
  layout.marginWidth=10;
  previewContainer.setLayout(layout);
  Label previewLabel=FormWidgetFactory.getInstance().createLabel(previewContainer,SWT.LEFT,isFormStyle);
  data=new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
  previewLabel.setLayoutData(data);
  previewLabel.setText(Messages.getString("String_Node_Str"));
  previewCanvas=new BorderCanvas(previewContainer,SWT.NONE);
  data=new GridData();
  data.widthHint=130;
  data.heightHint=130;
  previewCanvas.setLayoutData(data);
  return content;
}

Fixed version (ground truth):
public Control createControl(Composite parent){
  content=new Composite(parent,SWT.NONE);
  GridLayout layout=UIUtil.createGridLayoutWithoutMargin(2,false);
  layout.marginHeight=1;
  layout.marginWidth=1;
  layout.horizontalSpacing=10;
  content.setLayout(layout);
  content.setLayoutData(new GridData(GridData.FILL_BOTH));
  Composite choices=new Composite(content,SWT.NONE);
  GridData data=new GridData(GridData.FILL_BOTH);
  choices.setLayoutData(data);
  layout=WidgetUtil.createGridLayout(2);
  layout.marginHeight=1;
  layout.marginWidth=2;
  choices.setLayout(layout);
  Label styleLabel=FormWidgetFactory.getInstance().createLabel(choices,SWT.LEFT,isFormStyle);
  styleLabel.setText(styleProvider.getDisplayName());
  styleLabel.setLayoutData(new GridData());
  if (isFormStyle) {
    styleCombo=FormWidgetFactory.getInstance().createStyleCombo(choices,(IComboProvider)styleProvider);
  }
 else {
    styleCombo=new StyleCombo(choices,style,(IComboProvider)styleProvider);
  }
  data=new GridData();
  data.widthHint=200;
  styleCombo.setLayoutData(data);
  styleCombo.setItems(((IComboProvider)styleProvider).getItems());
  Label colorLabel=FormWidgetFactory.getInstance().createLabel(choices,SWT.LEFT,isFormStyle);
  colorLabel.setText(colorProvider.getDisplayName());
  colorLabel.setLayoutData(new GridData());
  builder=new ColorBuilder(choices,SWT.NONE,isFormStyle);
  builder.setChoiceSet(colorProvider.getElementChoiceSet());
  colorProvider.setIndex(IColorConstants.BLACK);
  data=new GridData();
  data.widthHint=200;
  data.heightHint=builder.computeSize(SWT.DEFAULT,SWT.DEFAULT).y;
  builder.setLayoutData(data);
  Label widthLabel=FormWidgetFactory.getInstance().createLabel(choices,SWT.LEFT,isFormStyle);
  widthLabel.setText(widthProvider.getDisplayName());
  widthLabel.setLayoutData(new GridData());
  if (isFormStyle) {
    widthCombo=FormWidgetFactory.getInstance().createStyleCombo(choices,(IComboProvider)widthProvider);
  }
 else {
    widthCombo=new StyleCombo(choices,style,(IComboProvider)widthProvider);
  }
  widthProvider.setIndex(widthProvider.getItems()[1].toString());
  data=new GridData();
  data.widthHint=200;
  widthCombo.setLayoutData(data);
  widthCombo.setItems(((IComboProvider)widthProvider).getItems());
  Composite composite=new Composite(choices,SWT.NONE);
  layout=new GridLayout();
  layout.horizontalSpacing=7;
  layout.numColumns=toggleProviders.length + 1;
  composite.setLayout(layout);
  data=new GridData();
  data.horizontalSpan=2;
  composite.setLayoutData(data);
  toggles=new Button[toggleProviders.length];
  for (int i=0; i < toggleProviders.length; i++) {
    Button button=new Button(composite,SWT.TOGGLE);
    toggles[i]=button;
    button.setLayoutData(new GridData());
    button.setToolTipText(toggleProviders[i].getTooltipText());
    button.setImage(ReportPlatformUIImages.getImage(toggleProviders[i].getImageName()));
    final BorderToggleDescriptorProvider provider=toggleProviders[i];
    button.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent e){
        if (((Button)e.widget).getSelection()) {
          SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
          BorderInfomation information=new BorderInfomation();
          information.setPosition(provider.getPosition());
          information.setColor(builder.getRGB());
          information.setStyle((String)styleCombo.getSelectedItem());
          information.setWidth((String)widthCombo.getSelectedItem());
          previewCanvas.setBorderInfomation(information);
          restoreInfo=information;
          try {
            provider.save(information);
          }
 catch (          Exception e1) {
            ExceptionHandler.handle(e1);
          }
          checkToggleButtons();
          SessionHandleAdapter.getInstance().getCommandStack().commit();
        }
 else {
          BorderInfomation oldInfo=(BorderInfomation)provider.load();
          RGB oldColor=oldInfo.getColor();
          RGB selectedColor=builder.getRGB();
          if (oldColor == null) {
            oldColor=autoColor;
          }
          if (selectedColor == null) {
            selectedColor=autoColor;
          }
          if (!(oldInfo.getStyle().equals((String)styleCombo.getSelectedItem())) || !(oldColor.equals(selectedColor)) || !(oldInfo.getWidth().equals((String)widthCombo.getSelectedItem()))) {
            SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
            BorderInfomation information=new BorderInfomation();
            information.setPosition(provider.getPosition());
            information.setColor(selectedColor);
            information.setStyle((String)styleCombo.getSelectedItem());
            information.setWidth((String)widthCombo.getSelectedItem());
            previewCanvas.setBorderInfomation(information);
            restoreInfo=information;
            try {
              provider.save(information);
            }
 catch (            Exception e1) {
              ExceptionHandler.handle(e1);
            }
            ((Button)e.widget).setSelection(true);
            SessionHandleAdapter.getInstance().getCommandStack().commit();
          }
 else {
            SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
            previewCanvas.removeBorderInfomation(provider.getPosition());
            if (allButton.getSelection())             allButton.setSelection(false);
            try {
              provider.reset();
            }
 catch (            Exception e1) {
              ExceptionHandler.handle(e1);
            }
            SessionHandleAdapter.getInstance().getCommandStack().commit();
          }
        }
        previewCanvas.redraw();
      }
    }
);
  }
  allButton=new Button(composite,SWT.TOGGLE);
  allButton.setImage(ReportPlatformUIImages.getImage(IReportGraphicConstants.ICON_ATTRIBUTE_BORDER_FRAME));
  allButton.setToolTipText(Messages.getString("String_Node_Str"));
  allButton.setLayoutData(new GridData());
  allButton.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      RGB selectedColor=null;
      RGB oldColor=null;
      if (((Button)e.widget).getSelection()) {
        SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
        selectedColor=builder.getRGB();
        if (selectedColor == null) {
          selectedColor=autoColor;
        }
        for (int i=0; i < toggleProviders.length; i++) {
          BorderInfomation information=new BorderInfomation();
          information.setPosition(toggleProviders[i].getPosition());
          information.setColor(selectedColor);
          information.setStyle((String)styleCombo.getSelectedItem());
          information.setWidth((String)widthCombo.getSelectedItem());
          toggles[i].setSelection(true);
          previewCanvas.setBorderInfomation(information);
          restoreInfo=information;
          try {
            toggleProviders[i].save(information);
          }
 catch (          Exception e1) {
            ExceptionHandler.handle(e1);
          }
        }
        SessionHandleAdapter.getInstance().getCommandStack().commit();
      }
 else {
        boolean reset=true;
        for (int i=0; i < toggleProviders.length; i++) {
          BorderInfomation info=(BorderInfomation)toggleProviders[i].load();
          oldColor=info.getColor();
          selectedColor=builder.getRGB();
          if (oldColor == null) {
            oldColor=autoColor;
          }
          if (selectedColor == null) {
            selectedColor=autoColor;
          }
          if (!(info.getStyle().equals((String)styleCombo.getSelectedItem())) || !(oldColor.equals(selectedColor)) || !(info.getWidth().equals((String)widthCombo.getSelectedItem()))) {
            reset=false;
            break;
          }
        }
        if (reset) {
          SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
          for (int i=0; i < toggleProviders.length; i++) {
            previewCanvas.removeBorderInfomation(toggleProviders[i].getPosition());
            toggles[i].setSelection(false);
            try {
              toggleProviders[i].reset();
            }
 catch (            Exception e1) {
              ExceptionHandler.handle(e1);
            }
          }
          SessionHandleAdapter.getInstance().getCommandStack().commit();
        }
 else {
          SessionHandleAdapter.getInstance().getCommandStack().startTrans(Messages.getString("String_Node_Str"));
          for (int i=0; i < toggleProviders.length; i++) {
            BorderInfomation information=new BorderInfomation();
            information.setPosition(toggleProviders[i].getPosition());
            if (builder.getRGB() == null) {
              information.setColor(autoColor);
            }
 else {
              information.setColor(builder.getRGB());
            }
            information.setStyle((String)styleCombo.getSelectedItem());
            information.setWidth((String)widthCombo.getSelectedItem());
            previewCanvas.setBorderInfomation(information);
            restoreInfo=information;
            try {
              toggleProviders[i].save(information);
            }
 catch (            Exception e1) {
              ExceptionHandler.handle(e1);
            }
          }
          ((Button)e.widget).setSelection(true);
          SessionHandleAdapter.getInstance().getCommandStack().commit();
        }
      }
      previewCanvas.redraw();
    }
  }
);
  Composite previewContainer=new Composite(content,SWT.NONE);
  data=new GridData(GridData.FILL_BOTH);
  previewContainer.setLayoutData(data);
  layout=new GridLayout();
  layout.numColumns=2;
  layout.marginHeight=1;
  layout.marginWidth=10;
  previewContainer.setLayout(layout);
  Label previewLabel=FormWidgetFactory.getInstance().createLabel(previewContainer,SWT.LEFT,isFormStyle);
  data=new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
  previewLabel.setLayoutData(data);
  previewLabel.setText(Messages.getString("String_Node_Str"));
  previewCanvas=new BorderCanvas(previewContainer,SWT.NONE);
  data=new GridData();
  data.widthHint=130;
  data.heightHint=130;
  previewCanvas.setLayoutData(data);
  return content;
}