List of usage examples for com.vaadin.ui Upload setButtonCaption
public void setButtonCaption(String buttonCaption)
From source file:fr.amapj.view.views.importdonnees.ImportDonneesView.java
License:Open Source License
private Component getUtilisateurPanel() { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/*w w w . j a va2 s.c o m*/ addEmptyLine(layout); addLabel(layout, "Pour importer les utilisateurs en masse, vous devez remplir un fichier Excel un certain format."); addLabel(layout, "Pour avoir un exemple du fichier remplir, merci de cliquer sur ce lien :"); layout.addComponent(LinkCreator.createLink(new EGListeAdherent(Type.EXAMPLE))); addEmptyLine(layout); addLabel(layout, "Une fois que votre fichier Excel est prt, vous pouvez le charger dans l'application." + " Pour cela, cliquez sur le bouton \"Charger les utilisateurs\", slectionnez votre fichier, cliquez sur OK. Les utilisateurs seront alors automatiquement crs, sans mot de passe "); addEmptyLine(layout); // UtilisateurImporter utilisateurImporter = new UtilisateurImporter(); Upload upload = new Upload(null, utilisateurImporter); upload.addSucceededListener(utilisateurImporter); upload.setImmediate(true); upload.setButtonCaption("Charger les utilisateurs"); layout.addComponent(upload); addEmptyLine(layout); return layout; }
From source file:fr.amapj.view.views.importdonnees.ImportDonneesView.java
License:Open Source License
private Component getProduitPanel() { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/*from w ww .j a va 2s. c o m*/ addEmptyLine(layout); addLabel(layout, "Pour importer les produits et les producteurs en masse, vous devez remplir un fichier Excel un certain format."); addLabel(layout, "Pour avoir un exemple du fichier remplir, merci de cliquer sur ce lien :"); layout.addComponent(LinkCreator.createLink(new EGListeProduitProducteur( fr.amapj.service.services.edgenerator.excel.EGListeProduitProducteur.Type.EXAMPLE))); addEmptyLine(layout); addLabel(layout, "Une fois que votre fichier Excel est prt, vous pouvez le charger dans l'application." + " Pour cela, cliquez sur le bouton \"Charger les produits et les producteurs\", slectionnez votre fichier, cliquez sur OK. Les produits et les producteurs seront alors automatiquement crs."); // ProduitImporter produitImporter = new ProduitImporter(); Upload upload = new Upload(null, produitImporter); upload.addSucceededListener(produitImporter); upload.setImmediate(true); upload.setButtonCaption("Charger les produits et les producteurs"); addEmptyLine(layout); layout.addComponent(upload); addEmptyLine(layout); return layout; }
From source file:nz.co.senanque.workflowui.AttachmentPopup.java
License:Apache License
public void load(final long pid) { panel.removeAllComponents();//from w w w .j a v a2 s . c o m final Upload upload = new Upload(null, receiver); upload.setImmediate(true); upload.setButtonCaption(m_messageSourceAccessor.getMessage("upload.file", "Upload File")); checkbox = new CheckBox(m_messageSourceAccessor.getMessage("upload.protected", "Protected")); comment = new TextField(m_messageSourceAccessor.getMessage("upload.comment", "Comment")); panel.addComponent(comment); panel.addComponent(checkbox); panel.addComponent(upload); upload.addFinishedListener(new Upload.FinishedListener() { private static final long serialVersionUID = 1L; public void uploadFinished(FinishedEvent event) { Attachment attachment = receiver.getWrapper().getCurrentAttachment(); attachment.setProcessInstanceId(pid); attachment.setComment((String) comment.getValue()); attachment.setProtectedDocument((boolean) checkbox.getValue()); m_workflowDAO.addAttachment(attachment); close(); } }); if (getParent() == null) { UI.getCurrent().addWindow(this); this.center(); } }
From source file:org.activiti.explorer.ui.profile.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.addListener(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 .ja v a2 s . co m*/ } else { receiver.reset(); } } }); return changePictureUpload; }
From source file:org.apache.usergrid.chop.webapp.view.user.KeyListLayout.java
License:Apache License
void addUploadControls() { keyNameField.setWidth("290px"); keyNameField.setValue("key-pair-name"); addComponent(keyNameField, "left: 0px; top: 50px;"); Upload upload = new Upload("", this); upload.setButtonCaption("Add"); upload.addSucceededListener(this); addComponent(upload, "left: 0px; top: 80px;"); }
From source file:org.bubblecloud.ilves.module.content.AssetFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(1, 3); gridLayout.setSizeFull();// w w w . j a v a 2 s .c om gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); assetEditor = new ValidatingEditor( FieldSetDescriptorRegister.getFieldSetDescriptor(Asset.class).getFieldDescriptors()); assetEditor.setCaption("Asset"); assetEditor.addListener(this); gridLayout.addComponent(assetEditor, 0, 1); final Upload upload = new Upload(getSite().localize("field-file-upload"), new Upload.Receiver() { @Override public OutputStream receiveUpload(String filename, String mimeType) { try { temporaryFile = File.createTempFile(entity.getAssetId(), ".upload"); return new FileOutputStream(temporaryFile, false); } catch (IOException e) { throw new SiteException("Unable to create temporary file for upload.", e); } } }); upload.setButtonCaption(getSite().localize("button-start-upload")); upload.addSucceededListener(new Upload.SucceededListener() { @Override public void uploadSucceeded(Upload.SucceededEvent event) { if (event.getLength() == 0) { return; } if (temporaryFile.length() > Long .parseLong(PropertiesUtil.getProperty("site", "asset-maximum-size"))) { Notification.show(getSite().localize("message-file-too-large"), Notification.Type.ERROR_MESSAGE); return; } entity.setName(event.getFilename().substring(0, event.getFilename().lastIndexOf('.'))); entity.setExtension(event.getFilename().substring(event.getFilename().lastIndexOf('.') + 1)); entity.setType(event.getMIMEType()); entity.setSize((int) event.getLength()); assetEditor.setItem(new BeanItem<Asset>(entity), assetEditor.isNewItem()); save(); } }); gridLayout.addComponent(upload, 0, 0); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); gridLayout.addComponent(buttonLayout, 0, 2); saveButton = getSite().getButton("save"); buttonLayout.addComponent(saveButton); saveButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (isValid()) { save(); } else { Notification.show(getSite().localize("message-invalid-form-asset"), Notification.Type.HUMANIZED_MESSAGE); } } }); discardButton = getSite().getButton("discard"); buttonLayout.addComponent(discardButton); discardButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { assetEditor.discard(); if (temporaryFile != null) { temporaryFile.deleteOnExit(); temporaryFile = null; } } }); editPrivilegesButton = getSite().getButton("edit-privileges"); buttonLayout.addComponent(editPrivilegesButton); editPrivilegesButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { final PrivilegesFlowlet privilegesFlowlet = getFlow().getFlowlet(PrivilegesFlowlet.class); privilegesFlowlet.edit(entity.getName(), entity.getAssetId(), "view", "edit"); getFlow().forward(PrivilegesFlowlet.class); } }); }
From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadLayout.java
License:Open Source License
private void buildLayout() { final Upload upload = new Upload(); final UploadHandler uploadHandler = new UploadHandler(null, 0, this, multipartConfigElement.getMaxFileSize(), upload, null, null, softwareModuleManagement); upload.setButtonCaption(i18n.getMessage("upload.file")); upload.setImmediate(true);/*from w w w. j a v a2s.c o m*/ upload.setReceiver(uploadHandler); upload.addSucceededListener(uploadHandler); upload.addFailedListener(uploadHandler); upload.addFinishedListener(uploadHandler); upload.addProgressListener(uploadHandler); upload.addStartedListener(uploadHandler); upload.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); upload.addStyleName("no-border"); fileUploadLayout = new HorizontalLayout(); fileUploadLayout.setSpacing(true); fileUploadLayout.addStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT); fileUploadLayout.addComponent(upload); fileUploadLayout.setComponentAlignment(upload, Alignment.MIDDLE_LEFT); fileUploadLayout.addComponent(processBtn); fileUploadLayout.setComponentAlignment(processBtn, Alignment.MIDDLE_RIGHT); fileUploadLayout.addComponent(discardBtn); fileUploadLayout.setComponentAlignment(discardBtn, Alignment.MIDDLE_RIGHT); fileUploadLayout.addComponent(uploadStatusButton); fileUploadLayout.setComponentAlignment(uploadStatusButton, Alignment.MIDDLE_RIGHT); setMargin(false); /* create drag-drop wrapper for drop area */ dropAreaWrapper = new DragAndDropWrapper(createDropAreaLayout()); dropAreaWrapper.setDropHandler(new DropAreahandler()); setSizeFull(); setSpacing(true); }
From source file:org.escidoc.browser.ui.maincontent.OnAddOrgUnitMetadata.java
License:Open Source License
public void showAddWindow() { final Window subwindow = new Window(ViewConstants.ADD_ORGANIZATIONAL_UNIT_S_METADATA); subwindow.setWidth("600px"); subwindow.setModal(true);// ww w . j a v a2s .c om // Make uploading start immediately when file is selected final Upload upload = new Upload("", receiver); upload.setImmediate(true); upload.setButtonCaption("Select file"); progressLayout.setSpacing(true); progressLayout.setVisible(false); final ProgressIndicator pi = new ProgressIndicator(); progressLayout.addComponent(pi); progressLayout.setComponentAlignment(pi, Alignment.MIDDLE_LEFT); /** * =========== Add needed listener for the upload component: start, progress, finish, success, fail =========== */ upload.addListener(new Upload.StartedListener() { @Override public void uploadStarted(final StartedEvent event) { upload.setVisible(false); progressLayout.setVisible(true); pi.setValue(Float.valueOf(0f)); pi.setPollingInterval(500); status.setValue("Uploading file \"" + event.getFilename() + "\""); } }); upload.addListener(new Upload.SucceededListener() { @Override public void uploadSucceeded(final SucceededEvent event) { // This method gets called when the upload finished successfully status.setValue("Uploading file \"" + event.getFilename() + "\" succeeded"); final String fileContent = receiver.getFileContent(); final boolean isWellFormed = XmlUtil.isWellFormed(fileContent); receiver.setWellFormed(isWellFormed); if (isWellFormed) { status.setValue(ViewConstants.XML_IS_WELL_FORMED); hl.setVisible(true); upload.setEnabled(false); } else { status.setValue(ViewConstants.XML_IS_NOT_WELL_FORMED); hl.setVisible(false); } } }); upload.addListener(new Upload.FailedListener() { @Override public void uploadFailed(final FailedEvent event) { // This method gets called when the upload failed status.setValue("Uploading interrupted"); } }); upload.addListener(new Upload.FinishedListener() { @Override public void uploadFinished(final FinishedEvent event) { // This method gets called always when the upload finished, // either succeeding or failing progressLayout.setVisible(false); upload.setVisible(true); upload.setCaption("Select another file"); } }); mdName = new TextField("Metadata name"); mdName.setValue(""); mdName.setImmediate(true); mdName.setValidationVisible(false); hl = new HorizontalLayout(); hl.setMargin(true); final Button btnAdd = new Button("Save", new Button.ClickListener() { private boolean containSpace(final String text) { final Pattern pattern = Pattern.compile("\\s"); final Matcher matcher = pattern.matcher(text); return matcher.find(); } @Override public void buttonClick(final ClickEvent event) { if (mdName.getValue().equals("")) { mdName.setComponentError(new UserError("You have to add a name for your MetaData")); } else if (containSpace(((String) mdName.getValue()))) { mdName.setComponentError(new UserError("The name of MetaData can not contain space")); } else { mdName.setComponentError(null); if (receiver.getFileContent().isEmpty()) { upload.setComponentError( new UserError("Please select a well formed XML file as metadata.")); } else if (!receiver.isWellFormed()) { upload.setComponentError(new UserError(ViewConstants.XML_IS_NOT_WELL_FORMED)); } else { final MetadataRecord metadataRecord = new MetadataRecord(mdName.getValue().toString()); try { metadataRecord.setContent(getMetadataContent()); controller.addMetaData(metadataRecord); controller.refreshView(); upload.setEnabled(true); subwindow.getParent().removeWindow(subwindow); } catch (final SAXException e) { LOG.error(e.getMessage()); mdName.setComponentError(new UserError( "Failed to add the new Metadata record" + e.getLocalizedMessage())); } catch (final IOException e) { LOG.error(e.getMessage()); mdName.setComponentError(new UserError( "Failed to add the new Metadata record" + e.getLocalizedMessage())); } catch (final ParserConfigurationException e) { LOG.error(e.getMessage()); mdName.setComponentError(new UserError( "Failed to add the new Metadata record" + e.getLocalizedMessage())); } } } } private Element getMetadataContent() throws SAXException, IOException, ParserConfigurationException { final String fileContent = receiver.getFileContent(); return XmlUtil.string2Dom(fileContent).getDocumentElement(); } }); final Button cnclAdd = new Button("Cancel", new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); hl.addComponent(btnAdd); hl.addComponent(cnclAdd); subwindow.addComponent(mdName); subwindow.addComponent(status); subwindow.addComponent(upload); subwindow.addComponent(progressLayout); subwindow.addComponent(hl); mainWindow.addWindow(subwindow); }
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();/*w ww . java2 s . c o m*/ outUpload.setReceiver(new Upload.Receiver() { @Override 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; }
From source file:org.lunifera.vaaclipse.ui.preferences.addon.internal.impexp.ImportPreferences.java
License:Open Source License
@Override public Component getComponent(OptionDialog optionDialog) { CssLayout layout = new CssLayout(); layout.addStyleName("import"); Upload upload = new Upload("Select file with preferences for upload", this); upload.setWidth("100%"); upload.setButtonCaption("Upload"); upload.addSucceededListener(this); layout.addComponent(upload);/* www . j a v a2s . c om*/ layout.addComponent(new Label("Select preferences to import")); createPreferencesTable(layout, new ArrayList<PreferencesPage>()); createStatusLabel(layout, "Choose file with preferences"); return layout; }