Example usage for com.vaadin.ui HorizontalLayout setComponentAlignment

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

Introduction

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

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

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

public TimelineEventLayout() {
    headline = new TextField();
    headline.setInputPrompt("Your event headline...");
    headline.setColumns(31);/*ww w .  ja  va  2s.  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.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);/*w  ww .  j a v  a  2s .co 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  w w . j a  v a  2s . 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.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 www .  j av a2s.  co 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.mendelson.comm.as2.webclient2.AS2WebUI.java

private HorizontalLayout createButtonBar() {
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSizeFull();/*from   w  w w  . j  av a2  s. co  m*/
    Button buttonRefresh = new Button("Refresh");
    buttonRefresh.setIcon(new ThemeResource("images/refresh16x16.gif"));
    buttonRefresh.setEnabled(true);
    buttonRefresh.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            AS2WebUI.this.refreshOverviewTableData();
        }
    });
    buttonLayout.addComponent(buttonRefresh);
    this.buttonDetails = new Button("Message details");
    this.buttonDetails.setIcon(new ThemeResource("images/messagedetails16x16.gif"));
    this.buttonDetails.setEnabled(false);
    this.buttonDetails.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            AS2WebUI.this.displayMessageDetailsOfSelectedRow();
        }
    });
    buttonLayout.addComponent(this.buttonDetails);
    this.labelUsername.setWidth(null);
    buttonLayout.addComponent(this.labelUsername);
    buttonLayout.setComponentAlignment(this.labelUsername, Alignment.MIDDLE_RIGHT);
    buttonLayout.setExpandRatio(buttonRefresh, 0.0f);
    buttonLayout.setExpandRatio(this.buttonDetails, 0.0f);
    buttonLayout.setExpandRatio(this.labelUsername, 1.0f);
    return (buttonLayout);
}

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);// w  w  w  . j  a v  a 2s  .  co  m
    contentLayout.setSizeFull();
    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.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);//  w w  w  . jav  a2 s.co  m

    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.CaseContactsView.java

License:Open Source License

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setWidth("100%");
    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  a 2s  .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());
    }
    statusFilterLayout
            .setExpandRatio(statusFilterLayout.getComponent(statusFilterLayout.getComponentCount() - 1), 1);

    // 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(), getCaseRef().getUuid());
        };
        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.deselectAll();
                            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.deselectAll();
                            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.deselectAll();
                            grid.reload();
                        }
                    });
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                deleteCommand);

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

    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EXPORT)) {
        Button exportButton = new Button(I18nProperties.getCaption(Captions.export));
        exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        exportButton.setIcon(VaadinIcons.DOWNLOAD);

        StreamResource streamResource = new GridExportStreamResource(grid, "sormas_contacts",
                "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(exportButton);

        statusFilterLayout.addComponent(exportButton);
        statusFilterLayout.setComponentAlignment(exportButton, Alignment.MIDDLE_RIGHT);
        if (!UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            statusFilterLayout.setExpandRatio(exportButton, 1);
        }
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CREATE)) {
        newButton = new Button(
                I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, Captions.contactNewContact));
        newButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        newButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        newButton.addClickListener(e -> ControllerProvider.getContactController().create(this.getCaseRef()));
        statusFilterLayout.addComponent(newButton);
        statusFilterLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT);
    }

    statusFilterLayout.addStyleName("top-bar");
    activeStatusButton = statusAll;
    return statusFilterLayout;
}

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 w  w .jav a  2s.co  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.caze.CasesView.java

License:Open Source License

private void addShowMoreOrLessFiltersButtons(HorizontalLayout parentLayout) {
    expandFiltersButton = new Button(I18nProperties.getCaption(Captions.actionShowMoreFilters),
            VaadinIcons.CHEVRON_DOWN);//from  www  . ja v a 2s . c  om
    CssStyles.style(expandFiltersButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.VSPACE_TOP_NONE,
            CssStyles.LABEL_PRIMARY);
    collapseFiltersButton = new Button(I18nProperties.getCaption(Captions.actionShowLessFilters),
            VaadinIcons.CHEVRON_UP);
    CssStyles.style(collapseFiltersButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.VSPACE_TOP_NONE,
            CssStyles.LABEL_PRIMARY);

    expandFiltersButton.addClickListener(e -> {
        setFiltersExpanded(true);
    });

    collapseFiltersButton.addClickListener(e -> {
        setFiltersExpanded(false);
    });

    parentLayout.addComponent(expandFiltersButton);
    parentLayout.addComponent(collapseFiltersButton);
    parentLayout.setComponentAlignment(expandFiltersButton, Alignment.TOP_LEFT);
    parentLayout.setComponentAlignment(collapseFiltersButton, Alignment.TOP_LEFT);
    collapseFiltersButton.setVisible(false);
}