Example usage for com.vaadin.ui Window Window

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

Introduction

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

Prototype

public Window(String caption) 

Source Link

Document

Creates a new, empty window with a given title.

Usage

From source file:com.save.reports.maintenance.MaintenanceReportUI.java

Window exportLargeData() {
    Window sub = new Window("EXPORT LARGE DATA");
    sub.setWidth("300px");
    sub.setModal(true);//from  w w  w  . j  ava2  s . c om
    sub.center();

    VerticalLayout v = new VerticalLayout();
    v.setSizeFull();
    v.setMargin(true);
    v.setSpacing(true);

    Label status = new Label("Exporting large amount of data will take longer and will eat a lot of memory.",
            ContentMode.HTML);
    status.setContentMode(ContentMode.HTML);
    v.addComponent(status);

    Button b = new CommonButton("PROCEED TO EXPORT?");
    b.addClickListener((Button.ClickEvent e) -> {
        sub.close();
        processExportDataToExcel();
    });
    v.addComponent(b);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();
    return sub;
}

From source file:com.save.reports.promodeals.PromoDealReportUI.java

private Window filterReport() {
    Window sub = new Window("FILTER REPORT");
    sub.setWidth("400px");
    sub.setModal(true);// w  w w .  j  a va 2s  . com
    sub.center();

    FormLayout f = new FormLayout();
    f.setWidth("100%");
    f.setMargin(true);
    f.setSpacing(true);

    CheckBox areaCheckBox = new CheckBox("Filter by Area");
    f.addComponent(areaCheckBox);

    CheckBox clientCheckBox = new CheckBox("Filter by Client");
    f.addComponent(clientCheckBox);

    CheckBox amountCheckBox = new CheckBox("Filter by Amount");
    f.addComponent(amountCheckBox);

    CheckBox dateCheckBox = new CheckBox("Filter by Date");
    f.addComponent(dateCheckBox);

    ComboBox areaComboBox = CommonComboBox.areas();
    ComboBox clientComboBox = CommonComboBox.getAllClients();

    areaComboBox.setEnabled(false);
    f.addComponent(areaComboBox);
    areaCheckBox.addValueChangeListener((Property.ValueChangeEvent event) -> {
        areaComboBox.setEnabled((boolean) event.getProperty().getValue());
        clientComboBox.setEnabled(!(boolean) event.getProperty().getValue());
        clientCheckBox.setValue(!(boolean) event.getProperty().getValue());
        isAreaSelect = (boolean) event.getProperty().getValue();
        isClientSelect = !(boolean) event.getProperty().getValue();
    });

    clientComboBox.setEnabled(false);
    f.addComponent(clientComboBox);
    clientCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        clientComboBox.setEnabled((boolean) e.getProperty().getValue());
        areaComboBox.setEnabled(!(boolean) e.getProperty().getValue());
        areaCheckBox.setValue(!(boolean) e.getProperty().getValue());
        isClientSelect = (boolean) e.getProperty().getValue();
        isAreaSelect = !(boolean) e.getProperty().getValue();
    });

    TextField amountField = new CommonTextField("Amount: ");
    amountField.addStyleName("align-right");
    amountField.setEnabled(false);
    f.addComponent(amountField);
    amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        amountField.setEnabled((boolean) e.getProperty().getValue());
        isAmountSelect = (boolean) e.getProperty().getValue();
    });

    HorizontalLayout h = new HorizontalLayout();
    h.setCaption("Date: ");
    h.setWidth("100%");
    h.setSpacing(true);

    DateField from = new DateField();
    from.setWidth("100%");
    from.setEnabled(false);
    h.addComponent(from);

    DateField to = new DateField();
    to.setWidth("100%");
    to.setEnabled(false);
    h.addComponent(to);

    dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        from.setEnabled((boolean) e.getProperty().getValue());
        to.setEnabled((boolean) e.getProperty().getValue());
        isDateSelect = (boolean) e.getProperty().getValue();
    });

    f.addComponent(h);

    Button generate = new CommonButton("Generate Report");
    generate.addClickListener((Button.ClickEvent e) -> {
        if (!isClientSelect && !isAmountSelect && !isDateSelect) {
            promoDealGrid.setContainerDataSource(new PromoDealDataContainer());
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && !isAmountSelect && !isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(
                    new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue())));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isClientSelect && !isAmountSelect && !isDateSelect) {
            if (clientComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (!isClientSelect && isAmountSelect && !isDateSelect) {
            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (!isClientSelect && !isAmountSelect && isDateSelect) {
            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer(from.getValue(), to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && isAmountSelect && !isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            promoDealGrid.setContainerDataSource(
                    new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isClientSelect && isAmountSelect && !isDateSelect) {
            if (clientComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(),
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && !isAmountSelect && isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer(
                    areaComboBox.getItemCaption(areaComboBox.getValue()), from.getValue(), to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isClientSelect && !isAmountSelect && isDateSelect) {
            if (clientComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(),
                    from.getValue(), to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (!isClientSelect && isAmountSelect && isDateSelect) {
            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(),
                    to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && isAmountSelect && isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(
                    new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim()),
                            from.getValue(), to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isClientSelect && isAmountSelect && isDateSelect) {
            if (clientComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(),
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(),
                    to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        sub.close();
    });
    f.addComponent(generate);

    sub.setContent(f);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.save.reports.reimbursement.ReimbursementReportUI.java

private Window filterReport() {
    Window sub = new Window("FILTER REPORT");
    sub.setWidth("400px");
    sub.setModal(true);/*from  w ww .  j a v  a2  s  .co  m*/
    sub.center();

    FormLayout f = new FormLayout();
    f.setWidth("100%");
    f.setMargin(true);
    f.setSpacing(true);

    CheckBox employeeCheckBox = new CheckBox("Filter by Employee");
    f.addComponent(employeeCheckBox);

    CheckBox amountCheckBox = new CheckBox("Filter by Amount");
    f.addComponent(amountCheckBox);

    CheckBox dateCheckBox = new CheckBox("Filter by Date");
    f.addComponent(dateCheckBox);

    ComboBox employeeComboBox = CommonComboBox.getAllEmpployees(null);
    employeeComboBox.setEnabled(false);
    f.addComponent(employeeComboBox);
    employeeCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        employeeComboBox.setEnabled((boolean) e.getProperty().getValue());
        isEmployee = (boolean) e.getProperty().getValue();
    });

    TextField amountField = new CommonTextField("Amount: ");
    amountField.addStyleName("align-right");
    amountField.setEnabled(false);
    f.addComponent(amountField);
    amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        amountField.setEnabled((boolean) e.getProperty().getValue());
        isAmount = (boolean) e.getProperty().getValue();
    });

    HorizontalLayout h = new HorizontalLayout();
    h.setCaption("Date: ");
    h.setWidth("100%");
    h.setSpacing(true);

    DateField from = new DateField();
    from.setWidth("100%");
    from.setEnabled(false);
    h.addComponent(from);

    DateField to = new DateField();
    to.setWidth("100%");
    to.setEnabled(false);
    h.addComponent(to);

    dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        from.setEnabled((boolean) e.getProperty().getValue());
        to.setEnabled((boolean) e.getProperty().getValue());
        isDate = (boolean) e.getProperty().getValue();
    });

    f.addComponent(h);

    Button generate = new CommonButton("Generate Report");
    generate.addClickListener((Button.ClickEvent e) -> {
        if (!isEmployee && !isAmount && !isDate) {
            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer());
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && !isAmount && !isDate) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(
                    new ReimbursementDataContainer(employeeComboBox.getValue().toString()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployee && isAmount && !isDate) {
            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployee && !isAmount && isDate) {
            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer(from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && isAmount && !isDate) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            mrDataGrid.setContainerDataSource(
                    new ReimbursementDataContainer(employeeComboBox.getValue().toString(),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && !isAmount && isDate) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer(
                    employeeComboBox.getValue().toString(), from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployee && isAmount && isDate) {
            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(),
                    to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && isAmount && isDate) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(
                    new ReimbursementDataContainer(employeeComboBox.getValue().toString(),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim()),
                            from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        sub.close();
    });
    f.addComponent(generate);

    sub.setContent(f);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.siemens.ct.osgi.vaadin.pm.main.MainApplication.java

License:Open Source License

@Override
public void init() {
    logger.info("Dynamic Vaadin OSGi demo init...");
    setTheme(Reindeer.THEME_NAME);//  w ww  .  j ava2s  .c om
    // setTheme(Runo.THEME_NAME);
    // setTheme("demo");
    main = new Window("Dynamic Vaadin OSGi Demo");
    mainLayout = (VerticalLayout) main.getContent();
    mainLayout.setMargin(false);
    mainLayout.setStyleName("blue");
    setMainWindow(main);

    mainLayout.setSizeFull();
    mainLayout.addComponent(getMenu());

    HorizontalLayout header = new HorizontalLayout();

    header.addComponent(getHeader());
    header.addComponent(getToolbar());
    mainLayout.addComponent(header);

    CssLayout margin = new CssLayout();
    margin.setMargin(false, true, true, true);
    margin.setSizeFull();
    tabSheet = new TabSheet();
    tabSheet.setSizeFull();
    margin.addComponent(tabSheet);
    mainLayout.addComponent(margin);
    mainLayout.setExpandRatio(margin, 1);

    for (IViewContribution viewContribution : viewContributions) {
        tabSheet.addTab(viewContribution.getView(this), viewContribution.getName(),
                new ThemeResource(viewContribution.getIcon()));
    }

    for (IActionContribution actionContribution : actionContributions) {
        addActionContribution(actionContribution);
    }

    // Create the indicator
    // this is used for a simple poll mechanism
    // so that manual server-side starting/stopping of bundles has a direct
    // effect on the client UI
    ProgressIndicator indicator = new ProgressIndicator();
    // Set polling frequency to 1 seconds.
    indicator.setPollingInterval(1000);
    // Add it to Application's main window
    main.addComponent(indicator);
    // Hide the component does not work...
    indicator.setWidth("1px");
    indicator.setHeight("1px");
    indicator.setVisible(true);

    initialized = true;
}

From source file:com.siemens.ct.osgi.vaadin.pm.main.MainApplication.java

License:Open Source License

private Window getAboutDialog() {
    if (aboutWindow == null) {
        aboutWindow = new Window("About...");
        aboutWindow.setModal(true);//  w w w  . j a  v  a 2  s  .  co m
        aboutWindow.setWidth("400px");

        VerticalLayout layout = (VerticalLayout) aboutWindow.getContent();
        layout.setMargin(true);
        layout.setSpacing(true);
        layout.setStyleName("blue");

        CssLayout titleLayout = new CssLayout();
        H2 title = new H2("Dynamic Vaadin OSGi Demo");
        titleLayout.addComponent(title);
        SmallText description = new SmallText("<br>Copyright (c) Siemens AG, Kai Tdter and others.<br>"
                + "Licensed under Eclipse Public License (EPL).<br><br>"
                + "This software contains modules licenced under<br>"
                + " the Apache Software Foundation 2.0 license (ASF) and EPL<br><br>"
                + "Many thanks to Chris Brind, Neil Bartlett and<br>"
                + " Petter Holmstrm for their OSGi and Vaadin<br>"
                + " related work, blogs, and bundles.<br><br>"
                + "The icons are from the Silk icon set by Mark James<br>"
                + "<a href=\"http://www.famfamfam.com/lab/icons/silk/\">http://www.famfamfam.com/lab/icons/silk/</a>");
        description.setSizeUndefined();
        description.setContentMode(Label.CONTENT_XHTML);

        titleLayout.addComponent(description);
        aboutWindow.addComponent(titleLayout);

        @SuppressWarnings("serial")
        Button close = new Button("Close", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                (aboutWindow.getParent()).removeWindow(aboutWindow);
            }

        });
        layout.addComponent(close);
        layout.setComponentAlignment(close, "right");
    }
    return aboutWindow;
}

From source file:com.snowy.UsersList.java

public UsersList(data d) {
    this.d = d;/*from   w  w  w . ja  va2 s .c o  m*/
    c.addContainerProperty("id", Integer.class, "");
    retrieveActiveUsers();
    //this.addItem("Chase");
    //this.addItem("Cole");

    //ll.addComponent(ll);
    //PopupView pop = new PopupView(null,ll);
    //pop.s
    //pop.addPopupVisibilityListener(e->{
    //   ll.addComponent(hl);
    //});

    //TODO add the select listener
    ls.addValueChangeListener(e -> {
        if (e.getProperty().getValue() != null) {
            Window w = new Window("Confirm Challenge");
            int id = Integer.parseInt(c.getItem(e.getProperty().getValue().toString()).getItemProperty("id")
                    .getValue().toString());
            String Username = e.getProperty().getValue().toString();
            //Logger.getLogger(UsersList.class.getName()).info(Username);
            //Logger.getLogger(UsersList.class.getName()).info(id+"");
            VerticalLayout ll = new VerticalLayout();
            VerticalLayout bb = new VerticalLayout();
            HorizontalLayout hl = new HorizontalLayout();
            Label la = new Label("Send challenge to " + Username + "?");
            bb.addComponent(la);
            ll.addComponent(bb);

            ll.setSizeUndefined();
            bb.setComponentAlignment(la, Alignment.MIDDLE_CENTER);

            ll.addComponent(hl);
            ll.setSpacing(true);
            ll.setMargin(new MarginInfo(true, true, false, true));
            hl.setMargin(new MarginInfo(false, true, true, true));
            hl.setSpacing(true);
            Button cancle = new Button("Cancel", b -> {
                w.close();
            });
            Button send = new Button("Send", c -> {
                if (d.sendChallenge(id)) {
                    ll.removeAllComponents();
                    ll.addComponent(new Label("Challenge Sent Succesfully!"));
                    ll.addComponent(new Button("Close", dd -> {
                        w.close();
                    }));
                    w.setCaption("Success");
                    ll.setSpacing(true);
                    ll.setMargin(true);
                } else {
                    ll.removeAllComponents();
                    ll.addComponent(new Label("Challenge Dend Failed"));
                    ll.addComponent(new Button("Close", dd -> {
                        w.close();
                    }));
                    w.setCaption("Failure");
                    ll.setSpacing(true);
                    ll.setMargin(true);
                }
            });
            hl.addComponents(cancle, send);
            //      this.addComponent(pop);
            //    ll.addComponent(la);
            //   pop.setPopupVisible(true);
            //w.setPosition(null, null);
            w.center();
            w.setModal(true);
            w.setClosable(false);
            w.setResizable(false);
            w.setContent(ll);
            this.getUI().addWindow(w);

        }
    });

    this.setSizeFull();
    this.addStyleName("mine");
    this.addComponent(ls);
    ls.setContainerDataSource(c);
    //ls.setContainerDataSource((Container) hm.keySet());
    ls.setSizeFull();
    ls.setImmediate(true);

}

From source file:com.studiodojo.qwikinvoice.QwikInvoiceApplication.java

License:Apache License

@Override
public void init() {
    this.mainWindow = new Window(
            "QwikInvoice CRM Tools - Developed by StudioDojo. Engineered by Vaadin. Powered by Google.");
    setMainWindow(mainWindow);// ww w  .  j av a  2 s  .co m
    //
    // Check if a user is logged in
    //
    UserService us = UserServiceFactory.getUserService();
    this.logoutURL = us.createLogoutURL(super.getURL().toExternalForm());
    if (us.getCurrentUser() == null || us.getCurrentUser().getEmail() == null) {
        super.setLogoutURL(logoutURL);
        super.close();
        return;
    }
    String login = us.getCurrentUser().getEmail();
    this.userKey = KeyFactory.createKey(TokenBean.class.getSimpleName(), us.getCurrentUser().getEmail());
    //
    Key ucKey = KeyFactory.createKey(UserCompanyBean.class.getSimpleName(), us.getCurrentUser().getEmail());
    UserCompanyBean ucBean = UserDAO.getUserCompanyBean(us.getCurrentUser().getEmail());

    this.theSession = new SessionBean(login, ucBean);
    //
    // SETUP WORKING AREA
    //
    HorizontalLayout appLayout = new HorizontalLayout();
    appLayout.setSizeFull();
    // The Main Layout
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setWidth(APP_WIDTH);
    mainLayout.setHeight(APP_HEIGHT);
    appLayout.addComponent(mainLayout);
    appLayout.setComponentAlignment(mainLayout, Alignment.TOP_CENTER);
    appLayout.setExpandRatio(mainLayout, 2);
    //
    // Setup Header (Welcome Message)
    //
    Label welcome = new Label(
            "<h1>QWIK!NVOICE</h1> You are " + (us.isUserLoggedIn() ? "logged in" : "logged out") + " as <b>"
                    + us.getCurrentUser().getNickname() + "</b>",
            Label.CONTENT_XHTML);
    mainLayout.addComponent(welcome);
    mainLayout.setComponentAlignment(welcome, Alignment.TOP_LEFT);
    //
    // Menu Bar
    //
    MenuBar menuBar = new MenuBar();
    menuBar.setWidth(APP_WIDTH);
    MenuBar.MenuItem fileMenuItem = menuBar.addItem("File", null, null);
    MenuItem newMenuItem = fileMenuItem.addItem("New...", null, null);
    newMenuItem.addItem("Invoice/Quote", new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                QwikInvoiceApplication.this.showPanel(InvoiceApplicationPanel.class);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error loading panel", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }

        }
    });
    newMenuItem.addItem("Order", new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                QwikInvoiceApplication.this.showPanel(FFOrderApplicationPanel.class);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error loading panel", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }

        }
    });
    /** SAVE */
    fileMenuItem.addItem("Save", new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                TokenBean userTokenBean = TokenStore.getToken(QwikInvoiceApplication.this.userKey);
                // User must have an OAuth AUTH Token to access Google Doc service
                if (userTokenBean != null) {
                    /*
                    GDocFileWindow saveWindow = new GDocFileWindow("Save As...");
                    saveWindow.init(QwikInvoiceApplication.this, PdfWriter.getFilename(QwikInvoiceApplication.this.theSession));
                    QwikInvoiceApplication.this.mainWindow.addWindow(saveWindow);
                    */
                    QwikInvoiceApplication.this.activePanel.validate();
                    QwikInvoiceApplication.this.activePanel.onSave();
                } else {
                    AuthSubWindow authsubWindow = new AuthSubWindow("Service Authorization Required");
                    authsubWindow.init(QwikInvoiceApplication.this.userKey);
                    QwikInvoiceApplication.this.mainWindow.addWindow(authsubWindow);
                }
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error Saving file", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    /**
     * SETTINGS
     */
    fileMenuItem.addSeparator();
    MenuItem settingsMenuItem = fileMenuItem.addItem("Settings...", null, null);
    settingsMenuItem.addItem("Profile", new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                UserCompanySetupWindow aWindow = new UserCompanySetupWindow();
                aWindow.init(QwikInvoiceApplication.this);
                QwikInvoiceApplication.this.mainWindow.addWindow(aWindow);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error Saving Profile", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    fileMenuItem.addSeparator();

    fileMenuItem.addItem("Logout", new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            QwikInvoiceApplication.this.setLogoutURL(logoutURL);
            QwikInvoiceApplication.this.close();

        }
    });
    /**
     * Products
     */
    MenuBar.MenuItem productsMenuItem = menuBar.addItem("Products", null, null);
    productsMenuItem.addItem("Products", null, new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                QwikInvoiceApplication.this.showPanel(ProductApplicationPanel.class);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error loading products", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    productsMenuItem.addItem("Categories", null, new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                ProductCategorySettingsWindow window = new ProductCategorySettingsWindow();
                window.setCaption("Product Category");
                window.init(QwikInvoiceApplication.this.theSession, QwikInvoiceApplication.this);
                QwikInvoiceApplication.this.mainWindow.addWindow(window);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error Loading Products", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    productsMenuItem.addItem("Catalogs", null, new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            try {
                QwikInvoiceApplication.this.showPanel(CatalogApplicationPanel.class);
            } catch (Exception e) {
                Log.log(Level.SEVERE, "Error loading catalogs", e);
                QwikInvoiceApplication.this.mainWindow.showNotification("Error", e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    /**
     * Help
     */
    MenuBar.MenuItem helpMenuItem = menuBar.addItem("Help", null, new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            AboutWindow aboutWindow = new AboutWindow();
            aboutWindow.init();
            QwikInvoiceApplication.this.mainWindow.addWindow(aboutWindow);
        }
    });
    helpMenuItem.addItem("About...", null, null);
    mainLayout.addComponent(menuBar);
    mainLayout.setComponentAlignment(menuBar, Alignment.TOP_CENTER);
    //
    // Load Main Panel
    //
    IApplicationPanel invoiceApplicationPanel = (IApplicationPanel) this.map.get(InvoiceApplicationPanel.class);
    try {
        invoiceApplicationPanel.init(this.theSession, this);
        mainLayout.addComponent((Component) invoiceApplicationPanel);
        mainLayout.setComponentAlignment((Component) invoiceApplicationPanel, Alignment.TOP_CENTER);
        this.activePanel = invoiceApplicationPanel;
    } catch (Exception e) {
    }
    //
    // Setup Footer
    //
    //Label footerMessage = new Label("QwikInvoice <b>version "+_VERSION_+"</b>. This service is provided as is. E&O accepted. Developed by <a href='mailto:public@studiodojo.com?subject=QwikInvoice' target='_blank'>StudioDojo</a>. Engineered by Vaadin. Powered by Google. Apache License 2.0", Label.CONTENT_XHTML);
    //mainLayout.addComponent(footerMessage);
    //mainLayout.setComponentAlignment(footerMessage, Alignment.TOP_CENTER);
    Panel mainPanel = new Panel();
    mainPanel.setScrollable(true);
    mainPanel.setContent(appLayout);
    this.mainWindow.setContent(mainPanel);
}

From source file:com.tapas.evidence.fe.child.ChildPresenter.java

License:Apache License

private void showCreateEditDialog(final ChildDTO childDTO) throws ViewFactoryException {
    // create view
    final ChildDetail view = this.createView(ChildDetail.class);
    // configure the form with bean item
    this.childForm = (ChildDetailForm) view.getChildForm();
    this.childForm.getFooter().setMargin(true, false, false, false);
    final MetaModel metaModel = formService.getMetaModel(childDTO);
    this.childForm.setItemDataSource(childDTO, metaModel, this.messageSource, "child.detail", this.getLocale());

    // photo upload setup
    upload = new EvidenceUpload(this.messageSource, this.getLocale());
    upload.setCaption(this.getMessage("child.detail.upload", this.getLocale()));
    this.childForm.addUpload(upload);
    // create a window using caption from view
    this.dialog = new Window(this.getMessage("child.detail.caption", this.getLocale()));
    this.dialog.setModal(true);
    this.dialog.addComponent(view);
    this.dialog.getContent().setSizeUndefined();
    this.eventBus.showDialog(this.dialog);
    if (childDTO.getPhoto() != null) {
        upload.showImage(childDTO.getPhoto());
    } else {/*from w  ww . j  a  v a 2s.c  o m*/
        upload.showImage(ApplicationConstants.NO_PHOTO);
    }
}

From source file:com.tapas.evidence.fe.kindergarten.KindergartenPresenter.java

License:Apache License

private void showCreateEditDialog(final KindergartenDTO kindergartenDTO) throws ViewFactoryException {
    // create view
    final KindergartenDetail view = this.createView(KindergartenDetail.class);
    // configure the form with bean item
    this.kindergartenForm = view.getKindergartenForm();
    final KindergartenDTO kindergarten = kindergartenDTO;
    final MetaModel metaModel = formService.getMetaModel(kindergarten);
    this.kindergartenForm.setItemDataSource(kindergarten, metaModel, this.messageSource, "kindergarten.detail",
            this.getLocale());

    // create a window using caption from view
    this.dialog = new Window(this.getMessage("kindergarten.detail.caption", this.getLocale()));
    this.dialog.setModal(true);
    this.dialog.addComponent(view);
    this.dialog.getContent().setSizeUndefined();
    this.eventBus.showDialog(this.dialog);
}

From source file:com.tapas.evidence.fe.responsible.ResponsiblePersonPresenter.java

License:Apache License

private void showCreateEditDialog(final ResponsiblePersonDTO responsiblePersonDTO) throws ViewFactoryException {
    // create view
    final ResponsiblePersonDetail view = this.createView(ResponsiblePersonDetail.class);
    // configure the form with bean item
    this.responsiblePersonForm = (ResponsiblePersonDetailForm) view.getResponsiblePersonForm();
    this.responsiblePersonForm.getFooter().setMargin(true, false, false, false);
    final MetaModel metaModel = formService.getMetaModel(responsiblePersonDTO);
    this.responsiblePersonForm.setItemDataSource(responsiblePersonDTO, metaModel, this.messageSource,
            "responsiblePerson.detail", this.getLocale());
    // photo upload setup
    upload = new EvidenceUpload(this.messageSource, this.getLocale());
    upload.setCaption(this.getMessage("responsiblePerson.detail.upload", this.getLocale()));
    this.responsiblePersonForm.addUpload(upload);
    // create a window using caption from view
    this.dialog = new Window(this.getMessage("responsiblePerson.detail.caption", this.getLocale()));
    this.dialog.setModal(true);
    this.dialog.addComponent(view);
    this.dialog.getContent().setSizeUndefined();
    this.eventBus.showDialog(this.dialog);
    if (responsiblePersonDTO.getPhoto() != null) {
        upload.showImage(responsiblePersonDTO.getPhoto());
    } else {//w ww  .j  a v a 2  s  .c  o  m
        upload.showImage(ApplicationConstants.NO_PHOTO);
    }
}