Example usage for com.vaadin.ui Upload setButtonCaption

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

Introduction

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

Prototype

public void setButtonCaption(String buttonCaption) 

Source Link

Document

In addition to the actual file chooser, upload components have button that starts actual upload progress.

Usage

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  w  w  w. j a  v  a 2  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.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 w  w.  j  a  v  a2  s .c  o  m

    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.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected Upload initChangePictureButton() {
    final Upload changePictureUpload = new Upload();
    changePictureUpload.setImmediate(true);
    changePictureUpload.setButtonCaption(i18nManager.getMessage(Messages.PROFILE_CHANGE_PICTURE));

    final InMemoryUploadReceiver receiver = initPictureReceiver(changePictureUpload);
    changePictureUpload.addFinishedListener(new FinishedListener() {
        private static final long serialVersionUID = 1L;

        public void uploadFinished(FinishedEvent event) {
            if (!receiver.isInterruped()) {
                picture = new Picture(receiver.getBytes(), receiver.getMimeType());
                identityService.setUserPicture(userId, picture);

                // reset picture
                imageLayout.removeAllComponents();
                initPicture();//ww w.  j a  v  a2 s . c  o m
            } else {
                receiver.reset();
            }
        }
    });

    return changePictureUpload;
}

From source file:com.peergreen.webconsole.scope.deployment.internal.DeploymentScope.java

License:Open Source License

@PostConstruct
public void init() {
    deploymentViewManager = createDeploymentViewManager();

    OptionGroup option = new OptionGroup();
    HorizontalLayout toolBar = new HorizontalLayout();
    toolBar.setWidth("100%");
    toolBar.setSpacing(true);/*w  w  w  . j a  v a2 s . c  o  m*/
    toolBar.setMargin(true);

    VerticalLayout uploadLayout = new VerticalLayout();

    Upload uploader = new Upload("Upload a file here", null);
    uploader.setButtonCaption("Upload");
    final FileUploader fileUploader = new FileUploader(deploymentViewManager, notifierService, artifactBuilder,
            option);
    uploader.setReceiver(fileUploader);
    uploader.addSucceededListener(fileUploader);
    uploader.addStartedListener(fileUploader);
    uploadLayout.addComponent(uploader);

    HorizontalLayout target = new HorizontalLayout();
    option.addContainerProperty("id", String.class, null);
    option.setItemCaptionPropertyId("id");
    option.addItem(DeployableContainerType.DEPLOYABLE.attribute()).getItemProperty("id")
            .setValue("Add to deployables");
    option.addItem(DeployableContainerType.DEPLOYED.attribute()).getItemProperty("id").setValue("Deploy");
    option.addItem(DeployableContainerType.DEPLOYMENT_PLAN.attribute()).getItemProperty("id")
            .setValue("Create a deployment plan");
    option.addStyleName("horizontal");
    option.select(DeployableContainerType.DEPLOYABLE.attribute());

    target.addComponent(option);
    uploadLayout.addComponent(target);
    toolBar.addComponent(uploadLayout);

    Label infoLabel = new Label("Drop files here to create a deployment plan");
    infoLabel.setSizeUndefined();
    final VerticalLayout deploymentPlanMaker = new VerticalLayout(infoLabel);
    deploymentPlanMaker.setComponentAlignment(infoLabel, Alignment.MIDDLE_CENTER);
    Button draft = new Button("A draft is under construction");
    draft.addStyleName("link");
    draft.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            deploymentViewManager.showDeploymentPlanView();
        }
    });
    draft.setVisible(false);
    deploymentViewManager.setDeploymentPlanDraftViewer(draft);
    deploymentPlanMaker.addComponent(draft);
    deploymentPlanMaker.setComponentAlignment(draft, Alignment.TOP_CENTER);
    deploymentPlanMaker.setSizeFull();
    deploymentPlanMaker.addStyleName("drop-area");
    deploymentPlanMakerWrapper = new DragAndDropWrapper(deploymentPlanMaker);
    deploymentPlanMakerWrapper.setSizeFull();
    toolBar.addComponent(deploymentPlanMakerWrapper);
    addComponent(toolBar);

    addComponent(framesContainer);
    setExpandRatio(framesContainer, 1.5f);

    helpWindow = notifierService.createHelpOverlay("Deployment module",
            "<p>To deploy, or undeploy, artifacts, you can drag and drop elements from deployables panel "
                    + "to deployed panel and vice versa.</p>"
                    + "<p>You can also drag files from desktop and drop them where you want to add them.");
}

From source file:control.ExperimentImportController.java

License:Open Source License

public void init(final String user) {
    ExperimentImportController control = this;
    Upload upload = new Upload("Upload your file here", uploader);
    view.initView(upload);// www.ja v  a2s . com
    upload.setButtonCaption("Upload");
    // Listen for events regarding the success of upload.
    upload.addFailedListener(uploader);
    upload.addSucceededListener(uploader);
    FinishedListener uploadFinListener = new FinishedListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -8413963075202260180L;

        public void uploadFinished(FinishedEvent event) {
            String uploadError = uploader.getError();
            File file = uploader.getFile();
            view.resetAfterUpload();
            if (file.getPath().endsWith("up_")) {
                String msg = "No file selected.";
                logger.warn(msg);
                Styles.notification("Failed to read file.", msg, NotificationType.ERROR);
                if (!file.delete())
                    logger.error("uploaded tmp file " + file.getAbsolutePath() + " could not be deleted!");
            } else {
                if (uploadError == null || uploadError.isEmpty()) {
                    String msg = "Upload successful!";
                    logger.info(msg);
                    try {
                        view.setRegEnabled(false);
                        prep = new SamplePreparator();
                        Map<String, Set<String>> experimentTypeVocabularies = new HashMap<String, Set<String>>();
                        experimentTypeVocabularies.put("Q_ANTIBODY", vocabs.getAntibodiesMap().keySet());
                        experimentTypeVocabularies.put("Q_CHROMATOGRAPHY_TYPE",
                                vocabs.getChromTypesMap().keySet());
                        experimentTypeVocabularies.put("Q_MS_DEVICE",
                                new HashSet<String>(vocabs.getDeviceMap().values()));
                        experimentTypeVocabularies.put("Q_MS_LCMS_METHOD",
                                new HashSet<String>(vocabs.getLcmsMethods()));

                        VocabularyValidator validator = new VocabularyValidator(experimentTypeVocabularies);
                        boolean readSuccess = prep.processTSV(file, getImportType());
                        boolean vocabValid = false;
                        if (readSuccess) {
                            msProperties = prep.getSpecialExperimentsOfTypeOrNull("Q_MS_MEASUREMENT");
                            mhcProperties = prep.getSpecialExperimentsOfTypeOrNull("Q_MHC_LIGAND_EXTRACTION");
                            List<Map<String, Object>> metadataList = new ArrayList<Map<String, Object>>();
                            if (msProperties != null)
                                metadataList.addAll(msProperties.values());
                            if (mhcProperties != null)
                                metadataList.addAll(mhcProperties.values());
                            vocabValid = validator.validateExperimentMetadata(metadataList);
                        }
                        if (readSuccess && vocabValid) {
                            List<SampleSummaryBean> summaries = prep.getSummary();
                            for (SampleSummaryBean s : summaries) {
                                String translation = reverseTaxMap.get(s.getFullSampleContent());
                                if (translation != null)
                                    s.setSampleContent(translation);
                            }
                            Styles.notification("Upload successful",
                                    "Experiment was successfully uploaded and read.", NotificationType.SUCCESS);
                            switch (getImportType()) {
                            // Standard hierarchic QBiC design
                            case QBIC:
                                view.setSummary(summaries);
                                view.setProcessed(prep.getProcessed());
                                view.setRegEnabled(true);
                                projectInfo = prep.getProjectInfo();
                                break;
                            // Standard non-hierarchic design without QBiC specific keywords
                            case Standard:
                                Map<String, List<String>> catToVocabulary = new HashMap<String, List<String>>();
                                catToVocabulary.put("Species", new ArrayList<String>(taxMap.keySet()));
                                catToVocabulary.put("Tissues", new ArrayList<String>(tissueMap.keySet()));
                                catToVocabulary.put("Analytes", new ArrayList<String>(analytesVocabulary));
                                Map<String, List<String>> missingCategoryToValues = new HashMap<String, List<String>>();
                                missingCategoryToValues.put("Species",
                                        new ArrayList<String>(prep.getSpeciesSet()));
                                missingCategoryToValues.put("Tissues",
                                        new ArrayList<String>(prep.getTissueSet()));
                                missingCategoryToValues.put("Analytes",
                                        new ArrayList<String>(prep.getAnalyteSet()));
                                initMissingInfoListener(prep, missingCategoryToValues, catToVocabulary);
                                break;
                            // MHC Ligands that have already been measured (Filenames exist)
                            case MHC_Ligands_Finished:
                                catToVocabulary = new HashMap<String, List<String>>();
                                catToVocabulary.put("Species", new ArrayList<String>(taxMap.keySet()));
                                catToVocabulary.put("Tissues", new ArrayList<String>(tissueMap.keySet()));
                                catToVocabulary.put("Analytes", new ArrayList<String>(analytesVocabulary));
                                missingCategoryToValues = new HashMap<String, List<String>>();
                                missingCategoryToValues.put("Species",
                                        new ArrayList<String>(prep.getSpeciesSet()));
                                missingCategoryToValues.put("Tissues",
                                        new ArrayList<String>(prep.getTissueSet()));
                                missingCategoryToValues.put("Analytes",
                                        new ArrayList<String>(prep.getAnalyteSet()));
                                initMissingInfoListener(prep, missingCategoryToValues, catToVocabulary);
                                break;
                            default:
                                logger.error("Error parsing tsv: " + prep.getError());
                                // view.showError(prep.getError());
                                Styles.notification("Failed to read file.", prep.getError(),
                                        NotificationType.ERROR);
                                break;
                            }
                        } else {
                            if (!readSuccess) {
                                String error = prep.getError();
                                Styles.notification("Failed to read file.", error, NotificationType.ERROR);
                            } else {
                                String error = validator.getError();
                                Styles.notification("Failed to process file.", error, NotificationType.ERROR);
                            }
                            if (!file.delete())
                                logger.error("uploaded tmp file " + file.getAbsolutePath()
                                        + " could not be deleted!");
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } else {
                    // view.showError(error);
                    Styles.notification("Failed to upload file.", uploadError, NotificationType.ERROR);
                    if (!file.delete())
                        logger.error("uploaded tmp file " + file.getAbsolutePath() + " could not be deleted!");
                }
            }
        }
    };
    upload.addFinishedListener(uploadFinListener);
    // view.initUpload(upload);

    Button.ClickListener cl = new Button.ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        /**
         * 
         */

        @Override
        public void buttonClick(ClickEvent event) {
            String src = event.getButton().getCaption();
            if (src.equals("Register All")) {
                view.getRegisterButton().setEnabled(false);
                view.showRegistration();
                // collect experiment information
                complexExperiments = new ArrayList<OpenbisExperiment>();
                complexExperiments
                        .addAll(collectComplexExperiments(msProperties, ExperimentType.Q_MS_MEASUREMENT));
                complexExperiments.addAll(
                        collectComplexExperiments(mhcProperties, ExperimentType.Q_MHC_LIGAND_EXTRACTION));
                openbisCreator.registerProjectWithExperimentsAndSamplesBatchWise(view.getSamples(),
                        projectInfo.getDescription(), complexExperiments, view.getProgressBar(),
                        view.getProgressLabel(), new RegisteredSamplesReadyRunnable(view, control), user,
                        projectInfo.isPilot());
                List<String> tsv = prep.getOriginalTSV();
                switch (getImportType()) {
                case Standard:
                case MHC_Ligands_Finished:
                    String tsvContent = addBarcodesToTSV(tsv, view.getSamples(), getImportType());
                    view.setTSVWithBarcodes(tsvContent,
                            uploader.getFileNameWithoutExtension() + "_with_barcodes");
                    break;
                default:
                    break;
                }
            }
        }

        private Collection<? extends OpenbisExperiment> collectComplexExperiments(
                Map<String, Map<String, Object>> propsMap, ExperimentType type) {
            List<OpenbisExperiment> res = new ArrayList<OpenbisExperiment>();
            if (propsMap != null) {
                for (String code : propsMap.keySet())
                    res.add(new OpenbisExperiment(code, type, propsMap.get(code)));
            }
            return res;
        }
    };
    view.getRegisterButton().addClickListener(cl);
}

From source file:cz.zcu.pia.social.network.frontend.components.profile.profile.ComponentEditProfile.java

@Override
@PostConstruct//from   ww w . j  a va 2 s .c  o m
public void postConstruct() {
    receiver = appContext.getBean(ImageUploader.class);
    Upload upload = new Upload(msgs.getMessage("upload.image"), receiver);
    upload.setButtonCaption(msgs.getMessage("upload"));
    upload.addSucceededListener(receiver);

    upload.addFailedListener(new Upload.FailedListener() {

        @Override
        public void uploadFailed(Upload.FailedEvent event) {
            Notification.show(msgs.getMessage("upload.not.ok"));
        }
    });
    this.layout.addComponent(upload, "upload");
    super.postConstruct();

    this.password.setVisible(false);
    this.passwordRepeat.setVisible(false);
    this.validation.setVisible(false);

}

From source file:cz.zcu.pia.social.network.frontend.components.profile.profile.ComponentProfile.java

/**
 * Post Construct//from w ww  .  j  a v a2 s  . c o  m
 */
@PostConstruct
public void postConstruct() {
    if (!securityHelper.isAuthenticated()) {
        ((MyUI) UI.getCurrent().getUI()).getNavigator().navigateTo(ViewHome.NAME);
        return;
    }
    Users user = usersService.getUserByUsername(securityHelper.getLogedInUser().getUsername());
    if (user == null) {
        return;
    }

    this.addComponent(editProfile);
    editProfile.setUser(user);
    editProfile.setVisible(false);
    editProfile.setParentReference(this);

    setLabels(user);
    editButton = new Button(msgs.getMessage("edit"));
    editButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            buttonEditFunction(event);
        }
    });

    if (securityHelper.getLogedInUser().getUserImageName() != null) {
        reloadImage();

    } else {
        ImageUploader receiver = appContext.getBean(ImageUploader.class);
        receiver.setParentReference(this);
        Upload upload = new Upload(msgs.getMessage("upload.image"), receiver);
        upload.setButtonCaption(msgs.getMessage("upload"));
        upload.addSucceededListener(receiver);

        upload.addFailedListener(new Upload.FailedListener() {

            @Override
            public void uploadFailed(Upload.FailedEvent event) {
                Notification.show(msgs.getMessage("upload.not.ok"));
            }
        });
        layout.addComponent(upload, "picture");

    }

    fullname = new Label(user.getName() + " " + user.getSurname());
    layout.addComponent(fullname, "name");

    Label usernameLabel = new Label(msgs.getMessage("username") + ":");
    Label postsLabel = new Label(msgs.getMessage("number-of-posts") + ":");
    Label followersLabel = new Label(msgs.getMessage("number-of-followers") + ":");

    usernameLabel.setWidth(LABEL_WIDTH, Unit.PIXELS);
    postsLabel.setWidth(LABEL_WIDTH, Unit.PIXELS);
    followersLabel.setWidth(LABEL_WIDTH, Unit.PIXELS);

    layout.addComponent(usernameLabel, "usernameLabel");
    layout.addComponent(postsLabel, "numberPostsLabel");
    layout.addComponent(followersLabel, "numberFollowersLabel");

    layout.addComponent(username, "username");
    layout.addComponent(numberOfposts, "numberPosts");
    layout.addComponent(numberOfFollowers, "numberFollowers");
    layout.addComponent(editButton, "button");
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultRowEditingFormView.java

License:Apache License

private Upload buildUpload(final ContainerRow row, final ContainerBlob containerBlob,
        final FileMetadata metadata, final Link downloadLink) {
    final Upload upload = new Upload();
    if (metadata.getUploadCaption() != null) {
        upload.setButtonCaption(metadata.getUploadCaption());
    } else {/*from w  w w  . ja  v  a  2s .c o m*/
        upload.setButtonCaption("Upload");
    }
    upload.setImmediate(true);
    upload.setReceiver(new BlobUploadReceiver());

    upload.addFinishedListener(new Upload.FinishedListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void uploadFinished(FinishedEvent event) {
            BlobUploadReceiver receiver = (BlobUploadReceiver) upload.getReceiver();
            if (receiver.getBaos().size() <= 0 || receiver.getBaos().size() <= metadata.getMaxFileSize()) {
                containerBlob.setValue(receiver.getBaos().toByteArray());
                if (metadata.getFilenameColumn() != null) {
                    row.getValues().put(metadata.getFilenameColumn(), receiver.getFilename());

                }
                if (metadata.getMimetypeColumn() != null) {
                    row.getValues().put(metadata.getMimetypeColumn(), receiver.getMimetype());
                }
                updateDownloadLink(row, containerBlob, metadata, downloadLink);

            } else {
                Notification.show(
                        "Ein Datei darauf nicht grer als " + metadata.getMaxFileSize() + " Bytes sein.",
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });
    return upload;
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.InitialScreenViewImpl.java

License:Open Source License

public void createImportButton() {
    importButton = new VerticalLayout();
    importButton.setWidth(150, com.vaadin.terminal.Sizeable.UNITS_PIXELS);
    importButton.setHeight(80, com.vaadin.terminal.Sizeable.UNITS_PIXELS);
    importButton.setStyleName("topBarButtonContainer");
    UploadReceiver receiver = new UploadReceiver(eventBus);
    Upload upload = new Upload(null, receiver);
    upload.setButtonCaption("");
    upload.setImmediate(true);/*from  w ww.  j a va2 s  . co  m*/
    upload.addListener(receiver);
    upload.setStyleName("importButton");
    upload.setWidth(30, com.vaadin.terminal.Sizeable.UNITS_PIXELS);
    upload.setHeight(30, com.vaadin.terminal.Sizeable.UNITS_PIXELS);
    Label gap = new Label();
    gap.setHeight("5px");
    Label label = new Label("Projekte");
    label.setStyleName("topBarButtonLabel");
    label.setSizeUndefined();
    Label label2 = new Label("importieren");
    label2.setStyleName("topBarButtonLabel");
    label2.setSizeUndefined();
    VerticalLayout labelLayout = new VerticalLayout();
    labelLayout.setHeight(45, com.vaadin.terminal.Sizeable.UNITS_PIXELS);
    labelLayout.setWidth(100, UNITS_PERCENTAGE);
    importButton.addComponent(upload);
    labelLayout.addComponent(label);
    labelLayout.addComponent(label2);
    importButton.addComponent(gap);
    importButton.addComponent(labelLayout);
    importButton.setComponentAlignment(upload, Alignment.TOP_CENTER);
    labelLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
    labelLayout.setComponentAlignment(label2, Alignment.MIDDLE_CENTER);
}

From source file:fi.vtt.RVaadin.RUpload.java

License:Apache License

/**
 * Contruct an upload element for R (implemented as Vaadin CustomComponent).
 * // ww w  .  j  a va  2s .  c o m
 * @param caption
 *            String caption or null
 * @param R
 *            the corresponding RSession to upload the files to
 */
public RUpload(String caption, RContainer R) {

    /* Create the RUpload custom component */
    super.setSizeUndefined();
    root = new Panel(caption);
    root.setWidth("90ex");

    setCompositionRoot(root);

    HorizontalLayout hbox = new HorizontalLayout();
    hbox.setWidth("100%");

    /* Create the Upload component */
    final Upload upload = new Upload("Choose file", this);
    upload.setButtonCaption("Submit");

    /* Listen for events regarding the success of upload. */
    upload.addSucceededListener(this);
    upload.addFailedListener(this);
    hbox.addComponent(upload);

    Label hfill = new Label();
    hbox.addComponent(hfill);
    hbox.setExpandRatio(hfill, 1.0f);

    remove = new Button("Remove", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            String current = getSelection();

            if (current != null) {
                /* Delete the file */
                delete(current);

                /* Update the lists and the notification area */
                int i = fileNames.indexOf(current);
                fileNames.remove(i);
                mimeTypes.remove(i);
                uploadedFiles.removeItem(current);

                /* Gray out the button, if this was the last item */
                if (fileNames.isEmpty()) {
                    remove.setEnabled(false);
                }
            }
        }
    });

    hbox.addComponent(remove);
    remove.setEnabled(false);
    hbox.setComponentAlignment(remove, Alignment.BOTTOM_RIGHT);

    /* Notification area for already uploaded files */
    uploadedFiles = new ListSelect("Already submitted files");
    uploadedFiles.setMultiSelect(false);
    uploadedFiles.setNullSelectionAllowed(false);
    uploadedFiles.setHeight("4em");
    uploadedFiles.setWidth("100%");

    // Changed for Vaadin 7, not tested!!
    VerticalLayout vbox = new VerticalLayout();
    vbox.addComponent(hbox);
    vbox.addComponent(uploadedFiles);
    root.setContent(vbox);

    /* Bind the component to the given R session */
    this.R = R;
}