Example usage for com.vaadin.ui HorizontalLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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

License:Apache License

@Override
public FocCentralPanel newWindow() {
    FocCentralPanel focCentralPanel = new FocCentralPanel();
    focCentralPanel.fill();//  w  w w  .  j av  a  2  s.  c  om

    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();//from  w  w w  .j a va  2s  . com
            ((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.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  ww .j  a  v a  2s .c om
    }
}

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);//from  w  ww . j av  a2  s. co 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);/*ww  w.  j  a  va 2 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%");
    ////from   w  w  w .  jav a 2 s  .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

/**
 * Initializes view when system enters 'initView' action state.
 *
 * @param event -  state event./*from   w w  w.j  ava  2s .c  o  m*/
 */
@SuppressWarnings("rawtypes")
public void initView(StateEvent event) {
    HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setSpacing(true);
    top.addStyleName("toolbar");
    setView(top);

}

From source file:com.github.lsiu.MyVaadinApplication.java

private void initTopBar(HorizontalLayout topBar) {
    topBar.setWidth("100%");
    final CheckBox editableCheckBox = new CheckBox("Editable");
    topBar.addComponent(editableCheckBox);
    topBar.setComponentAlignment(editableCheckBox, Alignment.BOTTOM_RIGHT);
    editableCheckBox.setValue(table.isEditable());
    editableCheckBox.setImmediate(true);
    editableCheckBox.addListener(new ValueChangeListener() {
        @Override/* w  w  w  .j a  va2s  . c  o m*/
        public void valueChange(ValueChangeEvent event) {
            table.setEditable((Boolean) editableCheckBox.getValue());
        }
    });
}

From source file:com.github.peholmst.springsecuritydemo.ui.MainView.java

License:Apache License

/**
 * TODO Document me!/*  w  w  w.  jav a  2 s  .c  o  m*/
 * 
 * @return
 */
protected Component createTicketBrowser() {
    final HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.setSpacing(true);
    toolbar.setWidth("100%");

    final Button refreshButton = new Button(getApplication().getMessage("tickets.refresh.caption"));
    refreshButton.setIcon(new ThemeResource("icons/16/refresh.png"));
    refreshButton.setStyleName("small");
    refreshButton.setDescription(getApplication().getMessage("tickets.refresh.descr"));
    toolbar.addComponent(refreshButton);
    toolbar.setComponentAlignment(refreshButton, Alignment.MIDDLE_LEFT);

    final Button addButton = new Button(getApplication().getMessage("tickets.add.caption"));
    addButton.setIcon(new ThemeResource("icons/16/add.png"));
    addButton.setStyleName("small");
    addButton.setDescription(getApplication().getMessage("tickets.add.descr"));
    toolbar.addComponent(addButton);
    toolbar.setComponentAlignment(addButton, Alignment.MIDDLE_RIGHT);

    final SplitPanel splitPanel = new SplitPanel();
    splitPanel.setSizeFull();

    final Table ticketsTable = new Table();
    ticketsTable.setSizeFull();
    splitPanel.addComponent(ticketsTable);

    splitPanel.addComponent(new Label("The form for editing tickets will show up here"));

    final VerticalLayout browser = new VerticalLayout();
    browser.setSizeFull();
    browser.addComponent(toolbar);
    browser.addComponent(splitPanel);
    browser.setExpandRatio(splitPanel, 1.0f);

    return browser;
}

From source file:com.github.peholmst.springsecuritydemo.ui.MainView.java

License:Apache License

/**
 * TODO Document me!//from  w ww  . j a  v a  2 s.com
 * 
 * @return
 */
@SuppressWarnings("serial")
protected Component createHeader() {
    final HorizontalLayout header = new HorizontalLayout();
    header.setMargin(true);
    header.setWidth("100%");

    /*
     * Header label will contain the name and version of the application.
     */
    final Label headerLabel = new Label(
            getApplication().getMessage("app.title", getApplication().getVersion()));
    headerLabel.setStyleName("appHeaderText");
    header.addComponent(headerLabel);
    header.setStyleName("appHeader");
    header.setExpandRatio(headerLabel, 1.0f);
    header.setComponentAlignment(headerLabel, Alignment.MIDDLE_LEFT);

    /*
     * User links contains information about the current user and a button
     * for logging out.
     */
    final HorizontalLayout userLinks = new HorizontalLayout();
    userLinks.setStyleName("appHeaderUserLinks");
    userLinks.setSpacing(true);

    /*
     * The user label contains the name of the current user.
     */
    final Label userLabel = new Label(
            getApplication().getMessage("main.currentlyLoggedIn", getApplication().getUser().getName()),
            Label.CONTENT_XHTML);
    userLinks.addComponent(userLabel);
    userLinks.setComponentAlignment(userLabel, Alignment.MIDDLE_LEFT);
    userLabel.setSizeUndefined();

    /*
     * The logout button closes the application, effectively logging the
     * user out.
     */
    final Button logoutButton = new Button(getApplication().getMessage("main.logout.caption"),
            new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    // TODO Add confirmation
                    getApplication().close();
                }
            });
    logoutButton.setDescription(getApplication().getMessage("main.logout.descr"));
    logoutButton.setStyleName("small");
    userLinks.addComponent(logoutButton);
    userLinks.setComponentAlignment(logoutButton, Alignment.MIDDLE_RIGHT);

    header.addComponent(userLinks);
    header.setComponentAlignment(userLinks, Alignment.MIDDLE_RIGHT);
    return header;
}