Package com.vaadin.ui

Examples of com.vaadin.ui.Upload$ChangeEvent


    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    @Override
    protected void setup() {
        Upload u = new Upload("Upload", new Upload.Receiver() {

            @Override
            public OutputStream receiveUpload(String filename, String mimeType) {
                return baos;
            }
        });
        u.setId("UPL");
        u.addFailedListener(new FailedListener() {

            @Override
            public void uploadFailed(FailedEvent event) {
                String hash = DigestUtils.md5Hex(baos.toByteArray());

                log.log("<span style=\"color: red;\">Upload failed. Name: "
                        + event.getFilename() + ", Size: " + baos.size()
                        + ", md5: " + hash + "</span>");
                baos.reset();
            }
        });
        u.addSucceededListener(new SucceededListener() {

            @Override
            public void uploadSucceeded(SucceededEvent event) {
                String hash = DigestUtils.md5Hex(baos.toByteArray());
                log.log("Upload finished. Name: " + event.getFilename()
View Full Code Here


public class DisabledUploadButton extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        final Upload upload = new Upload();

        addComponent(upload);

        addButton("Set readonly", new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                upload.setReadOnly(true);
            }
        });

        addButton("Set disabled", new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                upload.setEnabled(false);
            }
        });
    }
View Full Code Here

    @Override
    protected void setup() {
        getLayout().setMargin(new MarginInfo(true, false, false, false));
        getLayout().setSpacing(true);

        Upload u = new Upload("Upload", new Upload.Receiver() {

            @Override
            public OutputStream receiveUpload(String filename, String mimeType) {
                return baos;
            }
        });
        u.setId("UPL");
        u.addStartedListener(new Upload.StartedListener() {

            @Override
            public void uploadStarted(StartedEvent event) {
                expectedSize.setValue(String.valueOf(event.getContentLength()));
            }
        });
        u.addFinishedListener(new Upload.FinishedListener() {

            @Override
            public void uploadFinished(FinishedEvent event) {
                label.setValue("Upload finished. Name: " + event.getFilename());
                receivedSize.setValue(String.valueOf(baos.size()));
View Full Code Here

*/
public class UploadTitleWithTooltip extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        Upload upload = new Upload();
        upload.setDescription("tootlip");

        addComponent(upload);
    }
View Full Code Here

        final Label labe = new Label();

        addComponent(labe);

        final Upload u;
        u = new Upload(null, this);
        u.setImmediate(true);
        addTestComponent(u);

        l = new Label(getUploadcount());
        addComponent(l);

        u.addListener(new Upload.StartedListener() {

            @Override
            public void uploadStarted(StartedEvent event) {
                /*
                 * Remove component before upload from the same vertical layout.
                 * Causes upload to be detached/attached -> upload loses it
                 * target iframes onload listener -> puts VUpload inappropriate
                 * state.
                 */
                getLayout().removeComponent(labe);
            }
        });

        u.addListener(new Upload.FinishedListener() {
            @Override
            public void uploadFinished(FinishedEvent event) {
                getMainWindow().showNotification("Done");
                l.setValue(getUploadcount());
            }
View Full Code Here

        addComponent(layout);
    }

    private Upload getImmediateUpload(String id, String width) {
        Upload upload = new Upload();

        upload.setId(id);
        upload.setWidth(width);
        upload.setImmediate(true);

        return upload;
    }
View Full Code Here

        uploadsLayout.removeComponent(source);

    }

    protected void addUpload() {
        Upload upload = createUpload();
        upload.addSucceededListener(new SucceededListener() {

            @Override
            public void uploadSucceeded(SucceededEvent event) {
                log("Upload of " + event.getFilename() + " complete");
                uploadsLayout.removeComponent(event.getUpload());
            }
        });

        upload.addFailedListener(new FailedListener() {
            @Override
            public void uploadFailed(FailedEvent event) {
                log("Upload of " + event.getFilename() + " FAILED");
            }
        });

        upload.setReceiver(new Receiver() {
            @Override
            public OutputStream receiveUpload(String filename, String mimeType) {
                return new OutputStream() {
                    @Override
                    public void write(int arg0) throws IOException {

                    }
                };
            }
        });
        upload.setStyleName("hidden-button");
        uploadsLayout.addComponent(upload);

    }
View Full Code Here

        uploadsLayout.addComponent(upload);

    }

    private Upload createUpload() {
        Upload upload = new Upload();
        upload.addChangeListener(changeListener);
        return upload;
    }
View Full Code Here

        portletEdit.setEnabled(false);
        main.addComponent(portletEdit);
        portletMax.setEnabled(false);
        main.addComponent(portletMax);

        Upload upload = new Upload("Upload a file", new Receiver() {

            @Override
            public OutputStream receiveUpload(String filename, String mimeType) {
                return new ByteArrayOutputStream();
            }
View Full Code Here

        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        layout.setSpacing(true);
        setContent(layout);

        upload = new Upload(null, buffer);
        upload.setId("upload");
        layout.addComponent(upload);

        Button button = new Button("show notification");
        button.setId("notify");
View Full Code Here

TOP

Related Classes of com.vaadin.ui.Upload$ChangeEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.