Example #1
0
  public boolean validate(final PreferencePage parent) {
    boolean retval = true;
    String errorMsg = null;

    if (impls.size() <= 0) {
      errorMsg = UITexts.cabalImplsBlock_noCabalInstallations;
      retval = !retval;
    } else {
      Object[] checked = viewer.getCheckedElements();
      if (checked.length > 0) {
        if (checked.length > 1) {
          errorMsg = UITexts.cabalImplsBlock_multipleImplsSelected;
          retval = !retval;
        }
      } else {
        // <= 0...
        errorMsg = UITexts.cabalImplsBlock_noCabalInstallationSelected;
        retval = !retval;
      }
    }

    if (!retval) {
      parent.setErrorMessage(errorMsg);
    }

    return retval;
  }
 /**
  * Applies the status to the status line of a dialog page.
  *
  * @param status the status
  */
 private void applyToStatusLine(IStatus status) {
   String message = status.getMessage();
   switch (status.getSeverity()) {
     case IStatus.OK:
       fPreferencePage.setMessage(message, IMessageProvider.NONE);
       fPreferencePage.setErrorMessage(null);
       break;
     case IStatus.WARNING:
       fPreferencePage.setMessage(message, IMessageProvider.WARNING);
       fPreferencePage.setErrorMessage(null);
       break;
     case IStatus.INFO:
       fPreferencePage.setMessage(message, IMessageProvider.INFORMATION);
       fPreferencePage.setErrorMessage(null);
       break;
     default:
       if (message.length() == 0) {
         message = null;
       }
       fPreferencePage.setMessage(null);
       fPreferencePage.setErrorMessage(message);
       break;
   }
 }