Example usage for com.vaadin.ui Component setWidth

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

Introduction

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

Prototype

public void setWidth(float width, Unit unit);

Source Link

Document

Sets the width of the object.

Usage

From source file:com.expressui.core.view.page.DashboardPage.java

License:Open Source License

private void setWidthAndHeightIfNotNull(Component component) {
    if (cellPixelWidth != null) {
        component.setWidth(cellPixelWidth, Sizeable.UNITS_PIXELS);
        if (component instanceof VisualizationComponent) {
            ((VisualizationComponent) component).setOption("width", cellPixelWidth);
        }/* ww  w.  j ava2s.  com*/
    }
    if (cellPixelHeight != null) {
        component.setHeight(cellPixelHeight, Sizeable.UNITS_PIXELS);
        if (component instanceof VisualizationComponent) {
            ((VisualizationComponent) component).setOption("height", cellPixelHeight);
        }
    }
}

From source file:com.google.code.vaadin.internal.preconfigured.VaadinComponentsInjector.java

License:Apache License

private void configureComponentApi(Component component, Preconfigured preconfigured) {
    component.setEnabled(preconfigured.enabled());
    component.setVisible(preconfigured.visible());
    component.setReadOnly(preconfigured.readOnly());

    String[] styleName = preconfigured.styleName();
    if (styleName.length > 0) {
        for (String style : styleName) {
            component.addStyleName(style);
        }/* w w  w  .  j  av  a2 s.c  o  m*/
    }

    configureLocalization(component, preconfigured);

    String id = preconfigured.id();
    if (!id.isEmpty()) {
        component.setId(id);
    }

    if (preconfigured.sizeFull()) {
        component.setSizeFull();
    } else if (preconfigured.sizeUndefined()) {
        component.setSizeUndefined();
    } else {
        float width = preconfigured.width();
        if (width > -1.0f) {
            Sizeable.Unit widthUnits = preconfigured.widthUnits();
            component.setWidth(width, widthUnits);
        }
        float height = preconfigured.height();
        if (height > -1.0f) {
            Sizeable.Unit heightUnits = preconfigured.heightUnits();
            component.setHeight(height, heightUnits);
        }
    }
}

From source file:de.kaiserpfalzEdv.vaadin.ui.defaultviews.editor.impl.BaseEditorViewImpl.java

License:Apache License

private void initializeLayout() {
    layout = new HorizontalLayout();
    layout.setWidth(100f, PERCENTAGE);//from w ww.j av  a 2  s.co m
    layout.setHeight(97f, PERCENTAGE);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setResponsive(true);

    editorLayout = new VerticalLayout();
    editorLayout.setResponsive(true);
    layout.addComponent(editorLayout);

    Component data = getEditor(presenter.getData());
    data.setWidth(87f, PERCENTAGE);
    data.setHeight(100f, PERCENTAGE);

    Label fillSpace = new Label();
    fillSpace.setSizeFull();

    editorLayout.addComponent(data);
    editorLayout.addComponent(fillSpace);

    editorLayout.setExpandRatio(data, 10f);
    editorLayout.setExpandRatio(fillSpace, 90f);

    layout.setExpandRatio(editorLayout, 90f);
    setCompositionRoot(layout);
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showConfirmationPopup(String caption, Component content, String confirmCaption,
        String cancelCaption, Integer width, Consumer<Boolean> resultConsumer) {
    Window popupWindow = VaadinUiUtil.createPopupWindow();
    if (width != null) {
        popupWindow.setWidth(width, Unit.PIXELS);
    } else {//from ww  w  .  j a  v a  2s.  c  o m
        popupWindow.setWidthUndefined();
    }
    popupWindow.setCaption(caption);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    content.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(content);

    ConfirmationComponent confirmationComponent = new ConfirmationComponent(false) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onConfirm() {
            popupWindow.close();
            resultConsumer.accept(true);
        }

        @Override
        protected void onCancel() {
            popupWindow.close();
            resultConsumer.accept(false);
        }
    };
    confirmationComponent.getConfirmButton().setCaption(confirmCaption);
    confirmationComponent.getCancelButton().setCaption(cancelCaption);

    popupWindow.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(CloseEvent e) {
            confirmationComponent.getCancelButton().click();
        }
    });

    layout.addComponent(confirmationComponent);
    layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setSpacing(true);
    popupWindow.setContent(layout);

    UI.getCurrent().addWindow(popupWindow);
    return popupWindow;
}

From source file:org.activiti.explorer.ui.reports.ChartComponent.java

License:Apache License

public void addChart(String description, Component chart, String errorMessage) {

    addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
    addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));

    // Description
    if (description != null) {
        Label label = new Label(description);
        label.addStyleName(Reindeer.LABEL_H2);
        addComponent(label);//w  w w .  j  a  v a  2 s  .c o  m

        addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
    }

    // Chart
    if (chart != null) {
        if (chart instanceof DCharts) {
            // DCharts doesn't know how to size itself
            chart.setWidth(600, UNITS_PIXELS);
            chart.setHeight(450, UNITS_PIXELS);
            ((DCharts) chart).show();
        }
        addComponent(chart);
    }

    // Error message
    if (errorMessage != null) {
        Label errorLabel = new Label(errorMessage);
        addComponent(errorLabel);
    }
}

From source file:org.eclipse.emf.ecp.controls.vaadin.AbstractVaadinSimpleControlRenderer.java

License:Open Source License

@Override
protected Component render() {
    final Setting setting = getVElement().getDomainModelReference().getIterator().next();
    final Component component = createControl();
    createDatabinding(setting, getBindingComponent(component));
    component.setWidth(100, Unit.PERCENTAGE);
    return createUnsetLayout(setting, component);
}

From source file:org.eclipse.emf.ecp.controls.vaadin.internal.BooleanControlVaadinRenderer.java

License:Open Source License

@Override
protected Component render() {
    final Setting setting = getVElement().getDomainModelReference().getIterator().next();
    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    final Component checkBox = createControl();
    horizontalLayout.setData(checkBox);/*from  w ww .  ja v  a 2 s  .co  m*/
    createDatabinding(setting, checkBox);
    checkBox.setWidth(100, Unit.PERCENTAGE);
    horizontalLayout.setWidth(100, Unit.PERCENTAGE);
    horizontalLayout.addComponent(checkBox);
    horizontalLayout.setComponentAlignment(checkBox, Alignment.MIDDLE_LEFT);
    // TODO: Fix Size
    horizontalLayout.addStyleName("textheight");
    if (setting.getEStructuralFeature().isUnsettable()) {
        createSetOrUnsetComponent(checkBox, horizontalLayout, setting);
    }
    return horizontalLayout;
}

From source file:org.eclipse.emf.ecp.view.core.vaadin.AbstractContainerRendererVaadin.java

License:Open Source License

@Override
protected Component render() {
    final T renderable = getVElement();

    final AbstractOrderedLayout layout = getAbstractOrderedLayout();
    for (final VContainedElement composite : renderable.getChildren()) {
        final Component renderResult = getRendererFactory().render(composite, getViewModelContext());
        layout.addComponent(renderResult);
    }/*from w w  w. ja  v  a  2s  .  c o  m*/
    final Component renderComponent = getRenderComponent(layout);
    renderComponent.setWidth(100, Unit.PERCENTAGE);
    if (renderComponent instanceof AbstractOrderedLayout) {
        final AbstractOrderedLayout abstractOrderedLayout = (AbstractOrderedLayout) renderComponent;
        abstractOrderedLayout.setMargin(isMargin());
        abstractOrderedLayout.setSpacing(isSpacing());
    }
    return renderComponent;
}

From source file:org.hip.vif.forum.usersettings.ui.ShowCompletedRatingView.java

License:Open Source License

private void addComponentSized(final Component inComponent, final GridLayout inLayout) {
    inComponent.setWidth(110, Unit.PIXELS);
    inComponent.setStyleName("vif-colhead vif-center"); //$NON-NLS-1$
    inLayout.addComponent(inComponent);//from ww  w . ja va  2 s.co  m
    inLayout.setComponentAlignment(inComponent, Alignment.MIDDLE_CENTER);
}

From source file:org.jdal.vaadin.auth.LoginView.java

License:Apache License

@Override
protected Component buildPanel() {
    Label greeting = new Label(getMessage("loginView.greeting"));
    greeting.addStyleName("jd-login-greeting");
    greeting.addStyleName(Reindeer.LABEL_H2);
    Label applicationNameLabel = new Label(getMessage(applicationName));
    applicationNameLabel.addStyleName("jd-login-appname");
    applicationNameLabel.addStyleName(Reindeer.LABEL_H2);
    applicationNameLabel.setSizeUndefined();

    loginButton.addClickListener(this);
    loginButton.setCaption(getMessage("loginView.loginButtonCaption"));
    loginButton.addStyleName("jd-login-button");

    // add shortcut listener for enter key
    loginButton.addShortcutListener(new ShortcutListener("Sign In", KeyCode.ENTER, null) {
        @Override//from  ww  w.  j a  v  a2 s  . co  m
        public void handleAction(Object sender, Object target) {
            loginButton.click();
        }
    });

    Image image = null;
    HorizontalLayout imageWrapper = null;

    if (applicationIcon != null) {
        image = new Image(null, applicationIcon);
        image.setSizeUndefined();
        image.setStyleName("jd-login-icon");
        imageWrapper = new HorizontalLayout();
        imageWrapper.setMargin(false);
        imageWrapper.addComponent(image);
        imageWrapper.setComponentAlignment(image, Alignment.MIDDLE_CENTER);
    }

    BoxFormBuilder fb = new BoxFormBuilder();
    fb.setDefaultWidth(BoxFormBuilder.SIZE_FULL);
    fb.row();
    fb.startBox();
    fb.setFixedHeight();
    fb.row(false);
    fb.add(greeting, Alignment.TOP_LEFT);
    fb.add(applicationNameLabel, Alignment.TOP_RIGHT);
    fb.endBox();
    // add application icon
    if (image != null) {
        fb.row(BoxFormBuilder.SIZE_FULL);
        fb.add(imageWrapper, BoxFormBuilder.SIZE_FULL, Alignment.MIDDLE_CENTER);
    }
    fb.row();
    fb.startBox();
    fb.row(30);
    fb.add(errorLabel, BoxFormBuilder.SIZE_FULL, Alignment.BOTTOM_CENTER);
    fb.endBox();
    fb.row();
    fb.startBox();
    fb.setFixedHeight();
    fb.row();
    fb.add(username, getMessage("loginView.username"), Alignment.BOTTOM_CENTER);
    fb.add(password, getMessage("loginView.password"), Alignment.BOTTOM_CENTER);
    fb.add(loginButton, 100, Alignment.BOTTOM_CENTER);
    fb.endBox();

    Component form = fb.getForm();
    form.setWidth(this.getWidth(), Unit.PIXELS);
    form.setHeight(getHeight(), Unit.PIXELS);
    form.setStyleName("jd-login");

    return form;
}