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.iespuigcastellar.attendancemanager.AttendancemanagerApplication.java

License:Open Source License

@Override
public void init() {
    Window mainWindow = new Window(locale.getString("MAINWINDOW_TITLE"));

    LoginLayout loginLayout = new LoginLayout();

    mainWindow.addComponent(loginLayout);
    setMainWindow(mainWindow);/*ww w.jav a 2s  .  c om*/
}

From source file:org.ikasan.dashboard.ui.administration.panel.UserDirectoriesPanel.java

License:BSD License

protected void init() {
    Label userDirectories = new Label("User Directories");
    userDirectories.setStyleName(ValoTheme.LABEL_HUGE);

    Label parapraphOne = new Label();
    parapraphOne.setCaptionAsHtml(true);
    parapraphOne.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The table below shows the user directories currently configured for Ikasan.");
    parapraphOne.addStyleName(ValoTheme.LABEL_TINY);
    parapraphOne.addStyleName(ValoTheme.LABEL_LIGHT);

    Label parapraphTwo = new Label();
    parapraphTwo.setCaptionAsHtml(true);
    parapraphTwo.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml()
            + " The order of the directory is the order in which it will be searched for users and groups."
            + " It is recommended that each user exists in a single directory.");
    parapraphTwo.addStyleName(ValoTheme.LABEL_TINY);
    parapraphTwo.addStyleName(ValoTheme.LABEL_LIGHT);

    this.mainLayout.setWidth("100%");
    this.mainLayout.setSpacing(true);

    this.mainLayout.addComponent(userDirectories);
    this.mainLayout.addComponent(parapraphOne);
    this.mainLayout.addComponent(parapraphTwo);

    Button newDirectoryButton = new Button("Add Directory");
    newDirectoryButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            final UserDirectoryManagementPanel authMethodPanel = new UserDirectoryManagementPanel(
                    new AuthenticationMethod(), securityService, authenticationProviderFactory, ldapService);

            Window window = new Window("Configure User Directory");
            window.setModal(true);//from   w ww .  ja va2 s. c om
            window.setHeight("90%");
            window.setWidth("90%");

            window.setContent(authMethodPanel);

            UI.getCurrent().addWindow(window);

            window.addCloseListener(new Window.CloseListener() {
                @Override
                public void windowClose(Window.CloseEvent e) {
                    populateAll();
                }
            });
        }
    });

    this.mainLayout.addComponent(newDirectoryButton);

    this.setWidth("100%");
    this.setHeight("100%");

    this.directoryTable = new Table();
    this.directoryTable.setWidth("100%");
    this.directoryTable.setHeight("600px");
    this.directoryTable.setCellStyleGenerator(new IkasanCellStyleGenerator());
    this.directoryTable.addContainerProperty("Directory Name", String.class, null);
    this.directoryTable.addContainerProperty("Type", String.class, null);
    this.directoryTable.addContainerProperty("Order", Layout.class, null);
    this.directoryTable.addContainerProperty("Operations", Layout.class, null);

    this.directoryTable.setColumnExpandRatio("Directory Name", 25);
    this.directoryTable.setColumnExpandRatio("Type", 25);

    this.directoryTable.setColumnAlignment("Order", Align.CENTER);
    this.directoryTable.setColumnExpandRatio("Order", 10);
    this.directoryTable.setColumnAlignment("Operations", Align.CENTER);
    this.directoryTable.setColumnWidth("Operations", 300);

    this.mainLayout.addComponent(this.directoryTable);

    this.mainLayout.setMargin(true);

    Panel wrapperPanel = new Panel();
    wrapperPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    wrapperPanel.setSizeFull();
    wrapperPanel.setContent(this.mainLayout);

    HorizontalLayout wrapperLayout = new HorizontalLayout();
    wrapperLayout.setSizeFull();
    wrapperLayout.setMargin(true);
    wrapperLayout.addComponent(wrapperPanel);

    this.setContent(wrapperLayout);
}

From source file:org.ikasan.dashboard.ui.administration.panel.UserDirectoriesPanel.java

License:BSD License

protected void populateDirectoryTable(final AuthenticationMethod authenticationMethod) {
    Button test = new Button("Test");
    test.setStyleName(BaseTheme.BUTTON_LINK);
    test.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                authenticationProviderFactory.testAuthenticationConnection(authenticationMethod);
            } catch (RuntimeException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);//  w w  w  .j a  v  a 2  s .  c o m

                Notification.show("Error occurred while testing connection!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            } catch (Exception e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Error occurred while testing connection!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            }

            Notification.show("Connection Successful!");
        }
    });

    final Button enableDisableButton = new Button();

    if (authenticationMethod.isEnabled()) {
        enableDisableButton.setCaption("Disable");
    } else {
        enableDisableButton.setCaption("Enable");
    }
    enableDisableButton.setStyleName(BaseTheme.BUTTON_LINK);
    enableDisableButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                if (authenticationMethod.isEnabled()) {
                    authenticationMethod.setEnabled(false);
                } else {
                    authenticationMethod.setEnabled(true);
                }

                securityService.saveOrUpdateAuthenticationMethod(authenticationMethod);

                populateAll();
            } catch (RuntimeException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Error trying to enable/disable the authentication method!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            }

            if (authenticationMethod.isEnabled()) {
                enableDisableButton.setCaption("Disable");
                Notification.show("Enabled!");
            } else {
                enableDisableButton.setCaption("Enable");
                Notification.show("Disabled!");
            }
        }
    });

    Button delete = new Button("Delete");
    delete.setStyleName(BaseTheme.BUTTON_LINK);
    delete.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                securityService.deleteAuthenticationMethod(authenticationMethod);

                List<AuthenticationMethod> authenticationMethods = securityService.getAuthenticationMethods();

                directoryTable.removeAllItems();

                long order = 1;

                for (final AuthenticationMethod authenticationMethod : authenticationMethods) {
                    authenticationMethod.setOrder(order++);
                    securityService.saveOrUpdateAuthenticationMethod(authenticationMethod);
                }

                populateAll();
            } catch (RuntimeException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Error trying to delete the authentication method!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            }

            Notification.show("Deleted!");
        }
    });

    Button edit = new Button("Edit");
    edit.setStyleName(BaseTheme.BUTTON_LINK);
    edit.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            UserDirectoryManagementPanel authMethodPanel = new UserDirectoryManagementPanel(
                    authenticationMethod, securityService, authenticationProviderFactory, ldapService);

            Window window = new Window("Configure User Directory");
            window.setModal(true);
            window.setHeight("90%");
            window.setWidth("90%");

            window.setContent(authMethodPanel);

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

    Button synchronise = new Button("Synchronise");
    synchronise.setStyleName(BaseTheme.BUTTON_LINK);

    synchronise.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                ldapService.synchronize(authenticationMethod);

                authenticationMethod.setLastSynchronised(new Date());
                securityService.saveOrUpdateAuthenticationMethod(authenticationMethod);

                populateAll();
            } catch (UnexpectedRollbackException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                logger.error("Most specific cause: " + e.getMostSpecificCause());
                e.getMostSpecificCause().printStackTrace();
                logger.error("Most specific cause: " + e.getRootCause());
                e.getRootCause().printStackTrace();

                Notification.show("Error occurred while synchronizing!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            } catch (RuntimeException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Error occurred while synchronizing!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            } catch (Exception e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Error occurred while synchronizing!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            }

            Notification.show("Synchronized!");
        }
    });

    GridLayout operationsLayout = new GridLayout(9, 2);
    operationsLayout.setWidth("250px");
    operationsLayout.addComponent(enableDisableButton, 0, 0);
    operationsLayout.addComponent(new Label(" "), 1, 0);
    operationsLayout.addComponent(edit, 2, 0);
    operationsLayout.addComponent(new Label(" "), 3, 0);
    operationsLayout.addComponent(delete, 4, 0);
    operationsLayout.addComponent(new Label(" "), 5, 0);
    operationsLayout.addComponent(test, 6, 0);
    operationsLayout.addComponent(new Label(" "), 7, 0);
    operationsLayout.addComponent(synchronise, 8, 0);

    TextArea synchronisedTextArea = new TextArea();
    synchronisedTextArea.setRows(3);
    synchronisedTextArea.setWordwrap(true);

    if (authenticationMethod.getLastSynchronised() != null) {
        synchronisedTextArea.setValue(
                "This directory was last synchronised at " + authenticationMethod.getLastSynchronised());
    } else {
        synchronisedTextArea.setValue("This directory has not been synchronised");
    }

    synchronisedTextArea.setSizeFull();
    synchronisedTextArea.setReadOnly(true);

    operationsLayout.addComponent(synchronisedTextArea, 0, 1, 8, 1);

    HorizontalLayout orderLayout = new HorizontalLayout();
    orderLayout.setWidth("50%");

    if (authenticationMethod.getOrder() != 1) {
        Button upArrow = new Button(VaadinIcons.ARROW_UP);
        upArrow.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        upArrow.addStyleName(ValoTheme.BUTTON_BORDERLESS);
        upArrow.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                if (authenticationMethod.getOrder() != 1) {
                    AuthenticationMethod upAuthMethod = securityService
                            .getAuthenticationMethodByOrder(authenticationMethod.getOrder() - 1);

                    upAuthMethod.setOrder(authenticationMethod.getOrder());
                    authenticationMethod.setOrder(authenticationMethod.getOrder() - 1);

                    securityService.saveOrUpdateAuthenticationMethod(upAuthMethod);
                    securityService.saveOrUpdateAuthenticationMethod(authenticationMethod);

                    populateAll();
                }
            }
        });

        orderLayout.addComponent(upArrow);
    }

    long numberOfAuthMethods = securityService.getNumberOfAuthenticationMethods();

    if (authenticationMethod.getOrder() != numberOfAuthMethods) {
        Button downArrow = new Button(VaadinIcons.ARROW_DOWN);
        downArrow.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        downArrow.addStyleName(ValoTheme.BUTTON_BORDERLESS);
        downArrow.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                long numberOfAuthMethods = securityService.getNumberOfAuthenticationMethods();

                if (authenticationMethod.getOrder() != numberOfAuthMethods) {
                    AuthenticationMethod downAuthMethod = securityService
                            .getAuthenticationMethodByOrder(authenticationMethod.getOrder() + 1);

                    downAuthMethod.setOrder(authenticationMethod.getOrder());
                    authenticationMethod.setOrder(authenticationMethod.getOrder() + 1);

                    securityService.saveOrUpdateAuthenticationMethod(downAuthMethod);
                    securityService.saveOrUpdateAuthenticationMethod(authenticationMethod);

                    populateAll();
                }
            }
        });

        orderLayout.addComponent(downArrow);
    }

    this.directoryTable.addItem(new Object[] { authenticationMethod.getName(), "Microsoft Active Directory",
            orderLayout, operationsLayout }, authenticationMethod);
}

From source file:org.investovator.ui.main.AdminGameConfigLayout.java

License:Open Source License

private void startDailySummaryAddGameWizard() {
    // Create a sub-window and set the content
    Window subWindow = new Window("Create New Game");
    VerticalLayout subContent = new VerticalLayout();
    subContent.setMargin(true);/*from  w w  w. ja v  a2  s.  c o m*/
    subWindow.setContent(subContent);

    // Put some components in it
    subContent.addComponent(new NewDataPlaybackGameWizard(subWindow));

    // set window characteristics
    subWindow.center();
    subWindow.setClosable(false);
    subWindow.setDraggable(false);
    subWindow.setResizable(false);
    subWindow.setModal(true);

    subWindow.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent closeEvent) {
            //getUI().getNavigator().navigateTo(UIConstants.MAINVIEW);
            getUI().getPage().reload();
        }
    });

    // Add it to the root component
    UI.getCurrent().addWindow(subWindow);
}

From source file:org.investovator.ui.main.components.AdminGameCreateView.java

License:Open Source License

private void startDailySummaryAddGameWizard() {
    // Create a sub-window and set the content
    Window subWindow = new Window("Create New Game");
    VerticalLayout subContent = new VerticalLayout();
    subContent.setMargin(true);//from   ww w.j av  a  2  s .  com
    subWindow.setContent(subContent);

    // Put some components in it
    subContent.addComponent(new NewDataPlaybackGameWizard(subWindow));

    // set window characteristics
    subWindow.center();
    subWindow.setClosable(false);
    subWindow.setDraggable(false);
    subWindow.setResizable(false);
    subWindow.setModal(true);

    subWindow.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(Window.CloseEvent closeEvent) {
            getUI().getNavigator().navigateTo(UIConstants.MAINVIEW);
            //                getUI().getPage().reload();
        }
    });

    // Add it to the root component
    UI.getCurrent().addWindow(subWindow);
}

From source file:org.javabuilders.vaadin.sample.MyVaadinApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("My Vaadin Application");
    setMainWindow(window);//from  w  ww  .  j  av a2s  .c o m
    window.addComponent(new Button("Click Me"));
}

From source file:org.jdal.vaadin.ui.FormUtils.java

License:Apache License

/**
 * Show a YES/NO confirm dialog//from   ww w . j  a  va2 s.c  om
 * @param window Window to attach the dialog
 * @param msg the msg
 */
public static void showConfirmDialog(UI ui, final Command command, String msg) {

    final Window dlg = new Window("Please Confirm");
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    vl.setSpacing(true);
    vl.setMargin(true);
    Label label = new Label(msg, Label.CONTENT_XHTML);
    vl.addComponent(label);
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);

    Button ok = new Button(StaticMessageSource.getMessage("yes"));
    ok.addClickListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            command.execute(null);
            closeWindow(dlg);

        }
    });
    Button cancel = new Button(StaticMessageSource.getMessage("no"));
    cancel.addClickListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            closeWindow(dlg);
        }
    });

    hl.setSpacing(true);
    hl.addComponent(ok);
    hl.addComponent(cancel);
    hl.setSizeFull();
    vl.addComponent(hl);
    vl.setComponentAlignment(hl, Alignment.TOP_CENTER);

    dlg.setContent(vl);
    dlg.setModal(true);
    vl.setSizeUndefined();

    ui.addWindow(dlg);
}

From source file:org.kani.Application.java

License:Apache License

private void loadProtectedResources() {
    String applicationTitle = getMessage("title");
    main = new Window(applicationTitle);
    mainLayout = (VerticalLayout) main.getContent();
    mainLayout.setMargin(false);//  www  . j a  v  a  2  s  .c o  m
    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 (String viewKey : views.keySet()) {
        Object view = views.get(viewKey);
        String viewName = getMessage(viewKey, "title");
        Method createMethod;
        try {
            createMethod = view.getClass().getMethod("create", org.kani.Application.class);
            Component viewContent = (Component) createMethod.invoke(view, this);

            String viewIconPath = getMessage(viewKey, "icon");
            Resource viewIcon = new ClassResource(viewIconPath, this);

            tabSheet.addTab(viewContent, viewName, viewIcon);
        } catch (Exception e) {
            logger.log(Level.SEVERE, String.format("Could not initialize view %s", viewKey), e);
        }
    }
}

From source file:org.kani.Application.java

License:Apache License

private Window getAboutDialog() {
    if (aboutWindow == null) {
        aboutWindow = new Window("About...");
        aboutWindow.setModal(true);/*from   ww  w.java 2  s  .c  o 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 ?? and others.<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);

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

        });
        layout.addComponent(close);
        layout.setComponentAlignment(close, Alignment.MIDDLE_RIGHT);
    }
    return aboutWindow;
}

From source file:org.metawidget.example.vaadin.addressbook.AddressBook.java

License:BSD License

@Override
public void init() {

    setTheme("addressbook");
    Window mainWindow = new Window("Address Book (Metawidget Vaadin Example)");
    ((Layout) mainWindow.getContent()).setMargin(false);
    mainWindow.addComponent(mContent);//from  ww  w.  j  a va 2  s  .c om
    setMainWindow(mainWindow);
}