コード例 #1
0
  private void openNotificationsPopup(final ClickEvent event) {
    VerticalLayout notificationsLayout = new VerticalLayout();

    Label title = new Label("Notifications");
    title.addStyleName(ValoTheme.LABEL_H3);
    title.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    notificationsLayout.addComponent(title);

    Collection<DashboardNotification> notifications =
        DashboardUI.getDataProvider().getNotifications();
    DashboardEventBus.post(new NotificationsCountUpdatedEvent());

    for (DashboardNotification notification : notifications) {
      VerticalLayout notificationLayout = new VerticalLayout();
      notificationLayout.setMargin(false);
      notificationLayout.setSpacing(false);
      notificationLayout.addStyleName("notification-item");

      Label titleLabel =
          new Label(
              notification.getFirstName()
                  + " "
                  + notification.getLastName()
                  + " "
                  + notification.getAction());
      titleLabel.addStyleName("notification-title");

      Label timeLabel = new Label(notification.getPrettyTime());
      timeLabel.addStyleName("notification-time");

      Label contentLabel = new Label(notification.getContent());
      contentLabel.addStyleName("notification-content");

      notificationLayout.addComponents(titleLabel, timeLabel, contentLabel);
      notificationsLayout.addComponent(notificationLayout);
    }

    HorizontalLayout footer = new HorizontalLayout();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.setSpacing(false);
    Button showAll =
        new Button(
            "View All Notifications",
            new ClickListener() {
              @Override
              public void buttonClick(final ClickEvent event) {
                Notification.show("Not implemented in this demo");
              }
            });
    showAll.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    showAll.addStyleName(ValoTheme.BUTTON_SMALL);
    footer.addComponent(showAll);
    footer.setComponentAlignment(showAll, Alignment.TOP_CENTER);
    notificationsLayout.addComponent(footer);

    if (notificationsWindow == null) {
      notificationsWindow = new Window();
      notificationsWindow.setWidth(300.0f, Unit.PIXELS);
      notificationsWindow.addStyleName("notifications");
      notificationsWindow.setClosable(false);
      notificationsWindow.setResizable(false);
      notificationsWindow.setDraggable(false);
      notificationsWindow.setCloseShortcut(KeyCode.ESCAPE, null);
      notificationsWindow.setContent(notificationsLayout);
    }

    if (!notificationsWindow.isAttached()) {
      notificationsWindow.setPositionY(event.getClientY() - event.getRelativeY() + 40);
      getUI().addWindow(notificationsWindow);
      notificationsWindow.focus();
    } else {
      notificationsWindow.close();
    }
  }
コード例 #2
0
ファイル: Login.java プロジェクト: MunicipalOrg/AdminCDO
 @Override
 public void enter(ViewChangeEvent event) {
   // TODO Auto-generated method stub
   if (!dialog.isAttached()) UI.getCurrent().addWindow(dialog);
 }