Esempio n. 1
0
  public void onMessage(final Message message) {
    if (!message.isTransient()) {

      // update the visible message count
      reflectMessageCount();

      if (message.isSticky()) // sticky messages override each other like this
      {
        lastSticky = message;
        displayNotification(message);
      } else if (null == lastSticky
          || Message.Severity.Error == message.getSeverity()
          || Message.Severity.Fatal
              == message.getSeverity()) // regular message don't replace sticky ones
      {
        clearSticky();

        displayNotification(message);

        Timer hideTimer =
            new Timer() {
              @Override
              public void run() {
                // hide message
                messageDisplay.clear();
                if (displayPopup != null) displayPopup.hide();
              }
            };

        hideTimer.schedule(5000);
      }
    }
  }
 public boolean hasErrorMessages() {
   for (List<Message> sourceMessages : this.sourceMessages.values()) {
     for (Message message : sourceMessages) {
       if (message.getSeverity() == Severity.ERROR) {
         return true;
       }
     }
   }
   return false;
 }
Esempio n. 3
0
  private void displayNotification(final Message message) {

    String actualMessage =
        message.getConciseMessage().length() > 40
            ? message.getConciseMessage().substring(0, 40) + " ..."
            : message.getConciseMessage();

    displayPopup = new DefaultPopup(DefaultPopup.Arrow.RIGHTTOP);

    final HTML label = new HTML(message.getSeverity().getTag() + "&nbsp;" + actualMessage);

    label.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent clickEvent) {
            if (message.isSticky()) {
              MessageCenterView.this.lastSticky = null;
            }
            messageDisplay.clear();
            displayPopup.hide();
            showDetail(message);
          }
        });

    label.addStyleName("notification-display");
    final String css = getSeverityStyle(message.severity);
    label.addStyleName(css);

    displayPopup.setWidget(label);

    int width = 250;
    int height = 16;

    displayPopup.setPopupPosition(
        messageButton.getAbsoluteLeft() - (width + 2 - messageButton.getOffsetWidth() + 85),
        messageButton.getAbsoluteTop() - 2);

    displayPopup.show();

    displayPopup.setWidth(width + "px");
    displayPopup.setHeight(height + "px");
  }
 protected static void printMessages(ArrayOfMessage messages) {
   for (int ii = 0; ii < messages.size(); ii++) {
     Message message = messages.getMessage(ii);
     System.out.println(message.getSeverity().toString() + " " + ii + ": " + message.getSummary());
   }
 }
Esempio n. 5
0
  private void showDetail(final Message msg) {

    msg.setNew(false);

    final DefaultWindow window =
        new DefaultWindow(Console.CONSTANTS.common_label_messageDetailTitle());

    window.setWidth(480);
    window.setHeight(360);
    window.setGlassEnabled(true);

    // ImageResource icon = MessageCenterView.getSeverityIcon(msg.getSeverity());
    // AbstractImagePrototype prototype = AbstractImagePrototype.create(icon);

    SafeHtmlBuilder html = new SafeHtmlBuilder();

    // TODO: XSS prevention?
    html.appendHtmlConstant(msg.getSeverity().getTag());
    html.appendHtmlConstant("&nbsp;");
    html.appendHtmlConstant(msg.getFired().toString());
    html.appendHtmlConstant("<h3 id='consise-message'>");
    html.appendHtmlConstant(msg.getConciseMessage());
    html.appendHtmlConstant("</h3>");
    html.appendHtmlConstant("<p/>");

    String detail = msg.getDetailedMessage() != null ? msg.getDetailedMessage() : "";

    html.appendHtmlConstant(
        "<pre style='font-family:tahoma, verdana, sans-serif;' id='detail-message'>");
    html.appendHtmlConstant(detail);
    html.appendHtmlConstant("</pre>");

    final HTML widget = new HTML(html.toSafeHtml());
    widget.getElement().setAttribute("style", "margin:5px");

    DialogueOptions options =
        new DialogueOptions(
            "OK",
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent clickEvent) {
                window.hide();
              }
            },
            Console.CONSTANTS.common_label_cancel(),
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent clickEvent) {
                window.hide();
              }
            });

    options.getSubmit().setAttribute("aria-describedby", "consise-message detail-message");

    Widget windowContent = new WindowContentBuilder(widget, options).build();

    TrappedFocusPanel trap =
        new TrappedFocusPanel(windowContent) {
          @Override
          protected void onAttach() {
            super.onAttach();

            Scheduler.get()
                .scheduleDeferred(
                    new Scheduler.ScheduledCommand() {
                      @Override
                      public void execute() {
                        getFocus().onFirstButton();
                      }
                    });
          }
        };

    window.setWidget(trap);

    window.addCloseHandler(
        new CloseHandler<PopupPanel>() {

          @Override
          public void onClose(CloseEvent<PopupPanel> event) {
            messagePopup.getMessageList().getSelectionModel().setSelected(msg, false);
            messagePopup.hide();
          }
        });

    messagePopup.hide();
    window.center();
  }