Examples of Upload


Examples of com.vaadin.ui.Upload

    public TestForStyledUpload() {
        main.addComponent(new Label(
                "Clicking on button b updates information about upload components status or same with garbage collector."));

        up = new Upload(null, buffer);
        up.setButtonCaption("Select file");
        up.setImmediate(true);
        up.addListener((FinishedListener) this);
        up.addListener((FailedListener) this);
        up.addListener((SucceededListener) this);
View Full Code Here

Examples of com.vaadin.ui.Upload

        textField = new TextField("Test field");
        textFieldValue = new Label();
        main.addComponent(textField);
        main.addComponent(textFieldValue);

        up = new Upload("Upload", buffer);
        up.setImmediate(true);
        up.addListener(new Listener() {
            private static final long serialVersionUID = -8319074730512324303L;

            @Override
View Full Code Here

Examples of com.vaadin.ui.Upload

            @Override
            public VaadinSession getSession() {
                return application;
            }
        };
        owner = new Upload() {
            @Override
            public UI getUI() {
                return uI;
            }
        };
View Full Code Here

Examples of com.vaadin.ui.Upload

        final TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect "
                + count++);
        test(layout, twinColSelect);

        final Upload upload = new Upload("Upload (non-functional)", null);
        test(layout, upload);

        // Custom components
        layout.addComponent(new Label("<B>Below are few custom components</B>",
                ContentMode.HTML));
View Full Code Here

Examples of com.vaadin.ui.Upload

    protected void setup() {

        final TextField textField = new TextField("Test field");
        addComponent(textField);

        final Upload u;

        u = new Upload("Upload", this);

        u.setButtonCaption(null);

        addComponent(u);

        u.addListener(new Upload.FinishedListener() {
            @Override
            public void uploadFinished(FinishedEvent event) {
                String filename = event.getFilename();
                long length = event.getLength();
                getMainWindow().showNotification(
                        "Done. Filename : " + filename + " Lenght: " + length);
            }
        });

        u.addListener(new Upload.FailedListener() {
            @Override
            public void uploadFailed(FailedEvent event) {
                getMainWindow().showNotification("Failed. No file selected?");
            }
        });

        u.addListener(new Upload.StartedListener() {
            @Override
            public void uploadStarted(StartedEvent event) {
                getMainWindow().showNotification(
                        "Started upload. TF value :" + textField.getValue());
            }
        });

        Button button = new Button(
                "I'm an external button (not the uploads builtin), hit me to start upload.");
        button.addListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                u.submitUpload();
            }
        });

        addComponent(button);
View Full Code Here

Examples of com.vaadin.ui.Upload

        return "Uploading an empty selection (no file) will trigger FinishedEvent with 0-length file size and empty filename.";
    }

    @Override
    protected void setup(VaadinRequest request) {
        Upload u = new Upload("Upload", this);
        u.setId(UPLOAD_ID);
        u.setSizeUndefined();

        addComponent(u);

        u.addFinishedListener(new Upload.FinishedListener() {
            @Override
            public void uploadFinished(FinishedEvent event) {
                log(UPLOAD_FINISHED);
                log(FILE_LENGTH_PREFIX + " " + event.getLength());
                log(FILE_NAME_PREFIX + " " + event.getFilename());
            }
        });
        u.addFailedListener(new Upload.FailedListener() {

            @Override
            public void uploadFailed(FailedEvent event) {
                log("Upload Failed");
                log(FILE_LENGTH_PREFIX + " " + event.getLength());
View Full Code Here

Examples of com.vaadin.ui.Upload

    private UploadReceiver receiver = new UploadReceiver();

    @Override
    protected void setup() {

        Upload upload = new Upload("Upload a file", receiver);

        addComponent(upload);
        addComponent(result);

        upload.addListener(new Upload.FinishedListener() {
            @Override
            public void uploadFinished(FinishedEvent event) {
                result.setValue("Got file (should not contain path): "
                        + receiver.getFilename());
            }
View Full Code Here

Examples of com.vaadin.ui.Upload

    @Override
    protected void initializeComponents() {

        FormLayout formLayout = new FormLayout();
        formLayout.setWidth("100%");
        Upload u = new Upload("Upload in FormLayout", this);
        u.setImmediate(true);
        formLayout.addComponent(u);
        addTestComponent(formLayout);

    }
View Full Code Here

Examples of com.vaadin.ui.Upload

        return Upload.class;
    }

    @Override
    protected void initializeComponents() {
        Upload u;

        u = new Upload("Undefined wide upload", this);
        u.setSizeUndefined();
        addTestComponent(u);

        u.addListener(new Upload.FinishedListener() {
            @Override
            public void uploadFinished(FinishedEvent event) {
                getMainWindow().showNotification("Done");
            }
        });

        u = new Upload("300px wide upload", this);
        u.setWidth("300px");
        addTestComponent(u);

    }
View Full Code Here

Examples of com.vaadin.ui.Upload

    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
TOP
Copyright © 2018 www.massapi.com. 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.