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:org.opennms.features.vaadin.dashboard.config.ui.PreviewClickListener.java

License:Open Source License

@Override
public void buttonClick(Button.ClickEvent clickEvent) {
    final Window window = new Window("Preview");

    window.setModal(true);/*from  w  ww  .j  a  v a  2  s . c  o  m*/
    window.setClosable(false);
    window.setResizable(false);

    window.setWidth("80%");
    window.setHeight("90%");

    m_component.getUI().addWindow(window);

    final WallboardBody wallboardBody = new WallboardBody();

    window.setContent(new VerticalLayout() {
        {
            setMargin(true);
            setSpacing(true);
            setSizeFull();

            addComponent(wallboardBody);
            setExpandRatio(wallboardBody, 1.0f);
            addComponent(new HorizontalLayout() {
                {
                    setMargin(true);
                    setSpacing(true);
                    setWidth("100%");

                    Button closeButton = new Button("Close");

                    addComponent(closeButton);
                    setComponentAlignment(closeButton, Alignment.MIDDLE_RIGHT);
                    closeButton.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent clickEvent) {
                            window.close();
                        }
                    });
                }
            });
        }
    });
    wallboardBody.setDashletSpecs(m_wallboard.getDashletSpecs());
}

From source file:org.opennms.features.vaadin.dashboard.config.ui.WallboardConfigView.java

License:Open Source License

/**
 * This method is used to add a new {@link TabSheet.Tab} component. It creates a new window querying the user for the name of the new {@link Wallboard}.
 *///w  ww .  j a v a2 s .c  o m
protected void addNewTabComponent() {
    final Window window = new Window("New Ops Board");

    window.setModal(true);
    window.setClosable(false);
    window.setResizable(false);
    window.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent e) {
            m_dashboardOverview.refreshTable();
        }
    });
    getUI().addWindow(window);

    window.setContent(new VerticalLayout() {
        TextField name = new TextField("Ops Board Name");

        {
            addComponent(new FormLayout() {
                {
                    setSizeUndefined();
                    setMargin(true);

                    String newName = "Untitled";
                    int i = 1;
                    if (WallboardProvider.getInstance().containsWallboard(newName)) {
                        do {
                            i++;
                            newName = "Untitled #" + i;
                        } while (WallboardProvider.getInstance().containsWallboard(newName));
                    }
                    name.setValue(newName);
                    addComponent(name);
                    name.focus();
                    name.selectAll();

                    name.addValidator(new AbstractStringValidator("Title must be unique") {
                        @Override
                        protected boolean isValidValue(String s) {
                            return (!WallboardProvider.getInstance().containsWallboard(s) && !"".equals(s));
                        }
                    });
                }
            });

            addComponent(new HorizontalLayout() {
                {
                    setMargin(true);
                    setSpacing(true);
                    setWidth("100%");

                    Button cancel = new Button("Cancel");
                    cancel.setDescription("Cancel editing");
                    cancel.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            // NMS-7560: Toggle the tab in order to allow us to click it again
                            m_tabSheet.togglePlusTab();
                            window.close();
                        }
                    });

                    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
                    addComponent(cancel);
                    setExpandRatio(cancel, 1);
                    setComponentAlignment(cancel, Alignment.TOP_RIGHT);

                    Button ok = new Button("Save");
                    ok.setDescription("Save configuration");
                    ok.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            if (name.isValid()) {
                                Wallboard wallboard = new Wallboard();
                                wallboard.setTitle(name.getValue());

                                WallboardProvider.getInstance().addWallboard(wallboard);
                                WallboardProvider.getInstance().save();

                                WallboardEditor wallboardEditor = new WallboardEditor(m_dashletSelector,
                                        wallboard);
                                TabSheet.Tab tab = m_tabSheet.addTab(wallboardEditor, wallboard.getTitle());

                                wallboardEditor.setTab(tab);

                                m_wallboardEditorMap.put(wallboard, tab);

                                tab.setClosable(true);

                                m_tabSheet.setSelectedTab(tab);

                                window.close();
                            }
                        }
                    });

                    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

                    addComponent(ok);
                }
            });
        }
    });
}

From source file:org.opennms.features.vaadin.surveillanceviews.ui.PreviewClickListener.java

License:Open Source License

/**
 * {@inheritDoc}/*from   w  ww. j  a  v  a  2 s. c  o m*/
 */
@Override
public void buttonClick(Button.ClickEvent clickEvent) {
    final Window window = new Window("Preview");

    window.setModal(true);
    window.setClosable(true);
    window.setResizable(false);

    window.setWidth("80%");
    window.setHeight("90%");

    m_component.getUI().addWindow(window);

    window.setContent(new VerticalLayout() {
        {
            addComponent(new VerticalLayout() {
                {
                    setMargin(true);
                    setSpacing(true);
                    setSizeFull();

                    addComponent(new SurveillanceView(m_view, m_surveillanceViewService, false, false));
                }
            });
        }
    });
}

From source file:org.ops4j.pax.vaadin.samples.complex.app.MyComplexVaadinApplication.java

License:Apache License

@Override
public void init() {

    // TODO CHECK WHY THEME RENDERING IS TOO SLOW
    // setTheme("table");

    window = new Window("My Complex Vaadin Application");
    setMainWindow(window);/*from  ww  w . j  a v  a 2 s .co  m*/

    final VerticalLayout layout = new VerticalLayout();
    final Table table = new Table("The Pax projects");
    table.addStyleName("multirowlabels");

    // Define two columns for the built-in container
    table.addContainerProperty("Code", String.class, null);
    table.addContainerProperty("Description", String.class, null);
    table.addContainerProperty("Creation Date", Date.class, null);
    // table.addContainerProperty("Edit", CheckBox.class, null);

    // Add a row the hard way
    Object newItemId = table.addItem();
    Item row1 = table.getItem(newItemId);
    row1.getItemProperty("Code").setValue("pax-vaadin");
    row1.getItemProperty("Description").setValue("OSGI vaadin project");
    //row1.getItemProperty("Creation date").setValue(new Date());

    // Add a few other rows using shorthand addItem()
    table.addItem(new Object[] { "pax-cdi", "pax cdi project", new Date() }, 2);
    table.addItem(new Object[] { "pax-logging", "pax logging project", new Date() }, 3);
    table.addItem(new Object[] { "pax-runner", "osgi runner tool", new Date() }, 4);
    table.addItem(new Object[] { "pax-web", "pax web project", new Date() }, 5);
    table.addItem(new Object[] { "pax-jdbc", "pax jdbc project", new Date() }, 6);

    // Allow selecting
    table.setSelectable(true);

    // Put the table in editable mode
    table.setEditable(false);

    // Reordering
    table.setColumnReorderingAllowed(true);

    // Allow switching to non-editable mode
    final CheckBox editable = new CheckBox("Table is editable", false);
    editable.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 6291942958587745232L;

        public void valueChange(ValueChangeEvent event) {
            table.setEditable((Boolean) editable.getValue());
        }
    });
    editable.setImmediate(true);
    layout.addComponent(editable);

    // Handle selection changes
    table.addListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            if (event.getProperty().getValue() != null) {
                layout.addComponent(new Label("Selected item id " + event.getProperty().getValue().toString()));
            } else // Item deselected
            {
                layout.addComponent(new Label("Nothing selected"));
            }
        }
    });

    // Set Table Size
    table.setPageLength(table.size());

    layout.addComponent(table);
    window.addComponent(layout);

    IndexedContainer container = new IndexedContainer();
    container.addContainerProperty("foo", String.class, null);
    container.addContainerProperty("bar", String.class, null);
    container.addContainerProperty("baz", String.class, null);
    for (int i = 0; i < 100; i++) {
        Item item = container.addItem(i);
        item.getItemProperty("foo").setValue("foo " + i);
        item.getItemProperty("bar").setValue("bar");
        item.getItemProperty("baz").setValue("baz");
    }
    PagedTable pagedTable = new PagedTable("footable");
    pagedTable.setContainerDataSource(container);
    pagedTable.setPageLength(15);
    window.addComponent(pagedTable);
    window.addComponent(pagedTable.createControls());
    setMainWindow(window);

}

From source file:org.ortens.bone.client.ui.jpacontainer.VaadinJPAContainerApplication.java

License:Apache License

@Override
public void init() {
    this.getContext().addTransactionListener(this);
    this.mainWindow = new Window("My TOP GUN Vaadin JPA Client");
    this.setMainWindow(mainWindow);
    mainWindow.setContent(new LoginScreen(this));
}

From source file:org.pax.vaadin.samples.simple.app.MyVaadinApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("My Vaadin Application");
    setMainWindow(window);//w  w  w  .j  av a 2  s . com

    // Click & Fails Me buttons
    Button clickButton = new Button("Click Me");
    Button failsButton = new Button("Fail Me");

    // Notification displayed when click button is called
    final Window.Notification notif = new Window.Notification("The time is " + new Date(),
            Window.Notification.TYPE_WARNING_MESSAGE);
    // Notification position.
    notif.setPosition(Window.Notification.POSITION_CENTERED_BOTTOM);

    // Add a listener on Click button
    clickButton.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            window.addComponent(new Label("Thank you for clicking"));
            window.showNotification(notif);
        }
    });

    // Add a listener for Fails button
    failsButton.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            // Throw some exception.
            throw new RuntimeException("You can't catch this.");
        }
    });

    window.addComponent(clickButton);
    window.addComponent(failsButton);

}

From source file:org.processbase.ui.portlet.ChartPortlet.java

License:Open Source License

@Override
public void init() {
    setCurrent(this);
    if (!BAMConstants.LOADED) {
        BAMConstants.loadConstants();//from ww w  . ja v  a 2 s  . c  o m
    }
    messages = ResourceBundle.getBundle("resources/MessagesBundle", getLocale());
    portletApplicationContext2 = (PortletApplicationContext2) getContext();
    portletSession = portletApplicationContext2.getPortletSession();
    portletApplicationContext2.addPortletListener((Application) this, (PortletListener) this);
    setTheme("processbase");
    if (getContext() != null) {
        getContext().addTransactionListener(this);
    }
    mainWindow = new Window("Chart Application");
    mainWindow.setSizeFull();
    setMainWindow(mainWindow);

    configPanel = new ChartConfigurationPanel();
    recreateChartView();
}

From source file:org.processbase.ui.servlet.MainWindow.java

License:Open Source License

void openLogoutWindow() {
    Window logout = new Window(((PbApplication) getApplication()).getPbMessages().getString("btnLogout"));
    logout.setModal(true);//from   w w  w  .j  av  a  2s .c  om
    //        logout.setStyleName(Reindeer.WINDOW_BLACK);
    logout.setWidth("260px");
    logout.setResizable(false);
    logout.setClosable(false);
    logout.setDraggable(false);
    logout.setCloseShortcut(KeyCode.ESCAPE, null);

    Label helpText = new Label("Are you sure you want to log out?", Label.CONTENT_XHTML);
    logout.addComponent(helpText);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    Button yes = new Button(((PbApplication) getApplication()).getPbMessages().getString("btnLogout"),
            new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                    WebApplicationContext applicationContext = (WebApplicationContext) getApplication()
                            .getContext();
                    getApplication().close();
                    applicationContext.getHttpSession().invalidate();
                }
            });
    yes.setStyleName(Reindeer.BUTTON_DEFAULT);
    yes.focus();
    buttons.addComponent(yes);
    Button no = new Button(((PbApplication) getApplication()).getPbMessages().getString("btnCancel"),
            new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                    removeWindow(event.getButton().getWindow());
                }
            });
    buttons.addComponent(no);

    logout.addComponent(buttons);
    ((VerticalLayout) logout.getContent()).setComponentAlignment(buttons, Alignment.MIDDLE_CENTER);
    ((VerticalLayout) logout.getContent()).setSpacing(true);

    addWindow(logout);
}

From source file:org.qi4j.library.vaadin.MyVaadinApplication.java

License:Open Source License

@Override
public void init() {
    final TextField field = new TextField();
    field.setInputPrompt("Type your name here");
    Button button = new Button("Greetings mortals..");
    button.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            String name = "" + field.getValue();
            if (name.length() <= 0) {
                window.showNotification("You must type your name in the field",
                        Window.Notification.TYPE_ERROR_MESSAGE);
            } else {
                window.showNotification(greeter.greet("" + field.getValue()));
            }//  ww w. j a v  a2  s .  c om
        }

    });

    HorizontalLayout horizLayout = new HorizontalLayout();
    horizLayout.setMargin(true);
    horizLayout.addComponent(field);
    horizLayout.addComponent(button);

    Panel panel = new Panel("Vaadin seems nice : )");
    panel.addComponent(horizLayout);

    VerticalLayout vertLayout = new VerticalLayout();
    vertLayout.setMargin(true);
    vertLayout.addComponent(panel);

    window = new Window("test app");
    window.setSizeFull();
    window.setContent(vertLayout);
    setMainWindow(window);
}

From source file:org.robot.gtf.gui.GTFApplication.java

License:Apache License

@Override
public void init() {
    buildNewProjectWindow();//from w ww.  jav a 2s.c  o  m
    buildAboutWindow();
    buildMenuButtons();

    HorizontalLayout container = new HorizontalLayout();

    window = new Window(TextResources.getAppName() + " - " + TextResources.getAppVersion());
    window.setTheme("runo");
    window.setContent(container);
    setMainWindow(window);

    // Main Menu
    VerticalLayout menuContainer = new VerticalLayout();
    menuContainer.addComponent(buttonNewTestProject);
    menuContainer.addComponent(buttonOpenTestProject);
    menuContainer.addComponent(buttonSettings);
    menuContainer.addComponent(buttonHelp);
    menuContainer.setMargin(true, true, false, true);

    container.addComponent(menuContainer);

    // Main Content
    VerticalLayout mainContent = new VerticalLayout();
    mainContent.setMargin(true, false, false, false);
    mainContent.setSpacing(true);

    // Heading Layout
    VerticalLayout headingContent = new VerticalLayout();
    headingContent.setStyleName("v-window-header ");

    Label heading = new Label(TextResources.getAppName() + " - " + TextResources.getAppVersion());
    heading.setStyleName("v-label-h1");
    headingContent.addComponent(heading);

    mainContent.addComponent(headingContent);

    projectNameHeading = new Label();
    projectNameHeading.setStyleName("v-label-h3");
    mainContent.addComponent(projectNameHeading);

    // Testcase table and Scenario selection
    HorizontalLayout testcases = new HorizontalLayout();
    table.setVisible(false);

    // Selection list with scenarios
    scenariosListSelect.setNullSelectionAllowed(false);
    scenariosListSelect.setImmediate(true);
    scenariosListSelect.setVisible(false);

    testcases.setSpacing(true);
    testcases.addComponent(table);
    testcases.addComponent(scenariosListSelect);

    mainContent.addComponent(testcases);

    // Button Container
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);

    // Table Add Button
    addRowButton = new Button("Add Testcase", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            if (table2 == null) {
                table.addItem();
            } else {
                table2.addItem();
            }
        }
    });
    addRowButton.addStyleName(Runo.BUTTON_SMALL);
    addRowButton.addStyleName(Runo.BUTTON_DEFAULT);
    addRowButton.setIcon(new ThemeResource("../runo/icons/16/document-add.png"));
    addRowButton.setVisible(false);
    buttons.addComponent(addRowButton);

    // Table Save Button
    saveButton = new Button("Save", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
        }
    });
    saveButton.addStyleName(Runo.BUTTON_SMALL);
    saveButton.addStyleName(Runo.BUTTON_DEFAULT);
    saveButton.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
    saveButton.setVisible(false);
    buttons.addComponent(saveButton);

    mainContent.addComponent(buttons);
    container.addComponent(mainContent);
}