Example usage for com.vaadin.ui Upload setWidthUndefined

List of usage examples for com.vaadin.ui Upload setWidthUndefined

Introduction

In this page you can find the example usage for com.vaadin.ui Upload setWidthUndefined.

Prototype

@Override
    public void setWidthUndefined() 

Source Link

Usage

From source file:org.hip.vif.web.util.UploadComponent.java

License:Open Source License

private Upload createUpload(final IBibliographyTask inTask) {
    final Upload outUpload = new Upload();
    outUpload.setWidthUndefined();
    outUpload.setReceiver(new Upload.Receiver() {
        @Override//from w  w w . j a va  2s .  c  o  m
        public OutputStream receiveUpload(final String inFilename, // NOPMD
                final String inMimeType) {
            return createStream(inFilename);
        }
    });

    final String lCaption = Activator.getMessages().getMessage("ui.upload.button.lbl"); //$NON-NLS-1$
    outUpload.setButtonCaption(lCaption);
    outUpload.setImmediate(true);
    outUpload.setStyleName("vif-upload"); //$NON-NLS-1$

    outUpload.addStartedListener(new Upload.StartedListener() {
        @Override
        public void uploadStarted(final StartedEvent inEvent) { // NOPMD
            fileInfo = new FileInfo(inEvent.getFilename(), inEvent.getMIMEType());
            tempUpload = null; // NOPMD
            uploadFinished = false;
            outUpload.setVisible(false);
            if (hasDownloads) {
                dialog.setVisible(true); // FF
            }
        }
    });
    outUpload.addFinishedListener(new Upload.FinishedListener() {
        @Override
        public void uploadFinished(final FinishedEvent inEvent) { // NOPMD
            uploadFinished = true;
            outUpload.setVisible(true);
        }
    });
    outUpload.addSucceededListener(new Upload.SucceededListener() {
        @Override
        public void uploadSucceeded(final SucceededEvent inEvent) { // NOPMD
            if (!hasDownloads) {
                handleUpload(inTask, false);
            }
        }
    });
    outUpload.addFailedListener(new Upload.FailedListener() {
        @Override
        public void uploadFailed(final FailedEvent inEvent) { // NOPMD
            handleDeleteTemp();
        }
    });

    return outUpload;
}