Example usage for com.vaadin.ui Upload Upload

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

Introduction

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

Prototype

public Upload(String caption, Receiver uploadReceiver) 

Source Link

Usage

From source file:annis.gui.admin.ImportPanel.java

License:Apache License

public ImportPanel() {

    setSizeFull();//  w ww  . j a v a 2 s  .c om

    layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setHeight("100%");
    layout.setMargin(true);

    setContent(layout);

    FormLayout form = new FormLayout();
    layout.addComponent(form);

    cbOverwrite = new CheckBox("Overwrite existing corpus");
    form.addComponent(cbOverwrite);

    txtMail = new TextField("e-mail address for status updates");
    txtMail.addValidator(new EmailValidator("Must be a valid e-mail address"));
    form.addComponent(txtMail);

    txtAlias = new TextField("alias name");
    form.addComponent(txtAlias);

    HorizontalLayout actionBar = new HorizontalLayout();
    actionBar.setSpacing(true);
    actionBar.setWidth("100%");

    upload = new Upload("", this);
    upload.setButtonCaption("Upload ZIP file with relANNIS corpus and start import");
    upload.setImmediate(true);
    upload.addStartedListener(this);
    upload.addFinishedListener(this);
    upload.setEnabled(true);

    actionBar.addComponent(upload);

    progress = new ProgressBar();
    progress.setIndeterminate(true);
    progress.setVisible(false);

    actionBar.addComponent(progress);

    lblProgress = new Label();
    lblProgress.setWidth("100%");

    actionBar.addComponent(lblProgress);

    actionBar.setExpandRatio(lblProgress, 1.0f);
    actionBar.setComponentAlignment(lblProgress, Alignment.MIDDLE_LEFT);
    actionBar.setComponentAlignment(upload, Alignment.MIDDLE_LEFT);
    actionBar.setComponentAlignment(progress, Alignment.MIDDLE_LEFT);

    layout.addComponent(actionBar);

    btDetailedLog = new Button();
    btDetailedLog.setStyleName(BaseTheme.BUTTON_LINK);
    btDetailedLog.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setLogVisible(!isLogVisible());
        }
    });
    layout.addComponent(btDetailedLog);

    txtMessages = new TextArea();
    txtMessages.setSizeFull();
    txtMessages.setValue("");
    txtMessages.setReadOnly(true);
    layout.addComponent(txtMessages);

    layout.setExpandRatio(txtMessages, 1.0f);

    setLogVisible(false);
    appendMessage("Ready.");

}

From source file:com.constellio.app.ui.pages.management.updates.UpdateManagerViewImpl.java

private Component buildLicenseUploadPanel() {
    Upload upload = new Upload($("UpdateManagerViewImpl.uploadLicenseCaption"), new Receiver() {
        @Override/*from   ww  w .j  av a2 s . c  o m*/
        public OutputStream receiveUpload(String filename, String mimeType) {
            return presenter.getLicenseOutputStream();
        }
    });
    upload.addSucceededListener(new SucceededListener() {
        @Override
        public void uploadSucceeded(SucceededEvent event) {
            presenter.licenseUploadSucceeded();
        }
    });
    upload.setButtonCaption($("UpdateManagerViewImpl.uploadLicense"));

    Button cancel = new LinkButton($("cancel")) {
        @Override
        protected void buttonClick(ClickEvent event) {
            presenter.licenseUploadCancelled();
        }
    };

    VerticalLayout layout = new VerticalLayout(upload, cancel);
    layout.setWidth("100%");
    layout.setSpacing(true);

    return layout;
}

From source file:com.digitallabs.demos.Vaadin6BootstrapThemeDemo.java

License:Apache License

private void forms(ComponentContainer container) {
    VerticalLayout form = new VerticalLayout();
    form.addStyleName(Bootstrap.Forms.FORM.styleName());
    form.setSpacing(true);// w  ww  . j  av  a 2s  .co  m
    form.setCaption("Legend");

    TextField email = new TextField("Email address");
    email.setInputPrompt("Enter email");
    form.addComponent(email);

    PasswordField password = new PasswordField("Password");
    password.setInputPrompt("Password");
    form.addComponent(password);

    Upload upload = new Upload("File input", null);
    form.addComponent(upload);

    Label help = new Label("Example block-level help text here.");
    help.addStyleName("help-block");
    form.addComponent(help);

    CheckBox check = new CheckBox("Check me out");
    form.addComponent(check);

    Button submit = new Button("Submit");
    submit.addStyleName(Bootstrap.Buttons.DEFAULT.styleName());
    form.addComponent(submit);

    container.addComponent(form);
}

From source file:com.firstbanknigeria.ofsaaenhancers.UI.AdjustmentUI.java

public AdjustmentUI() {
    super("Load Adjustments");
    this.setWidth("1000px");
    this.setHeight("250px");

    objectContext = ObjectStore.getObjectContext(VaadinSession.getCurrent().getSession().getId());

    final VerticalLayout layout = new VerticalLayout();
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    layout.setSpacing(true);/*from   w ww .  ja v a  2  s.  com*/

    AdjustmentFileProcessor adjFileProcessor = new AdjustmentFileProcessor();
    adjFileProcessor.setAdjustmentUI(this);

    Upload uploadComponent = new Upload("", adjFileProcessor);
    uploadComponent.addSucceededListener(adjFileProcessor);
    uploadComponent.setButtonCaption("Upload Adjustments");
    uploadComponent.setImmediate(true);

    Button runAdjustmenstButton = new Button("Run Adjustments");
    runAdjustmenstButton.addClickListener(new Button.ClickListener() {

        public void buttonClick(Button.ClickEvent e) {
            ProcedureQuery query = new ProcedureQuery("RUN_ADJUSTMENTS");
            QueryResponse response = objectContext.performGenericQuery(query);
        }
    });

    layout.addComponents(uploadComponent, runAdjustmenstButton);
    layout.setMargin(true);
    layout.setSpacing(true);

    setContent(layout);
}

From source file:com.foc.vaadin.gui.components.FVUploadLayout_Form.java

License:Apache License

private void uploadButton() {
    setUpload(new Upload(null, new UploadReceiver(FocWebServer.getInstance())));

    getUpload().addFinishedListener(new FinishedListener() {

        @Override//from  ww  w  .jav a  2 s.c  o  m
        public void uploadFinished(FinishedEvent event) {
            try {
                FVUploadLayout_Form.this.uploadFinished(event.getFilename());
            } catch (Exception e) {
                Globals.logException(e);
            }
        }
    });

    getUpload().addFailedListener(new FailedListener() {

        @Override
        public void uploadFailed(FailedEvent event) {
            Globals.showNotification("File " + event.getFilename() + " failed to upload!", "",
                    IFocEnvironment.TYPE_ERROR_MESSAGE);
            goBack(null);
        }
    });
    addComponent(getUpload());
}

From source file:com.foc.vaadin.gui.components.upload.FVUpload_Document.java

License:Apache License

public FVUpload_Document() {
    root = new VerticalLayout();
    root.setSpacing(false);//  ww  w. ja  va2  s.co m
    root.setMargin(false);
    setCompositionRoot(root);

    // Create the Upload component.
    upload = new Upload(null, this);
    upload.setImmediate(true);

    upload.setButtonCaption("Upload");

    upload.addSucceededListener((Upload.SucceededListener) this);
    upload.addFailedListener((Upload.FailedListener) this);

    root.addComponent(upload);
}

From source file:com.foc.vaadin.gui.components.upload.FVUpload_Image.java

License:Apache License

public FVUpload_Image() {
    root = new VerticalLayout();
    root.setSpacing(false);/*from   w  ww.  ja v  a2 s . c  o m*/
    root.setMargin(false);
    setCompositionRoot(root);

    // Create the Upload component.
    upload = new Upload(null, this);
    upload.setImmediate(true);
    //      upload.addStyleName("focUpload");
    if (ConfigInfo.isArabic()) {
        upload.setButtonCaption("");//To hide the default ugly button we should set this to null
    } else {
        upload.setButtonCaption("Upload");//To hide the default ugly button we should set this to null
    }

    // Use a custom button caption instead of plain "Upload".
    //upload.setButtonCaption(null);
    /*
    uploadButton = new FVButton("", new Button.ClickListener() {
    public void buttonClick(ClickEvent event) {
       if(upload != null) upload.startUpload();
    }
    });
            
    uploadButton.setIcon(new ThemeResource("../runo/icons/32/document-add.png"));
    uploadButton.setStyleName(BaseTheme.BUTTON_LINK);
    */

    // Listen for events regarding the success of upload.
    upload.addSucceededListener((Upload.SucceededListener) this);
    upload.addFailedListener((Upload.FailedListener) this);
    upload.addStartedListener((Upload.StartedListener) this);

    root.addComponent(upload);
    root.setComponentAlignment(upload, Alignment.TOP_RIGHT);

    //      uploadButton = new Button();
    //      uploadButton.setIcon(FVIconFactory.getInstance().getFVIcon_24(FVIconFactory.ICON_UPLOAD));
    //      uploadButton.setDescription("Upload");
    //      uploadButton.addClickListener(new Button.ClickListener() {
    //         @Override
    //         public void buttonClick(ClickEvent event) {
    //            if(upload != null){
    //               upload.submitUpload();
    //            }
    //         }
    //      });
    //      root.addComponent(uploadButton);
}

From source file:com.klwork.explorer.ui.custom.UploadComponent.java

License:Apache License

protected void addUpload() {
    this.upload = new Upload(null, receiver);
    upload.setButtonCaption(i18nManager.getMessage(Messages.UPLOAD_SELECT));
    upload.setImmediate(true);/* ww  w  . j a v  a  2s .  co  m*/
    addComponent(upload);
    setComponentAlignment(upload, Alignment.MIDDLE_CENTER);

    // register ourselves as listener for upload events
    upload.addListener((StartedListener) this);
    upload.addListener((FailedListener) this);
    upload.addListener((FinishedListener) this);
    upload.addListener((ProgressListener) this);
}

From source file:com.ocs.dynamo.ui.composite.form.UploadForm.java

License:Apache License

@Override
protected void doBuildLayout(Layout main) {
    FormLayout form = new FormLayout();
    form.setMargin(true);//from   w w w  .ja v a 2s.  c o  m
    if (ScreenMode.VERTICAL.equals(screenMode)) {
        form.setStyleName(DynamoConstants.CSS_CLASS_HALFSCREEN);
    }

    main.addComponent(form);

    // add custom components
    doBuildForm(form);

    // add file upload field
    UploadReceiver receiver = new UploadReceiver();

    Upload upload = new Upload(message("ocs.uploadform.title"), receiver);

    upload.addSucceededListener(receiver);
    form.addComponent(upload);

    if (showCancelButton) {
        Button cancelButton = new Button(message("ocs.cancel"));
        cancelButton.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                cancel();
            }
        });
        main.addComponent(cancelButton);
    }
}

From source file:com.openhris.commons.UploadImage.java

public UploadImage(Panel imagePanel, Embedded avatar, String employeeId) {
    this.imagePanel = imagePanel;
    this.avatar = avatar;
    this.employeeId = employeeId;

    imagePanel = new Panel("Upload Component");
    imagePanel.setWidth("400px");
    addComponent(imagePanel);/*w  w  w.  jav a  2 s  .  c  o m*/

    // Create the Upload component.
    upload = new Upload("Upload the Image file here", receiver);
    // Use a custom button caption instead of plain "Upload".
    upload.setButtonCaption("Upload Now");

    // Listen for events regarding the success of upload. 
    upload.addListener((Upload.StartedListener) this);
    upload.addListener((Upload.SucceededListener) this);
    upload.addListener((Upload.FailedListener) this);

    panel.setWidth("100%");
    panel.addComponent(new Label("Click 'Choose file' to " + "select a file and then click 'Upload Now'. "
            + "image should have the same width and height so "
            + "that image will not look deformed when viewed."));

    imagePanel.addComponent(upload);
    imagePanel.addComponent(panel);

    avatar = new Embedded();
    avatar.setImmediate(true);
    avatar.setWidth(90, Sizeable.UNITS_PIXELS);
    avatar.setHeight(90, Sizeable.UNITS_PIXELS);
    imagePanel.addComponent(avatar);
}