Example usage for com.vaadin.ui VerticalLayout setMargin

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

Introduction

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

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

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();/*from w  w w. ja  va  2 s . 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   w  ww.  j  a  v  a2  s .c  o 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 -> {/*  ww  w  .  ja  v  a 2 s  .  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   ww  w  . j a va  2 s .  c  o  m*/

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

    return usersLayout;
}

From source file:ch.bfh.ti.soed.hs16.srs.white.view.LogInView.java

License:Open Source License

@Override
public Component load() {
    final VerticalLayout formContainer = new VerticalLayout();
    formContainer.setStyleName("login-form");
    formContainer.setWidthUndefined();//from   ww  w  .  j a  v a2 s  . com

    fieldMail.setCaption("Type your mail here:");
    fieldMail.setStyleName("textfield-form");
    fieldMail.setTabIndex(1);
    fieldMail.focus();

    fieldPassword.setCaption("Type your password here:");
    fieldPassword.setTabIndex(2);
    fieldPassword.setStyleName("textfield-form");

    btnLogin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    btnLogin.setTabIndex(3);
    btnLogin.addClickListener(e -> {
        switch (logInController.login()) {
        case ADMIN:
            AbstractView adminView = new AdminView();
            ApplicationController appController = ApplicationController.getInstance();
            appController.loadView(adminView);
            break;
        case USER:
            // Load the user view here
        default:
            break;
        }
    });

    btnLogin.setStyleName("button-center");
    btnLogin.setTabIndex(4);
    btnLogin.setWidth("91px");

    btnRegister.addClickListener(e -> {
        RegistrationView rView = new RegistrationView(this);
        ApplicationController applicationController = ApplicationController.getInstance();
        applicationController.loadView(rView);
    });
    btnRegister.setStyleName("button-center");
    btnRegister.setWidth("91px");

    labelMessage.setStyleName("horizontal-center");
    labelMessage.setSizeUndefined();

    final HorizontalLayout layoutButtons = new HorizontalLayout();

    layoutButtons.addComponents(btnLogin, btnRegister);
    layoutButtons.setStyleName("horizontal-center");
    layoutButtons.setMargin(true);
    layoutButtons.setSpacing(true);

    formContainer.addComponents(fieldMail, fieldPassword, layoutButtons, labelMessage);
    formContainer.setMargin(true);
    formContainer.setSpacing(true);

    Responsive.makeResponsive(formContainer);

    return formContainer;
}

From source file:cirad.cgh.vcf2fasta.Vcf2fastaUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    config = initConfig();//from  w  w  w. j a  v a  2s.c  o  m

    Panel mainPanel = new Panel("Vcf2fasta");

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    mainPanel.setContent(layout);

    vcf2fastaForm = new Vcf2fastaForm(this, config);
    vcf2fastaForm.setFormSubmitHandler(getSubmitClickListener(this));

    layout.addComponent(vcf2fastaForm);

    setTheme("tests-valo-reindeer");
    //setTheme("tests-valo-facebook");
    //setTheme("tests-valo-metro");

    setContent(mainPanel);
}

From source file:com.aaron.mbpet.views.users.UserEditor.java

License:Apache License

public UserEditor(Item personItem, String lableText, boolean mode) {
    this.editMode = mode;
    //       this.setModal(true);
    center();/*from  w w  w. j a  va2s  .  com*/
    setResizable(true);
    setClosable(true);
    setModal(true);
    //      setSizeUndefined();
    setWidth(25, Unit.EM);

    this.currsessionuser = ((MbpetUI) UI.getCurrent()).getSessionUser();

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);

    this.personItem = personItem;
    editorForm = new Form();
    editorForm.setFormFieldFactory(this);
    editorForm.setBuffered(true);
    editorForm.setImmediate(true);
    editorForm.setItemDataSource(personItem,
            Arrays.asList("firstname", "lastname", "email", "username", "password", "organization"));

    //buttons        
    saveButton = new Button("Save", this);
    saveButton.setClickShortcut(KeyCode.ENTER);
    cancelButton = new Button("Cancel", this);
    saveButton.addStyleName(ValoTheme.BUTTON_PRIMARY);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setWidth("100%");
    buttons.addComponents(saveButton, cancelButton);
    buttons.setComponentAlignment(saveButton, Alignment.BOTTOM_LEFT);
    buttons.setComponentAlignment(cancelButton, Alignment.BOTTOM_RIGHT);

    //        editorForm.getFooter().addComponent(buttons);
    //        editorForm.getFooter().addComponent(cancelButton);

    layout.addComponent(new Label("<h3>" + lableText + "</h3>", ContentMode.HTML));
    layout.addComponent(editorForm);
    layout.setComponentAlignment(editorForm, Alignment.MIDDLE_CENTER);
    layout.addComponent(buttons);

    setContent(layout); //editorForm
    setCaption(buildCaption());
}

From source file:com.abien.vaadin.helloapp.HelloApp.java

License:Apache License

@Override
public void init() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    Label header = new Label("Vaadin on Java EE");
    header.setStyleName("h1");
    layout.addComponent(header);/*  ww  w. j av a  2  s .co  m*/

    final TextField nameField = new TextField("Input something:");
    final Label greetingLbl = new Label();
    layout.addComponent(nameField);

    layout.addComponent(
            new Button("Say slow Hello, clicking this shouldn't stall other users", new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    try {
                        Thread.sleep(20 * 1000);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(HelloApp.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    getMainWindow().showNotification("Hello!");
                }
            }));

    layout.addComponent(new Button("Say Hello", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            greetingLbl.setCaption(greetingService.sayHello(nameField.getValue().toString()));
            buttonEvents.fire(event);
        }
    }));
    layout.addComponent(greetingLbl);

    Window mainWindow = new Window("Vaadin 6.8 - Java EE Integration", layout);
    setMainWindow(mainWindow);
}

From source file:com.anothernode.ballkontrolle.BallkontrolleUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {

    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    setContent(layout);//from   www .j  a va 2  s  .c o m

    Label team1Player1 = new Label("");
    Label team1Player2 = new Label("");
    Label team2Player1 = new Label("");
    Label team2Player2 = new Label("");

    final Button button = new Button("Draw Teams");
    button.addClickListener(event -> {

        final Drawing drawing = new Drawing(Data.summonPlayers());

        team1Player1.setValue(drawing.getTeam1().getPlayer1().toString());
        team1Player2.setValue(drawing.getTeam1().getPlayer2().toString());
        team2Player1.setValue(drawing.getTeam2().getPlayer1().toString());
        team2Player2.setValue(drawing.getTeam2().getPlayer2().toString());

    });

    layout.addComponent(button);
    layout.addComponent(new Label("Team 1:"));
    layout.addComponent(team1Player1);
    layout.addComponent(team1Player2);
    layout.addComponent(new Label("Team 2:"));
    layout.addComponent(team2Player1);
    layout.addComponent(team2Player2);
}

From source file:com.antonjohansson.lprs.view.ServiceView.java

License:Apache License

private Layout requestTokenLayout() {
    username.setInputPrompt("Username");
    username.setWidth(STANDARD_WIDTH, EM);
    captcha.setSize(NORMAL);//w  w  w.ja  va2s . c o m
    captcha.setTheme(LIGHT);
    captcha.setType(IMAGE);
    requestToken.setCaption("Request token");
    requestToken.setWidth(STANDARD_WIDTH, EM);
    requestToken.setEnabled(false);

    VerticalLayout layout = new VerticalLayout();
    layout.addComponents(username, captcha, requestToken);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setVisible(false);
    layout.setWidthUndefined();

    return layout;
}