Example usage for com.vaadin.ui HorizontalLayout HorizontalLayout

List of usage examples for com.vaadin.ui HorizontalLayout HorizontalLayout

Introduction

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

Prototype

public HorizontalLayout() 

Source Link

Document

Constructs an empty HorizontalLayout.

Usage

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 w  ww.java2  s.co m

    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:ch.bfh.ti.soed.hs16.srs.white.view.RegistrationView.java

License:Open Source License

@Override
public Component load() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setStyleName("registration-form");

    fieldFirstName.setStyleName("textfield-form");
    fieldLastName.setStyleName("textfield-form");
    fieldEmail.setStyleName("textfield-form");
    fieldConfirmEmail.setStyleName("textfield-form");
    fieldPassword.setStyleName("textfield-form");
    fieldConfirmPassword.setStyleName("textfield-form");

    btnSubmit.setStyleName("button-center");
    btnSubmit.setWidth("91px");
    btnSubmit.addClickListener(e -> registrationController.register());

    btnCancel.setStyleName("button-center");
    btnCancel.setWidth("91px");
    btnCancel.addClickListener(e -> registrationController.goBack(getLastView()));

    final HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.addComponents(btnSubmit, btnCancel);
    layoutButtons.setStyleName("horizontal-center");
    layoutButtons.setMargin(true);// ww  w.j  av  a2 s  . co  m
    layoutButtons.setSpacing(true);

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

    layout.addComponents(fieldFirstName, fieldLastName, fieldEmail, fieldConfirmEmail, fieldPassword,
            fieldConfirmPassword, layoutButtons, labelMessage);

    return layout;
}

From source file:ch.bfh.ti.soed.hs16.srs.yellow.views.MainView.java

License:Open Source License

public MainView() {

    setSizeFull();//from www .  j  a v a 2 s. c o m

    headerLayout = new HorizontalLayout();
    date = new Date();
    limitDate = Calendar.getInstance();
    limitDate.setTime(date);
    limitDate.add(Calendar.YEAR, 1);
    lastDate = limitDate.getTime();

    fromDate.setValue(date);
    fromDate.setRangeStart(date);
    fromDate.setRangeEnd(lastDate);
    fromDate.setImmediate(true);
    fromDate.setResolution(Resolution.MINUTE);

    toDate.setRangeStart(date);
    toDate.setRangeEnd(lastDate);
    toDate.setImmediate(true);
    toDate.setResolution(Resolution.MINUTE);

    objSelect.setSizeFull();
    equipSelect.setSizeFull();
    fromDate.setSizeFull();
    toDate.setSizeFull();
    searchBtn.setSizeFull();

    signupBtn.addClickListener(e -> {
        navigationRoot.navigator.navigateTo(NavigationRoot.SIGNUPVIEW);
    });

    loginBtn.addClickListener(e -> {
        navigationRoot.navigator.navigateTo(NavigationRoot.LOGINVIEW);
    });

    searchBtn.addClickListener(evt -> {
        Notification.show("Sorry, search will be made later with Vaadin Grid.");
    });

    loginLayout.addComponents(signupBtn, loginBtn);

    headerLayout.addComponent(titleLbl);
    leftVLayout.addComponents(fromDate, objSelect);
    leftVLayout.setSpacing(true);
    leftVLayout.setSizeFull();
    rightVLayout.addComponents(toDate, equipSelect);
    rightVLayout.setSpacing(true);
    rightVLayout.setSizeFull();
    inputLayout.addComponents(leftVLayout, rightVLayout);
    inputLayout.setSpacing(true);
    inputLayout.setSizeFull();

    searchLayout.addComponents(headerLayout, inputLayout, searchBtn);
    searchLayout.setComponentAlignment(headerLayout, Alignment.TOP_CENTER);
    searchLayout.setMargin(true);
    searchLayout.setSpacing(true);
    searchLayout.setWidth(500, Sizeable.Unit.PIXELS);

    panelContent.addComponents(loginLayout, searchLayout);
    panelContent.setComponentAlignment(searchLayout, Alignment.MIDDLE_CENTER);
    panelContent.setComponentAlignment(loginLayout, Alignment.TOP_RIGHT);
    panel.setContent(panelContent);
    setCompositionRoot(panelContent);
}

From source file:ch.wscr.management.ui.view.MemberView.java

/**
 * Kopfzeile fr das Grid erstellen/*  www .ja v a 2s. c  o  m*/
 *
 * @param grid das Grid dem die Kopfzeile hinzugefgt werden soll
 */
private void setHeaderRow(final Grid grid) {
    // TODO Erstellung neuer Mitglieder muss noch optimiert werden

    final Button addMember = new Button("Neu", clickEvent -> {
        BeanItem<Member> beanItem = memberBeanItemContainer.addItem(new Member());
        grid.setEditorEnabled(true);
        //grid.editItem(beanItem);

    });

    addMember.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    addMember.setIcon(FontAwesome.PLUS_CIRCLE);

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSizeFull();
    buttonLayout.setSpacing(true);
    buttonLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    buttonLayout.addComponent(addMember);

    HeaderRow headerRow = grid.prependHeaderRow();
    headerRow.join("memberId", "lastName", "firstName", "adrStreet", "adrPostalCode", "adrCity", "adrCountry",
            "birthDate", "driverLicense");
    headerRow.getCell("lastName").setComponent(buttonLayout);
}

From source file:ch.wscr.management.ui.view.MemberView.java

/**
 * Header der View erstellen//w ww.  ja  v  a 2  s .  c  om
 *
 * @return der Header
 */
private Component buidViewHeader() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth(100f, Unit.PERCENTAGE);
    header.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);
    header.setSpacing(true);

    Label title = new Label("Mitgliederverwaltung");
    title.setSizeUndefined();
    title.addStyleName(ValoTheme.LABEL_H1);

    header.addComponent(title);

    Label gap = new Label();
    gap.setWidth(10, Unit.PIXELS);

    header.addComponent(gap);
    header.setExpandRatio(title, 1);
    return header;
}

From source file:cirad.cgh.vcf2fasta.view.Vcf2fastaForm.java

License:Open Source License

private Component getSubmitLayout() {
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);//from www.ja va  2  s .  c  o m

    submitButton = getButton(SUBMIT_CAPTION);
    submitButton.addClickListener(getSubmitButtonClickListener());
    buttonLayout.addComponent(submitButton);

    resetButton = getButton(RESET_CAPTION);
    resetButton.addClickListener(getResetClickListener());
    buttonLayout.addComponent(resetButton);

    return buttonLayout;
}

From source file:cirad.cgh.vcf2fasta.view.Vcf2fastaForm.java

License:Open Source License

private Component getProgressLayout() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);//from  w  w  w . j a v  a 2 s  .  co  m

    status = new Label("");
    layout.addComponent(this.status);

    progress = new ProgressBar();
    progress.setEnabled(false);
    progress.setVisible(false);
    layout.addComponent(progress);

    return layout;
}

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 ww w .  j a  va 2  s.  c  o  m*/
    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.adonis.ui.menu.Menu.java

public Menu(PersonService personService, VehicleService vehicleService, Navigator navigator) {
    this.navigator = navigator;
    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    setPersonsCrudProperties(personService);
    setVehiclesCrudProperties(vehicleService);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);// www.  j  a v a  2  s .  co  m

    Label title = new Label("Vehicle manager");
    title.addStyleName(ValoTheme.LABEL_H1);
    title.setSizeUndefined();

    Image image = new Image(null, new ThemeResource("img/car.png"));
    image.setStyleName(ValoTheme.MENU_LOGO);

    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    //        HorizontalLayout logoutLayout = new HorizontalLayout();
    //        logoutLayout.addStyleName(ValoTheme.MENU_ITEM);
    //        logoutLayout.setSpacing(false);
    //
    //        MenuBar logoutMenu = new MenuBar();
    //        logoutMenu.setStyleName(VALO_MENUITEMS);
    //        logoutMenu.addItem("Logout", new MenuBar.Command() {
    //
    //            @Override
    //            public void menuSelected(MenuBar.MenuItem selectedItem) {
    //                VaadinSession.getCurrent().getSession().invalidate();
    //                Page.getCurrent().reload();
    //            }
    //        });
    //
    //        logoutMenu.addStyleName("user-menu");
    //        Image logout = new Image(null, new ThemeResource("img/logout.png"));
    //        logoutLayout.addComponent(logout, 0);
    //        logoutLayout.addComponent(logoutMenu, 1);
    //        menuPart.addComponent(logoutLayout);

    // button for toggling the visibility of the menu when on a small screen
    showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    //        showMenu.setIcon(FontAwesome.NAVICON);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
    addStyleName("backImage");
}

From source file:com.adonis.ui.menu.Menu.java

private void createViewButtonWithEditableImage(final String name, String caption, String nameImage) {
    Button button = new Button(caption, new ClickListener() {
        @Override/*from  w w w.ja  va  2 s. co m*/
        public void buttonClick(ClickEvent event) {
            navigator.navigateTo(name);
        }

    });

    button.setPrimaryStyleName(ValoTheme.BUTTON_FRIENDLY);
    //        button.setWidth(50, Unit.PERCENTAGE);
    image.setWidth(90, Unit.PIXELS);
    image.setHeight(90, Unit.PIXELS);

    FileReader.createDirectoriesFromCurrent(getInitialPath());
    final Image image = new Image("", new ThemeResource("img/" + nameImage));
    try {
        FileReader.copyFile(VaadinUtils.getResourcePath(nameImage),
                VaadinUtils.getInitialPath() + File.separator + nameImage);
        image.setSource(new FileResource(new File(VaadinUtils.getInitialPath() + File.separator + nameImage)));
    } catch (IOException e) {
        e.printStackTrace();
        image.setSource(new ThemeResource("img/" + nameImage));
    }

    //        image.setWidth(50, Unit.PERCENTAGE);
    image.setWidth(90, Unit.PIXELS);
    image.setHeight(90, Unit.PIXELS);
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setPrimaryStyleName(ValoTheme.MENU_ITEM);
    horizontalLayout.addComponents(image, button);
    image.addClickListener(new MouseEvents.ClickListener() {
        @Override
        public void click(MouseEvents.ClickEvent event) {
            uploadFieldImage = new UploadField();
            uploadFieldImage.setAcceptFilter("image/*");
            uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.FailedListener() {
                @Override
                public void uploadFailed(com.vaadin.v7.ui.Upload.FailedEvent event) {
                    uploadFieldImage.clearDefaulLayout();
                    horizontalLayout.removeComponent(uploadFieldImage);
                }

                private static final long serialVersionUID = 1L;

            });
            horizontalLayout.addComponent(uploadFieldImage, 2);
            uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.SucceededListener() {

                @Override
                public void uploadSucceeded(com.vaadin.v7.ui.Upload.SucceededEvent event) {
                    File file = (File) uploadFieldImage.getValue();
                    try {
                        showUploadedImage(uploadFieldImage, image, file.getName(), nameImage);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    uploadFieldImage.clearDefaulLayout();
                    horizontalLayout.removeComponent(uploadFieldImage);

                }
            });
            uploadFieldImage.setFieldType(UploadField.FieldType.FILE);
            horizontalLayout.markAsDirty();
            //                image.setWidth(50, Unit.PERCENTAGE);
            image.setWidth(90, Unit.PIXELS);
            image.setHeight(90, Unit.PIXELS);
            image.setVisible(false);
            image.markAsDirty();
            horizontalLayout.addComponent(image, 0);
        }
    });
    button.setVisible(true);
    image.setVisible(true);
    menuItemsLayout.addComponents(horizontalLayout);
    viewButtons.put(name, button);
}