/** Disposes of this wizard page support object, removing any listeners it may have attached. */
 public void dispose() {
   aggregateStatus.dispose();
   if (!uiChanged) {
     for (Iterator it = dbc.getBindings().iterator(); it.hasNext(); ) {
       Binding binding = (Binding) it.next();
       binding.getTarget().removeChangeListener(uiChangeListener);
     }
     dbc.getBindings().removeListChangeListener(bindingsListener);
   }
   aggregateStatus = null;
   dbc = null;
   uiChangeListener = null;
   bindingsListener = null;
   wizardPage = null;
 }
  /** @return true if page is valid */
  protected boolean updateValidationMessages() {
    boolean messageSet = false;
    IStatus statusParent =
        AggregateValidationStatus.getStatusMerged(getBindingContext().getBindings());

    // Iter for errors
    for (IStatus statusChild : statusParent.getChildren()) {
      if (statusChild.getSeverity() == IStatus.ERROR) {
        presentation.setErrorMessage(statusChild.getMessage());
        messageSet = true;
        if (statusChild.getException() != null) {
          statusChild.getException().printStackTrace();
        }
        break;
      }
    }
    if (!messageSet) {
      presentation.clearErrorMessage();
      // Iter for warnings
      for (IStatus statusChild : statusParent.getChildren()) {
        if (statusChild.getSeverity() == IStatus.WARNING) {
          presentation.setMessage(statusChild.getMessage(), IMessageProvider.WARNING);
          messageSet = true;
          break;
        }
      }
    }
    if (!messageSet) {
      // Iter for information
      for (IStatus statusChild : statusParent.getChildren()) {
        if (statusChild.getSeverity() == IStatus.INFO) {
          presentation.setMessage(statusChild.getMessage(), IMessageProvider.INFORMATION);
          messageSet = true;
          break;
        }
      }
    }

    if (!messageSet) {
      IStatus customValidationStatus = getValidationStatus();
      if (customValidationStatus == null) {
        presentation.clearErrorMessage();
        presentation.setMessage(null, IMessageProvider.NONE);
      } else if (customValidationStatus.getSeverity() == IStatus.ERROR) {
        presentation.setErrorMessage(customValidationStatus.getMessage());
      } else if (customValidationStatus.getSeverity() == IStatus.WARNING) {
        presentation.setMessage(customValidationStatus.getMessage(), IMessageProvider.WARNING);

      } else if (customValidationStatus.getSeverity() == IStatus.INFO) {
        presentation.setMessage(customValidationStatus.getMessage(), IMessageProvider.INFORMATION);
      }
    }

    if (!messageSet) {
      presentation.setMessage(null, IMessageProvider.NONE);
    }

    return !presentation.hasErrorMessage();
  }
  protected void init() {
    aggregateStatus =
        new AggregateValidationStatus(dbc.getBindings(), AggregateValidationStatus.MAX_SEVERITY);
    aggregateStatus.addValueChangeListener(
        new IValueChangeListener() {
          public void handleValueChange(ValueChangeEvent event) {

            currentStatus = (IStatus) event.diff.getNewValue();
            handleStatusChanged();
          }
        });
    currentStatus = (IStatus) aggregateStatus.getValue();
    handleStatusChanged();
    dbc.getBindings().addListChangeListener(bindingsListener);
    for (Iterator it = dbc.getBindings().iterator(); it.hasNext(); ) {
      Binding binding = (Binding) it.next();
      binding.getTarget().addChangeListener(uiChangeListener);
    }
  }
Example #4
0
  @Override
  protected final Control createContents(Composite parent) {
    Control answer = super.createContents(parent);

    bindings.onValidationStatusChanged(
        AggregateValidationStatus.getStatusMaxSeverity(
            getBindingContext().getValidationStatusProviders()));

    return answer;
  }