Example usage for com.vaadin.ui VerticalLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:by.bigvova.ui.LoginUI.java

License:Apache License

private Component buildFields() {
    final VerticalLayout layout = new VerticalLayout();
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);/*from   ww  w.j a v  a  2  s  .c o  m*/
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final PasswordField password = new PasswordField("Password");
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    signin.focus();

    final CheckBox checkBox = new CheckBox("Remember me", true);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            login(username.getValue(), password.getValue(), checkBox.getValue());
        }
    });

    fields.addComponents(username, password, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    layout.setSpacing(true);
    layout.addComponent(fields);
    layout.addComponent(checkBox);
    return layout;
}

From source file:by.bigvova.views.HomeView.java

License:Apache License

public HomeView() {
    setSpacing(true);/*from   www .ja  v a  2s.c  o m*/
    setMargin(true);
    setSizeFull();

    Label header = new Label("   -=FoodNote=-");
    header.addStyleName(ValoTheme.LABEL_H1);
    addComponent(header);
    Label body = new Label(
            "<h3> ?? ? ? <b>CRUD</b> ?  ? <b>enterprise</b> ."
                    + "   ?  ?? ,    ?  ? .</h3>"
                    + "? ?:" + "<ul>"
                    + "<li>?  ?  <b>Spring Boot</b>, ? ? - propertie .</li>"
                    + "<li>? ?  ?? ? ???   <b>Repository</b> - <b>Spring Data JPA</b>, <b>Hibernate</b> (<b>JdbcTemplate</b>  ?).</li>"
                    + "<li> ?? - ?? ,  :</li>"
                    + "<ul>" + "<li>  - <b>PostgreSQL</b></li>"
                    + "<li>connection pool - <b>HikariCP</b></li>" + "</ul>"
                    + "<li>? - <b>EhCache</b>.</li>"
                    + "<li> ? -  <b>EventBus</b>, ? <b>Google Guava</b>.</li>"
                    + "<li>?,  - <b>Spring Security</b>:</li>"
                    + "<ul>"
                    + "<li>    , ? <b>UserDetails</b></li>"
                    + "<li> ??   ? <b>BCrypt</b></li>"
                    + "<li>  <b>Remember Me</b> ??</li>"
                    + "</ul>" + "<li>? - <b>JUnit4</b></li>"
                    + "<li> - <b>slf4j</b>, <b>logback</b></li>"
                    + "<li>Front-end - <b>Vaadin framework</b>, <b>GWT</b></li>"
                    + "<li>   <b>Docker</b>      ? <b>Ubuntu Server 14.04</b></li>"
                    + "</ul>"
                    + "<p>? Spring Boot - Vaadin ?? : <a href=\"https://github.com/peholmst/vaadin4spring\">vaadin4spring</a></p>"
                    + "<p> ? <a href=\"https://github.com/BigVOVA/FoodNote\">github.com/BigVOVA/FoodNote</a></p>");
    body.setContentMode(ContentMode.HTML);
    VerticalLayout bodyLayout = new VerticalLayout();
    bodyLayout.setWidth(100, Unit.PERCENTAGE);
    bodyLayout.setMargin(new MarginInfo(false, true, false, true));
    bodyLayout.addComponent(body);
    Panel panel = new Panel();
    panel.setSizeFull();
    panel.setContent(bodyLayout);
    addComponent(panel);
    setExpandRatio(panel, 1);
}

From source file:by.bigvova.views.UserView.UserView.java

License:Apache License

@Override
public void enter(ViewChangeListener.ViewChangeEvent viewChangeEvent) {
    setSizeFull();// w  ww.j  a v a  2s  .c  o  m
    footerButtons.setSpacing(true);
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();

    Label header = new Label("Meal table");
    header.addStyleName(ValoTheme.LABEL_H1);
    layout.addComponent(header);

    layout.addComponent(mainGrid);
    layout.addComponent(footerButtons);
    layout.setExpandRatio(mainGrid, 1);

    setCompositionRoot(layout);
}

From source file:cb_server.SettingsWindow.java

License:Open Source License

private void fillContent() {

    if (Settingscontent != null) {
        content.removeComponent(Settingscontent);
        Settingscontent = null;//  w  w  w. j  a  va  2s .co  m
    }

    Settingscontent = new VerticalLayout();
    content.addComponent(Settingscontent);

    InetAddress addr;
    QRCode code = null;
    try {
        addr = InetAddress.getLocalHost();

        //Getting IPAddress of localhost - getHostAddress return IP Address
        // in textual format
        String ipAddress = addr.getHostAddress();

        ipAddress = "";
        // Network Interfaces nach IPv4 Adressen durchsuchen
        try {
            Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
            for (NetworkInterface netint : Collections.list(nets)) {
                Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
                for (InetAddress inetAddress : Collections.list(inetAddresses)) {
                    if (inetAddress.isLoopbackAddress())
                        continue;
                    if (inetAddress instanceof Inet4Address) {
                        System.out.println("InetAddress: " + inetAddress);
                        if (ipAddress.length() > 0) {
                            ipAddress += ";";
                        }
                        ipAddress += inetAddress;
                    }
                }
            }

        } catch (SocketException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        code = new QRCode();
        code.setWidth(150, Unit.PIXELS);
        code.setHeight(150, Unit.PIXELS);
        code.setValue(ipAddress);

    } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    TabSheet tabSheet = new TabSheet();
    tabSheet.setWidth(100, Unit.PERCENTAGE);
    tabSheet.setHeight(100, Unit.PERCENTAGE);
    Settingscontent.addComponent(tabSheet);

    VerticalLayout lay = new VerticalLayout();

    // add Lang Spinner

    langSpinner = new ComboBox();
    langSpinner.setCaption("select Lang");

    for (Lang lang : Translation.GetLangs(SettingsClass.LanguagePath.getValue())) {
        langSpinner.addItem(lang.Name);
        langSpinner.setItemCaption(lang.Name, lang.Name);
    }

    langSpinner.setValue(Translation.getLangId());
    langSpinner.setNullSelectionAllowed(false);
    lay.addComponent(langSpinner);

    lay.addComponent(code);
    SettingsLinearLayoutPanel info = new SettingsLinearLayoutPanel();

    info.setContent(lay, 400);

    tabSheet.addTab(info, "Info");

    // Categorie List zusammen stellen

    if (Categorys == null) {
        Categorys = new ArrayList<SettingCategory>();
    }

    Categorys.clear();
    SettingCategory[] tmp = SettingCategory.values();
    for (SettingCategory item : tmp) {
        if (item != SettingCategory.Button) {
            Categorys.add(item);
        }

    }

    Iterator<SettingCategory> iteratorCat = Categorys.iterator();
    if (iteratorCat != null && iteratorCat.hasNext()) {

        ArrayList<SettingBase<?>> SortedSettingList = new ArrayList<SettingBase<?>>();

        for (Iterator<SettingBase<?>> it = Config.settings.iterator(); it.hasNext();) {
            SettingBase<?> setting = it.next();

            if (setting.getModus() != SettingModus.Never
                    && (setting.getUsage() == SettingUsage.ALL || setting.getUsage() == SettingUsage.CBS)) {
                SortedSettingList.add(setting);
            }
        }

        do {
            int position = 0;

            SettingCategory cat = iteratorCat.next();

            // add Cat eintrge

            lay = new VerticalLayout();
            int entryCount = 0;

            if (cat == SettingCategory.Login) {
                final Component view = getLogInButton(position++);
                lay.addComponent(view);
            }

            // int layoutHeight = 0;
            for (Iterator<SettingBase<?>> it = SortedSettingList.iterator(); it.hasNext();) {
                SettingBase<?> settingItem = it.next();
                if (settingItem.getCategory().name().equals(cat.name())) {

                    if ((settingItem.getModus() == SettingModus.Normal)
                            && (settingItem.getModus() != SettingModus.Never)) {

                        final Component view = getView(settingItem, position++);

                        if (view == null)
                            continue;

                        lay.addComponent(view);
                        entryCount++;
                        Config.settings.indexOf(settingItem);

                    }

                }
            }

            if (entryCount > 0) {

                SettingsLinearLayoutPanel catPanel = new SettingsLinearLayoutPanel();

                catPanel.setContent(lay, 400);

                tabSheet.addTab(catPanel, cat.name());

                //               addControlToLinearLayout(lay, 100);

            }

        } while (iteratorCat.hasNext());

    }

}

From source file:ch.bfh.blue.UI.MainUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout layout = new VerticalLayout();
    final CssLayout viewLayout = new CssLayout();
    final Navigator navigator;

    getSession().setAttribute("databaseLock", true);
    try {/*from w  ww  . j a  v a  2s .c  o  m*/
        controller = new Controller();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    getSession().setAttribute("user", null);

    // /*
    // * is called upon closing of the UI do cleanup stuff here
    // */
    // addDetachListener(new DetachListener() {
    // @Override
    // public void detach(DetachEvent event) {
    // // during work
    // controller.close();
    //
    // }
    // });

    navigator = new Navigator(this, viewLayout);
    navigator.addView("", new HomeView(controller));
    navigator.addView("home", new HomeView(controller));
    navigator.addView("login", new LoginView(controller));
    navigator.addView("register", new RegisterView(controller));
    navigator.addView("availableSpaces", new AvailableSpacesView(controller));
    navigator.addView("reservationBySelectedRoom", new ReservationBySelectedRoomView(controller));
    navigator.addView("reservationBySelectedTime", new ReservationBySelectedTimeView(controller));

    layout.addComponent(viewLayout);
    layout.setMargin(true);
    setContent(layout);
}

From source file:ch.bfh.ti.soed.hs16.srs.black.view.loginView.LoginView.java

License:Open Source License

public LoginView() {
    usernameField = new TextField("Username");
    usernameField.setIcon(FontAwesome.USER);
    usernameField.setWidth(12, Unit.EM);
    passwordField = new PasswordField("Password");
    passwordField.setIcon(FontAwesome.KEY);
    passwordField.setWidth(12, Unit.EM);
    loginButton = new Button("Login");
    loginButton.setWidth(5, Unit.EM);/* w ww. ja  va2 s  . com*/
    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signUpButton = new Button("Sign Up");
    signUpButton.setWidth(6, Unit.EM);

    VerticalLayout layout = new VerticalLayout();
    HorizontalLayout layoutButtons = new HorizontalLayout(loginButton, signUpButton);
    layoutButtons.setSpacing(true);
    Panel panel = new Panel("Login - Smart ReservationEntity System");
    panel.setSizeUndefined();
    layout.addComponent(panel);

    FormLayout content = new FormLayout();
    content.addComponents(usernameField, passwordField, layoutButtons);
    content.setSizeFull();
    content.setMargin(true);
    panel.setContent(content);

    setCompositionRoot(layout);

    layout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    layout.setMargin(new MarginInfo(true, false, false, false));
}

From source file:ch.bfh.ti.soed.hs16.srs.black.view.signUpView.SignUpView.java

License:Open Source License

public SignUpView() {
    usernameField = new TextField("Username");
    usernameField.setIcon(FontAwesome.USER);
    usernameField.setWidth(12, Unit.EM);
    passwordField = new PasswordField("Password");
    passwordField.setIcon(FontAwesome.KEY);
    passwordField.setWidth(12, Unit.EM);
    passwordFieldRepeat = new PasswordField("Repeat Password");
    passwordFieldRepeat.setIcon(FontAwesome.KEY);
    passwordFieldRepeat.setWidth(12, Unit.EM);
    addUserButton = new Button("Add New User");
    addUserButton.setWidth(12, Unit.EM);
    goBackButton = new Button("Back");

    VerticalLayout layout = new VerticalLayout();
    Panel panel = new Panel("Sign Up - Smart ReservationEntity System");
    panel.setSizeUndefined();/*  w w w.  j ava 2s  . c o  m*/
    layout.addComponent(panel);

    FormLayout content = new FormLayout();
    content.addComponents(usernameField, passwordField, passwordFieldRepeat, addUserButton);
    content.setSizeUndefined();
    content.setMargin(true);
    VerticalLayout formAndBack = new VerticalLayout(content, goBackButton);
    formAndBack.setMargin(true);
    panel.setContent(formAndBack);

    setCompositionRoot(layout);

    layout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    layout.setMargin(new MarginInfo(true, false, false, false));
}

From source file:ch.bfh.ti.soed.hs16.srs.green.view.MyUI.java

License:Open Source License

/**
 * Method which actually creates the whole UI.
 *///from ww  w.  j  a v  a2 s . co  m
@Override
protected void init(VaadinRequest vaadinRequest) {

    VerticalLayout layout = new VerticalLayout();

    Panel panel = new Panel("Login");
    panel.setSizeUndefined();

    FormLayout content = new FormLayout();
    userName = new TextField("Username");
    content.addComponent(userName);

    PasswordField password = new PasswordField("Password");
    content.addComponent(password);

    Button login = new Button("Login");
    register = new Button("Register");
    CheckBox askBox = new CheckBox("Are you a Roommanager?");

    login.setStyleName(Reindeer.BUTTON_SMALL);
    login.setWidth("86px");

    register.setStyleName(Reindeer.BUTTON_SMALL);
    register.setWidth("86px");
    askBox.setStyleName(Reindeer.BUTTON_SMALL);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    hl.addComponent(login);
    hl.addComponent(register);
    hl.addComponent(askBox);

    content.addComponent(hl);
    content.setSizeUndefined();
    content.setMargin(true);

    panel.setContent(content);

    login.addClickListener(e -> {
        System.out.println(userName.getValue());
        System.out.println(password.getValue());
        try {
            if (controller.login(userName.getValue(), password.getValue())
                    || userName.equals(userName.getValue()) && password.equals(password.getValue())) {
                setContent(new ReservationUI());
            }
        } catch (Throwable e1) {
            e1.printStackTrace();
        }
    });

    register.addClickListener(e -> {
        try {
            Role x = askBox.getValue() ? Role.ROOMMANAGER : Role.CUSTOMER;
            controller.register(userName.getValue(), password.getValue(), x);
        } catch (Throwable e1) {
            e1.printStackTrace();
        }
    });

    layout.setMargin(true);
    layout.setSpacing(true);
    layout.addComponent(panel);
    setContent(layout);
}

From source file:ch.bfh.ti.soed.hs16.srs.kandr3.view.MyUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout layout = new VerticalLayout();

    final TextField name = new TextField();
    name.setCaption("Type your name here:");

    Button button = new Button("Click Me");
    button.addClickListener(e -> {//from  ww w  .ja v  a  2s  . c o m
        layout.addComponent(new Label("Thanks " + name.getValue() + ", it works!"));
    });

    layout.addComponents(name, button);
    layout.setMargin(true);
    layout.setSpacing(true);

    setContent(layout);
}

From source file:ch.bfh.ti.soed.hs16.srs.white.concept.AbstractTableView.java

License:Open Source License

@Override
public Component load() {
    VerticalLayout usersLayout = new VerticalLayout();
    List data = abstractTableController.getData();

    usersLayout.addComponent(createHeader());

    for (Object e : data) {
        Component itemView = createItemView(e);
        usersLayout.addComponent(itemView);
    }//from   www  .  j av a  2s .c o  m

    usersLayout.setMargin(true);
    usersLayout.setSpacing(true);

    return usersLayout;
}