Example usage for com.vaadin.ui HorizontalLayout setHeight

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

Introduction

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

Prototype

@Override
    public void setHeight(float height, Unit unit) 

Source Link

Usage

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

License:Apache License

/**
 * Adds the chart.// w  ww .  j a  v a  2 s .  c  o  m
 *
 * @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.pagemode.AbstractPageModContentFactoryImpl.java

License:Apache License

/**
 * Creates the page visit history.//from  w w  w  .  j  a  va 2s.  c  om
 *
 * @param pageName
 *            the page name
 * @param pageId
 *            the page id
 * @param panelContent
 *            the panel content
 */
protected final void createPageVisitHistory(final String pageName, final String pageId,
        final VerticalLayout panelContent) {

    final TabSheet tabsheet = new TabSheet();
    tabsheet.setWidth(100, Unit.PERCENTAGE);
    tabsheet.setHeight(100, Unit.PERCENTAGE);

    panelContent.addComponent(tabsheet);
    panelContent.setExpandRatio(tabsheet, ContentRatio.LARGE);

    final HorizontalLayout tabContentPageItemRankHistory = new HorizontalLayout();
    tabContentPageItemRankHistory.setWidth(100, Unit.PERCENTAGE);
    tabContentPageItemRankHistory.setHeight(100, Unit.PERCENTAGE);
    final Tab tabPageItemRankHistory = tabsheet.addTab(tabContentPageItemRankHistory);

    tabPageItemRankHistory.setCaption(CURRENT_PAGE_VISIT_HISTORY);
    adminChartDataManager.createApplicationActionEventPageElementDailySummaryChart(
            tabContentPageItemRankHistory, pageName, pageId);

    final HorizontalLayout tabContentPageModeSummary = new HorizontalLayout();
    tabContentPageModeSummary.setWidth(100, Unit.PERCENTAGE);
    tabContentPageModeSummary.setHeight(100, Unit.PERCENTAGE);
    final Tab tabPageModeSummary = tabsheet.addTab(tabContentPageModeSummary);
    tabPageModeSummary.setCaption(GENERAL_PAGE_MODE_PAGE_VISIT);

    adminChartDataManager.createApplicationActionEventPageModeDailySummaryChart(tabContentPageModeSummary,
            pageName);

}

From source file:com.hack23.cia.web.impl.ui.application.views.user.ballot.pagemode.BallotChartsPageModContentFactoryImpl.java

License:Apache License

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override/*w  w  w.  ja  v a2s. co m*/
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();

    final String pageId = getPageId(parameters);

    final DataContainer<ViewRiksdagenVoteDataBallotSummary, RiksdagenVoteDataBallotEmbeddedId> dataContainer = getApplicationManager()
            .getDataContainer(ViewRiksdagenVoteDataBallotSummary.class);

    final DataContainer<ViewRiksdagenVoteDataBallotPartySummary, RiksdagenVoteDataBallotPartyEmbeddedId> dataPartyContainer = getApplicationManager()
            .getDataContainer(ViewRiksdagenVoteDataBallotPartySummary.class);

    final List<ViewRiksdagenVoteDataBallotSummary> ballots = dataContainer.findListByEmbeddedProperty(
            ViewRiksdagenVoteDataBallotSummary.class, ViewRiksdagenVoteDataBallotSummary_.embeddedId,
            RiksdagenVoteDataBallotEmbeddedId.class, RiksdagenVoteDataBallotEmbeddedId_.ballotId, pageId);

    final List<ViewRiksdagenVoteDataBallotPartySummary> partyBallotList = dataPartyContainer
            .findListByEmbeddedProperty(ViewRiksdagenVoteDataBallotPartySummary.class,
                    ViewRiksdagenVoteDataBallotPartySummary_.embeddedId,
                    RiksdagenVoteDataBallotPartyEmbeddedId.class,
                    RiksdagenVoteDataBallotPartyEmbeddedId_.ballotId, pageId);

    if (!ballots.isEmpty()) {
        getBallotMenuItemFactory().createBallotMenuBar(menuBar, pageId);

        LabelFactory.createHeader2Label(panelContent, CHARTS);

        final TabSheet tabsheet = new TabSheet();
        tabsheet.setWidth(100, Unit.PERCENTAGE);
        tabsheet.setHeight(100, Unit.PERCENTAGE);

        panelContent.addComponent(tabsheet);
        panelContent.setExpandRatio(tabsheet, ContentRatio.LARGE);

        Collections.sort(ballots,
                (Comparator<ViewRiksdagenVoteDataBallotSummary>) (o1,
                        o2) -> (o1.getEmbeddedId().getIssue() + o2.getEmbeddedId().getConcern())
                                .compareTo(o1.getEmbeddedId().getIssue() + o2.getEmbeddedId().getConcern()));

        for (final ViewRiksdagenVoteDataBallotSummary viewRiksdagenVoteDataBallotSummary : ballots) {
            final HorizontalLayout tabContent = new HorizontalLayout();
            tabContent.setWidth(100, Unit.PERCENTAGE);
            tabContent.setHeight(100, Unit.PERCENTAGE);
            final Tab tab = tabsheet.addTab(tabContent);

            ballotChartDataManager.createChart(tab, tabContent, viewRiksdagenVoteDataBallotSummary);
        }

        final Map<String, List<ViewRiksdagenVoteDataBallotPartySummary>> concernIssuePartyBallotSummaryMap = createIssueConcernMap(
                partyBallotList);

        for (final List<ViewRiksdagenVoteDataBallotPartySummary> partyBallotSummaryList : concernIssuePartyBallotSummaryMap
                .values()) {
            final HorizontalLayout tabContent = new HorizontalLayout();
            tabContent.setWidth(100, Unit.PERCENTAGE);
            tabContent.setHeight(100, Unit.PERCENTAGE);
            final Tab tab = tabsheet.addTab(tabContent);

            ballotChartDataManager.createChart(tab, tabContent, partyBallotSummaryList);
        }

        panel.setCaption(BALLOT + pageId);
        getPageActionEventHelper().createPageEvent(ViewAction.VISIT_BALLOT_VIEW, ApplicationEventGroup.USER,
                NAME, parameters, pageId);
    }
    return panelContent;

}

From source file:com.neatresults.mgnltweaks.neatu2b.ui.form.field.U2BField.java

License:Open Source License

/**
 * Initialize the field. <br>//from   w w w  . jav  a  2 s .c  o m
 * Create as many configured Field as we have related values already stored.
 */
@Override
protected void initFields(final PropertysetItem newValue) {
    root.removeAllComponents();
    final TextField id = createTextField("Id", newValue);
    root.addComponent(id);
    final TextField title = createTextField("Title", newValue);
    root.addComponent(title);

    final TextFieldDefinition def = new TextFieldBuilder("description").label("Description").rows(3)
            .definition();
    final TextArea description = (TextArea) createLocalField(def, newValue.getItemProperty(def.getName()),
            false);
    newValue.addItemProperty(def.getName(), description.getPropertyDataSource());
    description.setNullRepresentation("");
    description.setWidth("100%");
    description.setNullSettingAllowed(true);
    root.addComponent(description);

    HorizontalLayout ddLine = new HorizontalLayout();
    final TextField publishedAt = createTextField("Published", newValue);
    ddLine.addComponent(publishedAt);
    final TextField duration = createTextField("Duration", newValue);
    ddLine.addComponent(duration);
    ddLine.addComponent(createTextField("Definition", newValue));

    Button fetchButton = new Button("Fetch metadata");
    fetchButton.addStyleName("magnoliabutton");
    fetchButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {

            String idStr = id.getValue();
            // extract id from url when whole url is passed
            if (idStr.startsWith("http")) {
                idStr = StringUtils.substringBefore(StringUtils.substringAfter(idStr, "?v="), "&");
            }

            U2BService service = null;
            try {
                RestEasyClient client = (RestEasyClient) restClientRegistry.getRestClient("youtube");
                service = client.getClientService(U2BService.class);
            } catch (RegistrationException e) {
                log.error("Failed to get a client for [" + U2BService.class.getName() + "] with: "
                        + e.getMessage(), e);
            }
            if (service != null) {
                String key = u2bModule.getGoogleKey();
                JsonNode response = service.meta(idStr, "snippet", key);
                try {
                    if (response.get("items").getElements().hasNext()) {
                        JsonNode videoItem = response.get("items").getElements().next();
                        String descriptionStr = videoItem.get("snippet").get("description").getTextValue();
                        newValue.getItemProperty("description").setValue(descriptionStr);
                        String titleStr = videoItem.get("snippet").get("title").getTextValue();
                        newValue.getItemProperty("title").setValue(titleStr);
                        Iterator<Entry<String, JsonNode>> thumbs = videoItem.get("snippet").get("thumbnails")
                                .getFields();
                        while (thumbs.hasNext()) {
                            Entry<String, JsonNode> entry = thumbs.next();
                            newValue.getItemProperty(entry.getKey() + "Url")
                                    .setValue(entry.getValue().get("url").getTextValue());
                            newValue.getItemProperty(entry.getKey() + "Width")
                                    .setValue("" + entry.getValue().get("width").getLongValue());
                            newValue.getItemProperty(entry.getKey() + "Height")
                                    .setValue("" + entry.getValue().get("height").getLongValue());
                        }
                        String publishedAtStr = videoItem.get("snippet").get("publishedAt").getTextValue();
                        newValue.getItemProperty("published").setValue(publishedAtStr);
                    }
                } catch (Exception e) {
                    log.error("Failed to parse the video metadata.", e);
                }

                response = service.meta(idStr, "contentDetails", key);
                try {
                    if (response.get("items").getElements().hasNext()) {
                        JsonNode videoItem = response.get("items").getElements().next();
                        String durationStr = videoItem.get("contentDetails").get("duration").getTextValue();
                        newValue.getItemProperty("duration").setValue(durationStr);
                        String definition = videoItem.get("contentDetails").get("definition").getTextValue();
                        newValue.getItemProperty("definition").setValue(definition);
                    }
                } catch (Exception e) {
                    log.error("Failed to parse the video duration.", e);
                }
            }
        }
    });

    ddLine.addComponent(fetchButton);
    ddLine.setWidth(100, Unit.PERCENTAGE);
    ddLine.setHeight(-1, Unit.PIXELS);
    ddLine.setComponentAlignment(fetchButton, Alignment.BOTTOM_RIGHT);
    root.addComponent(ddLine);

    PropertysetItem item = (PropertysetItem) getPropertyDataSource().getValue();
    root.addComponent(createEntryComponent("default", item), root.getComponentCount() - 1);
    root.addComponent(createEntryComponent("standard", item), root.getComponentCount() - 1);
    root.addComponent(createEntryComponent("medium", item), root.getComponentCount() - 1);
    root.addComponent(createEntryComponent("high", item), root.getComponentCount() - 1);
    root.addComponent(createEntryComponent("maxres", item), root.getComponentCount() - 1);
}

From source file:com.neatresults.mgnltweaks.neatu2b.ui.form.field.U2BField.java

License:Open Source License

/**
 * Create a single element.<br>/*from w w w  . jav  a 2s .c  o  m*/
 * This single element is composed of:<br>
 * - a configured field <br>
 * - a remove Button<br>
 */
private Component createEntryComponent(String propertyId, PropertysetItem newValue) {
    String cappedId = StringUtils.capitalize(propertyId);
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeight(-1, Unit.PIXELS);
    TextField url = createTextField(cappedId + " Thumbnail", newValue, propertyId + "Url");
    layout.addComponent(url);

    TextField width = createTextField("Width", newValue, propertyId + "Width");
    layout.addComponent(width);
    TextField height = createTextField("Height", newValue, propertyId + "Height");
    layout.addComponent(height);
    layout.setExpandRatio(url, .7f);
    layout.setExpandRatio(width, .15f);
    layout.setExpandRatio(height, .15f);

    return layout;
}

From source file:de.datenhahn.vaadin.componentrenderer.demo.StaticCustomerDetailsGenerator.java

License:Apache License

@Override
public Component getDetails(Grid.RowReference rowReference) {
    rowReference.getGrid().scrollTo(rowReference.getItemId());
    StaticCustomer customer = (StaticCustomer) rowReference.getItemId();

    HorizontalLayout layout = new HorizontalLayout();
    layout.setHeight(300, Sizeable.Unit.PIXELS);
    layout.setMargin(true);/*from  w  ww .  j ava  2s .  c o m*/
    layout.setSpacing(true);
    Image image = new Image("", customer.getPhoto());
    image.setHeight(200, Sizeable.Unit.PIXELS);
    image.setWidth(200, Sizeable.Unit.PIXELS);
    layout.addComponent(image);
    Label nameLabel = new Label("<h1>" + customer.getFirstName() + " " + customer.getLastName() + "</h1>",
            ContentMode.HTML);
    layout.addComponent(nameLabel);
    layout.setExpandRatio(nameLabel, 1.0f);
    return layout;
}

From source file:de.escidoc.admintool.view.admintask.filter.FilterView.java

License:Open Source License

private void addContent() {
    final HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setWidth(100, UNITS_PERCENTAGE);
    hLayout.setHeight(100, UNITS_PERCENTAGE);

    final FilterResourceView filterView = new FilterResourceView(services, mainWindow, pdpRequest);
    filterView.init();/*w  w w  .j  a  v  a 2 s.c om*/
    hLayout.addComponent(filterView);
    cssLayout.addComponent(hLayout);
}

From source file:de.escidoc.admintool.view.admintask.loadexamples.LoadExample.java

License:Open Source License

@Override
public void addView() {
    Label text = new H2(ViewConstants.LOAD_EXAMPLES_TITLE);
    text.setContentMode(Label.CONTENT_XHTML);
    cssLayout.addComponent(text);/*from   ww  w  . j av  a  2 s  .c o  m*/

    cssLayout.addComponent(new Ruler());

    text = new Label(ViewConstants.LOAD_EXAMPLE_TEXT, Label.CONTENT_XHTML);
    cssLayout.addComponent(text);

    final HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setWidth(100, UNITS_PERCENTAGE);
    hLayout.setHeight(100, UNITS_PERCENTAGE);

    final LoadExampleView filterView = new LoadExampleResourceViewImpl(mainWindow, services.getAdminService());
    hLayout.addComponent(filterView);
    cssLayout.addComponent(hLayout);
}

From source file:de.escidoc.admintool.view.admintask.repositoryinfo.RepositoryInfoMainView.java

License:Open Source License

@Override
public void addView() {

    Label text = new H2(ViewConstants.REPOSITORY_INFORMATION_TITLE);
    text.setContentMode(Label.CONTENT_XHTML);
    cssLayout.addComponent(text);// w  w w . j ava2  s .  c  om

    cssLayout.addComponent(new Ruler());

    text = new Label(ViewConstants.REPO_INFO_TEXT, Label.CONTENT_XHTML);
    cssLayout.addComponent(text);

    final HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setWidth(100, UNITS_PERCENTAGE);
    hLayout.setHeight(100, UNITS_PERCENTAGE);

    final RepoInfoClickListener listener = new RepoInfoClickListener(mainWindow, services.getAdminService());
    hLayout.addComponent(new RepositoryInfoView(listener));
    cssLayout.addComponent(hLayout);
}

From source file:de.escidoc.admintool.view.user.UserAddView.java

License:Open Source License

private Component createLayout(final String nameLabel, final AbstractTextField textField, final int leftMargin,
        final boolean required) {

    final HorizontalLayout hor = new HorizontalLayout();
    hor.setHeight(37, UNITS_PIXELS);
    hor.addComponent(new Label(" "));

    final String text = Constants.P_ALIGN_RIGHT + nameLabel + Constants.P;
    Label l;/*from w w w .  j  ava 2s  .c  om*/
    hor.addComponent(l = new Label(text, Label.CONTENT_XHTML));
    l.setWidth(leftMargin + Constants.PX);

    if (required) {
        hor.addComponent(new Label("&nbsp;<span style=\"color:red; position:relative; top:13px;\">*</span>",
                Label.CONTENT_XHTML));
    } else {
        hor.addComponent(new Label("&nbsp;&nbsp;", Label.CONTENT_XHTML));
    }
    hor.addComponent(textField);
    hor.setComponentAlignment(textField, Alignment.BOTTOM_RIGHT);
    hor.addComponent(new Label(" "));
    hor.setSpacing(false);
    return hor;
}