Example usage for com.vaadin.ui PopupView PopupView

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

Introduction

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

Prototype

public PopupView(final String small, final Component large) 

Source Link

Document

A simple way to create a PopupPanel.

Usage

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

License:Open Source License

/**
 * Creates a drop down menu.<p>//from   w  w w .jav a  2  s .  co m
 *
 * @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;
}

From source file:org.vaadin.tori.component.DebugControlPanel.java

License:Apache License

public DebugControlPanel(final DebugAuthorizationService authorizationService) {
    Page.getCurrent().getStyles()/* w  w w  . ja va  2 s . co  m*/
            .add(".v-popupview-popup { background: #fff; } .v-popupview-popup .v-widget { font-size: 12px; }");
    addStyleName("debugcontrolpanel");
    this.authorizationService = authorizationService;
    ToriNavigator.getCurrent().addViewChangeListener(new ViewChangeListener() {
        @Override
        public void afterViewChange(final ViewChangeEvent event) {
            currentView = event.getNewView();
        }

        @Override
        public boolean beforeViewChange(final ViewChangeEvent event) {
            return true;
        }
    });

    final PopupView popupButton = new PopupView("Debug Control Panel", new Panel());
    popupButton.setHideOnMouseOut(false);
    popupButton.addStyleName("v-button");
    popupButton.addPopupVisibilityListener(this);
    setCompositionRoot(popupButton);
    setSizeUndefined();
}

From source file:org.vaadin.tori.component.DebugControlPanel.java

License:Apache License

private Component createPostControl(final Method setter, final List<Post> posts) throws Exception {
    if (posts == null || posts.isEmpty()) {
        final Label label = new Label(getNameForCheckBox(setter));
        label.setEnabled(false);//w  w w . ja v a  2s. c  o m
        return label;
    }

    Component content = new CustomComponent() {
        {
            final CssLayout root = new CssLayout();
            root.addStyleName("postselect-content");
            root.addStyleName(setter.getName());
            setCompositionRoot(root);
            root.setWidth("100%");
            setWidth("400px");

            root.addComponent(new Label(setter.getName()));

            for (final Post post : posts) {
                final Method getter = getGetterFrom(setter);
                final boolean getterValue = (Boolean) getter.invoke(authorizationService, post.getId());

                final String authorName = post.getAuthor().getDisplayedName();

                String postBody = post.getBodyRaw();
                if (postBody.length() > 20) {
                    postBody = postBody.substring(0, 20);
                }

                final CheckBox checkbox = new CheckBox(authorName + " :: " + postBody);
                checkbox.setValue(getterValue);
                checkbox.addValueChangeListener(new PostCheckboxListener(post, setter));
                checkbox.setImmediate(true);
                checkbox.setWidth("100%");
                root.addComponent(checkbox);
            }
        }
    };
    final PopupView popup = new PopupView(getNameForCheckBox(setter), content);
    popup.setHideOnMouseOut(false);
    popup.setHeight(30.0f, Unit.PIXELS);
    return popup;
}

From source file:probe.com.view.body.quantcompare.PieChart.java

public PieChart(String title, double full, double found, final String notfound) {

    this.setWidth(200 + "px");
    this.setHeight(200 + "px");
    defaultKeyColorMap.put("Found", new Color(110, 177, 206));
    defaultKeyColorMap.put("Not found", new Color(219, 169, 1));
    otherSymbols.setGroupingSeparator('.');
    this.setStyleName("click");

    labels = new String[] { "Found", "Not found" };

    double foundPercent = ((found / full) * 100.0);
    df = new DecimalFormat("#.##", otherSymbols);
    valuesMap.put("Found", ((int) found) + " (" + df.format(foundPercent) + "%)");
    values = new Double[] { foundPercent, 100.0 - foundPercent };
    valuesMap.put("Not found", ((int) (full - found)) + " (" + df.format(100.0 - foundPercent) + "%)");

    String defaultImgURL = initPieChart(200, 200, title);
    chartImg.setSource(new ExternalResource(defaultImgURL));
    this.addComponent(chartImg);
    this.addLayoutClickListener(PieChart.this);

    popupLayout = new PopupView(null, popupBody);
    popupLayout.setHideOnMouseOut(false);
    popupBody.setWidth("300px");
    popupBody.setStyleName(Reindeer.LAYOUT_WHITE);
    popupBody.setHeightUndefined();// w w w . j a  v  a  2  s.c o  m
    this.addComponent(popupLayout);
    this.notfound = notfound.replace(" ", "").replace(",", "/n");

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setHeight("20px");

    Label header = new Label("<b>Not Found (New Proteins)</b>");
    header.setStyleName(Reindeer.LABEL_SMALL);
    topLayout.addComponent(header);
    header.setContentMode(ContentMode.HTML);

    VerticalLayout closeBtn = new VerticalLayout();
    closeBtn.setWidth("10px");
    closeBtn.setHeight("10px");
    closeBtn.setStyleName("closebtn");
    topLayout.addComponent(closeBtn);
    topLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT);
    closeBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            popupLayout.setPopupVisible(false);
        }
    });
    popupBody.addComponent(topLayout);
    popupBody.addComponent(textArea);
    textArea.setWidth("100%");
    textArea.setHeight("150px");
    textArea.setValue(this.notfound);
    textArea.setReadOnly(true);
    popupBody.setSpacing(true);

    HorizontalLayout bottomLayout = new HorizontalLayout();
    bottomLayout.setWidth("100%");
    bottomLayout.setHeight("40px");
    bottomLayout.setMargin(new MarginInfo(false, true, true, true));
    popupBody.addComponent(bottomLayout);

    Button exportTableBtn = new Button("");
    exportTableBtn.setHeight("24px");
    exportTableBtn.setWidth("24px");
    exportTableBtn.setPrimaryStyleName("exportxslbtn");
    exportTableBtn.setDescription("Export table data");
    exportTableBtn.addClickListener(new Button.ClickListener() {

        private Table table;

        @Override
        public void buttonClick(Button.ClickEvent event) {

            if (table == null) {
                table = new Table();
                table.addContainerProperty("Index", Integer.class, null, "", null, Table.Align.RIGHT);
                table.addContainerProperty("Accession", String.class, Table.Align.CENTER);
                table.setVisible(false);
                addComponent(table);
                int i = 1;
                for (String str : notfound.replace(" ", "").replace(",", "\n").split("\n")) {
                    table.addItem(new Object[] { i, str }, i++);
                }

            }

            ExcelExport csvExport = new ExcelExport(table, "Not found protein accessions (New proteins)");
            //                csvExport.setReportTitle("CSF-PR /  Not found protein accessions (New proteins) ");
            csvExport.setExportFileName("CSF-PR - Not found protein accessions" + ".xls");
            csvExport.setMimeType(CsvExport.EXCEL_MIME_TYPE);
            csvExport.setDisplayTotals(false);
            csvExport.setExcelFormatOfProperty("Index", "#0;[Red] #0");
            csvExport.export();

        }
    });

    bottomLayout.addComponent(exportTableBtn);
    bottomLayout.setComponentAlignment(exportTableBtn, Alignment.MIDDLE_RIGHT);

}

From source file:probe.com.view.core.InfoPopupBtn.java

public InfoPopupBtn(String infoText) {
    HorizontalLayout topLayout = new HorizontalLayout();
    VerticalLayout mainBody = new VerticalLayout();
    mainBody.setWidth("450px");
    mainBody.addComponent(topLayout);//ww w.ja  va2  s .  co m
    Label infoHeaderLabel = new Label(
            "<h3 style='font-family:verdana;color:black;font-weight:bold;margin-left:20px;margin-right:20px;'>Information</h3>");
    infoHeaderLabel.setContentMode(ContentMode.HTML);
    topLayout.addComponent(infoHeaderLabel);
    topLayout.setWidth("100%");
    Label infoLable = new Label(
            "<div style='text-align:justify;text-justify:inter-word;'><p  style='line-height:60px; font-family:verdana;color:black;margin-left:20px;margin-right:20px;'>"
                    + infoText + "</p></div>");
    infoLable.setContentMode(ContentMode.HTML);
    infoLable.setWidth("450px");
    mainBody.addComponent(infoLable);
    popupBodyLayout.addComponent(mainBody);
    mainBody.setStyleName("popupmainbody");
    VerticalLayout closeBtn = new VerticalLayout();
    closeBtn.setWidth("16px");
    closeBtn.setHeight("16px");
    closeBtn.setStyleName("defaultclosebtn");
    topLayout.addComponent(closeBtn);
    topLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT);
    popupLayout = new PopupView("", popupBodyLayout);
    this.setStyleName("infoicon");
    this.setWidth("16px");
    this.setHeight("16px");
    this.setDescription("Information");
    this.addLayoutClickListener(InfoPopupBtn.this);
    this.addComponent(popupLayout);
    this.popupLayout.setHideOnMouseOut(false);

    closeBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            popupLayout.setPopupVisible(false);
        }
    });

}

From source file:probe.com.view.core.NotificationComponent.java

public NotificationComponent(String text, String uniqueID) {

    this.uniqueID = uniqueID;
    popupBody = new VerticalLayout();
    popupBody.setWidthUndefined();//setWidth((200) + "px");
    popupBody.setHeightUndefined();//setHeight((200) + "px");
    popupBody.setStyleName("notificationbody");
    popupBody.addLayoutClickListener(NotificationComponent.this);
    popup = new PopupView(null, popupBody) {

        @Override/*from  w  ww  .j a  va  2s. com*/
        public void setPopupVisible(boolean visible) {
            super.setPopupVisible(visible); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public boolean isPopupVisible() {
            return super.isPopupVisible(); //To change body of generated methods, choose Tools | Templates.
        }

    };
    this.addComponent(popup);

    //        popupWindow = new Window() {
    //
    //            @Override
    //            public void close() {
    //                popupWindow.setVisible(false);
    //            }
    //
    //        };
    //
    //        popupWindow.setStyleName("notificationwindow");
    //        popupWindow.setCaption(null);
    //        popupWindow.setContent(popupBody);
    //        popupWindow.setWindowMode(WindowMode.NORMAL);
    //        popupWindow.setWidthUndefined();//.setWidth((200) + "px");
    //        popupWindow.setHeightUndefined();//setHeight((200) + "px");
    //        popupWindow.setVisible(false);
    //        popupWindow.setResizable(false);
    //        popupWindow.setClosable(false);
    //        popupWindow.setModal(false);
    //        popupWindow.setDraggable(false);
    //        popupWindow.setModal(false);
    //
    //        UI.getCurrent().addWindow(popupWindow);
    //        popupWindow.setPositionX(x);
    //        popupWindow.setPositionY(y);
    //
    //        popupWindow.setCaptionAsHtml(true);
    //        popupWindow.setClosable(false);
    popupBody.setMargin(true);
    popupBody.setSpacing(true);

    Label content = new Label("<center>" + text + "</center>");
    content.setStyleName("notificationtext");
    content.setContentMode(ContentMode.HTML);
    popupBody.addComponent(content);

    VerticalLayout footer = new VerticalLayout();
    footer.setStyleName("bubbletalkfooter");
    footer.setWidth("30px");
    footer.setHeight("20px");
    popupBody.addComponent(footer);
    popup.setHideOnMouseOut(false);
    popup.setStyleName("popupnotification");
    popupBody.addStyleName("slowinvisible");

}

From source file:probe.com.view.core.PopupInfoBtn.java

public PopupInfoBtn(VerticalLayout pupupLayout, String btnName, String publicationAuthor) {
    this.addLayoutClickListener(PopupInfoBtn.this);
    this.setHeight("80px");
    this.setWidth("200px");
    Label btnLabel = new Label(btnName);
    btnLabel.setContentMode(ContentMode.HTML);
    this.addComponent(btnLabel);
    this.setComponentAlignment(btnLabel, Alignment.MIDDLE_CENTER);
    this.setStyleName("tabbtn");

    //add popup for testing 
    VerticalLayout infoPopup = initPopupLayout(pupupLayout, publicationAuthor);
    pupupPanel = new PopupView(null, infoPopup);
    pupupPanel.setWidth("2px");
    pupupPanel.setHeight("2px");
    this.addComponent(pupupPanel);
    this.setComponentAlignment(pupupPanel, Alignment.BOTTOM_RIGHT);
    pupupPanel.setVisible(true);/*from  w  w  w .j av  a 2s .c o  m*/
    pupupPanel.setPopupVisible(false);
    pupupPanel.setHideOnMouseOut(false);

    this.setExpandRatio(btnLabel, 0.99f);
    this.setExpandRatio(pupupPanel, 0.01f);

}

From source file:ro.jtonic.handson.HandsonVaadinApplication.java

License:Apache License

private void setupEvents() {
    btn.addClickListener(new Button.ClickListener() {
        @Override/*from ww  w . j  av a  2 s.c  om*/
        public void buttonClick(Button.ClickEvent clickEvent) {
            sel1.setEnabled(false);
            VerticalLayout vl = new VerticalLayout();
            final Label fNameLbl = new Label("First name: ");
            final Label lNameLbl = new Label("Last name: ");
            vl.addComponents(fNameLbl, lNameLbl);

            PopupView view = new PopupView("Pop it up!!!", fNameLbl);
            ((AbstractLayout) HandsonVaadinApplication.this.p.getContent()).addComponent(view);
            view.setVisible(true);
        }
    });

    tree.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            System.err.println("Selected value: " + event.getProperty().getValue());
        }
    });

    tree.addExpandListener(new Tree.ExpandListener() {
        @Override
        public void nodeExpand(Tree.ExpandEvent event) {
            final Object selectedObj = event.getItemId();
            System.out.println("selectedObj = " + selectedObj);

            if (selectedObj instanceof Visitable) {
                Visitable visitable = (Visitable) selectedObj;
                if (visitable.isVisited()) {
                    System.out.println(String.format("The node %s was already visited.", selectedObj));
                    return;
                }
                if (selectedObj instanceof PmcVo) {
                    final long crtTime = System.currentTimeMillis();
                    final PmcVo.PmcyVo pmcyVo1 = new PmcVo.PmcyVo("PmcyVo1_" + crtTime, "2014 " + crtTime);
                    tree.addItem(pmcyVo1);
                    tree.setChildrenAllowed(pmcyVo1, true);
                    tree.setParent(pmcyVo1, selectedObj);

                    final PmcVo.PmcyVo pmcyVo2 = new PmcVo.PmcyVo("Pmcy2Vo_" + crtTime, "2015 " + crtTime);
                    tree.setChildrenAllowed(pmcyVo2, true);
                    tree.addItem(pmcyVo2);
                    tree.setParent(pmcyVo2, selectedObj);
                } else if (selectedObj instanceof PmcVo.PmcyVo) {
                    final PmcVo.PmVo pmVo1 = new PmcVo.PmVo("PmVo1_" + System.currentTimeMillis(),
                            "PmVo1_" + System.currentTimeMillis());
                    tree.setChildrenAllowed(pmVo1, false);
                    tree.addItem(pmVo1);
                    tree.setParent(pmVo1, selectedObj);

                    final PmcVo.PmVo pmVo2 = new PmcVo.PmVo("PmVo2_" + System.currentTimeMillis(),
                            "PmVo2_" + System.currentTimeMillis());
                    tree.setChildrenAllowed(pmVo2, false);
                    tree.addItem(pmVo2);
                    tree.setParent(pmVo2, selectedObj);
                }
                visitable.setVisited(true);
            }
        }
    });
}