Example usage for com.vaadin.ui AbstractOrderedLayout setExpandRatio

List of usage examples for com.vaadin.ui AbstractOrderedLayout setExpandRatio

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:com.hack23.cia.web.impl.ui.application.views.admin.system.pagemode.AbstractAdminSystemPageModContentFactoryImpl.java

License:Apache License

/**
 * Creates the paging controls./*  w  w w .ja  v  a2  s . co m*/
 *
 * @param name
 *            the name
 * @param pageId
 *            the page id
 * @param size
 *            the size
 * @param pageNr
 *            the page nr
 * @param resultPerPage
 *            the result per page
 * @return the horizontal layout
 */
protected final void createPagingControls(final AbstractOrderedLayout content, final String name,
        final String pageId, final Long size, final int pageNr, final int resultPerPage) {
    final HorizontalLayout pagingControls = new HorizontalLayout();
    pagingControls.setSpacing(true);
    pagingControls.setMargin(true);

    final int maxPages = (int) ((size + (resultPerPage - 1)) / resultPerPage);

    final StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(PAGE_HEADER).append(pageNr).append(PAGE_SEPARATOR).append(maxPages)
            .append(PAGES_TOTAL_RESULTS).append(size).append(RESULTS_PER_PAGE).append(resultPerPage)
            .append(SHOW);
    final Label pageInfo = new Label(stringBuilder.toString());
    pagingControls.addComponent(pageInfo);
    pagingControls.setExpandRatio(pageInfo, ContentRatio.SMALL);

    if (pageNr > PAGE_ONE) {
        addPagingLink(PREVIOUS_PAGE, name, pageId, pageNr - 1, pagingControls);
    }

    if (maxPages > PAGE_ONE && pageNr < maxPages) {
        addPagingLink(NEXT_PAGE, name, pageId, pageNr + 1, pagingControls);
    }

    if (maxPages > LIMIT_FOR_DISPLAYING_START_END_LINKS && pageNr > PAGE_ONE) {
        addPagingLink(FIRST_PAGE, name, pageId, 1, pagingControls);
    }

    if (maxPages > LIMIT_FOR_DISPLAYING_START_END_LINKS && pageNr < maxPages) {
        addPagingLink(LAST_PAGE, name, pageId, maxPages, pagingControls);
    }

    content.addComponent(pagingControls);
    content.setExpandRatio(pagingControls, ContentRatio.SMALL2);

}

From source file:com.hack23.cia.web.impl.ui.application.views.common.chartfactory.impl.AbstractChartDataManagerImpl.java

License:Apache License

/**
 * Adds the chart./*from www  .j ava  2  s .  c  om*/
 *
 * @param content
 *            the content
 * @param caption
 *            the caption
 * @param chart
 *            the chart
 */
protected final void addChart(final AbstractOrderedLayout content, final String caption, final DCharts chart) {
    final HorizontalLayout horizontalLayout = new HorizontalLayout();

    final int browserWindowWidth = Page.getCurrent().getBrowserWindowWidth() - 50;
    final int browserWindowHeight = Page.getCurrent().getBrowserWindowHeight() - 200;

    horizontalLayout.setWidth(browserWindowWidth, Unit.PIXELS);
    horizontalLayout.setHeight(browserWindowHeight, Unit.PIXELS);

    final Panel formPanel = new Panel();
    formPanel.setSizeFull();
    formPanel.setContent(horizontalLayout);

    content.addComponent(formPanel);
    content.setExpandRatio(formPanel, ContentRatio.LARGE);

    chart.setWidth(browserWindowWidth - 50, Unit.PIXELS);
    chart.setHeight(browserWindowHeight - 100, Unit.PIXELS);
    chart.setMarginRight(5);
    chart.setMarginLeft(5);
    chart.setMarginBottom(5);
    chart.setMarginTop(5);

    chart.setEnableDownload(true);
    chart.setChartImageFormat(ChartImageFormat.PNG);

    horizontalLayout.addComponent(chart);
    chart.setCaption(caption);
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.formfactory.impl.FormFactoryImpl.java

License:Apache License

@Override
public <T extends Serializable> void addFormPanelTextFields(final AbstractOrderedLayout panelContent,
        final BeanItem<T> item, final Class<T> beanType, final List<String> displayProperties) {

    final Panel formPanel = new Panel();
    formPanel.setSizeFull();// w  w  w .ja v  a2  s .co  m

    panelContent.addComponent(formPanel);
    panelContent.setExpandRatio(formPanel, ContentRatio.GRID);

    final FormLayout formContent = new FormLayout();
    formPanel.setContent(formContent);

    final BeanFieldGroup<T> fieldGroup = new BeanFieldGroup<>(beanType);
    fieldGroup.setItemDataSource(item);
    fieldGroup.setReadOnly(true);

    for (final String property : displayProperties) {

        final Field<?> buildAndBind = fieldGroup.buildAndBind(property);
        buildAndBind.setWidth(ContentSize.FULL_SIZE);

        formContent.addComponent(buildAndBind);
    }
    final Collection<Object> unboundPropertyIds = fieldGroup.getUnboundPropertyIds();
    for (final Object property : unboundPropertyIds) {
        LOGGER.debug(LOG_MSG_PROPERTY, property);
    }

}

From source file:com.hack23.cia.web.impl.ui.application.views.common.gridfactory.impl.GridFactoryImpl.java

License:Apache License

@Override
public void createBasicBeanItemNestedPropertiesGrid(final AbstractOrderedLayout panelContent,
        final Indexed datasource, final String caption, final String[] nestedProperties,
        final Object[] columnOrder, final Object[] hideColumns,
        final AbstractPageItemRendererClickListener<?> listener, final String actionId,
        final ListPropertyConverter[] collectionPropertyConverters) {
    final Grid grid = new Grid(datasource);

    grid.setCaption(caption);/*from www  .  ja  v a2 s. c om*/
    grid.setSelectionMode(SelectionMode.SINGLE);

    createNestedProperties(datasource, nestedProperties);

    configureColumnOrdersAndHiddenFields(columnOrder, hideColumns, grid);

    configureListeners(listener, grid);

    setColumnConverters(collectionPropertyConverters, grid);

    grid.setSizeFull();

    grid.setStyleName("Level2Header");

    grid.setImmediate(true);
    grid.setReadOnly(true);

    createGridCellFilter(columnOrder, grid);

    panelContent.addComponent(grid);
    panelContent.setExpandRatio(grid, ContentRatio.GRID);
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory.java

License:Apache License

/**
 * Creates a new Label object./*from   w w w  . ja  v  a2  s.  c om*/
 *
 * @param panel
 *            the panel
 * @param content
 *            the content
 */
public static void createHeader2Label(final AbstractOrderedLayout panel, final String content) {
    final Label label = new Label(content);
    label.setStyleName("Level2Header");

    panel.addComponent(label);
    panel.setExpandRatio(label, ContentRatio.SMALL);
}

From source file:com.haulmont.cuba.web.gui.components.WebComponentsHelper.java

License:Apache License

public static void expand(AbstractOrderedLayout layout, Component component, String height, String width) {
    if (!isHorizontalLayout(layout)
            && (StringUtils.isEmpty(height) || "-1px".equals(height) || height.endsWith("%"))) {
        component.setHeight("100%");
    }/*from   w  w  w  .  j av  a  2s . c om*/

    if (!isVerticalLayout(layout)
            && (StringUtils.isEmpty(width) || "-1px".equals(width) || width.endsWith("%"))) {
        component.setWidth("100%");
    }

    layout.setExpandRatio(component, 1);
}

From source file:com.haulmont.cuba.web.gui.WebWindow.java

License:Apache License

@Override
public void resetExpanded() {
    if (getContainer() instanceof AbstractOrderedLayout) {
        AbstractOrderedLayout container = (AbstractOrderedLayout) getContainer();

        for (com.vaadin.ui.Component child : container) {
            container.setExpandRatio(child, 0.0f);
        }//w  ww.j  a va2 s .  c o m
    } else {
        throw new UnsupportedOperationException();
    }
}

From source file:com.haulmont.timesheets.web.calendar.CalendarScreen.java

License:Apache License

protected void initCalendar() {
    dataSource = new TimeSheetsCalendarEventProvider(userSession.getCurrentOrSubstitutedUser());
    dataSource.addEventSetChangeListener(changeEvent -> updateSummaryColumn());

    calendar = new TimeSheetsCalendar(dataSource);

    calendar.setWidth("100%");
    calendar.setHeight("100%");
    calendar.setTimeFormat(Calendar.TimeFormat.Format24H);
    calendar.setMoreMsgFormat(messages.getMessage(getClass(), "calendar.moreMsgFormat"));
    calendar.setDropHandler(null);/*  w  w w .  ja  va 2 s  . c o m*/
    calendar.setHandler((CalendarComponentEvents.MoveEvent event) -> {
        if (event.getCalendarEvent() instanceof TimeEntryCalendarEventAdapter) {
            TimeEntryCalendarEventAdapter adapter = (TimeEntryCalendarEventAdapter) event.getCalendarEvent();
            adapter.getTimeEntry().setDate(event.getNewStart());
            TimeEntry committed = getDsContext().getDataSupplier().commit(adapter.getTimeEntry(),
                    viewRepository.getView(TimeEntry.class, "timeEntry-full"));
            dataSource.changeEventTimeEntity(committed);
            updateSummaryColumn();
        }
    });
    calendar.setHandler((CalendarComponentEvents.WeekClickHandler) null);
    calendar.setHandler((CalendarComponentEvents.DateClickEvent event) -> {
        TimeEntry timeEntry = metadata.create(TimeEntry.class);
        timeEntry.setDate(event.getDate());
        editTimeEntry(timeEntry);
    });
    calendar.setHandler((CalendarComponentEvents.EventResizeHandler) null);
    calendar.setHandler((CalendarComponentEvents.EventClick event) -> {
        if (event.getCalendarEvent() instanceof TimeEntryCalendarEventAdapter) {
            TimeEntryCalendarEventAdapter eventAdapter = (TimeEntryCalendarEventAdapter) event
                    .getCalendarEvent();
            editTimeEntry(eventAdapter.getTimeEntry());
        } else if (event.getCalendarEvent() instanceof HolidayCalendarEventAdapter) {
            HolidayCalendarEventAdapter eventAdapter = (HolidayCalendarEventAdapter) event.getCalendarEvent();
            editHoliday(eventAdapter.getHoliday());
        }
    });
    calendar.addActionHandler(new CalendarActionHandler());

    AbstractOrderedLayout calendarLayout = (AbstractOrderedLayout) WebComponentsHelper.unwrap(calBox);
    calendarLayout.addComponent(calendar);
    calendarLayout.setExpandRatio(calendar, 1);

    updateCalendarRange();
    updateSummaryColumn();
}

From source file:org.jdal.vaadin.ui.Box.java

License:Apache License

/**
 * Try to imitate a HorizalGlue of Swing BoxLayout.
 * A invisible component that get all extra space.
 * @param layout layout to add glue//ww w .  ja  v  a2s  . c o  m
 */
public static void addHorizontalGlue(AbstractOrderedLayout layout) {
    Label label = new Label();
    label.setWidth("100%");
    layout.addComponent(label);
    layout.setExpandRatio(label, 1.0f);
}

From source file:org.jdal.vaadin.ui.Box.java

License:Apache License

/**
 * Try to imitate a VerticalGlue of Swing BoxLayout
 *///from w ww.  j a va 2 s.  co m
public static void addVerticalGlue(AbstractOrderedLayout layout) {
    Label label = new Label(" ");
    label.setHeight("100%");
    layout.addComponent(label);
    layout.setExpandRatio(label, 1.0f);
}