Example usage for com.vaadin.ui HorizontalLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.foc.helpBook.HelpUI.java

License:Apache License

@Override
public FocCentralPanel newWindow() {
    FocCentralPanel focCentralPanel = new FocCentralPanel();
    focCentralPanel.fill();//from  ww w  . ja va2  s . c o m

    Label labelHelpContent = new Label();
    labelHelpContent.setContentMode(ContentMode.HTML);

    String htmlContent = (String) FocWebApplication.getFocWebSession_Static().getParameter("HELP_CONTENT");
    labelHelpContent.setValue(htmlContent);
    VerticalLayout mainLayout = new VerticalLayout();

    mainLayout.setSizeFull();

    HorizontalLayout navigationLayout = new HorizontalLayout();
    navigationLayout.setWidth("95%");

    navigationLayout.addComponent(getPreviousPageButton());
    navigationLayout.setComponentAlignment(getPreviousPageButton(), Alignment.BOTTOM_LEFT);

    navigationLayout.addComponent(getNextPageButton());
    navigationLayout.setComponentAlignment(getNextPageButton(), Alignment.BOTTOM_RIGHT);

    mainLayout.addComponent(labelHelpContent);

    mainLayout.addComponent(navigationLayout);
    mainLayout.setComponentAlignment(navigationLayout, Alignment.BOTTOM_CENTER);

    focCentralPanel.addComponent(mainLayout);
    return focCentralPanel;
}

From source file:com.foc.vaadin.FocCentralPanel.java

License:Apache License

protected void adjustToFullScreen(ICentralPanel newCentralPanel, boolean fullScreen) {
    //Panel-Vertical

    if (newCentralPanel != null && newCentralPanel instanceof Component) {
        if (fullScreen) {
            centralPanel.setContent((Component) newCentralPanel);
            centralPanel.markAsDirty();// www.  ja v a  2s.c  o  m
            ((Component) newCentralPanel).setWidth("100%");
            //getCentralPanelWrapper().setWidth("100%");
        } else {
            Component newCentralPanleComponent = (Component) newCentralPanel;

            HorizontalLayout wrapperOfCentralLayout = new HorizontalLayout();
            wrapperOfCentralLayout.addComponent(newCentralPanleComponent);
            wrapperOfCentralLayout.setComponentAlignment(newCentralPanleComponent, Alignment.TOP_CENTER);
            centralPanel.setContent(wrapperOfCentralLayout);
            centralPanel.markAsDirty();
            newCentralPanleComponent.setWidth(WIDTH_PORTRAIT);
            wrapperOfCentralLayout.setWidth("100%");

            //Apply same style to the wrapper
            if (newCentralPanleComponent instanceof FocXMLLayout) {
                Component firstComp = ((FocXMLLayout) newCentralPanleComponent).getFirstRootComponent();
                if (firstComp != null && firstComp instanceof FocXMLGuiComponent) {
                    Attributes attrib = ((FocXMLGuiComponent) firstComp).getAttributes();

                    String style = attrib != null ? attrib.getValue(FXML.ATT_STYLE) : null;
                    if (style != null) {
                        FocXMLGuiComponentStatic.applyStyle(wrapperOfCentralLayout, style);
                    }
                }
            }

            //            centralPanel.setContent((Component) newCentralPanel);
            //            centralPanel.markAsDirty();
            //            ((Component)newCentralPanel).setWidth(WIDTH_PORTRAIT);
        }
    }
}

From source file:com.foc.vaadin.gui.components.FVUploadLayout_Form.java

License:Apache License

private HorizontalLayout newHorizontalLayout(String title, String explanation, String sample, boolean isTitle) {
    HorizontalLayout colLay = new HorizontalLayout();

    FVLabel titleLbl = new FVLabel(title);
    if (isTitle)/*  w  w  w  .j a  v  a 2 s. com*/
        titleLbl.addStyleName("f14");
    else
        titleLbl.addStyleName("f12");
    titleLbl.addStyleName("b");
    titleLbl.setWidth("200px");
    colLay.addComponent(titleLbl);

    FVLabel explanationLbl = new FVLabel(explanation);
    if (isTitle) {
        explanationLbl.addStyleName("f14");
        titleLbl.addStyleName("b");
    } else {
        explanationLbl.addStyleName("f12");
    }
    explanationLbl.setWidth("400px");
    colLay.addComponent(explanationLbl);

    FVLabel sampleLbl = new FVLabel(sample);
    if (isTitle) {
        sampleLbl.addStyleName("f14");
        sampleLbl.addStyleName("b");
    } else {
        sampleLbl.addStyleName("f12");
    }
    sampleLbl.setWidth("200px");
    colLay.addComponent(sampleLbl);

    return colLay;
}

From source file:com.foc.vaadin.gui.xmlForm.FocXMLLayout.java

License:Apache License

@Override
public void addedToNavigator() {
    if (FocWebApplication.getInstanceForThread().isMobile() && validationLayout != null) {
        FocWebVaadinWindow focWebVaadinWindow = ((FocWebVaadinWindow) getMainWindow());
        if (focWebVaadinWindow != null && focWebVaadinWindow.getCentralHeader() != null) {
            HorizontalLayout centralHeader = focWebVaadinWindow.getCentralHeader();
            centralHeader.addComponent(validationLayout);
            centralHeader.setComponentAlignment(validationLayout, Alignment.MIDDLE_RIGHT);
            centralHeader.setExpandRatio(validationLayout, 1);
            centralHeader.setWidth("100%");
        }// w  w w.jav a2s .co  m
    }
}

From source file:com.foc.web.modules.admin.FocUser_HomePage_Form.java

License:Apache License

@Override
protected void afterLayoutConstruction() {
    super.afterLayoutConstruction();

    Button mobileCheckBox = (Button) getComponentByName("MOBILE_CHECKBOX");
    if (mobileCheckBox != null) {

    }/* ww w  .  j  a  v  a2 s  . c  o m*/

    if (!Globals.isValo()) {
        /*Button userCredentialsButton = (Button) getComponentByName("OPEN_USER_CREDENTIALS");*/
        Object object = getComponentByName("HOME_PAGE_HORIZONTAL_LAYOUT");
        if (object != null && object instanceof HorizontalLayout) {
            HorizontalLayout mainPageHorizontalLayout = (HorizontalLayout) object;
            Button userCredentialsButton = new Button("Modify");
            mainPageHorizontalLayout.addComponent(userCredentialsButton);

            if (userCredentialsButton != null) {
                userCredentialsButton.addClickListener(new ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        popupUserCredintionals(getMainWindow());
                    }
                });
            }
        }
    }
}

From source file:com.foc.web.modules.photoAlbum.PhotoAlbum_Thumb_Table.java

License:Apache License

private void redrawPhotos() {
    FVVerticalLayout vLay = getMainVerticalLayout();
    if (vLay != null) {
        vLay.removeAllComponents();//from  w ww.j  a va  2s . c o m

        HorizontalLayout hLay = null;

        int nbrPhotos = 0;

        PhotoAlbumListWithFilter list = (PhotoAlbumListWithFilter) getFocList();
        if (list != null && list.getFocListFilter() != null) {
            list.getFocListFilter().setActive(true);
            for (int i = 0; i < list.size(); i++) {
                PhotoAlbum photo = (PhotoAlbum) list.getFocObject(i);
                FocXMLAttributes attribs = new FocXMLAttributes();
                attribs.addAttribute(FXML.ATT_WIDTH, "100px");
                attribs.addAttribute(FXML.ATT_HEIGHT, "100px");
                attribs.addAttribute(FXML.ATT_EDITABLE, "false");

                FVImageField imgField = new FVImageField(photo.getFocProperty(PhotoAlbumDesc.FLD_IMAGE),
                        attribs);

                if (!imgField.isImage()) {
                    imgField.dispose();
                } else {

                    if (nbrPhotos % 4 == 0) {//4 Photos by line
                        hLay = null;
                    }
                    nbrPhotos++;

                    if (hLay == null) {
                        hLay = new HorizontalLayout();
                        hLay.setSpacing(true);
                        vLay.addComponent(hLay);
                    }

                    if (imgField.getEmbedded() != null) {
                        imgField.addStyleName("foc-ImageFieldClickable");
                        imgField.getEmbedded().addClickListener(new PhotoClickListener(photo));
                    }
                    hLay.addComponent(imgField);
                }
            }
        }

        PhotoAlbumAppGroup group = PhotoAlbumAppGroup.getCurrentAppGroup();
        if (isEditable() && group != null && group.isAllowUpload()) {
            FVUpload_Image uploadButton = newUploadButton();
            if (uploadButton != null) {
                uploadButton.setMaxSizeAllowed(8388608);
                vLay.addComponent(uploadButton);
            }
        }
    }
}

From source file:com.foo01.components.ReservationComponent.java

public static Component build(final Reservation r) {
    final HorizontalLayout reservationComponentLayout = new HorizontalLayout();

    final VerticalLayout datesLayout = new VerticalLayout();
    Label beginningDate = new Label(
            (new SimpleDateFormat("E dd.MM.", Locale.getDefault())).format(r.getBeginning().getTime()));
    Label endingDate = new Label(
            (new SimpleDateFormat("E dd.MM.", Locale.getDefault())).format(r.getEnding().getTime()));
    beginningDate.addStyleName("datelabel");
    endingDate.addStyleName("datelabel");
    datesLayout.addComponent(beginningDate);
    datesLayout.addComponent(endingDate);
    datesLayout.setSpacing(true);/*w w w.  ja va2 s.  c o m*/
    reservationComponentLayout.addComponent(datesLayout);

    Label reservationInfoLabel = new Label(r.getUser() + "</br></br>" + r.getDescription(), ContentMode.HTML);
    reservationInfoLabel.addStyleName("informationlabel");
    reservationComponentLayout.addComponent(reservationInfoLabel);

    Label rightArrowIconLabel = new Label("</br>" + FontAwesome.CHEVRON_RIGHT.getHtml(), ContentMode.HTML);
    rightArrowIconLabel.addStyleName("rightArrowIconLabel");
    reservationComponentLayout.addComponent(rightArrowIconLabel);

    reservationComponentLayout.setSpacing(true);
    reservationComponentLayout.setWidth("100%");
    datesLayout.setWidth("85px");
    reservationInfoLabel.setSizeFull();
    rightArrowIconLabel.setHeight("100%");
    rightArrowIconLabel.setWidth("20px");
    reservationComponentLayout.setExpandRatio(reservationInfoLabel, 1.0f);

    reservationComponentLayout.addLayoutClickListener(new LayoutClickListener() {
        @Override
        public void layoutClick(LayoutClickEvent event) {
            //System.out.println(event.getClickedComponent().getParent().getId());
            ((foo01TouchKitUI) UI.getCurrent()).NAVIGATIONMANAGER.navigateTo(new ReservationView(r));
        }
    });

    return reservationComponentLayout;
}

From source file:com.foo01.ui.ReservationDetailView.java

@Override
protected final void onBecomingVisible() {
    getNavigationBar().setCaption("Detail Rezervace");

    //buttony pod navbarem
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setStyleName("buttonToolBarLayout");
    buttonsLayout.setWidth("100%");

    Button deleteButton = new Button();
    deleteButton.setCaption("SMAZAT");
    deleteButton.setWidth(null);/*from www  .j ava2 s  .  c  o  m*/
    buttonsLayout.addComponent(deleteButton);

    Label plug = new Label();
    buttonsLayout.addComponent(plug);

    Button saveButton = new Button();
    saveButton.setCaption("ULOIT");
    saveButton.setWidth(null);
    buttonsLayout.addComponent(saveButton);
    buttonsLayout.setExpandRatio(plug, 1.0f);
    List<Source> sourcesList = MockSource.mockSources();

    //combobox na zdroje a jmeno uzivatele
    HorizontalLayout sourceAndNameLayout = new HorizontalLayout();
    sourceAndNameLayout.setWidth("100%");
    sourceAndNameLayout.setStyleName("sourceAndNameLayout");

    NativeSelect select = new NativeSelect();
    select.setNullSelectionAllowed(false);
    System.out.println(Page.getCurrent().getBrowserWindowWidth());
    String width = Page.getCurrent().getBrowserWindowWidth() / 2.5 + "px";
    select.setWidth(width);
    select.addItems(sourcesList);
    for (Source s : sourcesList) {
        if (reservation.getSource().equals(s)) {
            select.select(s);
            break;
        }
    }
    sourceAndNameLayout.addComponent(select);

    Label plug2 = new Label();
    sourceAndNameLayout.addComponent(plug2);

    Label name = new Label(reservation.getUser());
    name.setWidth(null);
    sourceAndNameLayout.addComponent(name);
    sourceAndNameLayout.setExpandRatio(plug2, 1.0f);

    //datepickery
    DatePicker dateFrom = new DatePicker();
    dateFrom.setStyleName("datePickerDetailView");
    dateFrom.setValue(reservation.getBeginning());
    dateFrom.setUseNative(true);
    dateFrom.setResolution(Resolution.TIME);
    dateFrom.setWidth("100%");

    DatePicker dateTo = new DatePicker();
    dateTo.setStyleName("datePickerDetailView");
    dateTo.setValue(reservation.getEnding());
    dateTo.setUseNative(true);
    dateTo.setResolution(Resolution.TIME);
    dateTo.setWidth("100%");

    //layout pro slider a popisky
    HorizontalLayout sliderLayout = new HorizontalLayout();
    sliderLayout.setStyleName("sliderLayout");
    sliderLayout.setWidth("100%");
    sliderLayout.setSpacing(true);

    Label sliderCaption = new Label("Po?et: ");
    sliderCaption.addStyleName("sliderCaption");
    sliderCaption.setWidth(null);
    sliderLayout.addComponent(sliderCaption);

    final Label horvalue = new Label();
    horvalue.setWidth("45px");
    horvalue.setStyleName("value");
    sliderLayout.addComponent(horvalue);

    final Slider horslider = new Slider(1, 10);
    horslider.setOrientation(SliderOrientation.HORIZONTAL);
    horslider.setValue(Double.valueOf(1));
    horslider.getState();
    horslider.getValue();
    horslider.setImmediate(true);
    horslider.setWidth("100%");
    sliderLayout.addComponent(horslider);
    sliderLayout.setExpandRatio(horslider, 1.0f);

    horvalue.setValue(String.valueOf(horslider.getValue().intValue()));

    horslider.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            int value = horslider.getValue().intValue();

            horvalue.setValue(String.valueOf(value));
        }
    });

    //switch schvaleno
    HorizontalLayout switchLayout = new HorizontalLayout();
    switchLayout.setStyleName("switchLayout");
    switchLayout.addComponent(new Label("Schvleno:"));
    switchLayout.setSpacing(true);
    Switch checkbox = new Switch(null, true);
    switchLayout.addComponent(checkbox);

    //popis rezervace
    TextArea description = new TextArea();
    description.setStyleName("descriptionDetailView");

    description.setWidth("100%");
    description.setImmediate(false);
    description.setCaption("Popis:");
    description.setValue(reservation.getDescription());
    //description.setRequired(true);
    description.setRequiredError("Popis mus bt zadn!");
    description.setNullRepresentation("");
    description.setReadOnly(true);
    //description.setRows(0);

    final VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    content.setStyleName(width);
    content.addComponent(buttonsLayout);
    content.addComponent(sourceAndNameLayout);
    content.addComponent(dateFrom);
    content.addComponent(dateTo);

    content.addComponent(sliderLayout);
    content.addComponent(switchLayout);
    content.addComponent(description);

    setContent(content);
}

From source file:com.foo01.ui.ReservationView.java

@Override
protected final void onBecomingVisible() {
    getNavigationBar().setCaption("Detail Rezervace");

    //buttony pod navbarem
    //        HorizontalLayout buttonsLayout = new HorizontalLayout();
    //        buttonsLayout.setStyleName("buttonToolBarLayout");
    //        buttonsLayout.setWidth("100%");
    ///* ww  w.j  a  v  a2s  .  c  o  m*/
    //        Button deleteButton = new Button();
    //        deleteButton.setCaption("SMAZAT");
    //        deleteButton.setWidth(null);
    //        buttonsLayout.addComponent(deleteButton);
    //
    //        Label plug = new Label();
    //        buttonsLayout.addComponent(plug);
    //
    //        Button saveButton = new Button();
    //        saveButton.setCaption("ULOIT");
    //        saveButton.setWidth(null);
    //        buttonsLayout.addComponent(saveButton);
    //        buttonsLayout.setExpandRatio(plug, 1.0f);  

    //combobox na zdroje a jmeno uzivatele
    List<Source> sourcesList = MockSource.mockSources();
    HorizontalLayout sourceAndNameLayout = new HorizontalLayout();
    sourceAndNameLayout.setWidth("100%");
    sourceAndNameLayout.setStyleName("sourceAndNameLayout");

    NativeSelect select = new NativeSelect();
    select.setNullSelectionAllowed(false);
    System.out.println(Page.getCurrent().getBrowserWindowWidth());
    String width = Page.getCurrent().getBrowserWindowWidth() / 2.5 + "px";
    select.setWidth(width);
    select.addItems(sourcesList);
    for (Source s : sourcesList) {
        if (reservation.getSource().equals(s)) {
            select.select(s);
            break;
        }
    }
    sourceAndNameLayout.addComponent(select);

    Label plug2 = new Label();
    sourceAndNameLayout.addComponent(plug2);

    Label name = new Label(reservation.getUser());
    name.setWidth(null);
    sourceAndNameLayout.addComponent(name);
    sourceAndNameLayout.setExpandRatio(plug2, 1.0f);

    //datepickery
    DatePicker dateFrom = new DatePicker();
    dateFrom.setStyleName("datePickerDetailView");
    dateFrom.setValue(reservation.getBeginning());
    dateFrom.setUseNative(true);
    dateFrom.setResolution(Resolution.TIME);
    dateFrom.setWidth("100%");

    DatePicker dateTo = new DatePicker();
    dateTo.setStyleName("datePickerDetailView");
    dateTo.setValue(reservation.getEnding());
    dateTo.setUseNative(true);
    dateTo.setResolution(Resolution.TIME);
    dateTo.setWidth("100%");

    //layout pro slider a popisky
    HorizontalLayout sliderLayout = new HorizontalLayout();
    sliderLayout.setStyleName("sliderLayout");
    sliderLayout.setWidth("100%");
    sliderLayout.setSpacing(true);

    Label sliderCaption = new Label("Po?et: ");
    sliderCaption.addStyleName("sliderCaption");
    sliderCaption.setWidth(null);
    sliderLayout.addComponent(sliderCaption);

    final Label horvalue = new Label();
    horvalue.setWidth("45px");
    horvalue.setStyleName("value");
    sliderLayout.addComponent(horvalue);

    final Slider horslider = new Slider(1, 10);
    horslider.setOrientation(SliderOrientation.HORIZONTAL);
    horslider.setValue(Double.valueOf(1));
    horslider.getState();
    horslider.getValue();
    horslider.setImmediate(true);
    horslider.setWidth("100%");
    sliderLayout.addComponent(horslider);
    sliderLayout.setExpandRatio(horslider, 1.0f);

    horvalue.setValue(String.valueOf(horslider.getValue().intValue()));

    horslider.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            int value = horslider.getValue().intValue();

            horvalue.setValue(String.valueOf(value));
        }
    });

    //switch schvaleno
    HorizontalLayout switchLayout = new HorizontalLayout();
    switchLayout.setStyleName("switchLayout");
    switchLayout.addComponent(new Label("Schvleno:"));
    switchLayout.setSpacing(true);
    Switch checkbox = new Switch(null, true);
    switchLayout.addComponent(checkbox);

    //popis rezervace
    TextArea description = new TextArea();
    description.setStyleName("descriptionDetailView");

    description.setWidth("100%");
    description.setImmediate(false);
    description.setCaption("Popis:");
    description.setValue(reservation.getDescription());
    //description.setRequired(true);
    description.setRequiredError("Popis mus bt zadn!");
    description.setNullRepresentation("");
    description.setReadOnly(true);
    //description.setRows(0);

    final VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    content.addComponent(new ButtonToolBarLayout(this));
    content.addComponent(sourceAndNameLayout);
    content.addComponent(dateFrom);
    content.addComponent(dateTo);

    content.addComponent(sliderLayout);
    content.addComponent(switchLayout);
    content.addComponent(description);

    setContent(content);
}

From source file:com.freebox.engeneering.application.web.layout.HeaderController.java

License:Apache License

/**
 * Loads data into the form when system enters 'loadData' state.
 *
 * @param event -  the state event.//from  www.ja va 2s . c  o m
 */
@SuppressWarnings("rawtypes")
@OnEnterState(StateConstants.PROFILE)
public void buildHeader(StateEvent event) {
    clearView(event);
    HorizontalLayout top = super.getView();
    final Label title = new Label("My Freebox Manager");
    title.setSizeUndefined();
    title.addStyleName("h1");
    top.addComponent(title);
    top.setComponentAlignment(title, Alignment.MIDDLE_LEFT);
    top.setExpandRatio(title, 1);

    Button notify = new Button();
    notify.setDescription("Notifications");
    notify.addStyleName("notifications");
    notify.addStyleName("unread");
    notify.addStyleName("icon-only");
    notify.addStyleName("icon-bell");
    top.addComponent(notify);
    top.setComponentAlignment(notify, Alignment.MIDDLE_LEFT);

    Button edit = new Button();
    edit.addStyleName("icon-edit");
    edit.addStyleName("icon-only");
    edit.setDescription("Edit Dashboard");
    top.addComponent(edit);
    top.setComponentAlignment(edit, Alignment.MIDDLE_LEFT);

    Button downloadB = new Button();
    downloadB.addStyleName("icon-edit");
    downloadB.addStyleName("icon-only");
    downloadB.setDescription("Tlcharger un fichier");
    top.addComponent(downloadB);
    top.setComponentAlignment(downloadB, Alignment.MIDDLE_LEFT);

}