Example usage for com.vaadin.ui CssLayout addComponent

List of usage examples for com.vaadin.ui CssLayout addComponent

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:de.fatalix.app.view.login.LoginView.java

private CssLayout buildLoginInformation() {
    CssLayout loginInformation = new CssLayout();
    loginInformation.setStyleName("login-information");
    Label loginInfoText = new Label("<h1>Welcome to Bookshelf</h1>"
            + "Please provide your login to access your library. If you have problems logging in, please contact your administrator.",
            ContentMode.HTML);/*from  ww  w .j  ava2 s  . c o m*/
    loginInformation.addComponent(loginInfoText);
    return loginInformation;
}

From source file:de.fatalix.bookery.view.login.LoginView.java

License:Open Source License

public LoginView() {
    setSizeFull();//from   w ww.  ja va  2s.co m
    CssLayout rootLayout = new CssLayout();
    rootLayout.addStyleName("login-screen");

    Component loginForm = buildLoginForm();

    VerticalLayout centeringLayout = new VerticalLayout();
    centeringLayout.setStyleName("centering-layout");
    centeringLayout.addComponent(loginForm);
    centeringLayout.setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);

    CssLayout loginInformation = buildLoginInformation();

    rootLayout.addComponent(centeringLayout);
    rootLayout.addComponent(loginInformation);

    setCompositionRoot(rootLayout);

}

From source file:de.fatalix.bookery.view.login.LoginView.java

License:Open Source License

private Component buildLoginForm() {
    FormLayout loginForm = new FormLayout();

    loginForm.addStyleName("login-form");
    loginForm.setSizeUndefined();//from  w ww.j a  va 2s .  c om
    loginForm.setMargin(false);

    loginForm.addComponent(username = new TextField("Username", "admin"));
    username.setWidth(15, Unit.EM);
    loginForm.addComponent(password = new PasswordField("Password"));
    password.setWidth(15, Unit.EM);
    password.setDescription("");

    CssLayout buttons = new CssLayout();
    buttons.setStyleName("buttons");
    loginForm.addComponent(buttons);
    login = new Button("login");
    buttons.addComponent(login);
    login.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                presenter.doLogin(username.getValue(), password.getValue());
            } catch (AuthenticationException ex) {
                LoginView.this.showNotification(
                        new Notification("Wrong login", Notification.Type.ERROR_MESSAGE),
                        ValoTheme.NOTIFICATION_FAILURE);
            } finally {
                login.setEnabled(true);
            }
        }
    });
    login.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    buttons.addComponent(forgotPassword = new Button("Forgot password?"));
    forgotPassword.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            showNotification(new Notification("Hint: Ask me", Notification.Type.HUMANIZED_MESSAGE),
                    ValoTheme.NOTIFICATION_SUCCESS);
        }
    });
    forgotPassword.addStyleName(ValoTheme.BUTTON_LINK);
    Panel loginPanel = new Panel(loginForm);
    loginPanel.setWidthUndefined();
    loginPanel.addStyleName(ValoTheme.PANEL_BORDERLESS);
    loginPanel.addAction(new ShortcutListener("commit", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            try {
                presenter.doLogin(username.getValue(), password.getValue());
            } catch (AuthenticationException ex) {
                LoginView.this.showNotification(
                        new Notification("Wrong login", Notification.Type.ERROR_MESSAGE),
                        ValoTheme.NOTIFICATION_FAILURE);
            }
        }
    });
    return loginPanel;
}

From source file:de.fatalix.bookery.view.login.LoginView.java

License:Open Source License

private CssLayout buildLoginInformation() {
    CssLayout loginInformation = new CssLayout();
    loginInformation.setStyleName("login-information");
    Label loginInfoText = new Label("<h1>Welcome to Bookery</h1>"
            + "Please provide your login to access your library. If you have problems logging in, please contact your administrator.",
            ContentMode.HTML);// w  w w.  j a v a 2  s  .  c o m
    loginInformation.addComponent(loginInfoText);
    return loginInformation;
}

From source file:de.kaiserpfalzEdv.vaadin.LoginScreen.java

License:Apache License

private Component buildLoginForm() {
    FormLayout loginForm = new FormLayout();

    loginForm.addStyleName("login-form");
    loginForm.setSizeUndefined();//from w w  w.  j ava2  s . c om
    loginForm.setMargin(false);

    loginForm.addComponent(username = new TextField(translate("login.name.caption")));
    username.setDescription(translate("login.name.description"));
    username.setWidth(15, Unit.EM);
    loginForm.addComponent(password = new PasswordField(translate("login.password.caption")));
    password.setWidth(15, Unit.EM);
    password.setDescription(translate("login.password.description"));
    CssLayout buttons = new CssLayout();
    buttons.setStyleName("buttons");
    loginForm.addComponent(buttons);

    login = new Button(translate("login.login-button.caption"));
    buttons.addComponent(login);
    login.setDescription(translate("login.login-button.description"));
    login.setDisableOnClick(true);
    login.addClickListener(event -> {
        try {
            login();
        } finally {
            login.setEnabled(true);
        }
    });
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    Button forgotPassword;
    buttons.addComponent(forgotPassword = new Button(translate("login.password-forgotten.caption")));
    forgotPassword.setDescription(translate("login.password-forgotten.description"));
    forgotPassword.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            NotificationPayload notification = new NotificationPayload("login.password-forgotten.text");
            bus.post(new NotificationEvent(this, notification));
        }
    });
    forgotPassword.addStyleName(ValoTheme.BUTTON_LINK);
    return loginForm;
}

From source file:de.kaiserpfalzEdv.vaadin.LoginScreen.java

License:Apache License

private CssLayout buildLoginInformation() {
    CssLayout loginInformation = new CssLayout();
    loginInformation.setStyleName("login-information");
    Label loginInfoText = new Label(translate("login.info-text"), ContentMode.HTML);
    loginInformation.addComponent(loginInfoText);
    return loginInformation;
}

From source file:de.lmu.ifi.dbs.knowing.vaadin.MainApplication.java

License:Apache License

private Window getAboutDialog() {
    if (aboutWindow == null) {
        aboutWindow = new Window("About...");
        aboutWindow.setModal(true);//from   w w  w  .j av a2 s.c o m
        aboutWindow.setWidth("400px");

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

        CssLayout titleLayout = new CssLayout();
        H2 title = new H2("Knowing Vaadin Application");
        titleLayout.addComponent(title);
        SmallText description = new SmallText("<br>Copyright (c) Nepomuk Seiler, LMU Database <br>"
                + "Licensed under Apache Software Foundation 2.0 license (ASF).<br><br>"
                + "This software contains modules licenced under<br>"
                + " the Apache Software Foundation 2.0 license (ASF) and EPL<br><br>"
                + "Many thanks to Kai Tdter, 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, Alignment.TOP_RIGHT);
    }
    return aboutWindow;
}

From source file:de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsSubComponent.java

License:Open Source License

public void addComponentToCountLayout(CssLayout countLayout, AbstractComponent countElement) {
    countElement.setWidthUndefined();/*from   w w  w.jav a  2s  . co m*/
    countElement.addStyleName(CssStyles.HSPACE_RIGHT_3);
    countLayout.addComponent(countElement);
}

From source file:de.symeda.sormas.ui.login.LoginScreen.java

License:Open Source License

private void buildUI() {
    addStyleName("login-screen");

    // login form, centered in the available part of the screen
    VerticalLayout loginFormLayout = new VerticalLayout();
    loginFormLayout.addStyleName("login-form");
    loginFormLayout.setMargin(false);/*  w w  w .jav  a  2 s . c o  m*/
    Component loginForm = buildLoginForm();
    loginFormLayout.addComponent(loginForm);
    loginFormLayout.addComponent(buildLoginDetailsLayout());

    // layout to center login form when there is sufficient screen space
    // - see the theme for how this is made responsive for various screen
    // sizes
    CssLayout loginLayout = new CssLayout();
    loginLayout.setStyleName("login-form-container");
    loginLayout.addComponent(loginFormLayout);

    // information text about logging in
    CssLayout loginInformation = buildLoginInformation();

    // custom html layout
    CssLayout loginSidebarLayout = buildLoginSidebarLayout();

    addComponent(loginInformation);
    addComponent(loginLayout);
    addComponent(loginSidebarLayout);
}

From source file:de.symeda.sormas.ui.login.LoginScreen.java

License:Open Source License

private CssLayout buildLoginInformation() {
    CssLayout loginInformation = new CssLayout();
    loginInformation.setStyleName("login-information");

    VerticalLayout innerLayout = new VerticalLayout();
    innerLayout.setSizeFull();/*from   www.  ja v  a 2 s  .  c o m*/

    Image img = new Image(null, new ThemeResource("img/sormas-logo-big.png"));
    img.setHeight(240, Unit.PIXELS);
    innerLayout.addComponent(img);
    innerLayout.setComponentAlignment(img, Alignment.TOP_CENTER);
    innerLayout.setExpandRatio(img, 0);

    Label loginInfoText = new Label("<h1>SORMAS</h1>"
            + "<h2 style='color:white'>Surveillance, Outbreak Response Management and Analysis System</h2>"
            + "<h3 style='color:white; text-transform:uppercase'>&#9679; Disease Prevention<br>&#9679; Disease Detection<br>&#9679; Outbreak Response</h3>",
            ContentMode.HTML);
    loginInfoText.setWidth(100, Unit.PERCENTAGE);
    innerLayout.addComponent(loginInfoText);
    innerLayout.setExpandRatio(loginInfoText, 1);

    Label loginInfoCopyright = new Label(" 2019 SORMAS. All Rights Reserved.");
    loginInfoCopyright.setWidth(100, Unit.PERCENTAGE);
    innerLayout.addComponent(loginInfoCopyright);
    innerLayout.setExpandRatio(loginInfoCopyright, 0);
    innerLayout.setComponentAlignment(loginInfoCopyright, Alignment.BOTTOM_LEFT);

    loginInformation.addComponent(innerLayout);
    return loginInformation;
}