Example usage for com.vaadin.ui HorizontalLayout setMargin

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

Introduction

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

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

From source file:de.fzi.fhemapi.view.vaadin.ui.DeviceDetailsPanel.java

License:Apache License

@AutoGenerated
private VerticalLayout buildMainLayout() {
    // common part: create layout
    VerticalLayout layout = new VerticalLayout();
    layout.setImmediate(false);/*from   w  w w .j  a  v  a2  s.  c o  m*/
    layout.setWidth("100.0%");
    layout.setHeight("-1");
    layout.setMargin(false);

    HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setImmediate(false);
    titleLayout.setWidth("-1");
    titleLayout.setHeight("50");
    titleLayout.setMargin(false);
    layout.addComponent(titleLayout);
    layout.setComponentAlignment(titleLayout, Alignment.TOP_CENTER);

    // deviceTitle
    deviceTitle = new TextField();
    deviceTitle.setImmediate(true);
    deviceTitle.setWidth("100%");
    deviceTitle.setHeight("-1px");
    deviceTitle.setValue(device.getName());
    deviceTitle.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (((String) event.getProperty().getValue()).length() > 1) {
                device.rename((String) event.getProperty().getValue());
                parent.reloadTree();
            }
        }
    });
    titleLayout.addComponent(deviceTitle);
    titleLayout.setComponentAlignment(deviceTitle, Alignment.TOP_CENTER);

    ComboBox combobox = new ComboBox();
    String[] classes = DeviceFactory.getAvailableDevicetypes();
    for (String name : classes) {
        combobox.addItem(name);
    }
    combobox.select(device.getClass().getSimpleName());
    combobox.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            setDeviceType((String) event.getProperty().getValue());
        }
    });
    combobox.setImmediate(true);

    deviceTypeHoriLayout = UIHelper.buildAttributePanel("Device Type", combobox);
    layout.addComponent(deviceTypeHoriLayout);
    layout.setComponentAlignment(deviceTypeHoriLayout, Alignment.TOP_CENTER);
    layout.setExpandRatio(deviceTypeHoriLayout, 1);

    ioDevHoriLayout = buildAttributePanel("IO Device", device.getType());
    layout.addComponent(ioDevHoriLayout);
    layout.setComponentAlignment(ioDevHoriLayout, Alignment.TOP_CENTER);
    layout.setExpandRatio(ioDevHoriLayout, 1);

    addDeviceDetails(DevicePanelManager.getDeviceDetails(device, this), layout);

    return layout;
}

From source file:de.fzi.fhemapi.view.vaadin.ui.NewDevicePanel.java

License:Apache License

private static HorizontalLayout getTitlePanel() {
    HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setImmediate(false);//from w  ww .  j  a  v a2 s  .c o m
    titleLayout.setWidth("-1");
    titleLayout.setHeight("-1");
    titleLayout.setMargin(false);

    // deviceTitle
    Label title = new Label();
    title.setImmediate(true);
    title.setWidth("100%");
    title.setHeight("50");
    title.setValue("<h1>Neues Gert..</h1>");
    title.setContentMode(Label.CONTENT_XHTML);

    titleLayout.addComponent(title);
    titleLayout.setComponentAlignment(title, Alignment.TOP_CENTER);
    return titleLayout;
}

From source file:de.fzi.fhemapi.view.vaadin.ui.UIHelper.java

License:Apache License

/**
 * Builds an attribute panel. This build a caption on the left side. This should be altered if
 * one would like to change the appearance of the whole UI.
 * @param attributeName the caption of the component
 * @param component a component/*ww  w .j av  a2s. c o  m*/
 * @return a horizontallayout.
 */
public static HorizontalLayout buildAttributePanel(String attributeName, AbstractComponent component) {
    // common part: create layout
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setImmediate(false);
    horizontalLayout.setWidth("100.0%");
    horizontalLayout.setHeight("-1px");
    horizontalLayout.setMargin(false);

    horizontalLayout.addComponent(buildRichTextField("<b>" + attributeName + "</b>"));
    horizontalLayout.addComponent(component);
    component.setCaption(attributeName);
    //      component.set

    return horizontalLayout;
}

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//from   w ww.  j a va2 s .c om
        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.mendelson.comm.as2.webclient2.OkDialog.java

public void init() {
    this.setModal(true);
    VerticalLayout okDialogLayout = new VerticalLayout();
    HorizontalLayout contentLayout = new HorizontalLayout();
    AbstractComponent contentPanel = this.getContentPanel();
    contentLayout.addComponent(contentPanel);
    contentLayout.setMargin(true);
    contentLayout.setSizeFull();/*from  w  w  w  . j ava2  s.  c om*/
    okDialogLayout.addComponent(contentLayout);
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSizeFull();
    buttonLayout.setMargin(false, true, false, false);
    buttonLayout.addComponent(this.okButton);
    buttonLayout.setComponentAlignment(this.okButton, Alignment.MIDDLE_RIGHT);
    this.okButton.addListener(this);
    okDialogLayout.addComponent(buttonLayout);
    okDialogLayout.setExpandRatio(contentLayout, 1.0f);
    okDialogLayout.setExpandRatio(buttonLayout, 0.0f);
    this.setContent(okDialogLayout);
    this.setHeight(this.height + "px");
    this.setWidth(this.width + "px");
}

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

License:Open Source License

private void updateCaseInfo() {
    this.removeAllComponents();

    PersonDto personDto = FacadeProvider.getPersonFacade().getPersonByUuid(caseDto.getPerson().getUuid());

    VerticalLayout leftColumnLayout = new VerticalLayout();
    leftColumnLayout.setMargin(false);/*from   ww w .ja v a 2s. c  o m*/
    leftColumnLayout.setSpacing(true);
    {
        addDescLabel(leftColumnLayout, DataHelper.getShortUuid(caseDto.getUuid()),
                I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.UUID))
                        .setDescription(caseDto.getUuid());

        addDescLabel(leftColumnLayout, caseDto.getEpidNumber(),
                I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.EPID_NUMBER))
                        .setDescription(caseDto.getEpidNumber());

        if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
            addDescLabel(leftColumnLayout, caseDto.getPerson(),
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.PERSON));

            HorizontalLayout ageSexLayout = new HorizontalLayout();
            ageSexLayout.setMargin(false);
            ageSexLayout.setSpacing(true);
            addDescLabel(ageSexLayout,
                    ApproximateAgeHelper.formatApproximateAge(personDto.getApproximateAge(),
                            personDto.getApproximateAgeType()),
                    I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.APPROXIMATE_AGE));
            addDescLabel(ageSexLayout, personDto.getSex(),
                    I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.SEX));
            leftColumnLayout.addComponent(ageSexLayout);
        }

        if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_MANAGEMENT_ACCESS)) {
            addDescLabel(leftColumnLayout, caseDto.getClinicianName(),
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CLINICIAN_NAME));
        }
    }
    this.addComponent(leftColumnLayout);

    VerticalLayout rightColumnLayout = new VerticalLayout();
    rightColumnLayout.setMargin(false);
    rightColumnLayout.setSpacing(true);
    {
        addDescLabel(rightColumnLayout,
                caseDto.getDisease() != Disease.OTHER ? caseDto.getDisease().toShortString()
                        : DataHelper.toStringNullable(caseDto.getDiseaseDetails()),
                I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE));

        if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
            addDescLabel(rightColumnLayout, caseDto.getCaseClassification(),
                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CASE_CLASSIFICATION));
            addDescLabel(rightColumnLayout,
                    DateHelper.formatLocalShortDate(caseDto.getSymptoms().getOnsetDate()),
                    I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE));
        }
    }
    this.addComponent(rightColumnLayout);
}

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   w ww .  ja v  a  2 s. 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 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);/*from   w w  w .ja  v a  2  s. c o m*/
    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  w w. j  a  v  a2  s .co m*/
        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.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);
    layout.setSpacing(false);/*from w w w .  j  av a 2s  . c  om*/

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

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

    return layout;
}