Java Code Examples for com.vaadin.ui.AbstractOrderedLayout#setExpandRatio()

The following examples show how to use com.vaadin.ui.AbstractOrderedLayout#setExpandRatio() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebWindow.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void resetExpanded() {
    if (getContainer() instanceof AbstractOrderedLayout) {
        AbstractOrderedLayout container = (AbstractOrderedLayout) getContainer();

        for (com.vaadin.ui.Component child : container) {
            container.setExpandRatio(child, 0.0f);
        }
    } else {
        throw new UnsupportedOperationException();
    }
}
 
Example 2
Source File: FormFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends Serializable> void addFormPanelTextFields(final AbstractOrderedLayout panelContent, final T item,
		final Class<T> beanType, final List<String> displayProperties) {


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


	panelContent.addComponent(formPanel);
	if (displayProperties.size() > SIZE_FOR_GRID) {
		panelContent.setExpandRatio(formPanel, ContentRatio.GRID);
	}
	else {
		panelContent.setExpandRatio(formPanel, ContentRatio.SMALL_GRID);
	}


	final FormLayout formContent = new FormLayout();
	formPanel.setContent(formContent);
	formContent.setWidth(ContentSize.FULL_SIZE);

	final Binder<T> binder = new Binder<>(beanType);
	binder.setBean(item);
	binder.setReadOnly(true);

	PropertyDescriptor[] propertyDescriptors=null;
	try {
		final BeanInfo info = Introspector.getBeanInfo(item.getClass());
		propertyDescriptors = info.getPropertyDescriptors();
	} catch (final IntrospectionException exception) {
		LOGGER.error("No able to getfieldtypes for type:+ item.getClass()", exception);
	}

	createDisplayPropertyConverters(displayProperties, formContent, binder, propertyDescriptors);
}
 
Example 3
Source File: AbstractChartDataManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the chart.
 *
 * @param content
 *            the content
 * @param caption
 *            the caption
 * @param chart
 *            the chart
 * @param fullPage
 *            the full page
 */
protected final void addChart(final AbstractOrderedLayout content,final String caption, final DCharts chart, final boolean fullPage) {
	final HorizontalLayout horizontalLayout = new HorizontalLayout();

	final int browserWindowWidth = getChartWindowWidth();

	final int browserWindowHeight = getChartWindowHeight(fullPage);

	horizontalLayout.setWidth(browserWindowWidth, Unit.PIXELS);
	horizontalLayout.setHeight(browserWindowHeight, Unit.PIXELS);
	horizontalLayout.setMargin(true);
	horizontalLayout.setSpacing(false);
	horizontalLayout.addStyleName("v-layout-content-overview-panel-level1");

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

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


	chart.setWidth(100, Unit.PERCENTAGE);
	chart.setHeight(100, Unit.PERCENTAGE);
	chart.setMarginRight(CHART_RIGHT_MARGIN);
	chart.setMarginLeft(CHART_LEFT_MARGIN);
	chart.setMarginBottom(CHART_BOTTOM_MARGIN_SIZE);
	chart.setMarginTop(CHART_TOP_MARGIN_SIZE);

	horizontalLayout.addComponent(chart);
	chart.setCaption(caption);
}
 
Example 4
Source File: RowUtil.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the grid layout.
 *
 * @param panelContent the panel content
 * @return the responsive row
 */
public static ResponsiveRow createGridLayout(final AbstractOrderedLayout panelContent) {
	final ResponsiveLayout layout = new ResponsiveLayout();
	Responsive.makeResponsive(layout);
	layout.addStyleName("v-layout-content-overview-panel-level1");
	layout.setWidth(100, Unit.PERCENTAGE);
	layout.setHeight(100, Unit.PERCENTAGE);
	panelContent.addComponent(layout);
	panelContent.setExpandRatio(layout, ContentRatio.LARGE);
	return layout.addRow();
}
 
Example 5
Source File: Box.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Try to imitate a HorizalGlue of Swing BoxLayout.
 * A invisible component that get all extra space.
 * @param layout layout to add glue
 */
public static void addHorizontalGlue(AbstractOrderedLayout layout) {
	Label label = new Label();
	label.setWidth("100%");
	layout.addComponent(label);
	layout.setExpandRatio(label, 1.0f);
}
 
Example 6
Source File: Box.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Try to imitate a VerticalGlue of Swing BoxLayout
 */
public static void addVerticalGlue(AbstractOrderedLayout layout) {
	Label label = new Label(" ");
	label.setHeight("100%");
	layout.addComponent(label);
	layout.setExpandRatio(label, 1.0f);
}
 
Example 7
Source File: Box.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Try to imitate HorizontalStruct on Swing BoxLayout
 * @param layout Layout to add the struct
 * @param width struct withd
 */
public static void addHorizontalStruct(AbstractOrderedLayout layout, int width) {
	Label label = new Label();
	label.setWidth(width + "px");
	layout.addComponent(label);
	layout.setExpandRatio(label, 0f);
}
 
Example 8
Source File: Box.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Try to imitate VerticalStruct of Swing BoxLayout
 * @param layout  layout to add struct
 * @param height struct height
 */
public static void addVerticalStruct(AbstractOrderedLayout layout, int height) {
	Label label = new Label();
	label.setHeight(height + "px");
	layout.addComponent(label);
	layout.setExpandRatio(label, 0f);
}
 
Example 9
Source File: WebGroupBox.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public void setExpandRatio(Component component, float ratio) {
    AbstractOrderedLayout layout = getComponentContent();
    layout.setExpandRatio(component.unwrapComposition(com.vaadin.ui.Component.class), ratio);
}
 
Example 10
Source File: AbstractGhantChartManagerImpl.java    From cia with Apache License 2.0 4 votes vote down vote up
/**
 * Creates the role ghant.
 *
 * @param roleSummaryLayoutTabsheet the role summary layout tabsheet
 * @param assignmentList            the assignment list
 */
public final void createRoleGhant(final AbstractOrderedLayout roleSummaryLayoutTabsheet, final Collection<T> assignmentList) {

	final Comparator<T> compare = getComparator();

	final List<T> list = assignmentList.stream().filter(
			(final T x) -> new DateTime(getStepMapping().getFromDate(x).getTime()).getYear() > FILTER_DATA_BEFORE_YEAR)
			.collect(Collectors.toList());

	Collections.sort(list, compare);

	final Gantt createGantt = createGenericGantt(list, getRoleMapping(), getStepMapping());
	roleSummaryLayoutTabsheet.addComponent(createGantt);
	roleSummaryLayoutTabsheet.setExpandRatio(createGantt, ContentRatio.GRID);

}
 
Example 11
Source File: PagingUtilImpl.java    From cia with Apache License 2.0 4 votes vote down vote up
/**
 * Creates the paging controls.
 *
 * @param content       the content
 * @param name          the name
 * @param pageId        the page id
 * @param size          the size
 * @param pageNr        the page nr
 * @param resultPerPage the result per page
 */
@Override
public 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 long maxPages = (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 -1L,pagingControls);
			}

			if (maxPages > PAGE_ONE && pageNr < maxPages) {
				addPagingLink(NEXT_PAGE,name, pageId, pageNr +1L,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);

		}
 
Example 12
Source File: LabelFactory.java    From cia with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a new Label object.
 *
 * @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);
}
 
Example 13
Source File: GridFactoryImpl.java    From cia with Apache License 2.0 3 votes vote down vote up
@Override
public <T extends Serializable> void createBasicBeanItemNestedPropertiesGrid(
		final AbstractOrderedLayout panelContent, final Class<T> dataType, final List<T> datasource,
		final String caption, final String[] nestedProperties, final String[] columnOrder,
		final String[] hideColumns, final PageItemRendererClickListener<?> listener, final String actionId,
		final ListPropertyConverter[] collectionPropertyConverters) {

	final Grid<T> grid = Grid.withPropertySet(BeanPropertySet.get(dataType));
	grid.setCaption(caption);

	grid.setItems(datasource.stream().filter(Objects::nonNull).collect(Collectors.toList()));

	grid.setSelectionMode(SelectionMode.SINGLE);

	createNestedProperties(grid, nestedProperties);
	
	setColumnConverters(collectionPropertyConverters, grid);

	configureColumnOrdersAndHiddenFields(columnOrder, hideColumns, grid);

	configureListeners(listener, grid);


	grid.setSizeFull();

	grid.setStyleName("Level2Header");

	createGridCellFilter(columnOrder, grid, dataType);

	grid.setResponsive(true);

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