Search in sources :

Example 61 with HorizontalLayout

use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.

the class BirthDateField method initContent.

@Override
protected Component initContent() {
    if (getValue() == null) {
        setValue(new BirthDateDto());
    }
    HorizontalLayout layout = new HorizontalLayout();
    dateOfBirthYear.setId("dateOfBirthYear");
    dateOfBirthYear.setEmptySelectionAllowed(true);
    dateOfBirthYear.setItems(DateHelper.getYearsToNow());
    dateOfBirthYear.setWidth(80, Unit.PIXELS);
    dateOfBirthYear.addStyleName(CssStyles.CAPTION_OVERFLOW);
    binder.forField(dateOfBirthYear).withValidator((e, context) -> {
        try {
            ControllerProvider.getPersonController().validateBirthDate(e, dateOfBirthMonth.getValue(), dateOfBirthDay.getValue());
            return ValidationResult.ok();
        } catch (Validator.InvalidValueException ex) {
            return ValidationResult.error(ex.getMessage());
        }
    }).bind(BirthDateDto.DATE_OF_BIRTH_YYYY);
    dateOfBirthMonth.setId("dateOfBirthMonth");
    dateOfBirthMonth.setEmptySelectionAllowed(true);
    dateOfBirthMonth.setItems(DateHelper.getMonthsInYear());
    dateOfBirthMonth.setPageLength(12);
    setItemCaptionsForMonths(dateOfBirthMonth);
    dateOfBirthMonth.setWidth(120, Unit.PIXELS);
    binder.forField(dateOfBirthMonth).withValidator((e, context) -> {
        try {
            ControllerProvider.getPersonController().validateBirthDate(dateOfBirthYear.getValue(), e, dateOfBirthDay.getValue());
            return ValidationResult.ok();
        } catch (Validator.InvalidValueException ex) {
            return ValidationResult.error(ex.getMessage());
        }
    }).bind(BirthDateDto.DATE_OF_BIRTH_MM);
    dateOfBirthDay.setId("dateOfBirthDay");
    dateOfBirthDay.setEmptySelectionAllowed(true);
    dateOfBirthDay.setWidth(80, Unit.PIXELS);
    binder.forField(dateOfBirthDay).withValidator((e, context) -> {
        try {
            ControllerProvider.getPersonController().validateBirthDate(dateOfBirthYear.getValue(), dateOfBirthMonth.getValue(), e);
            return ValidationResult.ok();
        } catch (Validator.InvalidValueException ex) {
            return ValidationResult.error(ex.getMessage());
        }
    }).bind(BirthDateDto.DATE_OF_BIRTH_DD);
    // Update the list of days according to the selected month and year
    dateOfBirthYear.addValueChangeListener(e -> {
        getValue().setDateOfBirthYYYY(e.getValue());
        updateListOfDays(e.getValue(), dateOfBirthMonth.getValue(), dateOfBirthDay);
        dateOfBirthMonth.markAsDirty();
        dateOfBirthDay.markAsDirty();
    });
    dateOfBirthMonth.addValueChangeListener(e -> {
        getValue().setDateOfBirthMM(e.getValue());
        updateListOfDays(dateOfBirthYear.getValue(), e.getValue(), dateOfBirthDay);
        dateOfBirthYear.markAsDirty();
        dateOfBirthDay.markAsDirty();
    });
    dateOfBirthDay.addValueChangeListener(e -> {
        getValue().setDateOfBirthDD(e.getValue());
        dateOfBirthYear.markAsDirty();
        dateOfBirthMonth.markAsDirty();
    });
    layout.addComponents(dateOfBirthYear, dateOfBirthMonth, dateOfBirthDay);
    layout.setComponentAlignment(dateOfBirthMonth, Alignment.BOTTOM_LEFT);
    layout.setComponentAlignment(dateOfBirthDay, Alignment.BOTTOM_LEFT);
    return layout;
}
Also used : CustomField(com.vaadin.ui.CustomField) Month(java.time.Month) Validator(com.vaadin.v7.data.Validator) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) ComboBox(com.vaadin.ui.ComboBox) DateHelper(de.symeda.sormas.api.utils.DateHelper) ValidationResult(com.vaadin.data.ValidationResult) Binder(com.vaadin.data.Binder) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) List(java.util.List) BirthDateDto(de.symeda.sormas.api.caze.BirthDateDto) CssStyles(de.symeda.sormas.ui.utils.CssStyles) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Component(com.vaadin.ui.Component) BirthDateDto(de.symeda.sormas.api.caze.BirthDateDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 62 with HorizontalLayout

use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.

the class EventParticipantsView method createTopBar.

public HorizontalLayout createTopBar() {
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setSpacing(true);
    topLayout.setWidth("100%");
    VerticalLayout exportLayout = new VerticalLayout();
    {
        exportLayout.setSpacing(true);
        exportLayout.setMargin(true);
        exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
        exportLayout.setWidth(250, Unit.PIXELS);
    }
    // import
    if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_IMPORT)) {
        Button importButton = ButtonHelper.createIconButton(Captions.actionImport, VaadinIcons.UPLOAD, e -> {
            Window popupWindow = VaadinUiUtil.showPopupWindow(new EventParticipantImportLayout(getEventRef()));
            popupWindow.setCaption(I18nProperties.getString(Strings.headingImportEventParticipant));
            popupWindow.addCloseListener(c -> this.grid.reload());
        }, ValoTheme.BUTTON_PRIMARY);
        addHeaderComponent(importButton);
    }
    // export
    PopupButton exportPopupButton = ButtonHelper.createIconPopupButton(Captions.export, VaadinIcons.DOWNLOAD, exportLayout);
    addHeaderComponent(exportPopupButton);
    {
        StreamResource streamResource = GridExportStreamResource.createStreamResourceWithSelectedItems(grid, () -> this.grid.getSelectionModel() instanceof MultiSelectionModelImpl ? this.grid.asMultiSelect().getSelectedItems() : null, ExportEntityName.EVENT_PARTICIPANTS);
        addExportButton(streamResource, exportPopupButton, exportLayout, VaadinIcons.TABLE, Captions.exportBasic, Strings.infoBasicExport);
    }
    {
        StreamResource extendedExportStreamResource = EventParticipantDownloadUtil.createExtendedEventParticipantExportResource(grid.getCriteria(), this::getSelectedRows, null);
        addExportButton(extendedExportStreamResource, exportPopupButton, exportLayout, VaadinIcons.FILE_TEXT, Captions.exportDetailed, Descriptions.descDetailedExportButton);
    }
    {
        Button btnCustomExport = ButtonHelper.createIconButton(Captions.exportCustom, VaadinIcons.FILE_TEXT, e -> {
            Window customExportWindow = VaadinUiUtil.createPopupWindow();
            ExportConfigurationsLayout customExportsLayout = new ExportConfigurationsLayout(ExportType.EVENT_PARTICIPANTS, ImportExportUtils.getEventParticipantExportProperties(EventParticipantDownloadUtil::getPropertyCaption, FacadeProvider.getConfigFacade().getCountryLocale()), customExportWindow::close);
            customExportsLayout.setExportCallback((exportConfig) -> Page.getCurrent().open(EventParticipantDownloadUtil.createExtendedEventParticipantExportResource(grid.getCriteria(), this::getSelectedRows, exportConfig), null, true));
            customExportWindow.setWidth(1024, Unit.PIXELS);
            customExportWindow.setCaption(I18nProperties.getCaption(Captions.exportCustom));
            customExportWindow.setContent(customExportsLayout);
            UI.getCurrent().addWindow(customExportWindow);
            exportPopupButton.setPopupVisible(false);
        }, ValoTheme.BUTTON_PRIMARY);
        btnCustomExport.setDescription(I18nProperties.getString(Strings.infoCustomExport));
        btnCustomExport.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(btnCustomExport);
    }
    filterForm = new EventParticipantsFilterForm();
    filterForm.addValueChangeListener(e -> {
        if (!filterForm.hasFilter()) {
            navigateTo(null);
        }
    });
    filterForm.addResetHandler(e -> {
        ViewModelProviders.of(EventParticipantsView.class).remove(EventParticipantCriteria.class);
        navigateTo(null);
    });
    filterForm.addApplyHandler(e -> navigateTo(criteria));
    topLayout.addComponent(filterForm);
    // Bulk operation dropdown
    if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS_EVENTPARTICIPANT)) {
        topLayout.setWidth(100, Unit.PERCENTAGE);
        List<MenuBarHelper.MenuBarItem> bulkActions = new ArrayList<>();
        bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkEventParticipantsToContacts), VaadinIcons.HAND, mi -> {
            grid.bulkActionHandler(items -> {
                EventDto eventDto = FacadeProvider.getEventFacade().getEventByUuid(getEventRef().getUuid(), false);
                ControllerProvider.getContactController().openLineListingWindow(eventDto, items);
            }, true);
        }));
        if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_DELETE)) {
            bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, mi -> {
                grid.bulkActionHandler(items -> {
                    ControllerProvider.getEventParticipantController().deleteAllSelectedItems(items, () -> navigateTo(criteria));
                }, true);
            }));
        }
        if (isDocGenerationAllowed()) {
            bulkActions.add(new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkActionCreatDocuments), VaadinIcons.FILE_TEXT, mi -> {
                grid.bulkActionHandler(items -> {
                    List<EventParticipantReferenceDto> references = grid.asMultiSelect().getSelectedItems().stream().map(EventParticipantIndexDto::toReference).collect(Collectors.toList());
                    if (references.size() == 0) {
                        new Notification(I18nProperties.getString(Strings.headingNoEventParticipantsSelected), I18nProperties.getString(Strings.messageNoEventParticipantsSelected), Notification.Type.WARNING_MESSAGE, false).show(Page.getCurrent());
                        return;
                    }
                    EventDto eventDto = FacadeProvider.getEventFacade().getEventByUuid(getEventRef().getUuid(), false);
                    ControllerProvider.getDocGenerationController().showBulkEventParticipantQuarantineOrderDocumentDialog(references, eventDto.getDisease());
                });
            }));
        }
        MenuBar bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, bulkActions);
        topLayout.addComponent(bulkOperationsDropdown);
        topLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT);
    }
    topLayout.addStyleName(CssStyles.VSPACE_3);
    return topLayout;
}
Also used : Window(com.vaadin.ui.Window) FeatureType(de.symeda.sormas.api.feature.FeatureType) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) Window(com.vaadin.ui.Window) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Page(com.vaadin.server.Page) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) UserProvider(de.symeda.sormas.ui.UserProvider) ValoTheme(com.vaadin.ui.themes.ValoTheme) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) ExportType(de.symeda.sormas.api.importexport.ExportType) Set(java.util.Set) EventDto(de.symeda.sormas.api.event.EventDto) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) MultiSelectionModelImpl(com.vaadin.ui.components.grid.MultiSelectionModelImpl) CoreEntityType(de.symeda.sormas.api.common.CoreEntityType) Descriptions(de.symeda.sormas.api.i18n.Descriptions) ExportConfigurationsLayout(de.symeda.sormas.ui.customexport.ExportConfigurationsLayout) StreamResource(com.vaadin.server.StreamResource) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) VerticalLayout(com.vaadin.ui.VerticalLayout) EventParticipantCriteria(de.symeda.sormas.api.event.EventParticipantCriteria) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) PopupButton(org.vaadin.hene.popupbutton.PopupButton) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) ArrayList(java.util.ArrayList) EventParticipantImportLayout(de.symeda.sormas.ui.events.eventparticipantimporter.EventParticipantImportLayout) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) EventParticipantIndexDto(de.symeda.sormas.api.event.EventParticipantIndexDto) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) ImportExportUtils(de.symeda.sormas.api.importexport.ImportExportUtils) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EventParticipantDownloadUtil(de.symeda.sormas.ui.utils.EventParticipantDownloadUtil) FeatureTypeProperty(de.symeda.sormas.api.feature.FeatureTypeProperty) Strings(de.symeda.sormas.api.i18n.Strings) DocGenerationHelper.isDocGenerationAllowed(de.symeda.sormas.ui.docgeneration.DocGenerationHelper.isDocGenerationAllowed) Collections(java.util.Collections) ExportConfigurationsLayout(de.symeda.sormas.ui.customexport.ExportConfigurationsLayout) EventParticipantImportLayout(de.symeda.sormas.ui.events.eventparticipantimporter.EventParticipantImportLayout) EventParticipantDownloadUtil(de.symeda.sormas.ui.utils.EventParticipantDownloadUtil) ArrayList(java.util.ArrayList) EventDto(de.symeda.sormas.api.event.EventDto) MenuBar(com.vaadin.ui.MenuBar) Notification(com.vaadin.ui.Notification) HorizontalLayout(com.vaadin.ui.HorizontalLayout) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) PopupButton(org.vaadin.hene.popupbutton.PopupButton) StreamResource(com.vaadin.server.StreamResource) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) MultiSelectionModelImpl(com.vaadin.ui.components.grid.MultiSelectionModelImpl) VerticalLayout(com.vaadin.ui.VerticalLayout) List(java.util.List) ArrayList(java.util.ArrayList) EventParticipantIndexDto(de.symeda.sormas.api.event.EventParticipantIndexDto)

Example 63 with HorizontalLayout

use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.

the class EventParticipantsView method createStatusFilterBar.

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setMargin(false);
    statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);
    Button statusAll = ButtonHelper.createButton(Captions.all, e -> {
    }, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    statusFilterLayout.addComponent(statusAll);
    activeStatusButton = statusAll;
    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    // Show active/archived/all dropdown
    if (Objects.nonNull(UserProvider.getCurrent()) && UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_VIEW)) {
        if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.AUTOMATIC_ARCHIVING, CoreEntityType.EVENT_PARTICIPANT)) {
            int daysAfterEventParticipantGetsArchived = FacadeProvider.getFeatureConfigurationFacade().getProperty(FeatureType.AUTOMATIC_ARCHIVING, CoreEntityType.EVENT_PARTICIPANT, FeatureTypeProperty.THRESHOLD_IN_DAYS, Integer.class);
            if (daysAfterEventParticipantGetsArchived > 0) {
                relevanceStatusInfoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + String.format(I18nProperties.getString(Strings.infoArchivedEventParticipants), daysAfterEventParticipantGetsArchived), ContentMode.HTML);
                relevanceStatusInfoLabel.setVisible(false);
                relevanceStatusInfoLabel.addStyleName(CssStyles.LABEL_VERTICAL_ALIGN_SUPER);
                actionButtonsLayout.addComponent(relevanceStatusInfoLabel);
                actionButtonsLayout.setComponentAlignment(relevanceStatusInfoLabel, Alignment.MIDDLE_RIGHT);
            }
        }
        eventParticipantRelevanceStatusFilter = buildRelevanceStatusFilter(Captions.eventParticipantActiveEventParticipants, Captions.eventParticipantArchivedEventParticipants, Captions.eventParticipantAllEventParticipants);
        eventParticipantRelevanceStatusFilter.addValueChangeListener(e -> {
            if (relevanceStatusInfoLabel != null) {
                relevanceStatusInfoLabel.setVisible(EntityRelevanceStatus.ARCHIVED.equals(e.getProperty().getValue()));
            }
            criteria.relevanceStatus((EntityRelevanceStatus) e.getProperty().getValue());
            navigateTo(criteria);
        });
        actionButtonsLayout.addComponent(eventParticipantRelevanceStatusFilter);
    }
    if (UserProvider.getCurrent().hasUserRight(UserRight.EVENTPARTICIPANT_CREATE)) {
        addButton = ButtonHelper.createIconButton(Captions.eventParticipantAddPerson, VaadinIcons.PLUS_CIRCLE, e -> {
            ControllerProvider.getEventParticipantController().createEventParticipant(this.getEventRef(), r -> navigateTo(criteria));
        }, ValoTheme.BUTTON_PRIMARY);
        actionButtonsLayout.addComponent(addButton);
    }
    statusFilterLayout.addComponent(actionButtonsLayout);
    statusFilterLayout.setComponentAlignment(actionButtonsLayout, Alignment.MIDDLE_RIGHT);
    statusFilterLayout.setExpandRatio(actionButtonsLayout, 1);
    return statusFilterLayout;
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) Window(com.vaadin.ui.Window) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ExportEntityName(de.symeda.sormas.ui.utils.ExportEntityName) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Page(com.vaadin.server.Page) VaadinIcons(com.vaadin.icons.VaadinIcons) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) UserProvider(de.symeda.sormas.ui.UserProvider) ValoTheme(com.vaadin.ui.themes.ValoTheme) MenuBar(com.vaadin.ui.MenuBar) ComboBox(com.vaadin.v7.ui.ComboBox) ExportType(de.symeda.sormas.api.importexport.ExportType) Set(java.util.Set) EventDto(de.symeda.sormas.api.event.EventDto) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) MultiSelectionModelImpl(com.vaadin.ui.components.grid.MultiSelectionModelImpl) CoreEntityType(de.symeda.sormas.api.common.CoreEntityType) Descriptions(de.symeda.sormas.api.i18n.Descriptions) ExportConfigurationsLayout(de.symeda.sormas.ui.customexport.ExportConfigurationsLayout) StreamResource(com.vaadin.server.StreamResource) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) VerticalLayout(com.vaadin.ui.VerticalLayout) EventParticipantCriteria(de.symeda.sormas.api.event.EventParticipantCriteria) GridExportStreamResource(de.symeda.sormas.ui.utils.GridExportStreamResource) PopupButton(org.vaadin.hene.popupbutton.PopupButton) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) ArrayList(java.util.ArrayList) EventParticipantImportLayout(de.symeda.sormas.ui.events.eventparticipantimporter.EventParticipantImportLayout) Notification(com.vaadin.ui.Notification) Label(com.vaadin.ui.Label) EventParticipantIndexDto(de.symeda.sormas.api.event.EventParticipantIndexDto) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) ImportExportUtils(de.symeda.sormas.api.importexport.ImportExportUtils) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EventParticipantDownloadUtil(de.symeda.sormas.ui.utils.EventParticipantDownloadUtil) FeatureTypeProperty(de.symeda.sormas.api.feature.FeatureTypeProperty) Strings(de.symeda.sormas.api.i18n.Strings) DocGenerationHelper.isDocGenerationAllowed(de.symeda.sormas.ui.docgeneration.DocGenerationHelper.isDocGenerationAllowed) Collections(java.util.Collections) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) Label(com.vaadin.ui.Label) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 64 with HorizontalLayout

use of com.vaadin.v7.ui.HorizontalLayout in project SORMAS-Project by hzi-braunschweig.

the class AbstractImportLayout method addImportCsvComponentWithOverwrite.

protected void addImportCsvComponentWithOverwrite(int step, Function<Boolean, ImportReceiver> receiverGenerator) {
    String headline = I18nProperties.getString(Strings.headingImportCsvFile);
    String infoText = I18nProperties.getString(Strings.infoImportCsvFile);
    ImportLayoutComponent importCsvComponent = new ImportLayoutComponent(step, headline, infoText, null, null);
    addComponent(importCsvComponent);
    generatedReceiver = receiverGenerator.apply(false);
    upload = new Upload("", generatedReceiver);
    upload.setButtonCaption(I18nProperties.getCaption(Captions.importImportData));
    CssStyles.style(upload, CssStyles.VSPACE_2);
    upload.addStartedListener(generatedReceiver);
    upload.addSucceededListener(generatedReceiver);
    HorizontalLayout checkboxBar = new HorizontalLayout();
    checkboxBar.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    checkboxBar.setDescription(I18nProperties.getString(Strings.infoImportInfrastructureAllowOverwrite));
    CssStyles.style(checkboxBar, CssStyles.VSPACE_TOP_3);
    CheckBox allowOverwrite = new CheckBox(I18nProperties.getCaption(Captions.infrastructureImportAllowOverwrite));
    allowOverwrite.setValue(false);
    checkboxBar.addComponent(allowOverwrite);
    Label labelInfo = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
    checkboxBar.addComponent(labelInfo);
    CssStyles.style(checkboxBar, CssStyles.VSPACE_3);
    addComponent(checkboxBar);
    addComponent(separator);
    addComponent(upload);
    allowOverwrite.addValueChangeListener(e -> {
        upload.removeSucceededListener(generatedReceiver);
        generatedReceiver = receiverGenerator.apply(e.getValue());
        upload.setReceiver(generatedReceiver);
        upload.addStartedListener(generatedReceiver);
        upload.addSucceededListener(generatedReceiver);
    });
}
Also used : CheckBox(com.vaadin.ui.CheckBox) Label(com.vaadin.ui.Label) Upload(com.vaadin.v7.ui.Upload) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 65 with HorizontalLayout

use of com.vaadin.v7.ui.HorizontalLayout in project opencms-core by alkacon.

the class CmsFileExplorer method initUI.

/**
 * @see org.opencms.ui.apps.I_CmsWorkplaceApp#initUI(org.opencms.ui.apps.I_CmsAppUIContext)
 */
public void initUI(I_CmsAppUIContext context) {
    m_appContext = context;
    m_appContext.setAttribute(ATTR_KEY, this);
    m_appContext.setMenuDialogContext(new CmsExplorerDialogContext(ContextType.appToolbar, m_fileTable, this, null));
    HorizontalSplitPanel sp = new HorizontalSplitPanel();
    sp.setSizeFull();
    sp.setFirstComponent(m_fileTree);
    CmsFileExplorerSettings settings;
    try {
        settings = OpenCms.getWorkplaceAppManager().getAppSettings(A_CmsUI.getCmsObject(), CmsFileExplorerSettings.class);
        m_fileTable.setTableState(settings);
    } catch (Exception e) {
        LOG.error("Error while reading file explorer settings from user.", e);
    }
    sp.setSecondComponent(m_fileTable);
    sp.setSplitPosition(LAYOUT_SPLIT_POSITION, Unit.PIXELS);
    context.setAppContent(sp);
    context.showInfoArea(true);
    HorizontalLayout inf = new HorizontalLayout();
    inf.setSizeFull();
    inf.setSpacing(true);
    inf.setMargin(true);
    m_siteSelector.setWidth("379px");
    inf.addComponent(m_siteSelector);
    CssLayout crumbWrapper = new CssLayout();
    crumbWrapper.setSizeFull();
    crumbWrapper.setPrimaryStyleName(OpenCmsTheme.CRUMB_WRAPPER);
    crumbWrapper.addComponent(m_crumbs);
    m_infoPath.setWidth("100%");
    crumbWrapper.addComponent(m_infoPath);
    inf.addComponent(crumbWrapper);
    inf.setExpandRatio(crumbWrapper, 1);
    m_searchField.setWidth("200px");
    inf.addComponent(m_searchField);
    context.setAppInfo(inf);
    initToolbarButtons(context);
    m_fileTable.updateColumnWidths(A_CmsUI.get().getPage().getBrowserWindowWidth() - LAYOUT_SPLIT_POSITION);
}
Also used : CssLayout(com.vaadin.ui.CssLayout) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) CmsException(org.opencms.main.CmsException) CmsVfsResourceNotFoundException(org.opencms.file.CmsVfsResourceNotFoundException) HorizontalLayout(com.vaadin.v7.ui.HorizontalLayout)

Aggregations

HorizontalLayout (com.vaadin.ui.HorizontalLayout)53 Button (com.vaadin.ui.Button)37 Label (com.vaadin.ui.Label)32 VerticalLayout (com.vaadin.ui.VerticalLayout)32 ComboBox (com.vaadin.v7.ui.ComboBox)29 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)29 CssStyles (de.symeda.sormas.ui.utils.CssStyles)29 Alignment (com.vaadin.ui.Alignment)28 ValoTheme (com.vaadin.ui.themes.ValoTheme)28 Captions (de.symeda.sormas.api.i18n.Captions)28 ButtonHelper (de.symeda.sormas.ui.utils.ButtonHelper)27 FacadeProvider (de.symeda.sormas.api.FacadeProvider)26 Strings (de.symeda.sormas.api.i18n.Strings)26 VaadinIcons (com.vaadin.icons.VaadinIcons)25 UserProvider (de.symeda.sormas.ui.UserProvider)25 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)24 ComboBoxHelper (de.symeda.sormas.ui.utils.ComboBoxHelper)23 MenuBar (com.vaadin.ui.MenuBar)22 UserRight (de.symeda.sormas.api.user.UserRight)22 ViewModelProviders (de.symeda.sormas.ui.ViewModelProviders)22