Search in sources :

Example 1 with Upload

use of com.vaadin.flow.component.upload.Upload in project karnak by OsiriX-Foundation.

the class ProfileView method initUploadProfile.

private void initUploadProfile() {
    memoryBuffer = new MemoryBuffer();
    // https://github.com/vaadin/vaadin-upload-flow/blob/6fa9cc429e1d0894704fb962e0df375a9d0439c8/vaadin-upload-flow-integration-tests/src/main/java/com/vaadin/flow/component/upload/tests/it/UploadView.java#L122
    uploadProfile = new Upload(memoryBuffer);
    uploadProfile.setDropLabel(new Span("Drag and drop your profile here"));
}
Also used : MemoryBuffer(com.vaadin.flow.component.upload.receivers.MemoryBuffer) Upload(com.vaadin.flow.component.upload.Upload) Span(com.vaadin.flow.component.html.Span)

Example 2 with Upload

use of com.vaadin.flow.component.upload.Upload in project karnak by OsiriX-Foundation.

the class ExternalIDView method setUploadCSVElement.

public void setUploadCSVElement() {
    uploadCsvLabelDiv = new Div();
    uploadCsvLabelDiv.setText("Upload the CSV file containing the external ID associated with patient(s): ");
    uploadCsvLabelDiv.getStyle().set("font-size", "large").set("font-weight", "bolder");
    MemoryBuffer memoryBuffer = new MemoryBuffer();
    uploadCsvButton = new Upload(memoryBuffer);
    uploadCsvButton.setDropLabel(new Span("Drag and drop your CSV file here"));
    uploadCsvButton.addSucceededListener(event -> {
        inputStream = memoryBuffer.getInputStream();
        Dialog chooseSeparatorDialog = new Dialog();
        TextField separatorCSVField = new TextField("Choose the separator for reading the CSV file");
        separatorCSVField.setWidthFull();
        separatorCSVField.setMaxLength(1);
        separatorCSVField.setValue(",");
        Button openCSVButton = new Button("Open CSV");
        openCSVButton.addClickListener(buttonClickEvent -> {
            chooseSeparatorDialog.close();
            char separator = ',';
            if (!separatorCSVField.getValue().equals("")) {
                separator = separatorCSVField.getValue().charAt(0);
            }
            CSVDialog csvDialog = new CSVDialog(inputStream, separator, projectDropDown.getValue());
            csvDialog.setWidth("80%");
            csvDialog.open();
            csvDialog.getReadCSVButton().addClickListener(buttonClickEvent1 -> {
                externalIDGrid.addPatientList(csvDialog.getPatientsList());
                checkDuplicatePatient();
                csvDialog.resetPatientsList();
            });
        });
        chooseSeparatorDialog.add(separatorCSVField, openCSVButton);
        chooseSeparatorDialog.open();
        separatorCSVField.focus();
    });
}
Also used : Div(com.vaadin.flow.component.html.Div) MemoryBuffer(com.vaadin.flow.component.upload.receivers.MemoryBuffer) Button(com.vaadin.flow.component.button.Button) Dialog(com.vaadin.flow.component.dialog.Dialog) Upload(com.vaadin.flow.component.upload.Upload) TextField(com.vaadin.flow.component.textfield.TextField) Span(com.vaadin.flow.component.html.Span)

Example 3 with Upload

use of com.vaadin.flow.component.upload.Upload in project projecte-dam-v2-equip2 by IESEBRE.

the class UploadView method initUploaderImage.

private void initUploaderImage() {
    MemoryBuffer buffer = new MemoryBuffer();
    upload = new Upload(buffer);
    upload.setAcceptedFileTypes("image/jpeg", "image/jpg", "image/png", "image/gif");
    upload.addSucceededListener(event -> {
        try {
            // The image can be jpg png or gif, but we store it always as png file in this example
            BufferedImage inputImage = ImageIO.read(buffer.getInputStream());
            ByteArrayOutputStream pngContent = new ByteArrayOutputStream();
            ImageIO.write(inputImage, "png", pngContent);
            saveProfilePicture(pngContent.toByteArray());
            showImage();
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    add(getContent(), imageContainer, upload);
}
Also used : MemoryBuffer(com.vaadin.flow.component.upload.receivers.MemoryBuffer) Upload(com.vaadin.flow.component.upload.Upload) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) BufferedImage(java.awt.image.BufferedImage)

Example 4 with Upload

use of com.vaadin.flow.component.upload.Upload in project flow-components by vaadin.

the class FileBufferView method createMultiFileUpload.

private static Div createMultiFileUpload() {
    final MultiFileBuffer buffer = new MultiFileBuffer();
    final Upload multiFileUpload = new Upload(buffer);
    multiFileUpload.setId("multi-upload");
    return setupUploadSection(multiFileUpload, e -> buffer.getInputStream(e.getFileName()));
}
Also used : Upload(com.vaadin.flow.component.upload.Upload) MultiFileBuffer(com.vaadin.flow.component.upload.receivers.MultiFileBuffer)

Example 5 with Upload

use of com.vaadin.flow.component.upload.Upload in project flow-components by vaadin.

the class UploadI18nView method createFullUploadI18N.

private void createFullUploadI18N() {
    MemoryBuffer buffer = new MemoryBuffer();
    Upload upload = new Upload(buffer);
    upload.setId("upload-full-i18n");
    upload.setI18n(UploadTestsI18N.RUSSIAN_FULL);
    add(new H1("Full I18N"), upload, new Hr());
}
Also used : MemoryBuffer(com.vaadin.flow.component.upload.receivers.MemoryBuffer) Upload(com.vaadin.flow.component.upload.Upload) H1(com.vaadin.flow.component.html.H1) Hr(com.vaadin.flow.component.html.Hr)

Aggregations

Upload (com.vaadin.flow.component.upload.Upload)11 MemoryBuffer (com.vaadin.flow.component.upload.receivers.MemoryBuffer)5 Div (com.vaadin.flow.component.html.Div)4 MultiFileMemoryBuffer (com.vaadin.flow.component.upload.receivers.MultiFileMemoryBuffer)4 H1 (com.vaadin.flow.component.html.H1)2 Hr (com.vaadin.flow.component.html.Hr)2 Label (com.vaadin.flow.component.html.Label)2 Span (com.vaadin.flow.component.html.Span)2 MultiFileBuffer (com.vaadin.flow.component.upload.receivers.MultiFileBuffer)2 IOException (java.io.IOException)2 Button (com.vaadin.flow.component.button.Button)1 Dialog (com.vaadin.flow.component.dialog.Dialog)1 NativeButton (com.vaadin.flow.component.html.NativeButton)1 TextField (com.vaadin.flow.component.textfield.TextField)1 FileBuffer (com.vaadin.flow.component.upload.receivers.FileBuffer)1 BufferedImage (java.awt.image.BufferedImage)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1