com.vaadin.shared.ui.grid.HeightMode Java Examples

The following examples show how to use com.vaadin.shared.ui.grid.HeightMode. 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: WebAbstractDataGrid.java    From cuba with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected void initComponent(Grid<E> component) {
    setSelectionMode(SelectionMode.SINGLE);

    component.setColumnReorderingAllowed(true);

    component.addItemClickListener(this::onItemClick);
    component.addColumnReorderListener(this::onColumnReorder);
    component.addSortListener(this::onSort);

    component.setSizeUndefined();
    component.setHeightMode(HeightMode.UNDEFINED);

    component.setStyleGenerator(this::getGeneratedRowStyle);

    ((CubaEnhancedGrid<E>) component).setCubaEditorFieldFactory(createEditorFieldFactory());
    ((CubaEnhancedGrid<E>) component).setBeforeRefreshHandler(this::onBeforeRefreshGridData);

    initEmptyState();
}
 
Example #2
Source File: WebTree.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void initComponent(CubaTree<E> component) {
    component.setItemCaptionGenerator(this::generateItemCaption);

    component.setSizeUndefined();
    component.getCompositionRoot().setHeightMode(HeightMode.UNDEFINED);

    setSelectionMode(SelectionMode.SINGLE);
}
 
Example #3
Source File: WebTree.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void updateTreeHeight() {
    if (getHeight() < 0) {
        treeWrapper.setHeightUndefined();

        tree.setHeightUndefined();
        tree.getCompositionRoot().setHeightMode(HeightMode.UNDEFINED);
    } else {
        treeWrapper.setHeight(100, Unit.PERCENTAGE);

        tree.setHeight(100, Unit.PERCENTAGE);
        tree.getCompositionRoot().setHeightMode(HeightMode.CSS);
    }
}
 
Example #4
Source File: WebAbstractDataGrid.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void setHeight(float height, Unit unit) {
    super.setHeight(height, unit);

    if (getHeight() < 0) {
        grid.setHeightUndefined();
        grid.setHeightMode(HeightMode.UNDEFINED);
    } else {
        grid.setHeight(100, Unit.PERCENTAGE);
        grid.setHeightMode(HeightMode.CSS);
    }
}
 
Example #5
Source File: CubaGridWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected double recalculateHeightOfEscalator() {
    double heightOfEscalator = super.recalculateHeightOfEscalator();
    if (getHeightMode() == HeightMode.UNDEFINED) {
        // In case of HeightMode.UNDEFINED we miss 1px, as the result:
        // 1. if no rows then the Sidebar button is bigger than header row
        // 2. if there are rows then the last row has the focus border cropped
        heightOfEscalator += 1;
    }
    return heightOfEscalator;
}
 
Example #6
Source File: MainView.java    From anx with Apache License 2.0 4 votes vote down vote up
void showYangNode(WrappedYangNode node) {
 selectedNode = node;
    sidebarPanel.removeAllComponents();

    if (gnmiTools != null)
        gnmiTools.updateNode(node);

    LinkedList<AbstractMap.SimpleEntry<String,String>> parameters = new LinkedList<>();
    parameters.add(new AbstractMap.SimpleEntry<>("Name", node.getName()));
    parameters.add(new AbstractMap.SimpleEntry<>("Namespace", node.getNamespace()));
    parameters.add(new AbstractMap.SimpleEntry<>("Type", node.getType() + " (" +
                    (node.isConfiguration() ? "configuration" : "operational") + ")"));

    String type = node.getDataType();
    if (!type.isEmpty())
        parameters.add(new AbstractMap.SimpleEntry<>("Data Type", type));

    String keys = node.getKeys().collect(Collectors.joining(" "));
    if (!keys.isEmpty())
        parameters.add(new AbstractMap.SimpleEntry<>("Keys", keys));

    parameters.add(new AbstractMap.SimpleEntry<>("XPath", node.getXPath()));
    parameters.add(new AbstractMap.SimpleEntry<>("Sensor Path", node.getSensorPath(false, null)));
    parameters.add(new AbstractMap.SimpleEntry<>("Filter Path", node.getSensorPath(true, selectedData)));
    parameters.add(new AbstractMap.SimpleEntry<>("Maagic Path", node.getMaagic(false)));
    parameters.add(new AbstractMap.SimpleEntry<>("Maagic QPath", node.getMaagic(true)));

    Grid<AbstractMap.SimpleEntry<String,String>> parameterGrid = new Grid<>("Parameters");
    parameterGrid.addColumn(AbstractMap.SimpleEntry::getKey).setCaption("Name");
    parameterGrid.addColumn(AbstractMap.SimpleEntry::getValue).setCaption("Value");
    parameterGrid.setItems(parameters);
    parameterGrid.setHeightMode(HeightMode.UNDEFINED);
    parameterGrid.setWidth("100%");
    sidebarPanel.addComponent(parameterGrid);

    TextArea descriptionLabel = new TextArea("Description");
    descriptionLabel.setValue(node.getDescription());
    descriptionLabel.setReadOnly(true);
    descriptionLabel.setWidth("100%");
    descriptionLabel.setRows(2);
    sidebarPanel.addComponent(descriptionLabel);

    TextArea subtreeFilter = new TextArea("Subtree Filter");
    node.createNetconfTemplate().map(XMLElement::toString).ifPresent(subtreeFilter::setValue);
    subtreeFilter.setReadOnly(true);
    subtreeFilter.setWidth("100%");
    subtreeFilter.setRows(3);
    sidebarPanel.addComponent(subtreeFilter);
}
 
Example #7
Source File: DemoContentLayout.java    From GridExtensionPack with Apache License 2.0 4 votes vote down vote up
public DemoContentLayout() {
	final SelectGrid<TestObject> grid = new SelectGrid<>();
	grid.addColumn(TestObject::getFoo).setCaption("Foo");
	grid.addColumn(TestObject::getBar, new NumberRenderer()).setCaption("Bar");
	grid.addColumn(TestObject::getKm, new NumberRenderer()).setCaption("KM");
	grid.setHeightByRows(10);
	grid.setHeightMode(HeightMode.ROW);

	// Show it in the middle of the screen
	setStyleName("demoContentLayout");
	setSizeFull();
	addComponent(grid);
	setComponentAlignment(grid, Alignment.MIDDLE_CENTER);

	final TableSelectionModel<TestObject> tableSelect = new TableSelectionModel<>();
	grid.setSelectionModel(tableSelect);
	tableSelect.setMode(TableSelectionMode.CTRL);

	HorizontalLayout tableSelectionControls = new HorizontalLayout();
	tableSelectionControls.setCaption("Table Selection Controls");

	// Controls for testing different TableSelectionModes
	for (final TableSelectionMode t : TableSelectionMode.values()) {
		tableSelectionControls.addComponent(new Button(t.toString(), e -> tableSelect.setMode(t)));
	}

	addComponent(tableSelectionControls);

	// TODO: PagingDataProvider

	PagedDataProvider<TestObject, SerializablePredicate<TestObject>> dataProvider = new PagedDataProvider<>(
			DataProvider.ofCollection(TestObject.generateTestData(995)));
	grid.setDataProvider(dataProvider);
	PagingControls pagingControls = dataProvider.getPagingControls();

	HorizontalLayout pages = new HorizontalLayout();
	pages.setCaption("Paging controls");
	pages.addComponent(new Button("First", e -> pagingControls.setPageNumber(0)));
	pages.addComponent(new Button("Previous", e -> pagingControls.previousPage()));
	pages.addComponent(new Button("Next", e -> pagingControls.nextPage()));
	pages.addComponent(new Button("Last", e -> pagingControls.setPageNumber(pagingControls.getPageCount() - 1)));
	VerticalLayout controls = new VerticalLayout();
	controls.addComponents(tableSelectionControls, pages);
	controls.setWidth("100%");
	controls.setHeightUndefined();
	controls.setComponentAlignment(tableSelectionControls, Alignment.MIDDLE_CENTER);
	controls.setComponentAlignment(pages, Alignment.BOTTOM_CENTER);
	addComponent(controls);
	setComponentAlignment(controls, Alignment.MIDDLE_CENTER);

	grid.getEditor().setEnabled(true);
	for (Column<TestObject, ?> c : grid.getColumns()) {
		c.setHidable(true);
	}
}