Example usage for com.vaadin.ui HorizontalLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(float width, Unit unit) 

Source Link

Usage

From source file:de.escidoc.admintool.view.contentmodel.ContentModelEditView.java

License:Open Source License

private void addFooter() {
    final HorizontalLayout footerLayout = new HorizontalLayout();
    footerLayout.setWidth(480, UNITS_PIXELS);
    addButtons(footerLayout);//  w w w . j a v a 2  s. c o m
    panel.addComponent(footerLayout);
}

From source file:de.fatalix.timeline.web.root.block.TimelineEventLayout.java

public TimelineEventLayout() {
    headline = new TextField();
    headline.setInputPrompt("Your event headline...");
    headline.setColumns(31);//  w  w  w.j av a 2  s .  c o m
    headline.setNullRepresentation("");
    text = new TextArea();
    text.setInputPrompt("Your event description...");
    text.setColumns(31);
    text.setRows(10);
    text.setNullRepresentation("");

    startDate = new DateField(null, new Date());
    startDate.setDateFormat("dd-MM-yyyy");
    startDate.setResolution(Resolution.DAY);
    startDate.setDescription("Set the start date of an event.");

    endDate = new DateField();
    endDate.setDateFormat("dd-MM-yyyy");
    endDate.setResolution(Resolution.DAY);
    endDate.setDescription("Set the end date of an event. Optional!");

    deleteButton = new VerticalLayout();
    deleteButton.setWidth(16, Unit.PIXELS);
    deleteButton.setHeight(16, Unit.PIXELS);
    deleteButton.addStyleName("delete");
    deleteButton.setDescription("Click to remove this event");
    deleteButton.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            for (EventDeleteListener listener : listeners) {
                listener.deleteEvent(TimelineEventLayout.this);
            }
        }
    });

    HorizontalLayout dateLayout = new HorizontalLayout();
    dateLayout.setWidth(100, Unit.PERCENTAGE);
    dateLayout.addComponents(startDate, endDate, deleteButton);
    dateLayout.setComponentAlignment(deleteButton, Alignment.MIDDLE_RIGHT);
    this.setMargin(true);
    this.setSpacing(true);
    this.addComponent(headline);
    this.addComponent(text);

    this.addComponent(dateLayout);
}

From source file:de.gedoplan.webclients.vaadin.views.CustomerDetailView.java

public void init() {
    Double discount = customerService.calculateCustomerDiscount(customer.getCustomerID()).getDiscount();
    Label name = new Label(new PropertyFormatter(form.getProperty(Customer_.companyName)) {
        @Override/* www. j  a  v  a2  s  . c o  m*/
        public String format(Object value) {
            return value + " (" + customer.getCustomerID() + ")";
        }

        @Override
        public Object parse(String formattedValue) throws Exception {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    name.setStyleName(ValoTheme.LABEL_BOLD);
    Label rabattLabel = new Label(Messages.customer_discount.value());
    rabattLabel.setStyleName(ValoTheme.LABEL_BOLD);
    rabattLabel.setSizeUndefined();
    Label rabatt = new Label(new DecimalFormat("#0.00").format(discount) + "%");
    rabatt.setSizeUndefined();
    rabatt.addStyleName(ValoTheme.LABEL_COLORED);
    rabatt.addStyleName(ValoTheme.LABEL_BOLD);
    HorizontalLayout headline = new HorizontalLayout(name, rabattLabel, rabatt);
    headline.setComponentAlignment(rabatt, Alignment.TOP_RIGHT);
    headline.setExpandRatio(name, 1);
    headline.setWidth(100, Unit.PERCENTAGE);
    headline.setSpacing(true);
    headline.setStyleName(ValoTheme.LAYOUT_WELL);
    headline.setMargin(new MMarginInfo(false, true));
    Panel panel = new Panel();
    panel.setContent(form);
    setMargin(true);
    setSpacing(true);
    addComponents(headline, panel);
}

From source file:de.symeda.sormas.ui.caze.AbstractTableField.java

License:Open Source License

@Override
protected Component initContent() {

    this.addStyleName(CssStyles.CAPTION_HIDDEN);
    this.addStyleName(CssStyles.VSPACE_2);

    layout = new VerticalLayout();
    layout.setSpacing(false);//from   w  w  w.  j  a va 2  s. c  om

    HorizontalLayout headerLayout = new HorizontalLayout();
    {
        headerLayout.setWidth(100, Unit.PERCENTAGE);

        captionLabel = new Label(getCaption());
        captionLabel.setSizeUndefined();
        headerLayout.addComponent(captionLabel);
        headerLayout.setComponentAlignment(captionLabel, Alignment.BOTTOM_LEFT);
        headerLayout.setExpandRatio(captionLabel, 0);

        addButton = createAddButton();
        headerLayout.addComponent(addButton);
        headerLayout.setComponentAlignment(addButton, Alignment.BOTTOM_RIGHT);
        headerLayout.setExpandRatio(addButton, 1);
    }
    layout.addComponent(headerLayout);

    table = createTable();
    table.addItemSetChangeListener(new ItemSetChangeListener() {
        @Override
        public void containerItemSetChange(ItemSetChangeEvent event) {
            applyTablePageLength();
        }
    });
    layout.addComponent(table);

    return layout;
}

From source file:de.symeda.sormas.ui.caze.CasesView.java

License:Open Source License

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setMargin(false);
    statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);

    statusButtons = new HashMap<>();

    Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> {
        criteria.investigationStatus(null);
        navigateTo(criteria);/*from  ww w .  j  av  a2s . c  o  m*/
    });
    CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    statusFilterLayout.addComponent(statusAll);
    statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
    activeStatusButton = statusAll;

    for (InvestigationStatus status : InvestigationStatus.values()) {
        Button statusButton = new Button(status.toString(), e -> {
            criteria.investigationStatus(status);
            navigateTo(criteria);
        });
        statusButton.setData(status);
        CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER,
                CssStyles.BUTTON_FILTER_LIGHT);
        statusButton.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusButton);
        statusButtons.put(statusButton, status.toString());
    }

    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show archived/active cases button
        if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW_ARCHIVED)) {
            switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.caseShowArchived));
            switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
            switchArchivedActiveButton.addClickListener(e -> {
                criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE);
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(switchArchivedActiveButton);
        }

        // Bulk operation dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            MenuBar bulkOperationsDropdown = new MenuBar();
            MenuItem bulkOperationsItem = bulkOperationsDropdown
                    .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

            Command changeCommand = selectedItem -> {
                ControllerProvider.getCaseController()
                        .showBulkCaseDataEditComponent(grid.asMultiSelect().getSelectedItems());
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H,
                    changeCommand);

            Command deleteCommand = selectedItem -> {
                ControllerProvider.getCaseController()
                        .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                    deleteCommand);

            Command archiveCommand = selectedItem -> {
                ControllerProvider.getCaseController()
                        .archiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            archiveItem = bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.actionArchive),
                    VaadinIcons.ARCHIVE, archiveCommand);

            Command dearchiveCommand = selectedItem -> {
                ControllerProvider.getCaseController()
                        .dearchiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            dearchiveItem = bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.actionDearchive),
                    VaadinIcons.ARCHIVE, dearchiveCommand);
            dearchiveItem.setVisible(false);

            actionButtonsLayout.addComponent(bulkOperationsDropdown);
        }
    }
    statusFilterLayout.addComponent(actionButtonsLayout);
    statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);

    return statusFilterLayout;
}

From source file:de.symeda.sormas.ui.configuration.outbreak.OutbreakRegionConfigurationForm.java

License:Open Source License

private HorizontalLayout createHeader() {
    HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.setWidth(100, Unit.PERCENTAGE);
    headerLayout.setSpacing(true);//  www  .ja  v a 2 s.  co  m
    CssStyles.style(headerLayout, CssStyles.VSPACE_2);

    // Headline and info text
    Label infoTextLabel = new Label(I18nProperties.getString(Strings.headingDefineOutbreakDistricts));
    infoTextLabel.setWidthUndefined();
    CssStyles.style(infoTextLabel, CssStyles.VSPACE_TOP_4);
    headerLayout.addComponent(infoTextLabel);

    // Number of affected districts and options to toggle outbreak mode for all districts   
    HorizontalLayout allDistrictsLayout = new HorizontalLayout();
    allDistrictsLayout.setWidthUndefined();
    allDistrictsLayout.setSpacing(true);
    {
        Label allDistrictsLabel = new Label(I18nProperties.getString(Strings.headingSetOutbreakStatus));
        allDistrictsLabel.setWidthUndefined();
        CssStyles.style(allDistrictsLabel, CssStyles.VSPACE_TOP_4);
        allDistrictsLayout.addComponent(allDistrictsLabel);

        OptionGroup outbreakToggle = new OptionGroup();
        CssStyles.style(outbreakToggle, ValoTheme.OPTIONGROUP_HORIZONTAL,
                CssStyles.OPTIONGROUP_HORIZONTAL_SWITCH_CRITICAL);
        outbreakToggle.addItem(OUTBREAK);
        outbreakToggle.addItem(NORMAL);

        if (affectedDistricts.isEmpty()) {
            outbreakToggle.setValue(NORMAL);
        } else if (affectedDistricts.size() == totalDistricts) {
            outbreakToggle.setValue(OUTBREAK);
        }

        outbreakToggle.addValueChangeListener(e -> {
            for (OptionGroup districtOutbreakToggle : outbreakToggles) {
                districtOutbreakToggle.setValue(e.getProperty().getValue());
            }
        });

        outbreakToggle.setWidthUndefined();
        allDistrictsLayout.addComponent(outbreakToggle);

        affectedDistrictsNumberLabel = new Label();
        affectedDistrictsNumberLabel.setWidthUndefined();
        allDistrictsLayout.addComponent(affectedDistrictsNumberLabel);
    }
    headerLayout.addComponent(allDistrictsLayout);
    headerLayout.setComponentAlignment(allDistrictsLayout, Alignment.TOP_RIGHT);

    headerLayout.setExpandRatio(infoTextLabel, 1);

    return headerLayout;
}

From source file:de.symeda.sormas.ui.configuration.outbreak.OutbreakRegionConfigurationForm.java

License:Open Source License

private HorizontalLayout createAffectedDistrictsComponent() {
    HorizontalLayout affectedDistrictsComponent = new HorizontalLayout();
    affectedDistrictsComponent.setWidth(100, Unit.PERCENTAGE);
    affectedDistrictsComponent.setMargin(false);
    CssStyles.style(affectedDistrictsComponent, CssStyles.VSPACE_3);

    // Create two columns to display the districts
    VerticalLayout leftColumn = new VerticalLayout();
    leftColumn.setMargin(false);//  w  w w  .j a v a2s  .c om
    VerticalLayout middleColumn = new VerticalLayout();
    middleColumn.setMargin(false);
    VerticalLayout rightColumn = new VerticalLayout();
    rightColumn.setMargin(false);

    affectedDistrictsComponent.addComponent(leftColumn);
    // Add spacer label
    affectedDistrictsComponent.addComponent(new Label());
    affectedDistrictsComponent.addComponent(middleColumn);
    // Add spacer label
    affectedDistrictsComponent.addComponent(new Label());
    affectedDistrictsComponent.addComponent(rightColumn);

    affectedDistrictsComponent.setExpandRatio(leftColumn, 1);
    affectedDistrictsComponent.setExpandRatio(middleColumn, 1);
    affectedDistrictsComponent.setExpandRatio(rightColumn, 1);

    List<DistrictReferenceDto> districts = FacadeProvider.getDistrictFacade().getAllByRegion(region.getUuid());
    int index = 1;
    for (DistrictReferenceDto district : districts) {
        OptionGroup outbreakToggle = createOutbreakToggle(district);
        outbreakToggle.setWidth(100, Unit.PERCENTAGE);
        outbreakToggles[index - 1] = outbreakToggle;

        // Split districts evenly to all three columns
        if ((districts.size() % 3 == 0 && index <= districts.size() / 3)
                || (districts.size() % 3 != 0 && index <= (districts.size() / 3) + 1)) {
            leftColumn.addComponent(outbreakToggle);
        } else if ((districts.size() % 3 == 0 && index <= districts.size() / 1.5f)
                || ((districts.size() % 3 == 1 || districts.size() % 3 == 2)
                        && index <= (districts.size() / 1.5f) + 1)) {
            middleColumn.addComponent(outbreakToggle);
        } else {
            rightColumn.addComponent(outbreakToggle);
        }

        index++;
    }

    return affectedDistrictsComponent;
}

From source file:de.symeda.sormas.ui.contact.ContactsView.java

License:Open Source License

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setMargin(false);
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);

    statusButtons = new HashMap<>();

    Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> {
        criteria.contactStatus(null);/*from w ww.  j av a 2 s. com*/
        navigateTo(criteria);
    });
    CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    statusFilterLayout.addComponent(statusAll);
    statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
    activeStatusButton = statusAll;

    for (ContactStatus status : ContactStatus.values()) {
        Button statusButton = new Button(status.toString(), e -> {
            criteria.contactStatus(status);
            navigateTo(criteria);
        });
        statusButton.setData(status);
        CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER,
                CssStyles.BUTTON_FILTER_LIGHT);
        statusButton.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusButton);
        statusButtons.put(statusButton, status.toString());
    }

    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show archived/active cases button
        if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW_ARCHIVED)) {
            switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.contactShowArchived));
            switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
            switchArchivedActiveButton.addClickListener(e -> {
                criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE);
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(switchArchivedActiveButton);
        }

        // Bulk operation dropdown
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            statusFilterLayout.setWidth(100, Unit.PERCENTAGE);

            MenuBar bulkOperationsDropdown = new MenuBar();
            MenuItem bulkOperationsItem = bulkOperationsDropdown
                    .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

            Command changeCommand = selectedItem -> {
                ControllerProvider.getContactController()
                        .showBulkContactDataEditComponent(grid.asMultiSelect().getSelectedItems(), null);
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H,
                    changeCommand);

            Command cancelFollowUpCommand = selectedItem -> {
                ControllerProvider.getContactController().cancelFollowUpOfAllSelectedItems(
                        grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp),
                    VaadinIcons.CLOSE, cancelFollowUpCommand);

            Command lostToFollowUpCommand = selectedItem -> {
                ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp(
                        grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp),
                    VaadinIcons.UNLINK, lostToFollowUpCommand);

            Command deleteCommand = selectedItem -> {
                ControllerProvider.getContactController()
                        .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                    deleteCommand);

            actionButtonsLayout.addComponent(bulkOperationsDropdown);
        }
    }
    statusFilterLayout.addComponent(actionButtonsLayout);
    statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.TOP_RIGHT);
    statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);

    return statusFilterLayout;
}

From source file:de.symeda.sormas.ui.contact.ContactVisitsView.java

License:Open Source License

public HorizontalLayout createTopBar() {
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setSpacing(true);//from  w w  w  . j av a2  s  .  c o  m
    topLayout.setWidth(100, Unit.PERCENTAGE);

    //      statusButtons = new HashMap<>();
    //
    //      Button contactButton = new Button(I18nProperties.getCaption(Captions.contactRelated), e -> {
    //         grid.reload(getContactRef());
    //         processStatusChangeVisuals(e.getButton());
    //      });
    //      CssStyles.style(contactButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    //      contactButton.setCaptionAsHtml(true);
    //      topLayout.addComponent(contactButton);
    //      statusButtons.put(contactButton, I18nProperties.getCaption(Captions.contactRelated));
    //
    //      Button personButton = new Button(I18nProperties.getCaption(Captions.contactPersonVisits), e -> {
    //         ContactDto contact = FacadeProvider.getContactFacade().getContactByUuid(getContactRef().getUuid());
    //         grid.reload(contact.getPerson());
    //         processStatusChangeVisuals(e.getButton());
    //      });
    //      CssStyles.style(personButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT);
    //      personButton.setCaptionAsHtml(true);
    //      topLayout.addComponent(personButton);
    //      statusButtons.put(personButton, I18nProperties.getCaption(Captions.contactPersonVisits));

    //      topLayout.setExpandRatio(topLayout.getComponent(topLayout.getComponentCount()-1), 1);

    // Bulk operation dropdown
    if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
        topLayout.setWidth(100, Unit.PERCENTAGE);

        MenuBar bulkOperationsDropdown = new MenuBar();
        MenuItem bulkOperationsItem = bulkOperationsDropdown
                .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

        Command deleteCommand = selectedItem -> {
            ControllerProvider.getVisitController()
                    .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                        public void run() {
                            grid.deselectAll();
                            grid.reload();
                        }
                    });
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                deleteCommand);

        topLayout.addComponent(bulkOperationsDropdown);
        topLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT);
        topLayout.setExpandRatio(bulkOperationsDropdown, 1);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.VISIT_CREATE)) {
        newButton = new Button(I18nProperties.getCaption(Captions.visitNewVisit));
        newButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        newButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        newButton.addClickListener(e -> {
            ControllerProvider.getVisitController().createVisit(this.getContactRef(), r -> grid.reload());
        });
        topLayout.addComponent(newButton);
        topLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT);
    }

    topLayout.addStyleName(CssStyles.VSPACE_3);
    //      activeStatusButton = contactButton;
    return topLayout;
}

From source file:de.symeda.sormas.ui.dashboard.contacts.ContactsDashboardView.java

License:Open Source License

protected HorizontalLayout createEpiCurveAndMapLayout() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.addStyleName(DashboardCssStyles.CURVE_AND_MAP_LAYOUT);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(false);/*from   ww w  .ja v a  2s. com*/
    layout.setSpacing(false);

    // Epi curve layout
    epiCurveLayout = createEpiCurveLayout();
    layout.addComponent(epiCurveLayout);

    // Map layout
    mapLayout = createMapLayout();
    layout.addComponent(mapLayout);

    return layout;
}