Example usage for com.vaadin.ui Window center

List of usage examples for com.vaadin.ui Window center

Introduction

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

Prototype

public void center() 

Source Link

Document

Sets this window to be centered relative to its parent window.

Usage

From source file:edu.nps.moves.mmowgli.modules.gamemaster.AddAuthorEventHandler.java

License:Open Source License

@SuppressWarnings("serial")
public static void inviteAuthorsToActionPlan() {
    final Window win = new Window("Choose Action Plan");
    win.setWidth("600px");
    win.setHeight("500px");

    VerticalLayout layout = new VerticalLayout();
    win.setContent(layout);//ww w.jav a 2s . com
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();

    final ActionPlanTable apt = new ActionPlanTable() {
        @Override
        public ItemClickListener getItemClickListener() {
            return new ItemClickListener() {
                public void itemClick(ItemClickEvent event) {
                }
            }; // null listener
        }
    };
    apt.setMultiSelect(false);
    apt.setPageLength(10);
    apt.setSizeFull();
    layout.addComponent(apt);
    layout.setExpandRatio(apt, 1.0f);

    HorizontalLayout buttHL = new HorizontalLayout();
    layout.addComponent(buttHL);
    buttHL.setWidth("100%");
    buttHL.setSpacing(true);
    Label sp;
    buttHL.addComponent(sp = new Label());
    sp.setWidth("1px");
    buttHL.setExpandRatio(sp, 1.0f);

    Button selectButton = new Button("Select");
    buttHL.addComponent(selectButton);
    Button cancelButton = new Button("Cancel");
    buttHL.addComponent(cancelButton);

    UI.getCurrent().addWindow(win);
    win.center();

    selectButton.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            win.close();
            Object o = apt.getValue();
            if (o != null) {
                HSess.init();
                inviteAuthorsToActionPlanTL(o);
                HSess.close();
            }
        }
    });
    cancelButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            win.close();
        }
    });
}

From source file:edu.nps.moves.mmowgli.modules.gamemaster.UserAdminPanel.java

License:Open Source License

@SuppressWarnings("serial")
Table createTable(TableFiller filler) {/*from  w ww.j ava2s  .c  o m*/
    final Table tab = new Table();
    tab.setStyleName("m-useradmintable");
    tab.setWidth("920px");
    tab.setHeight("100%");
    tab.setPageLength(40);

    // Special column renderers
    Table.ColumnGenerator colGen = new columnCustomizer();
    tab.addGeneratedColumn(USER_ID_COL, colGen);
    tab.addGeneratedColumn(ADMIN_COL, colGen);
    tab.addGeneratedColumn(DESIGNER_COL, colGen);
    tab.addGeneratedColumn(LOCKEDOUT_COL, colGen);
    tab.addGeneratedColumn(TWEETER_COL, colGen);
    tab.addGeneratedColumn(GAMEMASTER_COL, colGen);
    tab.addGeneratedColumn(EMAIL_COL, colGen);
    tab.addGeneratedColumn(CONFIRMED_COL, colGen);

    filler.fillTable(tab);

    tab.setColumnWidth(USER_ID_COL, 25);
    tab.setColumnWidth(ADMIN_COL, 25);
    tab.setColumnWidth(GAMEMASTER_COL, 25);
    tab.setColumnWidth(DESIGNER_COL, 25);
    tab.setColumnWidth(LOCKEDOUT_COL, 43);
    tab.setColumnWidth(TWEETER_COL, 50);
    tab.setColumnWidth(UNAME_COL, 120);
    tab.setColumnWidth(FIRSTNAME_COL, 108); //128);
    tab.setColumnWidth(LASTNAME_COL, 108); //128);
    tab.setColumnWidth(EMAIL_COL, 190);
    tab.setColumnWidth(CONFIRMED_COL, 67);

    tab.setEditable(false);
    tab.setSelectable(true);
    tab.setImmediate(true); // to immed update view
    tab.setNullSelectionAllowed(false); // can't deselect a row

    tab.addItemClickListener(new ItemClickListener() {
        EditPanel ep;

        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        @HibernateUserRead
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                HSess.init();
                Window w = new Window("Edit Player Account");
                w.setWidth("620px");
                w.setHeight("505px");
                w.setModal(true);

                @SuppressWarnings({ "unchecked" })
                final QuickUser qu = (QuickUser) ((BeanItem<QuickUser>) event.getItem()).getBean();
                User u = User.getTL(qu.getId());
                if (u == null) {
                    // This has been happening infrequently...some error on signup where (maybe) a user object gets created
                    // but doesn't make it into the db.
                    Notification.show("Woops, database error!",
                            "A player account identified by id = " + qu.getId() + " is not in the database.",
                            Notification.Type.ERROR_MESSAGE);
                    HSess.close();
                    return;
                }
                VerticalLayout vl = new VerticalLayout();
                w.setContent(vl);
                vl.addComponent(ep = new EditPanel(w, qu.getId()));
                ep.setWidth("100%");
                UI.getCurrent().addWindow(w);
                w.center();

                w.addCloseListener(new CloseListener() {
                    @Override
                    public void windowClose(CloseEvent e) {
                        if (ep.user != null) {
                            BeanItem<QuickUser> bi = lastTableFiller.getContainer().getItem(ep.user.getId());
                            QuickUser qu = bi.getBean();
                            qu.update(ep.user);
                            tab.refreshRowCache();
                        }
                    }
                });
                HSess.close();
            }
        }
    });
    return tab;
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.PasswordResetPopup.java

License:Open Source License

private void makeResetAnnounceDialogTL_5(String email, ArrayList<User> aLis) {
    UI myUI = getUI();// w  ww. j ava2  s  .co m
    myUI.removeWindow(PasswordResetPopup.this);

    final Window resetAnnounceDialog = new Window("Password Reset Announcement");
    resetAnnounceDialog.setModal(true);
    resetAnnounceDialog.setClosable(false);
    VerticalLayout vLay = new VerticalLayout();
    resetAnnounceDialog.setContent(vLay);
    vLay.setMargin(true);
    vLay.setSpacing(true);
    vLay.setSizeUndefined();
    vLay.setWidth("400px");

    Label message = new HtmlLabel("An email has been sent to <b>" + email + "</b>.");
    vLay.addComponent(message);

    message = new Label(
            "Follow the link in the message to confirm your password reset request to enable login to your mmowgli player account.");
    vLay.addComponent(message);

    message = new Label(
            "Please be advised that you will only have three hours to complete this process, after which time "
                    + "you will have to re-initiate a new password reset process from the game login page.");
    vLay.addComponent(message);

    message = new HtmlLabel(
            "Now, press <b>Homepage -- Return to login</b> after receiving a reset request confirmation email.");
    vLay.addComponent(message);

    @SuppressWarnings("serial")
    Button laterButt = new Button("Homepage -- Return to login", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            HSess.init();
            Mmowgli2UI.getAppUI().quitAndGoTo(GameLinks.getTL().getGameHomeUrl());
            HSess.close();
        }
    });
    vLay.addComponent(laterButt);

    @SuppressWarnings("serial")
    Button troubleButt = new Button("Send trouble report", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            HSess.init();
            Mmowgli2UI.getAppUI().quitAndGoTo(GameLinks.getTL().getTroubleLink());
            HSess.close();
        }
    });
    vLay.addComponent(troubleButt);

    myUI.addWindow(resetAnnounceDialog);
    resetAnnounceDialog.center();

    // This process generates unique uId for th3 reset process that will
    // need to be confirmed once the user receives a confirmation email and
    // click on the link containing the uId
    Iterator<User> itr = aLis.iterator();
    // sends email to all user accounts (which are at the same email address)
    // if a game name was entered, only that account receives the email
    while (itr.hasNext()) {
        User usr = itr.next();
        PasswordReset pr = new PasswordReset(usr);
        PasswordReset.saveTL(pr);

        String confirmUrl = buildConfirmUrl(pr);
        AppMaster.instance().getMailManager().sendPasswordResetEmailTL(email, usr.getUserName(), confirmUrl);
    }
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageBase.java

License:Open Source License

@SuppressWarnings("serial")
public static void openPopupWindow(final UI browserWindow, Window popup, int topOffset) {
    popup.setModal(true);/* w  ww .  j  a va  2  s  .  co m*/
    browserWindow.addWindow(popup);
    popup.center();
    browserWindow.setScrollTop(topOffset);

    popup.addCloseListener(new CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            browserWindow.setScrollTop(0);
        }
    });
}

From source file:eu.lod2.stat.StatLOD2Demo.java

License:Apache License

/**
 * A function to get an ontowiki export command
 * @param format - the formating string defining the format to export in
 *///from   w  w w  .j a  v a2s . co m
private MenuBar.Command getOWExportCommand(final String format) {
    return new MenuBar.Command() {
        public void menuSelected(final MenuItem selectedItem) {
            String currentGraph = state.getCurrentGraph();
            if (currentGraph == null || currentGraph.isEmpty()) {
                final Window window = new Window("No graph selected");
                window.setWidth("550px");
                LOD2DemoState.CurrentGraphListener listener = new LOD2DemoState.CurrentGraphListener() {
                    boolean ignoreFirst = true;

                    public void notifyCurrentGraphChange(String graph) {
                        if (ignoreFirst) {
                            ignoreFirst = false;
                            return;
                        }
                        window.getParent().removeWindow(window);
                        menuSelected(selectedItem);
                        state.removeCurrentGraphListener(this);
                    }
                };
                VerticalLayout layout = (VerticalLayout) window.getContent();
                layout.addComponent(new Label(
                        "You did not specify a graph to work with. Please do so below and try again: "));
                ConfigurationTab configure = new ConfigurationTab(state);
                layout.addComponent(configure);
                layout.setComponentAlignment(configure, Alignment.BOTTOM_CENTER);
                getMainWindow().addWindow(window);
                window.center();
                state.addCurrentGraphListener(listener);
                return;
            }
            try {
                getMainWindow()
                        .open(new ExternalResource(state.getHostNameWithoutPort() + "/ontowiki/model/export?m="
                                + URLEncoder.encode(currentGraph, "UTF-8") + "&f=" + format));
            } catch (UnsupportedEncodingException e) {
                // should never happen
                throw new RuntimeException("The lod2 server encountered error when exporting the graph: "
                        + e.getMessage() + " Please contact an administrator");
            }
        }
    };
}

From source file:eu.maxschuster.vaadin.autocompletetextfield.demo.DemoUI.java

License:Apache License

private void openTestWindow() {
    Window testWindow = new Window();
    DemoOverlayTest test = new DemoOverlayTest();
    test.setSuggestionProvider(languageProvider);
    testWindow.setContent(test);/*from  ww  w . ja  va  2 s . c o  m*/
    testWindow.setCaption("Window Demo");
    testWindow.center();
    getUI().addWindow(testWindow);
}

From source file:facs.components.BookAdmin.java

License:Open Source License

private Component deletedBookingsGrid() {
    VerticalLayout devicesLayout = new VerticalLayout();
    devicesLayout.setCaption("Trash");
    // HorizontalLayout buttonLayout = new HorizontalLayout();

    // there will now be space around the test component
    // components added to the test component will now not stick together but have space between
    // them/*from   w w  w.  ja v  a2s  . c  o  m*/
    devicesLayout.setMargin(true);
    devicesLayout.setSpacing(true);
    // buttonLayout.setMargin(true);
    // buttonLayout.setSpacing(true);

    // buttonLayout.addComponent(add);

    BeanItemContainer<BookingBean> booking = getDeletedBookings();

    GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(booking);

    gpc.addGeneratedProperty("restore", new PropertyValueGenerator<String>() {
        /**
         * 
         */
        private static final long serialVersionUID = 4082425701384202280L;

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            // return FontAwesome.TRASH_O.getHtml(); // The caption
            return "Restore"; // The caption

        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });

    gpc.addGeneratedProperty("delete", new PropertyValueGenerator<String>() {
        /**
         * 
         */
        private static final long serialVersionUID = 1307493624895857513L;

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            // return FontAwesome.TRASH_O.getHtml(); // The caption
            return "Purge"; // The caption

        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });

    devicesGridTrash = new Grid(gpc);
    // Create a grid

    devicesGridTrash.setWidth("100%");
    devicesGridTrash.setSelectionMode(SelectionMode.SINGLE);
    devicesGridTrash.getColumn("delete").setRenderer(new HtmlRenderer());
    devicesGridTrash.getColumn("restore").setRenderer(new HtmlRenderer());
    setRenderers(devicesGridTrash);
    devicesGridTrash.setColumnOrder("ID", "deviceName", "service", "start", "end", "username", "phone",
            "price");

    // Render a button that deletes the data row (item)

    /*
     * devicesGrid.addColumn("delete", FontIcon.class).setWidth(35) .setRenderer(new
     * FontIconRenderer(new RendererClickListener() {
     * 
     * @Override public void click(RendererClickEvent e) { Notification.show("Deleted item " +
     * e.getItemId()); } }));
     */

    devicesGridTrash.getColumn("delete")
            .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() {
                /**
                 * 
                 */
                private static final long serialVersionUID = 302628105070456680L;

                @Override
                public void click(RendererClickEvent event) {

                    try {

                        Window cd = new Window("Purge Booking");

                        cd.setHeight("200px");
                        cd.setWidth("400px");
                        cd.setResizable(false);

                        GridLayout dialogLayout = new GridLayout(3, 3);

                        Button okButton = new Button("Yes");
                        okButton.addStyleName(ValoTheme.BUTTON_DANGER);
                        Button cancelButton = new Button("No, I'm actually not sure!");
                        cancelButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
                        Label information = new Label("Are you sure you want to purge this item?");
                        information.addStyleName(ValoTheme.LABEL_NO_MARGIN);

                        okButton.addClickListener(new Button.ClickListener() {

                            /**
                             * 
                             */
                            private static final long serialVersionUID = 3739260172118651857L;

                            @Override
                            public void buttonClick(ClickEvent okEvent) {
                                purgeBooking((BookingBean) event.getItemId());
                                cd.close();
                                Notification("The booking was purged!",
                                        "At the end, you are the admin, you have the power.", "");
                            }
                        });

                        cancelButton.addClickListener(new Button.ClickListener() {

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

                            @Override
                            public void buttonClick(ClickEvent okEvent) {
                                cd.close();
                            }
                        });

                        dialogLayout.addComponent(information, 0, 0, 2, 0);
                        dialogLayout.addComponent(okButton, 0, 1);
                        dialogLayout.addComponent(cancelButton, 1, 1);
                        dialogLayout.setMargin(true);
                        dialogLayout.setSpacing(true);
                        cd.setContent(dialogLayout);
                        cd.center();
                        UI.getCurrent().addWindow(cd);

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    FieldGroup fieldGroup = devicesGridTrash.getEditorFieldGroup();
                    fieldGroup.addCommitHandler(new FieldGroup.CommitHandler() {
                        /**
                         * 
                         */
                        private static final long serialVersionUID = 3799806709907688919L;

                        @Override
                        public void preCommit(FieldGroup.CommitEvent commitEvent)
                                throws FieldGroup.CommitException {

                        }

                        @Override
                        public void postCommit(FieldGroup.CommitEvent commitEvent)
                                throws FieldGroup.CommitException {

                            Notification("Successfully Updated",
                                    "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.",
                                    "success");

                            refreshGrid();
                        }

                        private void refreshGrid() {
                            getDeletedBookings();
                        }

                    });

                }
            }));

    devicesGridTrash.getColumn("restore")
            .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() {
                /**
                 * 
                 */
                private static final long serialVersionUID = -9104571186503913834L;

                @Override
                public void click(RendererClickEvent event) {
                    restoreBooking((BookingBean) event.getItemId());
                }
            }));

    // devicesGrid.setEditorEnabled(true);

    // devicesLayout.addComponent(buttonLayout);
    devicesLayout.addComponent(devicesGridTrash);

    // TODO filtering
    // HeaderRow filterRow = devicesGrid.prependHeaderRow();

    return devicesLayout;
}

From source file:facs.components.Booking.java

License:Open Source License

private Component myUpcomingBookings() {
    VerticalLayout devicesLayout = new VerticalLayout();
    // devicesLayout.setCaption("My Bookings");
    // there will now be space around the test component
    // components added to the test component will now not stick together but have space between
    // them/*from   ww w  .  j  ava  2 s.c om*/
    devicesLayout.setMargin(true);
    devicesLayout.setSpacing(true);

    Date serverTime = new WebBrowser().getCurrentDate();
    Date nextDayTime = new Date(serverTime.getTime() + (1000 * 60 * 60 * 24));

    BeanItemContainer<BookingBean> users = getMyUpcomingBookings(bookingModel.getLDAP(), nextDayTime);
    // System.out.println(bookingModel.getLDAP());

    GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(users);
    gpc.addGeneratedProperty("delete", new PropertyValueGenerator<String>() {
        /**
         * 
         */
        private static final long serialVersionUID = 1263377339178640406L;

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            // return FontAwesome.TRASH_O.getHtml(); // The caption
            return "Trash"; // The caption

        }

        @Override
        public Class<String> getType() {
            return String.class;
        }
    });

    /*
     * 
     * try {
     * 
     * FreeformQuery query = new FreeformQuery(
     * "SELECT * FROM booking INNER JOIN user ON booking.user_ldap = user.user_ldap WHERE deleted IS NULL AND booking.user_ldap ='"
     * + bookingModel.getLDAP() + "';", DBManager.getDatabaseInstanceAlternative(), "booking_id");
     * SQLContainer container = new SQLContainer(query);
     * 
     * // System.out.println("Print Container: " + container.size());
     * container.setAutoCommit(isEnabled());
     * 
     * myBookings = new Grid(container);
     * 
     * } catch (Exception e) { e.printStackTrace(); }
     * 
     * myBookings.setColumnOrder("booking_id", "confirmation", "device_name", "service", "start",
     * "end", "kostenstelle", "price", "project");
     * 
     * myBookings.removeColumn("user_ldap"); myBookings.removeColumn("timestamp");
     * myBookings.removeColumn("deleted"); myBookings.removeColumn("user_name");
     * myBookings.removeColumn("group_id"); myBookings.removeColumn("workgroup_id");
     * myBookings.removeColumn("email"); myBookings.removeColumn("phone");
     * myBookings.removeColumn("admin_panel"); myBookings.removeColumn("user_id");
     * 
     * myBookings.getColumn("booking_id").setHeaderCaption("Booking ID");
     */

    upcomingBookings = new Grid(gpc);
    // Create a grid
    upcomingBookings.setStyleName("my-style");
    upcomingBookings.setWidth("100%");
    upcomingBookings.setSelectionMode(SelectionMode.SINGLE);
    upcomingBookings.setEditorEnabled(false);

    upcomingBookings.setColumnOrder("ID", "confirmation", "deviceName", "service", "start", "end", "username",
            "phone", "price");
    upcomingBookings.getColumn("price").setHeaderCaption("Approx. Price");

    // System.out.println(myBookings.getColumns());
    setRenderers(upcomingBookings);
    devicesLayout.addComponent(upcomingBookings);

    upcomingBookings.getColumn("delete")
            .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() {
                /**
                 * 
                 */
                private static final long serialVersionUID = 302628105070456680L;

                @Override
                public void click(RendererClickEvent event) {

                    try {

                        Window cd = new Window("Delete Booking");

                        cd.setHeight("200px");
                        cd.setWidth("400px");
                        cd.setResizable(false);

                        GridLayout dialogLayout = new GridLayout(3, 3);

                        Button okButton = new Button("Yes");
                        okButton.addStyleName(ValoTheme.BUTTON_DANGER);
                        Button cancelButton = new Button("No, I'm actually not sure!");
                        cancelButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
                        Label information = new Label("Are you sure you want to trash this item?");
                        information.addStyleName(ValoTheme.LABEL_NO_MARGIN);

                        okButton.addClickListener(new Button.ClickListener() {
                            /**
                             * 
                             */
                            private static final long serialVersionUID = 1778157399909757369L;

                            @Override
                            public void buttonClick(ClickEvent okEvent) {

                                purgeBooking((BookingBean) event.getItemId());

                                booking.setSelectedTab(myUpcomingBookings());

                                cd.close();

                                showNotification("The booking was deleted!",
                                        "You wanted to delete an upcoming booking and it wasn't within the next 24 hours. All good, item purged.");
                            }
                        });

                        cancelButton.addClickListener(new Button.ClickListener() {
                            /**
                             * 
                             */
                            private static final long serialVersionUID = -8957620319158438769L;

                            @Override
                            public void buttonClick(ClickEvent okEvent) {
                                cd.close();
                            }
                        });

                        dialogLayout.addComponent(information, 0, 0, 2, 0);
                        dialogLayout.addComponent(okButton, 0, 1);
                        dialogLayout.addComponent(cancelButton, 1, 1);
                        dialogLayout.setMargin(true);
                        dialogLayout.setSpacing(true);
                        cd.setContent(dialogLayout);
                        cd.center();
                        UI.getCurrent().addWindow(cd);

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }

            }));

    // TODO filtering
    // HeaderRow filterRow = devicesGrid.prependHeaderRow();

    return devicesLayout;
}

From source file:facs.components.Settings.java

License:Open Source License

private void addNewDevice() {
    final Window subWindow = new Window("Add Device");
    FormLayout form = new FormLayout();
    form.setMargin(true);// www.j a  v  a 2 s. c o  m
    final TextField name = new TextField();
    name.setImmediate(true);
    name.addValidator(new StringLengthValidator("The name must be 1-85 letters long (Was {0}).", 1, 85, true));
    name.setCaption("Name of new device");
    form.addComponent(name);
    final TextArea description = new TextArea();
    description.setImmediate(true);
    description.addValidator(
            new StringLengthValidator("The name must be 1-255 letters long (Was {0}).", 1, 255, true));
    description.setCaption("Description");
    form.addComponent(description);
    final OptionGroup restricted = new OptionGroup("Is Device restricted by operators?");
    restricted.addItem("yes");
    restricted.setMultiSelect(true);
    form.addComponent(restricted);
    HorizontalLayout buttons = new HorizontalLayout();
    Button save = new Button("save");
    buttons.addComponent(save);
    Button discard = new Button("discard");
    discard.setDescription("discarding will abort the process of adding a new device into the databse.");
    buttons.addComponent(discard);
    buttons.setSpacing(true);
    form.addComponent(buttons);
    subWindow.setContent(form);

    form.setMargin(true);
    form.setSpacing(true);
    buttons.setMargin(true);
    buttons.setSpacing(true);

    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setWidth("50%");
    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

    discard.addClickListener(new ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -5808910314649620731L;

        @Override
        public void buttonClick(ClickEvent event) {
            subWindow.close();
        }
    });
    save.addClickListener(new ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 3748395242651585005L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (name.isValid() && description.isValid()) {
                Set<String> restr = (Set<String>) restricted.getValue();
                int deviceId = DBManager.getDatabaseInstance().addDevice(name.getValue(),
                        description.getValue(), (restr.size() == 1));
                DeviceBean bean = new DeviceBean(deviceId, name.getValue(), description.getValue(),
                        (restr.size() == 1));
                devicesGrid.addRow(bean);
            } else {
                Notification.show("Failed to add device to database.");
            }
        }
    });

    // DeviceBean db = new DeviceBean(0, "Device 1","some description1", false);
    // TODO
    // add to database
    /*
     * boolean added = false;//DBManager.getDatabaseInstance().addDevice(db); //TODO test //add to
     * grid if(added){ devicesGrid.addRow(db); }else{ //TODO log failed operation
     * Notification.show("Failed to add device to database.", Type.ERROR_MESSAGE); }
     */
}

From source file:io.mateu.ui.vaadin.framework.MyUI.java

License:Apache License

public void showInWindow(String caption, Component vaadinComponent, Window.CloseListener closeListener) {

    // Create a sub-window and set the content
    Window subWindow = new Window(caption);

    subWindow.setContent(vaadinComponent);

    if (closeListener != null)
        subWindow.addCloseListener(closeListener);

    // Center it in the browser window
    subWindow.center();

    subWindow.setModal(true);/*from   ww  w. ja va2s .co m*/

    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);

}