Example usage for com.vaadin.ui Window setHeight

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

Introduction

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

Prototype

@Override
    public void setHeight(String height) 

Source Link

Usage

From source file:dhbw.clippinggorilla.userinterface.windows.PDFWindow.java

public static Window get(Path pdfFile) {
    Window window = new Window();
    window.setModal(true);/*  w w  w  .  ja  v a2  s  .co  m*/
    window.setResizable(false);
    window.setWidth("90%");
    window.setHeight("90%");
    window.addCloseShortcut(ShortcutAction.KeyCode.ENTER, null);
    BrowserFrame e = new BrowserFrame(pdfFile.getFileName().toString(), new FileResource(pdfFile.toFile()));
    e.setSizeFull();
    window.setContent(e);
    return window;
}

From source file:edu.kit.dama.ui.commons.util.UIUtils7.java

License:Apache License

public static void openResourceSubWindow(File sourceFile) {
    boolean fileAccessible = sourceFile != null && sourceFile.exists() && sourceFile.canRead();

    // Set subwindow for displaying file resource
    final Window window = new Window(fileAccessible ? sourceFile.getName() : "Information");
    window.center();/*ww w  .  j  a v  a  2 s  .com*/
    // Set window layout
    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setSizeFull();

    if (fileAccessible) {
        // Set resource that has to be embedded
        final Embedded resource = new Embedded(null, new FileResource(sourceFile));
        if ("application/octet-stream".equals(resource.getMimeType())) {
            window.setWidth("570px");
            window.setHeight("150px");
            windowLayout.setMargin(true);

            Label attentionNote = new Label(
                    "A file preview is not possible as the file type is not supported by your browser.");
            attentionNote.setContentMode(ContentMode.HTML);
            Link fileURL = new Link("Click here for downloading the file.", new FileResource(sourceFile));

            windowLayout.addComponent(attentionNote);
            windowLayout.addComponent(fileURL);
            windowLayout.setComponentAlignment(attentionNote, Alignment.MIDDLE_CENTER);
            windowLayout.setComponentAlignment(fileURL, Alignment.MIDDLE_CENTER);
        } else {
            window.setResizable(true);
            window.setWidth("800px");
            window.setHeight("500px");
            final Image image = new Image(null, new FileResource(sourceFile));
            image.setSizeFull();
            windowLayout.addComponent(image);
        }
    } else {
        //file is not accessible
        window.setWidth("570px");
        window.setHeight("150px");
        windowLayout.setMargin(true);
        Label attentionNote = new Label("Provided file cannot be accessed.");
        attentionNote.setContentMode(ContentMode.HTML);
        windowLayout.addComponent(attentionNote);
        windowLayout.setComponentAlignment(attentionNote, Alignment.MIDDLE_CENTER);
    }

    window.setContent(windowLayout);
    UI.getCurrent().addWindow(window);
}

From source file:edu.nps.moves.mmowgli.components.MmowgliDialogContent.java

License:Open Source License

public static void throwUpDialog2() {
    Window w = new Window();
    w.setClosable(false);/*from  w  ww.ja v a  2s  . com*/
    w.setResizable(true);
    w.setStyleName("m-mmowglidialog2");
    w.addStyleName("m-transparent"); // don't know why I need this, .mmowglidialog sets it too
    w.setWidth("600px");
    w.setHeight("400px");
    MmowgliDialogContent con = new MmowgliDialogContent();
    w.setContent(con);
    con.setSizeFull();
    con.initGui();
    con.setTitleString("Yippee ki awol!");

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

}

From source file:edu.nps.moves.mmowgli.components.SignupsTable.java

License:Open Source License

@SuppressWarnings("serial")
public static void showDialog(String title) {
    final Button bulkMailButt = new Button("Initiate bulk mail job sending to filtered list");

    final Button emailButt = new Button("Compose email");
    emailButt.setDescription("Opens editing dialog to compose an email message to the selected individuals");
    final Button displayButt = new Button("Display as plain text");
    Button closeButt;/*from   w  w w .j a  v a2 s .c o m*/

    final SignupsTable tab = new SignupsTable(null, null, new ValueChangeListener() // selected
    {
        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            emailButt.setEnabled(true);
        }
    });

    final Window dialog = new Window(title);
    dialog.setWidth("950px");
    dialog.setHeight("650px");

    VerticalLayout vl = new VerticalLayout();
    dialog.setContent(vl);
    vl.setSizeFull();
    vl.setMargin(true);
    vl.setSpacing(true);
    addFilterCheckBoxes(vl);
    vl.addComponent(new Label("Individuals who have established game accounts are shown faintly"));

    tab.setSizeFull();
    vl.addComponent(tab);
    vl.setExpandRatio(tab, 1.0f);

    HorizontalLayout buttHL = new HorizontalLayout();
    buttHL.setSpacing(true);

    buttHL.addComponent(bulkMailButt);
    bulkMailButt.setImmediate(true);
    ;
    Label lab = new Label("");
    buttHL.addComponent(lab);
    buttHL.setExpandRatio(lab, 1.0f);

    buttHL.addComponent(emailButt);
    emailButt.setImmediate(true);
    buttHL.addComponent(displayButt);
    displayButt.setImmediate(true);
    buttHL.addComponent(closeButt = new Button("Close"));
    closeButt.setImmediate(true);

    emailButt.setEnabled(false);

    closeButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            dialog.close();
        }
    });

    emailButt.addClickListener(new ClickListener() {
        @SuppressWarnings("rawtypes")
        @Override
        public void buttonClick(ClickEvent event) {
            HSess.init();
            Set set = (Set) tab.getValue();
            ArrayList<String> emails = new ArrayList<String>(set.size());
            Iterator itr = set.iterator();
            while (itr.hasNext()) {
                QueryWrapper wrap = (QueryWrapper) itr.next();
                emails.add(wrap.getEmail());
            }
            new SendMessageWindow(emails);
            HSess.close();
        }
    });

    displayButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            dumpSignupsTL();
            HSess.close();
        }
    });

    bulkMailButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            BulkMailHandler.showDialog((QueryContainer) tab.getContainerDataSource());
        }
    });

    vl.addComponent(buttHL);
    vl.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT);

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

From source file:edu.nps.moves.mmowgli.export.BaseExporter.java

License:Open Source License

protected void getMetaStringOrCancel(final MetaListener lis, String title, final Map<String, String> params) {
    final Window dialog = new Window(title);
    final TextField[] parameterFields;

    dialog.setModal(true);// w  w w.  ja  v a 2  s  . c o m

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

    final TextArea ta = new TextArea();
    ta.setWidth("100%");
    ta.setInputPrompt("Type a description of this data, or the game which generated this data (optional)");

    ta.setImmediate(true);
    layout.addComponent(ta);

    Set<String> keySet = params.keySet();
    parameterFields = new TextField[keySet.size()];
    int i = 0;
    GridLayout pGL = new GridLayout();
    pGL.addStyleName("m-greyborder");
    pGL.setColumns(2);
    Label hdr = new HtmlLabel("<b>Parameters</b>");
    hdr.addStyleName("m-textaligncenter");
    pGL.addComponent(hdr, 0, 0, 1, 0); // top row
    pGL.setComponentAlignment(hdr, Alignment.MIDDLE_CENTER);
    pGL.setSpacing(false);
    for (String key : keySet) {
        pGL.addComponent(new HtmlLabel("&nbsp;" + key + "&nbsp;&nbsp;"));
        pGL.addComponent(parameterFields[i] = new TextField());
        parameterFields[i++].setValue(params.get(key));
    }
    if (i > 0) {
        layout.addComponent(pGL);
        layout.setComponentAlignment(pGL, Alignment.TOP_CENTER);
    }

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

    @SuppressWarnings("serial")
    Button exportButt = new Button("Export", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();

            Set<String> keySet = params.keySet();
            int i = 0;
            for (String key : keySet)
                params.put(key, parameterFields[i++].getValue().toString());

            lis.continueOrCancel(ta.getValue().toString());
        }
    });
    hl.addComponent(cancelButt);
    hl.addComponent(exportButt);
    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("385px");
    dialog.setHeight("310px");
    hl.setWidth("100%");
    ta.setWidth("100%");
    ta.setHeight("100%");
    layout.setExpandRatio(ta, 1.0f);

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

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);//w w w .j a v a  2 s.  co m
    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 w w  . j a v a 2 s.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: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//w w w  .  j  a  v  a2  s . com
    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/*www.  j a v  a  2s. co m*/
    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:fi.semantum.strategia.Utils.java

License:Open Source License

public static void editTextAndId(final Main main, String title, final Base container) {

    final Database database = main.getDatabase();

    final Window subwindow = new Window(title, new VerticalLayout());
    subwindow.setModal(true);// www . j a  va  2s . co  m
    subwindow.setWidth("400px");
    subwindow.setHeight("500px");
    subwindow.setResizable(false);

    VerticalLayout winLayout = (VerticalLayout) subwindow.getContent();
    winLayout.setMargin(true);
    winLayout.setSpacing(true);

    final TextField tf = new TextField();
    tf.setCaption("Lyhytnimi:");
    tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    tf.setValue(container.getId(database));
    tf.setWidth("100%");
    winLayout.addComponent(tf);

    final TextArea ta = new TextArea();
    ta.setCaption("Teksti:");
    ta.setValue(container.getText(database));
    ta.setWidth("100%");
    ta.setHeight("290px");
    winLayout.addComponent(ta);

    Button save = new Button("Tallenna", new Button.ClickListener() {

        private static final long serialVersionUID = 6641880870005364983L;

        public void buttonClick(ClickEvent event) {
            String idValue = tf.getValue();
            String value = ta.getValue();
            main.removeWindow(subwindow);
            container.modifyId(main, idValue);
            container.modifyText(main, value);
            Collection<String> tags = Tag.extractTags(value);
            database.assertTags(tags);
            ArrayList<Tag> tagObjects = new ArrayList<Tag>();
            for (String s : tags)
                tagObjects.add(database.getOrCreateTag(s));
            container.assertRelatedTags(database, tagObjects);
            Updates.update(main, true);
            Property emails = Property.find(database, Property.EMAIL);
            String addr = emails.getPropertyValue(container);
            if (addr != null && !addr.isEmpty()) {
                String[] addrs = addr.split(",");
                if (addrs.length > 0) {
                    try {
                        Email.send(addrs, "Muutos strategiakartassa: " + container.getId(database),
                                "Kyttj " + main.account.getId(database)
                                        + " on muuttanut strategiakarttaa.<br/><br/>Lyhytnimi: "
                                        + container.getId(database) + "<br/><br/>Teksti: "
                                        + container.getText(database));
                    } catch (MessagingException e) {
                        e.printStackTrace();
                    }
                }
            }
        }

    });

    Button discard = new Button("Peru muutokset", new Button.ClickListener() {

        private static final long serialVersionUID = -784522457615993823L;

        public void buttonClick(ClickEvent event) {
            Updates.update(main, true);
            main.removeWindow(subwindow);
        }

    });

    HorizontalLayout hl2 = new HorizontalLayout();
    hl2.setSpacing(true);
    hl2.addComponent(save);
    hl2.addComponent(discard);
    winLayout.addComponent(hl2);
    winLayout.setComponentAlignment(hl2, Alignment.MIDDLE_CENTER);
    main.addWindow(subwindow);

    ta.setCursorPosition(ta.getValue().length());

}