List of usage examples for com.vaadin.ui Upload addProgressListener
public Registration addProgressListener(ProgressListener listener)
From source file:com.wcs.wcslib.vaadin.widget.multifileupload.component.SmartMultiUpload.java
License:Apache License
private void initSingleUpload() { upload = new CustomUpload(); Upload singleUpload = (Upload) upload; singleUpload.setReceiver(new Upload.Receiver() { @Override//from w ww. j a v a2 s.co m public OutputStream receiveUpload(String filename, String mimeType) { return handler.getOutputStream(); } }); singleUpload.setImmediate(true); SimpleFileUploadListener uploadEventListener = new SimpleFileUploadListener(handler); singleUpload.addStartedListener(uploadEventListener); singleUpload.addProgressListener(uploadEventListener); singleUpload.addFailedListener(uploadEventListener); singleUpload.addFinishedListener(uploadEventListener); }
From source file:facs.components.UploadBox.java
License:Open Source License
public UploadBox() { this.setCaption(CAPTION); // there has to be a device selected. devices = new NativeSelect("Devices"); devices.setDescription("Select a device in order to upload information for that specific devices."); devices.setNullSelectionAllowed(false); deviceNameToId = new HashMap<String, Integer>(); for (DeviceBean bean : DBManager.getDatabaseInstance().getDevices()) { deviceNameToId.put(bean.getName(), bean.getId()); devices.addItem(bean.getName()); // System.out.println("Bean.getName: " + bean.getName() + " Bean.getId: " + bean.getId()); }//from w w w . java2 s . c o m occupationGrid = new Grid(); occupationGrid.setSizeFull(); // Create the upload component and handle all its events final Upload upload = new Upload(); upload.setReceiver(this); upload.addProgressListener(this); upload.addFailedListener(this); upload.addSucceededListener(this); upload.setVisible(false); // one can only upload csvs, if a device was selected. devices.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = 7890499571475184208L; @Override public void valueChange(ValueChangeEvent event) { upload.setVisible(event.getProperty().getValue() != null); } }); // Put the upload and image display in a panel // Panel panel = new Panel(UPLOAD_CAPTION); // panel.setWidth("100%"); VerticalLayout panelContent = new VerticalLayout(); panelContent.setSpacing(true); // panel.setContent(panelContent); panelContent.addComponent(devices); panelContent.addComponent(upload); panelContent.addComponent(progress); panelContent.addComponent(occupationGrid); panelContent.setMargin(true); panelContent.setSpacing(true); progress.setVisible(false); setCompositionRoot(panelContent); }
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 va 2s . co 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.ikasan.dashboard.ui.mappingconfiguration.window.MappingConfigurationImportWindow.java
License:BSD License
/** * Helper method to initialise this object. *///from w w w . j av a2s .co m protected void init() { this.setModal(true); super.setHeight(40.0f, Unit.PERCENTAGE); super.setWidth(40.0f, Unit.PERCENTAGE); super.center(); super.setStyleName("ikasan"); progressLayout.setSpacing(true); progressLayout.setVisible(false); progressLayout.addComponent(uploadLabel); final Upload upload = new Upload("", receiver); upload.addSucceededListener(receiver); upload.addFinishedListener(new Upload.FinishedListener() { public void uploadFinished(FinishedEvent event) { upload.setVisible(false); try { parseUploadFile(); } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Caught exception trying to import a Mapping Configuration!\n", sw.toString(), Notification.Type.ERROR_MESSAGE); } } }); final Button importButton = new Button("Import"); importButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { upload.interruptUpload(); } }); upload.addStartedListener(new Upload.StartedListener() { public void uploadStarted(StartedEvent event) { // This method gets called immediately after upload is started upload.setVisible(false); } }); upload.addProgressListener(new Upload.ProgressListener() { public void updateProgress(long readBytes, long contentLength) { // This method gets called several times during the update } }); importButton.setStyleName(ValoTheme.BUTTON_SMALL); importButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { saveImportedMappingConfiguration(); mappingConfiguration = null; progressLayout.setVisible(false); upload.setVisible(true); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Imported mapping configuration: [Client=" + mappingConfiguration.getConfigurationServiceClient().getName() + "] [Source Context=" + mappingConfiguration.getSourceContext().getName() + "] [Target Context=" + mappingConfiguration.getTargetContext().getName() + "] [Type=" + mappingConfiguration.getConfigurationType().getName() + "]", authentication.getName()); } catch (MappingConfigurationServiceException e) { if (e.getCause() instanceof DataIntegrityViolationException) { Notification.show("Caught exception trying to save an imported Mapping Configuration!", "This is due to the fact " + "that, combined, the client, type, source and target context values are unique for a Mapping Configuration. The values" + " that are being imported and not unique.", Notification.Type.ERROR_MESSAGE); } else { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Caught exception trying to save an imported Mapping Configuration!\n", sw.toString(), Notification.Type.ERROR_MESSAGE); } } close(); } }); progressLayout.addComponent(importButton); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.addComponent(new Label("Select file to upload mapping configurations.")); layout.addComponent(upload); layout.addComponent(progressLayout); Button cancelButton = new Button("Cancel"); cancelButton.setStyleName(ValoTheme.BUTTON_SMALL); cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mappingConfiguration = null; progressLayout.setVisible(false); upload.setVisible(true); close(); } }); HorizontalLayout hlayout = new HorizontalLayout(); hlayout.addComponent(cancelButton); layout.addComponent(hlayout); super.setContent(layout); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.MappingConfigurationValuesImportWindow.java
License:BSD License
/** * Helper method to initialise this object. *///w ww. j a v a 2 s .c om protected void init() { this.setModal(true); super.setHeight(40.0f, Unit.PERCENTAGE); super.setWidth(40.0f, Unit.PERCENTAGE); super.center(); super.setStyleName("ikasan"); progressLayout.setSpacing(true); progressLayout.setVisible(false); progressLayout.addComponent(uploadLabel); final Upload upload = new Upload("", receiver); upload.addSucceededListener(receiver); upload.addFinishedListener(new Upload.FinishedListener() { public void uploadFinished(FinishedEvent event) { upload.setVisible(false); parseUploadFile(); } }); final Button importButton = new Button("Import"); importButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { upload.interruptUpload(); } }); upload.addStartedListener(new Upload.StartedListener() { public void uploadStarted(StartedEvent event) { // This method gets called immediately after upload is started upload.setVisible(false); } }); upload.addProgressListener(new Upload.ProgressListener() { public void updateProgress(long readBytes, long contentLength) { // This method gets called several times during the update } }); importButton.setStyleName(ValoTheme.BUTTON_SMALL); importButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { saveImportedMappingConfigurationValues(); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Imported mapping configuration values for mapping configuration: [Client=" + mappingConfiguration.getConfigurationServiceClient().getName() + "] [Source Context=" + mappingConfiguration.getSourceContext().getName() + "] [Target Context=" + mappingConfiguration.getTargetContext().getName() + "] [Type=" + mappingConfiguration.getConfigurationType().getName() + "]", authentication.getName()); logger.info("User: " + authentication.getName() + " successfully imported the following Mapping Configuration: " + mappingConfiguration); } catch (Exception e) { Notification.show( "An error occurred trying to import a mapping configuration: " + e.getMessage(), Notification.Type.ERROR_MESSAGE); } mappingConfigurationConfigurationValuesTable.populateTable(mappingConfiguration); close(); } }); progressLayout.addComponent(importButton); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.addComponent(new Label("Select file to upload mapping configurations.")); layout.addComponent(upload); layout.addComponent(progressLayout); Button cancelButton = new Button("Cancel"); cancelButton.setStyleName(ValoTheme.BUTTON_SMALL); cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); HorizontalLayout hlayout = new HorizontalLayout(); hlayout.addComponent(cancelButton); layout.addComponent(hlayout); super.setContent(layout); }