Example usage for com.vaadin.ui PopupView addListener

List of usage examples for com.vaadin.ui PopupView addListener

Introduction

In this page you can find the example usage for com.vaadin.ui PopupView addListener.

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

From source file:com.liferay.mail.vaadin.MessageToolbar.java

License:Open Source License

protected void selectMoveTarget() {

    // Ensure a mail is selected
    List<Message> message = mainMailView.getSelectedMessages();
    if (message.isEmpty()) {
        Controller.get().showInfo(Lang.get("no-messages-selected"));
        return;/*from w  ww. j ava  2 s.c  om*/
    }

    Account account;
    try {
        account = MessageUtil.getAccountForMessage(message.get(0));
    } catch (Exception e) {
        Controller.get().showError(Lang.get("unable-to-move-messages"), e);
        return;
    }

    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setMargin(false, true, true, false);
    panelLayout.setSizeUndefined();

    Panel p = new Panel(panelLayout);
    p.setSizeUndefined();

    final PopupView popupView = new PopupView("", p);

    FolderTree destinationTree = new FolderTree(new FolderChangeListener() {

        public void selectedFolderChanged(Folder folder) {

            if (folder != null) {
                popupView.setPopupVisible(false);
                Controller controller = Controller.get();
                try {
                    MessageUtil.moveMessagesTo(mainMailView.getSelectedMessages(), folder);

                    controller.showInfo(Lang.get("messages-have-been-moved"));
                } catch (MailException me) {
                    if (me.getType() == MailException.FOLDER_INVALID_DESTINATION) {
                        controller.showError(Lang.get("cannot-move-messages-to-this-folder"));
                    }
                } catch (PortalException e) {
                    controller.showError(Lang.get("unable-to-move-messages"), e);
                } catch (SystemException e) {
                    controller.showError(Lang.get("unable-to-move-messages"), e);
                }

            }
        }
    }, null);

    p.addComponent(destinationTree);

    popupView.setPopupVisible(true);
    popupView.addListener(new PopupVisibilityListener() {

        public void popupVisibilityChange(PopupVisibilityEvent event) {

            // Remove popupview from layout when it has been closed
            if (!event.isPopupVisible()) {
                removeComponent(event.getPopupView());

            }
        }
    });

    // Set tree properties
    List<Account> accounts = new ArrayList<Account>();
    accounts.add(account);
    final FolderContainer folderContainer = new FolderContainer(accounts);

    destinationTree.setContainerDataSource(folderContainer);
    destinationTree.expandItemsRecursively(destinationTree.rootItemIds().iterator().next());

    addComponent(popupView, moveToIndex);

}

From source file:org.escidoc.browser.ui.GroupRolesView.java

License:Open Source License

private VerticalLayout addRoleExcludeInformation() {
    VerticalLayout rlexclude = new VerticalLayout();
    final Label content = new Label("<ul><li>The following Roles have been excluded from this view: <br />"
            + ViewConstants.roleExcludeList.toString() + "</li></ul>", Label.CONTENT_RAW);
    content.setWidth("300px");

    final PopupView popup = new PopupView("?", content);
    popup.setHideOnMouseOut(true);//  www .  jav a 2s. c  o m
    popup.addListener(new PopupVisibilityListener() {
        @Override
        public void popupVisibilityChange(PopupVisibilityEvent event) {
        }
    });

    popup.addStyleName("paddingright10");
    rlexclude.addComponent(popup);
    rlexclude.setComponentAlignment(popup, Alignment.MIDDLE_RIGHT);
    rlexclude.setMargin(true);
    return rlexclude;
}

From source file:org.escidoc.browser.ui.mainpage.HeaderContainer.java

License:Open Source License

private void createSearchForm() {
    final Form form = new Form();
    searchField.setImmediate(true);/*from w  w  w  . ja v a2s .  co m*/
    form.getLayout().addComponent(searchField);
    form.addStyleName("paddingright10");
    hl.addComponent(form);
    hl.setComponentAlignment(form, Alignment.MIDDLE_RIGHT);

    final Button btnSearch = new Button("Go", this, "onClickSearch");

    // btnSearch.setClickShortcut(KeyCode.ENTER);
    btnSearch.addStyleName("primary");
    btnSearch.removeStyleName("v-button");

    btnSearch.addStyleName("paddingright10");
    hl.addComponent(btnSearch);
    hl.setComponentAlignment(btnSearch, Alignment.MIDDLE_RIGHT);

    // Create the content for the popup
    final Label content = new Label(
            "<ul><li>&raquo; The default search operator is AND</li><li>&raquo; To search for a phrase place the text in double quotes</li></ul>",
            Label.CONTENT_RAW);
    // The PopupView popup will be as large as needed by the content
    content.setWidth("300px");

    // Construct the PopupView with simple HTML text representing the
    // minimized view
    final PopupView popup = new PopupView("?", content);
    popup.setHideOnMouseOut(true);
    popup.addListener(this);

    popup.addStyleName("paddingright10");
    hl.addComponent(popup);
    hl.setComponentAlignment(popup, Alignment.MIDDLE_RIGHT);
}