Пример #1
0
 @Override
 public void init() {
   setTheme("mocha");
   Window window = new Window();
   window.setCaption(applicationTitle());
   window.setSizeFull();
   window.addStyleName("mocha-window");
   setMainWindow(window);
   boolean needLogin = true;
   // check user
   if (getUser() != null) {
     needLogin = false;
   } else {
     if (isDevelopMode()) {
       setUser(loadTestUser());
       needLogin = false;
     }
   }
   if (!needLogin) {
     AbstractMainPage homepage = SpringContextUtils.getBean("homepage", AbstractMainPage.class);
     homepage.setResponse(response);
     window.setContent(homepage);
   } else {
     LoginScreen loginScreen = new LoginScreen(cookieUsername);
     loginScreen.setResponse(response);
     window.setContent(loginScreen);
   }
 }
  public void showWindowForm() {

    itemDetilModel = new PerubahanHargaItemModel();
    itemDetilView = new PerubahanHargaItemView(itemDetilModel);
    itemDetilPresenter = new PerubahanHargaItemPresenter(itemDetilModel, itemDetilView);

    itemDetilView.setSizeFull();
    panelFormDetil.setContent(itemDetilView);

    windowForm = new Window();
    windowForm.setModal(true);

    windowForm.center();

    windowForm.setWidth("650px");
    windowForm.setHeight("300px");
    windowForm.setClosable(true);
    windowForm.setResizable(false);

    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSizeFull();
    content.addComponent(panelFormDetil);
    windowForm.setContent(content);

    getUI().addWindow(windowForm);
  }
Пример #3
0
  public ConfirmDialog(
      String caption, String message, String okButtonText, String cancelButtonText) {
    super(caption);
    super.setModal(true);
    super.setClosable(false);
    super.setResizable(false);

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setMargin(true);

    // confirmation message
    windowLayout.addComponent(new Label(message, ContentMode.HTML));
    windowLayout.setSpacing(true);

    // buttons
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100.0f, Unit.PERCENTAGE);
    windowLayout.addComponent(buttonsLayout);

    okButton = new Button(okButtonText);
    buttonsLayout.addComponent(okButton);
    okButton.setTabIndex(1);
    okButton.addClickListener(this);
    buttonsLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER);

    cancelButton = new Button(cancelButtonText);
    buttonsLayout.addComponent(cancelButton);
    cancelButton.setTabIndex(0);
    cancelButton.setClickShortcut(KeyCode.ESCAPE, null);
    cancelButton.addClickListener(this);
    buttonsLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER);

    super.setContent(windowLayout);
  }
Пример #4
0
  @Override
  public void init() {
    setMainWindow(mainWindow);
    setTheme("bluesmoke");

    helper = new SpringContextHelper(this);
    feed = (OHLCFeed) helper.getBean("feed");
    correlatorPool = (CorrelatorPool) helper.getBean("correlatorPool");
    correlatorBuilderManager =
        (CorrelatorBuilderManager) helper.getBean("correlatorBuilderManager");
    emulator = (PassageOfTimeEmulationWorker) helper.getBean("emulator");

    buildMainLayout();
    mainWindow.setContent(mainLayout);
    mainLayout.setSizeFull();
    mainWindow.addListener(
        new Window.CloseListener() {
          public void windowClose(Window.CloseEvent e) {
            analytics.terminate();
          }
        });
    mainWindow.addListener(
        new Window.ResizeListener() {
          public void windowResized(Window.ResizeEvent e) {
            analytics.resize();
          }
        });
    mainWindow.addComponent(pusher);
  }
Пример #5
0
 /** 增加 编辑 删除窗体初始化 * */
 private void createWindow(Item item) {
   Window window = new Window();
   window.setHeight(250, Unit.PIXELS);
   window.setWidth(300, Unit.PIXELS);
   window.setModal(true);
   window.setContent(createForm(item, window));
   window.close();
   getUI().addWindow(window);
 }
Пример #6
0
  private void buildMainWindow() {
    root = new FormLayout();
    root.addComponent(buildTopMenu());
    super.setContent(root);

    content = new LoginPanel();
    root.addComponent(content);

    root.addComponent(buildBottomMenu());
  }
Пример #7
0
  @Override
  public void init() {
    this.setTheme("wmhd");

    this.getContext().addTransactionListener(this);

    this.mainWindow = new Window("My Vaadin Application");

    this.setMainWindow(mainWindow);

    mainWindow.setContent(new LoginScreen(this));
  }
Пример #8
0
 private void tambahUserYayasanbaru(UserOprYayasan i) {
   final Window win = new Window("Tambah User Baru");
   Component c = new TambahUserYayasan(i, win);
   VerticalLayout vl = new VerticalLayout();
   vl.setMargin(true);
   vl.addComponent(c);
   win.setContent(vl);
   win.setModal(true);
   win.setWidth("600px");
   win.center();
   UI.getCurrent().addWindow(win);
 }
  /** {@inheritdoc} */
  @Override
  public void init() {
    // Add a horizontal SplitPanel to the lower area
    final HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
    horizontalSplitPanel.setSplitPosition(150, Sizeable.UNITS_PIXELS);
    horizontalSplitPanel.setSizeFull();

    final Window mainWindow = new Window("NodeGraph Widget Application");

    final Button openWindow = new Button("Open diagram");
    openWindow.addListener(
        new Button.ClickListener() {

          /** */
          private static final long serialVersionUID = -1522261898787739587L;

          /** {@inheritdoc} */
          @Override
          public void buttonClick(ClickEvent event) {
            final Window subwindow = new Window("Node Graph Widget");
            subwindow.setWidth("850px");
            subwindow.setHeight("500px");
            subwindow.setModal(true);

            final VerticalLayout layout = (VerticalLayout) subwindow.getContent();
            layout.setMargin(true);
            layout.setSpacing(true);
            layout.setSizeFull();

            final GraphComponent nodeGraphWidget = getNodeGraph();
            layout.addComponent(nodeGraphWidget);

            mainWindow.addWindow(subwindow);
          }
        });

    final HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeFull();

    horizontalSplitPanel.setFirstComponent(openWindow);
    horizontalSplitPanel.setSecondComponent(hl);

    mainWindow.setContent(horizontalSplitPanel);
    mainWindow.setSizeFull();

    this.setMainWindow(mainWindow);
  }
  @Override
  public Undoer execute(List<VertexRef> targets, OperationContext operationContext) {
    UI mainWindow = operationContext.getMainWindow();
    CommandManager commandManager = m_commandManager;

    Window window = new Window();
    window.setModal(true);

    VerticalLayout layout = new VerticalLayout();
    for (Command command : commandManager.getHistoryList()) {
      layout.addComponent(new Label(command.toString()));
    }
    window.setContent(layout);

    mainWindow.addWindow(window);
    return null;
  }
Пример #11
0
  public Window getWindow() {
    if (!isFloatingWindow) {
      return null;
    }

    if (keyboardWindow == null) {
      keyboardWindow = new Window();
      keyboardWindow.setCaption("Virtual Keyboard");
      // keyboardWindow.setPositionX(200);
      // keyboardWindow.setPositionY(100);
      // keyboardWindow.setWidth("600");
      // keyboardWindow.setHeight("300");
      keyboardWindow.setVisible(false);
      keyboardWindow.setContent(this);
      keyboardWindow.setResizable(false);
    }
    return keyboardWindow;
  }
Пример #12
0
  @Override
  protected void setup(VaadinRequest request) {

    Window w = new Window();
    w.setId(WINDOW_ID);
    w.setWidth("300px");
    w.setHeight("300px");
    w.center();

    VerticalLayout content = new VerticalLayout();
    w.setContent(content);
    content.setHeight("1000px");
    ComboBox<String> cb = new ComboBox<>();
    cb.setId(COMBOBOX_ID);
    content.addComponent(cb);
    content.setComponentAlignment(cb, Alignment.BOTTOM_CENTER);

    addWindow(w);
  }
Пример #13
0
  public Login() {
    // TODO Auto-generated constructor stub
    VaadinSession.getCurrent().setAttribute("municipaldata", null);
    VaadinSession.getCurrent().setAttribute("barangaydata", null);
    VaadinSession.getCurrent().setAttribute("id", null);
    setSizeFull();
    dialog = new Window("Login");
    dialog.setClosable(false);
    dialog.setResizable(false);
    dialog.center();

    //		new CreateAccount();

    VerticalLayout content = new VerticalLayout();
    content.setSpacing(true);
    content.setMargin(new MarginInfo(false, true, true, true));
    dialog.setContent(content);

    Label title = new Label("Login");
    title.addStyleName(ValoTheme.LABEL_H2);
    title.addStyleName(ValoTheme.LABEL_COLORED);

    HorizontalLayout form = new HorizontalLayout();
    form.setSpacing(true);
    form.addStyleName("wrapping");
    content.addComponent(form);

    username.setIcon(FontAwesome.USER);
    username.focus();
    form.addComponent(username);

    password.setIcon(FontAwesome.LOCK);
    form.addComponent(password);

    Button submit = new Button("Login");
    submit.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_RIGHT);
    submit.addStyleName(ValoTheme.BUTTON_PRIMARY);
    submit.setIcon(FontAwesome.ARROW_RIGHT);
    submit.setWidth("100%");
    submit.addListener(ClickEvent.class, this, "gotoMain");
    content.addComponent(submit);
  }
Пример #14
0
  /**
   * @param caption
   * @param primaryStyleName - the style defined styleName
   * @param styleName - the user defined styleName
   * @return
   */
  private void createWindowWith(String caption, String primaryStyleName, String styleName) {

    Window window = new Window();
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    window.setContent(layout);
    layout.addComponent(new Label("Some content"));

    if (caption != null) {
      window.setCaption(caption);
    }

    if (primaryStyleName != null) {
      window.addStyleName(primaryStyleName);
    }

    if (styleName != null) {
      window.addStyleName(styleName);
    }

    parent.getUI().addWindow(window);
  }
  @Override
  public void init() {
    Window mainWindow = new Window("SplitButton Demo Application");
    setMainWindow(mainWindow);

    setTheme("splitbuttondemo-reindeer");

    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    mainLayout.setMargin(true);
    mainWindow.setContent(mainLayout);

    Label headerLabel = new Label("SplitButton");
    headerLabel.setStyleName(Reindeer.LABEL_H1);
    mainLayout.addComponent(headerLabel);

    TabSheet tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    mainLayout.addComponent(tabSheet);
    mainLayout.setExpandRatio(tabSheet, 1);

    tabSheet.addTab(createChameleonTab(), "Chameleon", null);
    tabSheet.addTab(createReindeerTab(), "Reindeer", null);
  }
Пример #16
0
  @Override
  public void execute() {
    List<ChangeRecord> historyList = view.getUi().getStockService().findChanges(good);
    Window subWindow = new Window();
    subWindow.setModal(true);
    subWindow.setHeight("650px");
    subWindow.setWidth("700px");
    subWindow.setClosable(true);
    view.getUi().addWindow(subWindow);

    final Button pdfButton = new Button(bundle.getString("pdf.export"));
    pdfButton.setIcon(new ThemeResource("img/pdf.png"));
    pdfButton.setWidth("150");
    StreamResource pdfStream = getPDFStream(view.getUi().getStockService().findChanges(good));
    pdfStream.setMIMEType("application/pdf");
    FileDownloader pdfDownloader = new FileDownloader(pdfStream);
    pdfDownloader.extend(pdfButton);

    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addComponent(pdfButton);

    for (ChangeRecord record : historyList) {
      for (ChangeRecord.PropertyChange p : record.getChangeList()) {
        p.setName(bundle.getString(p.getName()));
      }
      Panel panel = new Panel();
      BeanItemContainer<ChangeRecord.PropertyChange> container =
          new BeanItemContainer<>(ChangeRecord.PropertyChange.class, record.getChangeList());
      Table table = new Table();
      table.setContainerDataSource(container);
      table.setVisibleColumns("name", "oldValue", "newValue");
      table.setColumnHeaders(
          bundle.getString("history.property"),
          bundle.getString("history.old"),
          bundle.getString("history.new"));
      table.setColumnExpandRatio("name", 0.33f);
      table.setColumnExpandRatio("oldValue", 0.33f);
      table.setColumnExpandRatio("newValue", 0.33f);
      table.setPageLength(0);
      table.setWidth("100%");

      VerticalLayout panelLayout = new VerticalLayout();
      panelLayout.addComponent(
          new Label(
              "<b>"
                  + new SimpleDateFormat("dd-MM-YYYY HH:mm").format(record.getDate())
                  + ": "
                  + record.getUser().getName()
                  + " "
                  + record.getUser().getSurname()
                  + "</b><br/>",
              ContentMode.HTML));
      panelLayout.addComponent(table);
      panel.setContent(panelLayout);
      layout.addComponent(panel);
    }

    subWindow.setContent(layout);
  }
  public void init(final Window main) {
    VerticalLayout mainLayout = new VerticalLayout();
    main.setContent(mainLayout);
    mainLayout.setSizeFull();

    HorizontalLayout titlebar = new HorizontalLayout();
    titlebar.addStyleName("titlebar");
    titlebar.setWidth("100%");
    Label title = new Label("Book of Vaadin Examples");
    title.addStyleName("title");
    titlebar.addComponent(title);
    titlebar.setComponentAlignment(title, Alignment.MIDDLE_RIGHT);
    Embedded logo = new Embedded(null, new ThemeResource("img/vaadin-logo.png"));
    titlebar.addComponent(logo);
    titlebar.setComponentAlignment(logo, Alignment.MIDDLE_RIGHT);
    main.addComponent(titlebar);

    HorizontalLayout hor = new HorizontalLayout();
    hor.setSizeFull();
    main.addComponent(hor);
    mainLayout.setExpandRatio(hor, 1.0f);

    final Panel menupanel = new Panel("Examples");
    menupanel.addStyleName("menupanel");
    menupanel.setWidth(null);
    menupanel.setHeight("100%");
    menupanel.getContent().setWidth(null);
    // menupanel.getContent().setHeight("100%");
    hor.addComponent(menupanel);

    final Tree menu = new Tree();
    menu.setWidth(null);
    // menu.setHeight("100%");
    menu.setImmediate(true);
    menupanel.addComponent(menu);

    final Panel viewpanel = new Panel("Selected Example");
    viewpanel.addStyleName("viewpanel");
    viewpanel.setSizeFull();
    VerticalLayout viewlayout = new VerticalLayout();
    viewlayout.addStyleName("viewlayout");
    viewlayout.setSpacing(true);
    viewlayout.setMargin(true);
    viewpanel.setContent(viewlayout);

    hor.addComponent(viewpanel);
    hor.setExpandRatio(viewpanel, 1.0f);

    WebApplicationContext ctx = (WebApplicationContext) getContext();
    BookExampleLibrary library = BookExampleLibrary.getInstance(ctx.getBaseDirectory());

    AbstractExampleItem[] examples = library.getAllExamples();

    // Collect redirects here
    final HashMap<String, String> redirects = new HashMap<String, String>();

    // Collect examples here
    final HashMap<String, CaptionedExampleItem> exampleitems =
        new HashMap<String, CaptionedExampleItem>();

    // Build the menu and collect redirections
    for (int i = 0; i < examples.length; i++)
      if (examples[i] instanceof BookExample || examples[i] instanceof ExampleCtgr) {
        CaptionedExampleItem example = (CaptionedExampleItem) examples[i];
        exampleitems.put(example.getExampleId(), example);

        String itemid = example.getExampleId();
        menu.addItem(itemid);
        menu.setItemCaption(itemid, example.getShortName());

        if (examples[i].getParentId() != null) menu.setParent(itemid, examples[i].getParentId());
      } else if (examples[i] instanceof RedirctItem) {
        RedirctItem redirect = (RedirctItem) examples[i];
        redirects.put(redirect.getExampleId(), redirect.redirectid);
      }

    // Expand the menu
    for (int i = 0; i < examples.length; i++) {
      if (examples[i].getParentId() == null)
        menu.expandItemsRecursively(examples[i].getExampleId());

      if (examples[i].isCollapsed()) menu.collapseItem(examples[i].getExampleId());

      if (menu.getChildren(examples[i].getExampleId()) == null)
        menu.setChildrenAllowed(examples[i].getExampleId(), false);
    }

    // Set selected example as given in the URI fragment
    final UriFragmentUtility urifu = new UriFragmentUtility();
    urifu.addListener(
        new FragmentChangedListener() {
          private static final long serialVersionUID = -6588416218607827834L;

          public void fragmentChanged(FragmentChangedEvent source) {
            String fragment = source.getUriFragmentUtility().getFragment();
            if (fragment != null) {
              // Handle redirection
              while (redirects.containsKey(fragment)) fragment = redirects.get(fragment);

              menu.setValue(fragment);

              // Open the tree nodes leading to the example
              for (Object parent = menu.getParent(fragment);
                  parent != null;
                  parent = menu.getParent(parent)) menu.expandItem(parent);
            }
          }
        });
    mainLayout.addComponent(urifu);

    // Handle menu selection
    menu.addListener(
        new Property.ValueChangeListener() {
          private static final long serialVersionUID = 8236533959795019956L;

          public void valueChange(ValueChangeEvent event) {
            viewpanel.removeAllComponents();

            String selection = (String) event.getProperty().getValue();

            // Find the example
            CaptionedExampleItem exampleItem = exampleitems.get(selection);
            if (selection != null && exampleItem == null)
              main.showNotification("Invalid item " + selection);
            else if (exampleItem != null) {
              if (exampleItem.getClass().isAssignableFrom(ExampleCtgr.class)) {
                if (menu.hasChildren(exampleItem.getExampleId())) {
                  menu.select((String) menu.getChildren(exampleItem.getExampleId()).toArray()[0]);
                }
              } else { // A leaf
                BookExample example = (BookExample) exampleItem;

                // Load unless already loaded
                WebApplicationContext ctx = (WebApplicationContext) getContext();
                example.loadExample(ctx.getBaseDirectory());

                if (example.getDescription() != null) {
                  Label descLabel = new Label(example.getDescription(), Label.CONTENT_XHTML);
                  descLabel.addStyleName("example-description");
                  viewpanel.addComponent(descLabel);
                }

                // The actual example component
                viewpanel.addComponent(example.createInstance());

                // Java sources on the left, CSS on the right
                HorizontalLayout horizontalOrder = new HorizontalLayout();
                horizontalOrder.addStyleName("sourcecontainer");
                horizontalOrder.setSpacing(true);
                horizontalOrder.setMargin(true);

                Panel bookRefs = null;
                Panel forumLinks = null;
                Panel kbRefs = null;

                List<SourceFragment> fragments = example.getSourceFragments();
                if (fragments != null) {
                  // Java Sources are laid out vertically
                  VerticalLayout verticalListings = new VerticalLayout();
                  verticalListings.setSizeUndefined();
                  verticalListings.setSpacing(true);
                  horizontalOrder.addComponent(verticalListings);

                  // Find the widest source fragment
                  int widestIndex = 0;
                  int widestWidth = 0;
                  for (int fragmentNum = 0; fragmentNum < fragments.size(); fragmentNum++)
                    if (fragments.get(fragmentNum).getSrcWidth() > widestWidth) {
                      widestIndex = fragmentNum;
                      widestWidth = fragments.get(fragmentNum).getSrcWidth();
                    }
                  System.out.println("Widest listing: " + widestIndex + " which is " + widestWidth);

                  for (int fragmentNum = 0; fragmentNum < fragments.size(); fragmentNum++) {
                    SourceFragment fragment = fragments.get(fragmentNum);

                    // Have caption only in the beginning of the listings
                    String listingCaption = fragmentNum == 0 ? "Source Code" : "";

                    String srcurl =
                        "http://dev.vaadin.com/browser/doc/book-examples/trunk/src"
                            + fragment.getSrcName();
                    SourceListing listing = new SourceListing(listingCaption, srcurl, fragment);
                    verticalListings.addComponent(listing);

                    // Use the width of the widest listing for all listings
                    if (fragmentNum == widestIndex) listing.setWidth(Sizeable.SIZE_UNDEFINED, 0);
                    else listing.setWidth("100%");

                    if (!fragment.getBookRefs().isEmpty()) {
                      bookRefs = new Panel("Book References");
                      bookRefs.setSizeUndefined();
                      for (Iterator<String> iter = fragment.getBookRefs().iterator();
                          iter.hasNext(); ) {
                        String ref = iter.next();
                        int hashPos = ref.indexOf('#');
                        String refFragment = "";
                        if (hashPos != -1) {
                          refFragment = "#" + ref.replace('#', '.');
                          ref = ref.substring(0, hashPos);
                        }
                        String bookUrl =
                            "http://vaadin.com/book/-/page/" + ref + ".html" + refFragment;
                        Link link = new Link(bookUrl, new ExternalResource(bookUrl));
                        link.setTargetName("_new");
                        bookRefs.addComponent(link);
                      }
                    }

                    if (!fragment.getForumLinks().isEmpty()) {
                      forumLinks = new Panel("Forum Messages");
                      forumLinks.setSizeUndefined();
                      for (Iterator<String> iter = fragment.getForumLinks().iterator();
                          iter.hasNext(); ) {
                        String url = iter.next();
                        Link link = new Link(url, new ExternalResource(url));
                        link.setTargetName("_new");
                        forumLinks.addComponent(link);
                      }
                    }

                    if (!fragment.getKbRefs().isEmpty()) {
                      kbRefs = new Panel("Pro Account Knowledge Base Articles");
                      kbRefs.setSizeUndefined();
                      for (Iterator<SourceFragment.Ref> iter = fragment.getKbRefs().iterator();
                          iter.hasNext(); ) {
                        SourceFragment.Ref ref = iter.next();
                        String url = "http://vaadin.com/knowledge-base#" + ref.ref;
                        Link link = new Link(ref.caption, new ExternalResource(url));
                        link.setTargetName("_new");
                        forumLinks.addComponent(link);
                      }
                    }
                  }
                }

                // Show associated CSS
                if (example.getCssFragments() != null && example.getCssFragments().size() > 0) {
                  SourceFragment csscode = example.getCssFragments().get(0);
                  String srcurl =
                      "http://dev.vaadin.com/browser/doc/book-examples/trunk/WebContent/VAADIN/themes/book-examples/styles.css";
                  horizontalOrder.addComponent(new SourceListing("CSS Code", srcurl, csscode));
                }

                if (horizontalOrder.getComponentIterator().hasNext())
                  viewpanel.addComponent(horizontalOrder);
                if (bookRefs != null) viewpanel.addComponent(bookRefs);
                if (forumLinks != null) viewpanel.addComponent(forumLinks);
                if (kbRefs != null) viewpanel.addComponent(kbRefs);

                urifu.setFragment(example.getExampleId());
              }
            }
          }
        });

    Tree.ItemStyleGenerator itemStyleGenerator =
        new Tree.ItemStyleGenerator() {
          private static final long serialVersionUID = -3231268865512947125L;

          public String getStyle(Object itemId) {
            // Chapter title items do not contain a period
            if (!((String) itemId).contains(".")) return "chaptertitle";
            return null;
          }
        };
    menu.setItemStyleGenerator(itemStyleGenerator);
  }
Пример #18
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();
    }
  }