コード例 #1
0
  @Override
  public void initializeHandlers() {
    super.initializeHandlers();

    // Initialize the list of alerts:
    final ClusterGeneralModel model = getModelProvider().getModel();
    updateAlerts(getView(), model);

    // Listen for changes in the properties of the model in order
    // to update the alerts panel:
    model
        .getPropertyChangedEvent()
        .addListener(
            new IEventListener<PropertyChangedEventArgs>() {
              @Override
              public void eventRaised(
                  Event<? extends PropertyChangedEventArgs> ev,
                  Object sender,
                  PropertyChangedEventArgs args) {
                if (args.propertyName.contains("Alert")) { // $NON-NLS-1$
                  updateAlerts(getView(), model);
                } else if (args.propertyName.contains(
                    "consoleAddressPartiallyOverridden")) { //$NON-NLS-1$
                  updateAlerts(getView(), model);
                }
              }
            });
  }
コード例 #2
0
  /**
   * Review the model and if there are alerts add them to the view.
   *
   * @param view the view where alerts should be added
   * @param model the model to review
   */
  private void updateAlerts(final ViewDef view, final ClusterGeneralModel model) {
    // Clear all the alerts:
    view.clearAlerts();

    // Review the alerts and add those that are active:
    if (model.getHasNewGlusterHostsAlert()) {
      addTextAndLinkAlert(
          view,
          messages.clusterHasNewGlusterHosts(),
          model.getImportNewGlusterHostsCommand(),
          model.getDetachNewGlusterHostsCommand());
    }

    if (model.isConsoleAddressPartiallyOverridden()) {
      view.addAlert(new Label(constants.consolePartiallyOverridden()));
    }
  }