Program: 10648
Project: 10648
Buggy source:
@Override public void createSection(Composite parent){
  super.createSection(parent);
  FormToolkit toolkit=getFormToolkit(parent.getDisplay());
  Section section=toolkit.createSection(parent,ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
  section.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  section.setText(sectionTitle);
  Composite composite=toolkit.createComposite(section);
  section.setClient(composite);
  GridLayout layout=new GridLayout();
  composite.setLayout(layout);
  composite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
  Composite topComposite=new Composite(composite,SWT.NONE);
  topComposite.setLayout(new GridLayout(2,false));
  topComposite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  Label emailLabel=toolkit.createLabel(topComposite,Messages.COMMONTXT_EMAIL_WITH_COLON,SWT.NONE);
  emailLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  emailLabel.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,false,false));
  emailText=toolkit.createText(topComposite,"String_Node_Str");
  emailText.setEditable(false);
  emailText.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  emailText.setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TEXT_BORDER);
  if (cfServer.getUsername() != null) {
    emailText.setText(cfServer.getUsername());
  }
  emailText.addModifyListener(new DataChangeListener(DataType.EMAIL));
  Label passwordLabel=toolkit.createLabel(topComposite,Messages.COMMONTXT_PW,SWT.NONE);
  passwordLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  passwordLabel.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,false,false));
  passwordText=toolkit.createText(topComposite,"String_Node_Str",SWT.PASSWORD);
  passwordText.setEditable(false);
  passwordText.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  passwordText.setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TEXT_BORDER);
  if (cfServer.getPassword() != null) {
    passwordText.setText(cfServer.getPassword());
  }
  passwordText.addModifyListener(new DataChangeListener(DataType.PASSWORD));
  Label label=toolkit.createLabel(topComposite,Messages.COMMONTXT_URL);
  label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  label.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,false,false));
  urlText=toolkit.createText(topComposite,"String_Node_Str",SWT.NONE);
  urlText.setEditable(false);
  urlText.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  urlText.setData(FormToolkit.KEY_DRAW_BORDER,Boolean.FALSE);
  if (cfServer.getUrl() != null) {
    urlText.setText(CloudUiUtil.getDisplayTextFromUrl(cfServer.getUrl(),cfServer.getServer().getServerType().getId()));
  }
  Label orgLabel=toolkit.createLabel(topComposite,Messages.CloudFoundryAccountSection_LABEL_ORG,SWT.NONE);
  orgLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  orgLabel.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,false,false));
  orgText=toolkit.createText(topComposite,"String_Node_Str",SWT.NONE);
  orgText.setEditable(false);
  orgText.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  orgText.setData(FormToolkit.KEY_DRAW_BORDER,Boolean.FALSE);
  if (cfServer.getCloudFoundrySpace() != null && cfServer.getCloudFoundrySpace().getOrgName() != null) {
    orgText.setText(cfServer.getCloudFoundrySpace().getOrgName());
  }
  Label spaceLabel=toolkit.createLabel(topComposite,Messages.CloudFoundryAccountSection_LABEL_SPACE,SWT.NONE);
  spaceLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  spaceLabel.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,false,false));
  spaceText=toolkit.createText(topComposite,"String_Node_Str",SWT.NONE);
  spaceText.setEditable(false);
  spaceText.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  spaceText.setData(FormToolkit.KEY_DRAW_BORDER,Boolean.FALSE);
  if (cfServer.getCloudFoundrySpace() != null && cfServer.getCloudFoundrySpace().getSpaceName() != null) {
    spaceText.setText(cfServer.getCloudFoundrySpace().getSpaceName());
  }
  final Composite buttonComposite=toolkit.createComposite(composite);
  buttonComposite.setLayout(new GridLayout(4,false));
  GridDataFactory.fillDefaults().align(SWT.END,SWT.FILL).grab(true,false).applyTo(buttonComposite);
  Composite validateComposite=toolkit.createComposite(composite);
  validateComposite.setLayout(new GridLayout(1,false));
  validateComposite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  validateLabel=toolkit.createLabel(validateComposite,"String_Node_Str",SWT.NONE);
  validateLabel.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false));
  createCloneServerArea(buttonComposite,toolkit);
  final Button changePasswordButton=toolkit.createButton(buttonComposite,Messages.CloudFoundryAccountSection_BUTTON_CHANGE_PW,SWT.PUSH);
  changePasswordButton.setEnabled(false);
  changePasswordButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false));
  changePasswordButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      if (server.isDirty()) {
        boolean confirm=MessageDialog.openQuestion(getShell(),Messages.CloudFoundryAccountSection_DIALOG_UNSAVE_TITLE,Messages.CloudFoundryAccountSection_DIALOG_UNSAVE_BODY);
        if (!confirm) {
          return;
        }
      }
      UpdatePasswordDialog dialog=new UpdatePasswordDialog(getShell(),cfServer.getUsername());
      if (dialog.open() == IDialogConstants.OK_ID) {
        final String newPassword=dialog.getPassword();
        String errorMsg=CloudUiUtil.updatePassword(newPassword,cfServer,server);
        if (errorMsg != null) {
          validateLabel.setText(errorMsg);
          validateLabel.setForeground(validateLabel.getDisplay().getSystemColor(SWT.COLOR_RED));
        }
 else {
          validateLabel.setText(Messages.CloudFoundryAccountSection_LABEL_PW_CHANGED);
          passwordText.setText(newPassword);
        }
      }
    }
  }
);
  final Button validateButton=toolkit.createButton(buttonComposite,Messages.CloudFoundryAccountSection_BUTTON_VALIDATE_ACCOUNT,SWT.PUSH);
  validateButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false));
  validateButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent event){
      final String url=cfServer.getUrl();
      final String userName=emailText.getText();
      final String password=passwordText.getText();
      final String org=orgText.getText();
      final String space=spaceText.getText();
      try {
        CloudUiUtil.validateCredentials(userName,password,url,false,cfServer.getSelfSignedCertificate(),null);
        if (org != null && space != null) {
          validateLabel.setText(Messages.VALID_ACCOUNT);
          validateLabel.setForeground(validateLabel.getDisplay().getSystemColor(SWT.COLOR_BLACK));
        }
 else {
          String errorMsg=null;
          if (org == null) {
            errorMsg=Messages.ERROR_INVALID_ORG;
          }
 else           if (space == null) {
            errorMsg=Messages.ERROR_INVALID_SPACE;
          }
          validateLabel.setText(errorMsg);
          validateLabel.setForeground(validateLabel.getDisplay().getSystemColor(SWT.COLOR_RED));
        }
      }
 catch (      CoreException e) {
        validateLabel.setText(e.getMessage());
      }
      buttonComposite.layout(new Control[]{validateLabel,validateButton});
    }
  }
);
  if (CloudFoundryURLNavigation.canEnableCloudFoundryNavigation(cfServer)) {
    Button cfSignup=toolkit.createButton(buttonComposite,CloudFoundryConstants.PUBLIC_CF_SERVER_SIGNUP_LABEL,SWT.PUSH);
    cfSignup.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false));
    cfSignup.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent event){
        IServer iServer=cfServer.getServer();
        if (iServer != null) {
          String signupURL=CloudFoundryBrandingExtensionPoint.getSignupURL(cfServer.getServerId(),cfServer.getUrl());
          if (signupURL != null) {
            CloudFoundryURLNavigation nav=new CloudFoundryURLNavigation(signupURL);
            nav.navigate();
          }
        }
      }
    }
);
  }
  toolkit.paintBordersFor(topComposite);
  section.setExpanded(true);
  ServerEventHandler.getDefault().addServerListener(this);
}

Fixed version (ground truth):
@Override public void createSection(Composite parent){
  super.createSection(parent);
  FormToolkit toolkit=getFormToolkit(parent.getDisplay());
  Section section=toolkit.createSection(parent,ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
  section.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  section.setText(sectionTitle);
  Composite composite=toolkit.createComposite(section);
  section.setClient(composite);
  GridLayout layout=new GridLayout();
  composite.setLayout(layout);
  composite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
  Composite topComposite=new Composite(composite,SWT.NONE);
  topComposite.setLayout(new GridLayout(2,false));
  topComposite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  Label emailLabel=toolkit.createLabel(topComposite,Messages.COMMONTXT_EMAIL_WITH_COLON,SWT.NONE);
  emailLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  emailLabel.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,false,false));
  emailText=toolkit.createText(topComposite,"String_Node_Str");
  emailText.setEditable(false);
  emailText.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  emailText.setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TEXT_BORDER);
  if (cfServer.getUsername() != null) {
    emailText.setText(cfServer.getUsername());
  }
  emailText.addModifyListener(new DataChangeListener(DataType.EMAIL));
  Label passwordLabel=toolkit.createLabel(topComposite,Messages.COMMONTXT_PW,SWT.NONE);
  passwordLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  passwordLabel.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,false,false));
  passwordText=toolkit.createText(topComposite,"String_Node_Str",SWT.PASSWORD);
  passwordText.setEditable(false);
  passwordText.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  passwordText.setData(FormToolkit.KEY_DRAW_BORDER,FormToolkit.TEXT_BORDER);
  if (cfServer.getPassword() != null) {
    passwordText.setText(cfServer.getPassword());
  }
  passwordText.addModifyListener(new DataChangeListener(DataType.PASSWORD));
  Label label=toolkit.createLabel(topComposite,Messages.COMMONTXT_URL);
  label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  label.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,false,false));
  urlText=toolkit.createText(topComposite,"String_Node_Str",SWT.NONE);
  urlText.setEditable(false);
  urlText.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  urlText.setData(FormToolkit.KEY_DRAW_BORDER,Boolean.FALSE);
  if (cfServer.getUrl() != null) {
    urlText.setText(CloudUiUtil.getDisplayTextFromUrl(cfServer.getUrl(),cfServer.getServer().getServerType().getId()));
  }
  Label orgLabel=toolkit.createLabel(topComposite,Messages.CloudFoundryAccountSection_LABEL_ORG,SWT.NONE);
  orgLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  orgLabel.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,false,false));
  orgText=toolkit.createText(topComposite,"String_Node_Str",SWT.NONE);
  orgText.setEditable(false);
  orgText.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  orgText.setData(FormToolkit.KEY_DRAW_BORDER,Boolean.FALSE);
  if (cfServer.getCloudFoundrySpace() != null && cfServer.getCloudFoundrySpace().getOrgName() != null) {
    orgText.setText(cfServer.getCloudFoundrySpace().getOrgName());
  }
  Label spaceLabel=toolkit.createLabel(topComposite,Messages.CloudFoundryAccountSection_LABEL_SPACE,SWT.NONE);
  spaceLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  spaceLabel.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,false,false));
  spaceText=toolkit.createText(topComposite,"String_Node_Str",SWT.NONE);
  spaceText.setEditable(false);
  spaceText.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  spaceText.setData(FormToolkit.KEY_DRAW_BORDER,Boolean.FALSE);
  if (cfServer.getCloudFoundrySpace() != null && cfServer.getCloudFoundrySpace().getSpaceName() != null) {
    spaceText.setText(cfServer.getCloudFoundrySpace().getSpaceName());
  }
  final Composite buttonComposite=toolkit.createComposite(composite);
  buttonComposite.setLayout(new GridLayout(4,false));
  GridDataFactory.fillDefaults().align(SWT.END,SWT.FILL).grab(true,false).applyTo(buttonComposite);
  final Composite validateComposite=toolkit.createComposite(composite);
  validateComposite.setLayout(new GridLayout(1,false));
  validateComposite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
  validateLabel=toolkit.createLabel(validateComposite,"String_Node_Str",SWT.NONE);
  validateLabel.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false));
  createCloneServerArea(buttonComposite,toolkit);
  final Button changePasswordButton=toolkit.createButton(buttonComposite,Messages.CloudFoundryAccountSection_BUTTON_CHANGE_PW,SWT.PUSH);
  changePasswordButton.setEnabled(false);
  changePasswordButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false));
  changePasswordButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      if (server.isDirty()) {
        boolean confirm=MessageDialog.openQuestion(getShell(),Messages.CloudFoundryAccountSection_DIALOG_UNSAVE_TITLE,Messages.CloudFoundryAccountSection_DIALOG_UNSAVE_BODY);
        if (!confirm) {
          return;
        }
      }
      UpdatePasswordDialog dialog=new UpdatePasswordDialog(getShell(),cfServer.getUsername());
      if (dialog.open() == IDialogConstants.OK_ID) {
        final String newPassword=dialog.getPassword();
        String errorMsg=CloudUiUtil.updatePassword(newPassword,cfServer,server);
        if (errorMsg != null) {
          validateLabel.setText(errorMsg);
          validateLabel.setForeground(validateLabel.getDisplay().getSystemColor(SWT.COLOR_RED));
        }
 else {
          validateLabel.setText(Messages.CloudFoundryAccountSection_LABEL_PW_CHANGED);
          passwordText.setText(newPassword);
        }
      }
    }
  }
);
  final Button validateButton=toolkit.createButton(buttonComposite,Messages.CloudFoundryAccountSection_BUTTON_VALIDATE_ACCOUNT,SWT.PUSH);
  validateButton.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false));
  validateButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent event){
      final String url=cfServer.getUrl();
      final String userName=emailText.getText();
      final String password=passwordText.getText();
      final String org=orgText.getText();
      final String space=spaceText.getText();
      try {
        CloudUiUtil.validateCredentials(userName,password,url,false,cfServer.getSelfSignedCertificate(),null);
        if (org != null && space != null) {
          validateLabel.setText(Messages.VALID_ACCOUNT);
          validateLabel.setForeground(validateLabel.getDisplay().getSystemColor(SWT.COLOR_BLACK));
        }
 else {
          String errorMsg=null;
          if (org == null) {
            errorMsg=Messages.ERROR_INVALID_ORG;
          }
 else           if (space == null) {
            errorMsg=Messages.ERROR_INVALID_SPACE;
          }
          validateLabel.setText(errorMsg);
          validateLabel.setForeground(validateLabel.getDisplay().getSystemColor(SWT.COLOR_RED));
        }
      }
 catch (      CoreException e) {
        validateLabel.setText(e.getMessage());
      }
      buttonComposite.layout(new Control[]{validateButton});
      validateComposite.layout(new Control[]{validateLabel});
    }
  }
);
  if (CloudFoundryURLNavigation.canEnableCloudFoundryNavigation(cfServer)) {
    Button cfSignup=toolkit.createButton(buttonComposite,CloudFoundryConstants.PUBLIC_CF_SERVER_SIGNUP_LABEL,SWT.PUSH);
    cfSignup.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false));
    cfSignup.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent event){
        IServer iServer=cfServer.getServer();
        if (iServer != null) {
          String signupURL=CloudFoundryBrandingExtensionPoint.getSignupURL(cfServer.getServerId(),cfServer.getUrl());
          if (signupURL != null) {
            CloudFoundryURLNavigation nav=new CloudFoundryURLNavigation(signupURL);
            nav.navigate();
          }
        }
      }
    }
);
  }
  toolkit.paintBordersFor(topComposite);
  section.setExpanded(true);
  ServerEventHandler.getDefault().addServerListener(this);
}