Program: 7704
Project: 7704
Buggy source:
@Override protected Control createDialogArea(Composite parent){
  boolean advancedMode=Activator.getDefault().getPreferenceStore().getBoolean(ADVANCED_MODE_PREFERENCE);
  final Composite main=new Composite(parent,SWT.NONE);
  main.setLayout(new GridLayout(1,false));
  GridDataFactory.fillDefaults().grab(true,true).applyTo(main);
  Composite repositoryGroup=new Composite(main,SWT.SHADOW_ETCHED_IN);
  repositoryGroup.setLayout(new GridLayout(2,false));
  GridDataFactory.fillDefaults().grab(true,false).applyTo(repositoryGroup);
  Label repositoryLabel=new Label(repositoryGroup,SWT.NONE);
  repositoryLabel.setText(UIText.SimpleConfigureFetchDialog_RepositoryLabel);
  Text repositoryText=new Text(repositoryGroup,SWT.BORDER | SWT.READ_ONLY);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(repositoryText);
  repositoryText.setText(Activator.getDefault().getRepositoryUtil().getRepositoryName(repository));
  Label branchLabel=new Label(repositoryGroup,SWT.NONE);
  branchLabel.setText(UIText.SimpleConfigureFetchDialog_BranchLabel);
  String branch;
  try {
    branch=repository.getBranch();
  }
 catch (  IOException e2) {
    branch=null;
  }
  if (branch == null || ObjectId.isId(branch)) {
    branch=UIText.SimpleConfigureFetchDialog_DetachedHeadMessage;
  }
  Text branchText=new Text(repositoryGroup,SWT.BORDER | SWT.READ_ONLY);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(branchText);
  branchText.setText(branch);
  Group remoteGroup=new Group(main,SWT.SHADOW_ETCHED_IN);
  remoteGroup.setLayout(new GridLayout(1,false));
  GridDataFactory.fillDefaults().grab(true,true).applyTo(remoteGroup);
  remoteGroup.setText(NLS.bind(UIText.SimpleConfigureFetchDialog_RemoteGroupHeader,config.getName()));
  addDefaultOriginWarningIfNeeded(remoteGroup);
  final Composite sameUriDetails=new Composite(remoteGroup,SWT.NONE);
  sameUriDetails.setLayout(new GridLayout(4,false));
  GridDataFactory.fillDefaults().grab(true,false).applyTo(sameUriDetails);
  Label commonUriLabel=new Label(sameUriDetails,SWT.NONE);
  commonUriLabel.setText(UIText.SimpleConfigureFetchDialog_UriLabel);
  commonUriText=new Text(sameUriDetails,SWT.BORDER | SWT.READ_ONLY);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(commonUriText);
  changeCommonUri=new Button(sameUriDetails,SWT.PUSH);
  changeCommonUri.setText(UIText.SimpleConfigureFetchDialog_ChangeUriButton);
  changeCommonUri.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      SelectUriWizard wiz;
      if (commonUriText.getText().length() > 0)       wiz=new SelectUriWizard(false,commonUriText.getText());
 else       wiz=new SelectUriWizard(false);
      if (new WizardDialog(getShell(),wiz).open() == Window.OK) {
        if (commonUriText.getText().length() > 0)         try {
          config.removeURI(new URIish(commonUriText.getText()));
        }
 catch (        URISyntaxException ex) {
          Activator.handleError(ex.getMessage(),ex,true);
        }
        config.addURI(wiz.getUri());
        updateControls();
      }
    }
  }
);
  final Button deleteCommonUri=new Button(sameUriDetails,SWT.PUSH);
  deleteCommonUri.setText(UIText.SimpleConfigureFetchDialog_DeleteUriButton);
  deleteCommonUri.setEnabled(false);
  deleteCommonUri.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      config.removeURI(config.getURIs().get(0));
      updateControls();
    }
  }
);
  commonUriText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      deleteCommonUri.setEnabled(commonUriText.getText().length() > 0);
    }
  }
);
  final Group refSpecGroup=new Group(remoteGroup,SWT.SHADOW_ETCHED_IN);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(refSpecGroup);
  refSpecGroup.setText(UIText.SimpleConfigureFetchDialog_RefMappingGroup);
  refSpecGroup.setLayout(new GridLayout(5,false));
  ExpandableComposite advanced=new ExpandableComposite(refSpecGroup,ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
  if (advancedMode)   advanced.setExpanded(true);
  advanced.setText(UIText.SimpleConfigureFetchDialog_AdvancedCompositeButton);
  GridDataFactory.fillDefaults().align(SWT.BEGINNING,SWT.FILL).span(5,1).grab(true,false).applyTo(advanced);
  advanced.addExpansionListener(new ExpansionAdapter(){
    @Override public void expansionStateChanged(    ExpansionEvent e){
      Activator.getDefault().getPreferenceStore().setValue(ADVANCED_MODE_PREFERENCE,e.getState());
      GridData data=(GridData)changeRefSpec.getLayoutData();
      data.exclude=!e.getState();
      changeRefSpec.setVisible(!data.exclude);
      refSpecGroup.layout(true);
    }
  }
);
  Label refSpecLabel=new Label(refSpecGroup,SWT.NONE);
  refSpecLabel.setText(UIText.SimpleConfigureFetchDialog_RefSpecLabel);
  GridDataFactory.fillDefaults().span(5,1).applyTo(refSpecLabel);
  specViewer=new TableViewer(refSpecGroup,SWT.BORDER | SWT.MULTI);
  specViewer.setContentProvider(ArrayContentProvider.getInstance());
  GridDataFactory.fillDefaults().hint(SWT.DEFAULT,150).span(5,1).grab(true,true).applyTo(specViewer.getTable());
  specViewer.getTable().addKeyListener(new KeyAdapter(){
    @Override public void keyPressed(    KeyEvent e){
      if (e.stateMask == SWT.MOD1 && e.keyCode == 'v') {
        doPaste();
      }
    }
  }
);
  addRefSpec=new Button(refSpecGroup,SWT.PUSH);
  addRefSpec.setText(UIText.SimpleConfigureFetchDialog_AddRefSpecButton);
  addRefSpec.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      SimpleFetchRefSpecWizard wiz=new SimpleFetchRefSpecWizard(repository,config);
      WizardDialog dlg=new WizardDialog(getShell(),wiz);
      if (dlg.open() == Window.OK) {
        config.addFetchRefSpec(wiz.getSpec());
      }
      updateControls();
    }
  }
);
  changeRefSpec=new Button(refSpecGroup,SWT.PUSH);
  changeRefSpec.setText(UIText.SimpleConfigureFetchDialog_ChangeRefSpecButton);
  changeRefSpec.setEnabled(false);
  GridDataFactory.fillDefaults().exclude(!advancedMode).applyTo(changeRefSpec);
  changeRefSpec.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      RefSpec oldSpec=(RefSpec)((IStructuredSelection)specViewer.getSelection()).getFirstElement();
      RefSpecDialog dlg=new RefSpecDialog(getShell(),repository,config,oldSpec,false);
      if (dlg.open() == Window.OK) {
        config.removeFetchRefSpec(oldSpec);
        config.addFetchRefSpec(dlg.getSpec());
      }
      updateControls();
    }
  }
);
  final Button deleteRefSpec=new Button(refSpecGroup,SWT.PUSH);
  deleteRefSpec.setText(UIText.SimpleConfigureFetchDialog_DeleteRefSpecButton);
  deleteRefSpec.setEnabled(false);
  deleteRefSpec.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      for (      Object spec : ((IStructuredSelection)specViewer.getSelection()).toArray()) {
        config.removeFetchRefSpec((RefSpec)spec);
      }
      updateControls();
    }
  }
);
  final Button copySpec=new Button(refSpecGroup,SWT.PUSH);
  copySpec.setText(UIText.SimpleConfigureFetchDialog_CopyRefSpecButton);
  copySpec.setEnabled(false);
  copySpec.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      String toCopy=((IStructuredSelection)specViewer.getSelection()).getFirstElement().toString();
      Clipboard clipboard=new Clipboard(getShell().getDisplay());
      try {
        clipboard.setContents(new String[]{toCopy},new TextTransfer[]{TextTransfer.getInstance()});
      }
  finally {
        clipboard.dispose();
      }
    }
  }
);
  final Button pasteSpec=new Button(refSpecGroup,SWT.PUSH);
  pasteSpec.setText(UIText.SimpleConfigureFetchDialog_PateRefSpecButton);
  pasteSpec.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      doPaste();
    }
  }
);
  addRefSpecAdvanced=new Button(advanced,SWT.PUSH);
  advanced.setClient(addRefSpecAdvanced);
  GridDataFactory.fillDefaults().align(SWT.BEGINNING,SWT.FILL).applyTo(addRefSpecAdvanced);
  addRefSpecAdvanced.setText(UIText.SimpleConfigureFetchDialog_EditAdvancedButton);
  addRefSpecAdvanced.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      if (new WizardDialog(getShell(),new RefSpecWizard(repository,config,false)).open() == Window.OK)       updateControls();
    }
  }
);
  specViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      IStructuredSelection sel=(IStructuredSelection)specViewer.getSelection();
      copySpec.setEnabled(sel.size() == 1);
      changeRefSpec.setEnabled(sel.size() == 1);
      deleteRefSpec.setEnabled(!sel.isEmpty());
    }
  }
);
  applyDialogFont(main);
  return main;
}

Fixed version (ground truth):
@Override protected Control createDialogArea(Composite parent){
  boolean advancedMode=Activator.getDefault().getPreferenceStore().getBoolean(ADVANCED_MODE_PREFERENCE);
  final Composite main=new Composite(parent,SWT.NONE);
  main.setLayout(new GridLayout(1,false));
  GridDataFactory.fillDefaults().grab(true,true).applyTo(main);
  Composite repositoryGroup=new Composite(main,SWT.SHADOW_ETCHED_IN);
  repositoryGroup.setLayout(new GridLayout(2,false));
  GridDataFactory.fillDefaults().grab(true,false).applyTo(repositoryGroup);
  Label repositoryLabel=new Label(repositoryGroup,SWT.NONE);
  repositoryLabel.setText(UIText.SimpleConfigureFetchDialog_RepositoryLabel);
  Text repositoryText=new Text(repositoryGroup,SWT.BORDER | SWT.READ_ONLY);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(repositoryText);
  repositoryText.setText(Activator.getDefault().getRepositoryUtil().getRepositoryName(repository));
  Label branchLabel=new Label(repositoryGroup,SWT.NONE);
  branchLabel.setText(UIText.SimpleConfigureFetchDialog_BranchLabel);
  String branch;
  try {
    branch=repository.getBranch();
  }
 catch (  IOException e2) {
    branch=null;
  }
  if (branch == null || ObjectId.isId(branch)) {
    branch=UIText.SimpleConfigureFetchDialog_DetachedHeadMessage;
  }
  Text branchText=new Text(repositoryGroup,SWT.BORDER | SWT.READ_ONLY);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(branchText);
  branchText.setText(branch);
  Group remoteGroup=new Group(main,SWT.SHADOW_ETCHED_IN);
  remoteGroup.setLayout(new GridLayout(1,false));
  GridDataFactory.fillDefaults().grab(true,true).applyTo(remoteGroup);
  remoteGroup.setText(NLS.bind(UIText.SimpleConfigureFetchDialog_RemoteGroupHeader,config.getName()));
  addDefaultOriginWarningIfNeeded(remoteGroup);
  final Composite sameUriDetails=new Composite(remoteGroup,SWT.NONE);
  sameUriDetails.setLayout(new GridLayout(4,false));
  GridDataFactory.fillDefaults().grab(true,false).applyTo(sameUriDetails);
  Label commonUriLabel=new Label(sameUriDetails,SWT.NONE);
  commonUriLabel.setText(UIText.SimpleConfigureFetchDialog_UriLabel);
  commonUriText=new Text(sameUriDetails,SWT.BORDER | SWT.READ_ONLY);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(commonUriText);
  changeCommonUri=new Button(sameUriDetails,SWT.PUSH);
  changeCommonUri.setText(UIText.SimpleConfigureFetchDialog_ChangeUriButton);
  changeCommonUri.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      SelectUriWizard wiz;
      if (commonUriText.getText().length() > 0)       wiz=new SelectUriWizard(false,commonUriText.getText());
 else       wiz=new SelectUriWizard(false);
      if (new WizardDialog(getShell(),wiz).open() == Window.OK) {
        if (commonUriText.getText().length() > 0)         try {
          config.removeURI(new URIish(commonUriText.getText()));
        }
 catch (        URISyntaxException ex) {
          Activator.handleError(ex.getMessage(),ex,true);
        }
        config.addURI(wiz.getUri());
        updateControls();
      }
    }
  }
);
  final Button deleteCommonUri=new Button(sameUriDetails,SWT.PUSH);
  deleteCommonUri.setText(UIText.SimpleConfigureFetchDialog_DeleteUriButton);
  deleteCommonUri.setEnabled(false);
  deleteCommonUri.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      config.removeURI(config.getURIs().get(0));
      updateControls();
    }
  }
);
  commonUriText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      deleteCommonUri.setEnabled(commonUriText.getText().length() > 0);
    }
  }
);
  final Group refSpecGroup=new Group(remoteGroup,SWT.SHADOW_ETCHED_IN);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(refSpecGroup);
  refSpecGroup.setText(UIText.SimpleConfigureFetchDialog_RefMappingGroup);
  refSpecGroup.setLayout(new GridLayout(5,false));
  ExpandableComposite advanced=new ExpandableComposite(refSpecGroup,ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
  if (advancedMode)   advanced.setExpanded(true);
  advanced.setText(UIText.SimpleConfigureFetchDialog_AdvancedCompositeButton);
  GridDataFactory.fillDefaults().align(SWT.BEGINNING,SWT.FILL).span(5,1).grab(true,false).applyTo(advanced);
  advanced.addExpansionListener(new ExpansionAdapter(){
    @Override public void expansionStateChanged(    ExpansionEvent e){
      Activator.getDefault().getPreferenceStore().setValue(ADVANCED_MODE_PREFERENCE,e.getState());
      GridData data=(GridData)changeRefSpec.getLayoutData();
      data.exclude=!e.getState();
      changeRefSpec.setVisible(!data.exclude);
      refSpecGroup.layout(true);
    }
  }
);
  Label refSpecLabel=new Label(refSpecGroup,SWT.NONE);
  refSpecLabel.setText(UIText.SimpleConfigureFetchDialog_RefSpecLabel);
  GridDataFactory.fillDefaults().span(5,1).applyTo(refSpecLabel);
  specViewer=new TableViewer(refSpecGroup,SWT.BORDER | SWT.MULTI);
  specViewer.setContentProvider(ArrayContentProvider.getInstance());
  GridDataFactory.fillDefaults().hint(SWT.DEFAULT,150).minSize(SWT.DEFAULT,30).span(5,1).grab(true,true).applyTo(specViewer.getTable());
  specViewer.getTable().addKeyListener(new KeyAdapter(){
    @Override public void keyPressed(    KeyEvent e){
      if (e.stateMask == SWT.MOD1 && e.keyCode == 'v') {
        doPaste();
      }
    }
  }
);
  addRefSpec=new Button(refSpecGroup,SWT.PUSH);
  addRefSpec.setText(UIText.SimpleConfigureFetchDialog_AddRefSpecButton);
  addRefSpec.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      SimpleFetchRefSpecWizard wiz=new SimpleFetchRefSpecWizard(repository,config);
      WizardDialog dlg=new WizardDialog(getShell(),wiz);
      if (dlg.open() == Window.OK) {
        config.addFetchRefSpec(wiz.getSpec());
      }
      updateControls();
    }
  }
);
  changeRefSpec=new Button(refSpecGroup,SWT.PUSH);
  changeRefSpec.setText(UIText.SimpleConfigureFetchDialog_ChangeRefSpecButton);
  changeRefSpec.setEnabled(false);
  GridDataFactory.fillDefaults().exclude(!advancedMode).applyTo(changeRefSpec);
  changeRefSpec.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      RefSpec oldSpec=(RefSpec)((IStructuredSelection)specViewer.getSelection()).getFirstElement();
      RefSpecDialog dlg=new RefSpecDialog(getShell(),repository,config,oldSpec,false);
      if (dlg.open() == Window.OK) {
        config.removeFetchRefSpec(oldSpec);
        config.addFetchRefSpec(dlg.getSpec());
      }
      updateControls();
    }
  }
);
  final Button deleteRefSpec=new Button(refSpecGroup,SWT.PUSH);
  deleteRefSpec.setText(UIText.SimpleConfigureFetchDialog_DeleteRefSpecButton);
  deleteRefSpec.setEnabled(false);
  deleteRefSpec.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      for (      Object spec : ((IStructuredSelection)specViewer.getSelection()).toArray()) {
        config.removeFetchRefSpec((RefSpec)spec);
      }
      updateControls();
    }
  }
);
  final Button copySpec=new Button(refSpecGroup,SWT.PUSH);
  copySpec.setText(UIText.SimpleConfigureFetchDialog_CopyRefSpecButton);
  copySpec.setEnabled(false);
  copySpec.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      String toCopy=((IStructuredSelection)specViewer.getSelection()).getFirstElement().toString();
      Clipboard clipboard=new Clipboard(getShell().getDisplay());
      try {
        clipboard.setContents(new String[]{toCopy},new TextTransfer[]{TextTransfer.getInstance()});
      }
  finally {
        clipboard.dispose();
      }
    }
  }
);
  final Button pasteSpec=new Button(refSpecGroup,SWT.PUSH);
  pasteSpec.setText(UIText.SimpleConfigureFetchDialog_PateRefSpecButton);
  pasteSpec.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      doPaste();
    }
  }
);
  addRefSpecAdvanced=new Button(advanced,SWT.PUSH);
  advanced.setClient(addRefSpecAdvanced);
  GridDataFactory.fillDefaults().align(SWT.BEGINNING,SWT.FILL).applyTo(addRefSpecAdvanced);
  addRefSpecAdvanced.setText(UIText.SimpleConfigureFetchDialog_EditAdvancedButton);
  addRefSpecAdvanced.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      if (new WizardDialog(getShell(),new RefSpecWizard(repository,config,false)).open() == Window.OK)       updateControls();
    }
  }
);
  specViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      IStructuredSelection sel=(IStructuredSelection)specViewer.getSelection();
      copySpec.setEnabled(sel.size() == 1);
      changeRefSpec.setEnabled(sel.size() == 1);
      deleteRefSpec.setEnabled(!sel.isEmpty());
    }
  }
);
  applyDialogFont(main);
  return main;
}