Example usage for com.vaadin.ui PopupView setHideOnMouseOut

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

Introduction

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

Prototype

public void setHideOnMouseOut(boolean hideOnMouseOut) 

Source Link

Document

Should the popup automatically hide when the user takes the mouse cursor out of the popup area?

Usage

From source file:com.cavisson.gui.dashboard.components.controls.PopupViews.java

License:Apache License

public PopupViews() {
    setMargin(true);//from ww  w.j  av  a  2 s.co m

    Label h1 = new Label("Popup Views");
    h1.addStyleName("h1");
    addComponent(h1);

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

    PopupView pv = new PopupView(new Content() {
        @Override
        public Component getPopupComponent() {
            return new VerticalLayout() {
                {
                    setMargin(true);
                    setWidth("300px");
                    addComponent(new Label(
                            "Fictum,  deserunt mollit anim laborum astutumque! Magna pars studiorum, prodita quaerimus."));
                }
            };
        }

        @Override
        public String getMinimizedValueAsHTML() {
            return "Click to view";
        }
    });
    row.addComponent(pv);
    pv.setHideOnMouseOut(true);
    pv.setCaption("Hide on mouse-out");

    pv = new PopupView(new Content() {
        int count = 0;

        @Override
        public Component getPopupComponent() {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {

            }
            return new VerticalLayout() {
                {
                    setMargin(true);
                    addComponent(new Label("<h3>Thanks for waiting!</h3><p>You've opened this popup <b>"
                            + ++count + " time" + (count > 1 ? "s" : " only") + "</b>.</p>", ContentMode.HTML));
                }
            };
        }

        @Override
        public String getMinimizedValueAsHTML() {
            return "Show slow loading content";
        }
    });
    row.addComponent(pv);
    pv.setHideOnMouseOut(false);
    pv.setCaption("Hide on click-outside");
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultCompoundSearchView.java

License:Apache License

@Override
public void initialize(TableColumns fields) {
    this.fields = fields;
    searchBox = new SearchBox(this);
    searchBox.setWidth("100%");
    searchBox.setOptionHandler(new SearchOptionsHandler(fields));
    searchBox.focus();/*from  w  ww .  ja v a2s  .  c om*/
    searchBox.setInputPrompt(getMessage("portlet.crud.compoundsearch.inputPrompt"));

    Button resetButton = new Button(getMessage("portlet.crud.compoundsearch.reset"));
    resetButton.setStyleName(LiferayTheme.BUTTON_LINK);
    resetButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            presenter.reset();
        }
    });

    PopupView infoButton = new PopupView(new Content() {
        @Override
        public String getMinimizedValueAsHTML() {
            return "?";
        }

        @Override
        public Component getPopupComponent() {
            return createSearchInfo();
        }
    });
    infoButton.setHideOnMouseOut(false);

    searchBar = new HorizontalLayout(searchBox, resetButton, infoButton);
    searchBar.setWidth("100%");
    searchBar.addStyleName("compsearchbar");
    searchBar.setExpandRatio(searchBox, 1);
    searchBar.setSpacing(true);
    searchBar.setComponentAlignment(resetButton, Alignment.MIDDLE_CENTER);
    searchBar.setComponentAlignment(infoButton, Alignment.MIDDLE_CENTER);

    addComponent(searchBar);
}

From source file:edu.kit.dama.ui.repo.MyVaadinUI.java

License:Apache License

/**
 * Build the search view and execute the provided query immediately.
 *
 * @param pQuery The query to execute or null if an empty view should be
 * shown.// ww w .ja  v  a2 s . co  m
 */
private void buildSearchView(String pQuery) {
    loginButton.setWidth("70px");
    loginButton.setStyleName(BaseTheme.BUTTON_LINK);
    logoutButton.setWidth("70px");
    logoutButton.setStyleName(BaseTheme.BUTTON_LINK);
    adminButton.setWidth("70px");
    adminButton.setStyleName(BaseTheme.BUTTON_LINK);

    logoutButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            loggedInUser = UserData.NO_USER;
            refreshMainLayout();
        }
    });

    adminButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Page.getCurrent()
                    .open(DataManagerSettings.getSingleton().getStringProperty(
                            DataManagerSettings.GENERAL_BASE_URL_ID, "http://localhost:8889/BaReDemo")
                            + "/admin", "_blank");
        }
    });

    searchField = UIUtils7.factoryTextField(null, "Search for...");
    searchField.setWidth("920px");
    searchField.setHeight("60px");
    searchField.addStyleName("searchField");

    paginationPanel = new PaginationPanel(this);
    paginationPanel.setSizeFull();
    paginationPanel.setAllEntries(new LinkedList<DigitalObjectId>());

    searchProvider = new FulltextElasticSearchProvider(
            DataManagerSettings.getSingleton()
                    .getStringProperty(DataManagerSettings.ELASTIC_SEARCH_DEFAULT_CLUSTER_ID, "KITDataManager"),
            DataManagerSettings.getSingleton()
                    .getStringProperty(DataManagerSettings.ELASTIC_SEARCH_DEFAULT_HOST_ID, "localhost"),
            DataManagerSettings.getSingleton().getStringProperty(
                    DataManagerSettings.ELASTIC_SEARCH_DEFAULT_INDEX_ID,
                    ElasticsearchHelper.ELASTICSEARCH_TYPE),
            ElasticsearchHelper.ELASTICSEARCH_TYPE);
    NativeButton goButton = new NativeButton();
    goButton.setIcon(new ThemeResource("img/24x24/search.png"));
    goButton.setWidth("60px");
    goButton.setHeight("60px");
    goButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            doSearch();
        }
    });
    goButton.setClickShortcut(KeyCode.ENTER);

    setupLoginForm();
    loginForm.setWidth("320px");
    loginForm.setHeight("150px");
    final PopupView loginPopup = new PopupView(null, loginForm);
    loginPopup.setHideOnMouseOut(false);
    loginButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //mainLayout.replaceComponent(searchLayout, loginForm);
            loginPopup.setPopupVisible(true);
        }
    });

    Label filler = new Label();
    memberLayout = new HorizontalLayout(filler, adminButton, loginButton, loginPopup);
    memberLayout.setComponentAlignment(loginButton, Alignment.TOP_RIGHT);
    memberLayout.setComponentAlignment(adminButton, Alignment.TOP_RIGHT);
    memberLayout.setComponentAlignment(loginPopup, Alignment.TOP_RIGHT);

    memberLayout.setExpandRatio(filler, 1.0f);
    memberLayout.setMargin(false);
    memberLayout.setSpacing(false);
    memberLayout.setWidth("100%");
    memberLayout.setHeight("30px");

    Label spacer = new Label("<hr/>", ContentMode.HTML);
    spacer.setHeight("20px");

    searchLayout = new UIUtils7.GridLayoutBuilder(3, 4)
            .addComponent(searchField, Alignment.TOP_LEFT, 0, 0, 2, 1)
            .addComponent(goButton, Alignment.TOP_RIGHT, 2, 0, 1, 1).fillRow(spacer, 0, 1, 1)
            .addComponent(paginationPanel, Alignment.MIDDLE_CENTER, 0, 2, 3, 2).getLayout();
    searchLayout.addStyleName("paper");
    searchLayout.setSpacing(true);
    searchLayout.setMargin(true);
    paginationPanel.setWidth("980px");
    //wrapper
    Label icon8Link = new Label("<a href=\"http://icons8.com\">Icons by icon8.com</a>", ContentMode.HTML);
    mainLayout = new VerticalLayout(memberLayout, searchLayout, icon8Link);
    mainLayout.setComponentAlignment(memberLayout, Alignment.TOP_CENTER);
    mainLayout.setComponentAlignment(searchLayout, Alignment.TOP_CENTER);
    mainLayout.setComponentAlignment(icon8Link, Alignment.BOTTOM_RIGHT);
    mainLayout.setExpandRatio(memberLayout, .05f);
    mainLayout.setExpandRatio(searchLayout, .93f);
    mainLayout.setExpandRatio(icon8Link, .02f);

    VerticalLayout fullscreen = new VerticalLayout(mainLayout);
    fullscreen.setComponentAlignment(mainLayout, Alignment.TOP_CENTER);
    fullscreen.setSizeFull();
    setContent(fullscreen);

    mainLayout.setWidth("1024px");
    mainLayout.setHeight("768px");

    if (pQuery != null) {
        searchField.setValue(pQuery);
        doSearch();
    }
}

From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java

License:Open Source License

@SuppressWarnings({ "unchecked", "serial" })
private void showViewOrDelete(final DeleteListener lis) {
    dialog = new Window("View / Delete VIPs");
    dialog.setModal(true);//from www. ja va2 s  .  com

    VerticalLayout layout = new VerticalLayout();
    dialog.setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();

    List<VipPii> vLis = VHibPii.getAllVips();

    vipListSelect = new ListSelect("Select items to delete");
    StringBuffer sb = new StringBuffer(); // for popup
    vipListSelect.addStyleName("m-greyborder");
    String lf = System.getProperty("line.separator");
    for (int i = 0; i < vLis.size(); i++) {
        VipPii v;
        vipListSelect.addItem(v = vLis.get(i));
        sb.append(v.getEntry());
        sb.append(lf);
    }
    if (sb.length() > 0)
        sb.setLength(sb.length() - 1); // last space

    vipListSelect.setNullSelectionAllowed(true);
    vipListSelect.setMultiSelect(true);
    vipListSelect.setImmediate(true);
    vipListSelect.addValueChangeListener(new VipSelectListener());

    layout.addComponent(vipListSelect);

    Label copyPopupList = new HtmlLabel("<pre>" + sb.toString() + "</pre>");
    Panel p = new Panel();
    VerticalLayout lay = new VerticalLayout();
    p.setContent(lay);
    lay.addComponent(copyPopupList);
    p.setWidth("400px");
    p.setHeight("300px");
    PopupView popup = new PopupView("Display list as copyable text", p);
    popup.setHideOnMouseOut(false);
    if (sb.length() <= 0)
        popup.setEnabled(false);

    layout.addComponent(popup);
    layout.setComponentAlignment(popup, Alignment.MIDDLE_CENTER);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    Button cancelButt = new Button("Cancel", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();
            lis.continueOrCancel(null);
        }
    });

    deleteButt = new Button("Delete & Close", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Set<VipPii> set = (Set<VipPii>) vipListSelect.getValue();
            if (set.size() <= 0)
                set = null;
            dialog.close();
            lis.continueOrCancel(set);
        }
    });
    deleteButt.setEnabled(false);
    hl.addComponent(cancelButt);
    hl.addComponent(deleteButt);
    hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT);
    hl.setExpandRatio(cancelButt, 1.0f);

    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(hl);
    dialog.setWidth("300px");
    dialog.setHeight("350px");
    hl.setWidth("100%");
    vipListSelect.setWidth("99%");
    vipListSelect.setHeight("99%");
    layout.setExpandRatio(vipListSelect, 1.0f);

    UI.getCurrent().addWindow(dialog);
    dialog.center();
}

From source file:helpers.Utils.java

License:Open Source License

public static HorizontalLayout questionize(Component c, final String info, final String header) {
    final HorizontalLayout res = new HorizontalLayout();
    res.setSpacing(true);/*  ww  w  .  j a v a  2 s .c o m*/
    if (c instanceof CustomVisibilityComponent) {
        CustomVisibilityComponent custom = (CustomVisibilityComponent) c;
        c = custom.getInnerComponent();
        custom.addListener(new VisibilityChangeListener() {

            @Override
            public void setVisible(boolean b) {
                res.setVisible(b);
            }
        });
    }

    res.setVisible(c.isVisible());
    res.setCaption(c.getCaption());
    c.setCaption(null);
    res.addComponent(c);

    PopupView pv = new PopupView(new Content() {

        @Override
        public Component getPopupComponent() {
            Label l = new Label(info, ContentMode.HTML);
            l.setCaption(header);
            l.setIcon(FontAwesome.INFO);
            l.setWidth("250px");
            l.addStyleName("info");
            return new VerticalLayout(l);
        }

        @Override
        public String getMinimizedValueAsHTML() {
            return "[?]";
        }
    });
    pv.setHideOnMouseOut(false);

    res.addComponent(pv);

    return res;
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ProjectMavenBox.java

License:Open Source License

@Override
public Component getContent(Project project, ExtensionUtil util) {
    Layout layout = new CssLayout();
    layout.addStyleName(STYLE_MAVEN_INFOBOX);
    layout.setSizeFull();//from w  w  w  . j  av a 2s.co  m

    boolean rendered = false;
    String groupId = null;
    MavenReactorProjectExt reactorExt = project.getExtension(MavenReactorProjectExt.class);
    if (reactorExt != null) {
        MavenReactor mavenReactor = reactorExt.getMavenReactor();
        if (mavenReactor != null) {
            MavenCoordinate coordinate = mavenReactor.getCoordinate();
            groupId = coordinate.getGroupId();
            createLabel(layout, "GroupId: <b>" + groupId + "</b>");//$NON-NLS-1$ //$NON-NLS-2$
            createLabel(layout, "ArtifactId: <b>" + coordinate.getArtefactId() + "</b>");//$NON-NLS-1$ //$NON-NLS-2$
            TreeSet<MavenModule> modules = mavenReactor.getModules();
            StringBuilder sb = new StringBuilder();

            if (modules.size() > 0) {
                int lineLength = 0;
                for (MavenModule module : modules) {
                    //create popup with xml snippet
                    sb.append("<dependency>\n");
                    sb.append("    <artifactId>" + module.getArtefactId() + "</artifactId>\n");
                    sb.append("    <groupId>" + module.getGroupId() + "</groupId>\n");
                    String latestVersion = module.getLatestVersion();
                    if (StringUtils.isNotBlank(latestVersion)) {
                        sb.append("    <version>" + latestVersion + "</version>\n");
                    } else {
                        sb.append("    <!--<version>0.0.0</version>-->\n");
                    }
                    String packaging = module.getPackaging();
                    if (StringUtils.isNotBlank(packaging)) {
                        sb.append("    <type>" + packaging + "</type>\n");
                    }
                    sb.append("</dependency>\n");
                    lineLength = calculateLineLength(module, lineLength);
                }

                final Label label = new Label(sb.toString(), Label.CONTENT_PREFORMATTED);
                //add a buffer 10, as we didn't calculate the length of surrounding strings.
                label.setWidth(lineLength + 10, Sizeable.UNITS_EM);

                PopupView.Content content = new PopupView.Content() {
                    private static final long serialVersionUID = -8362267064485433525L;

                    @Override
                    public String getMinimizedValueAsHTML() {
                        return "Modules";
                    }

                    @Override
                    public Component getPopupComponent() {
                        return label;
                    }
                };

                PopupView popup = new PopupView(content);
                popup.setHideOnMouseOut(false);
                popup.addStyleName(STYLE_MODULE_POPUP);
                layout.addComponent(popup);
            }
            rendered = true;
        }
    }
    MavenProjectExt mavenExt = project.getExtension(MavenProjectExt.class);
    if (mavenExt != null) {
        if (groupId == null) {
            groupId = mavenExt.getGroupID();
            if (StringUtils.isNotBlank(groupId)) {
                createLabel(layout, "GroupId: <b>&nbsp;" + groupId + "</b>");//$NON-NLS-1$ //$NON-NLS-2$
                rendered = true;
            }
        }
        DevInfProjectExt devInf = project.getExtension(DevInfProjectExt.class);
        if (devInf != null) {
            String reactorPomUrl = getReactorPomUrl(project, devInf, mavenExt);
            if (reactorPomUrl == null) {
                String reactorPomPath = mavenExt.getReactorPOM();
                String caption = MessageFormat.format("Reactor POM Path: {0} (relative to SCM root location)",
                        StringUtils.isNotBlank(reactorPomPath) ? reactorPomPath : "/");
                createLabel(layout, caption);
            } else {
                createLink(layout, "Reactor POM", reactorPomUrl);
            }
            rendered = true;
        }
        if (StringUtils.isNotBlank(mavenExt.getSiteUrl())) {
            createLink(layout, "Project Site", mavenExt.getSiteUrl());
            rendered = true;
        }
    }
    if (!rendered) {
        createLabel(layout, "Maven extension added but no data maintained.");
    }
    return layout;
}

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);
    popup.addListener(new PopupVisibilityListener() {
        @Override//from w w w  .  ja va  2  s.  co m
        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  www  .  j a v  a2s  .  com*/
    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);
}

From source file:org.ikasan.dashboard.ui.dashboard.panel.DashboardPanel.java

License:BSD License

@Subscribe
public void receiveAlertEvent(final AlertEvent event) {
    UI.getCurrent().access(new Runnable() {
        @Override/*from   ww w.ja  va  2s  .  c o m*/
        public void run() {
            VaadinSession.getCurrent().getLockInstance().lock();
            try {
                Item item = container.addItemAt(0, event.getAlert() + this);

                Property<String> alertProperty = item.getItemProperty("Alert");

                alertProperty.setValue(event.getAlert());

                final Property<String> moduleProperty = item.getItemProperty("Module");

                moduleProperty.setValue(event.getModule());

                TextArea notesField = new TextArea("Notes");
                notesField.setWidth("500px");
                notesField.setRequired(false);
                notesField.setHeight("150px");
                notesField.setImmediate(true);
                notesField.setStyleName("coursedetailtext");
                // popup notes view
                final PopupView notesPopupView = new PopupView("Details", notesField);
                notesPopupView.setCaption("Details");
                notesPopupView.setHideOnMouseOut(false);
                notesPopupView.setData(event.getAlert() + this);

                final Property<PopupView> detailsProperty = item.getItemProperty("Details");

                detailsProperty.setValue(notesPopupView);

                System.out.println("container = " + container);
                System.out.println("Item = " + item);
            } finally {
                VaadinSession.getCurrent().getLockInstance().unlock();
            }

            //               UI.getCurrent().push();   
        }
    });
}

From source file:org.opencms.ui.components.CmsToolBar.java

License:Open Source License

/**
 * Creates a drop down menu.<p>/*  ww w .j a  v  a  2 s .com*/
 *
 * @param buttonHtml the button HTML
 * @param content the drop down content
 * @param title the button title
 *
 * @return the component
 */
public static Component createDropDown(String buttonHtml, Component content, String title) {

    PopupView pv = new PopupView(buttonHtml, content);
    pv.setDescription(title);
    pv.addStyleName(OpenCmsTheme.NAVIGATOR_DROPDOWN);
    pv.setHideOnMouseOut(false);
    return pv;
}