Example usage for com.vaadin.ui PopupView setVisible

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

Introduction

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

Prototype

@Override
    public void setVisible(boolean visible) 

Source Link

Usage

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

License:Apache License

private void setupEvents() {
    btn.addClickListener(new Button.ClickListener() {
        @Override//from   w w w .j ava 2 s  .  com
        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);
            }
        }
    });
}