UploadHandler(final String fileName, final long fileSize, final UploadLayout view, final long maxSize, final Upload upload, final String mimeType, final SoftwareModule selectedSw, final SoftwareModuleManagement softwareManagement) { super(); this.aborted = false; this.fileName = fileName; this.fileSize = fileSize; this.view = view; this.maxSize = maxSize; this.upload = upload; this.mimeType = mimeType; this.selectedSw = selectedSw; this.i18n = SpringContextHelper.getBean(VaadinMessageSource.class); this.eventBus = SpringContextHelper.getBean(EventBus.UIEventBus.class); this.artifactUploadState = SpringContextHelper.getBean(ArtifactUploadState.class); this.softwareModuleManagement = softwareManagement; eventBus.subscribe(this); }
public ApplianceUploader() { this.upload = new Upload(); this.upload.setButtonCaption(null); this.upload.setReceiver(this); this.upload.addFailedListener(this); this.upload.setImmediate(false); final UploadInfoWindow uploadInfoWindow = new UploadInfoWindow(this.upload); this.upload.addStartedListener(new StartedListener() { @Override public void uploadStarted(final StartedEvent event) { if (uploadInfoWindow.getParent() == null) { ViewUtil.addWindow(uploadInfoWindow); } } }); this.verLayout.setSpacing(true); this.verLayout.addStyleName(StyleConstants.COMPONENT_SPACING); this.verLayout.addComponent(this.upload); this.panel.setWidth("100%"); this.panel.setContent(this.verLayout); setCompositionRoot(this.panel); }
protected void createUpload() { this.upload = new Upload(); this.upload.setButtonCaption(getString(MAINTENANCE_SSLCONFIGURATION_UPLOAD)); this.upload.setReceiver(this); this.upload.addFailedListener(this); this.upload.addSucceededListener(this); this.upload.setImmediate(false); final UploadInfoWindow uploadInfoWindow = new UploadInfoWindow(this.upload); this.upload.addStartedListener((StartedListener) event -> { if (uploadInfoWindow.getParent() == null) { ViewUtil.addWindow(uploadInfoWindow); } }); }
@AutoGenerated private VerticalLayout buildMainLayout() { // common part: create layout mainLayout = new VerticalLayout(); mainLayout.setImmediate(false); mainLayout.setWidth("-1px"); mainLayout.setHeight("-1px"); mainLayout.setMargin(true); mainLayout.setSpacing(true); // top-level component properties setWidth("-1px"); setHeight("-1px"); // upload_1 upload = new Upload(); upload.setImmediate(false); upload.setWidth("-1px"); upload.setHeight("-1px"); mainLayout.addComponent(upload); return mainLayout; }
@Override public void uploadSucceeded(Upload.SucceededEvent event) { try { image = baos.toByteArray(); File file = new File(); file.setBody(image); file.setScope(File.SCOPE.CASE); file.setFileName(filename); file.setMime(file.getId() != null ? file.getMime() : mimeType); file.setSize(image.length); FileField fileField = new FileField(file); addComponent(fileField, getComponentIndex(fileUpload)); checkVisibility(); } catch (Exception ex) { Logger.getLogger(FileManager.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); } }
@Override public void uploadSucceeded(Upload.SucceededEvent event) { try { image = baos.toByteArray(); binder.commit(); document = binder.getItemDataSource().getBean(); document.setUpdateDate(new Date()); document.setName(document.getId() != null ? document.getName() : filename); document.setBody(image); document.setMime(document.getId() != null ? document.getMime() : mimeType); document.setSize(image.length); binder.setItemDataSource(document); checkVisibility(); } catch (FieldGroup.CommitException ex) { Logger.getLogger(DocumentFormLayout.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); } }
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(); } else { receiver.reset(); } } }); return changePictureUpload; }
public JUploader() { setWidth("100%"); setMargin(new MarginInfo(true, false, true, false)); setStyleName("j-upload"); upload = new Upload(); upload.setWidth("100%"); upload.setImmediate(true); addComponent(upload); pi = new JProgressIndicator(); upload.addProgressListener(pi); addComponent(pi); pi.setVisible(false); receiver = new JFileReceiver(); upload.setReceiver(receiver); upload.addSucceededListener(this); upload.addStartedListener(this); }
/** * Invoked when the upload reached the Web Server (not the CMIS server). * * @param event the Upload successful event. */ @Override public void uploadSucceeded(Upload.SucceededEvent event) { if (fileName == null) { fileName = event.getFilename(); } String mimeType = event.getMIMEType(); long length = event.getLength(); InputStream stream = new ByteArrayInputStream(outputStream.toByteArray()); documentView = client.upload(parent, fileName, mimeType, stream, BigInteger.valueOf(length), versioningState, checkInComment, properties); onCmisUploadReceived(documentView); }
public PluginUploader(ServerApi server) { this.server = server; this.upload = new Upload(); this.upload.setButtonCaption("Upload"); this.upload.setReceiver(this); this.upload.addFailedListener(this); this.upload.addSucceededListener(this); this.upload.setImmediate(false); final UploadInfoWindow uploadInfoWindow = new UploadInfoWindow(this.upload); this.upload.addStartedListener(new StartedListener() { @Override public void uploadStarted(final StartedEvent event) { if (uploadInfoWindow.getParent() == null) { ViewUtil.addWindow(uploadInfoWindow); } } }); this.verLayout.setSpacing(true); this.verLayout.addStyleName(StyleConstants.COMPONENT_SPACING); this.verLayout.addComponent(this.upload); this.panel.setWidth("100%"); this.panel.setContent(this.verLayout); setCompositionRoot(this.panel); }
public DbRestorer(RestoreServiceApi restoreService, ServerApi server, ValidationApi validator) { this.restoreService = restoreService; this.server = server; this.validator = validator; this.upload = new Upload(); this.upload.setButtonCaption(VmidcMessages.getString(VmidcMessages_.UPLOAD_RESTORE)); this.upload.setReceiver(this); this.upload.addFailedListener(this); this.upload.addSucceededListener(this); this.upload.setImmediate(false); final UploadInfoWindow uploadInfoWindow = new UploadInfoWindow(this.upload); this.upload.addStartedListener(new StartedListener() { @Override public void uploadStarted(final StartedEvent event) { if (uploadInfoWindow.getParent() == null) { ViewUtil.addWindow(uploadInfoWindow); } } }); this.verLayout.setSpacing(true); this.panel.setWidth("100%"); this.panel.setContent(this.verLayout); this.verLayout.addComponent(this.upload); this.verLayout.addStyleName(StyleConstants.COMPONENT_SPACING); setCompositionRoot(this.panel); }
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); 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); }
@Override public void uploadSucceeded(Upload.SucceededEvent event) { image = baos.toByteArray(); document.setCreateDate(new Date()); document.setBody(image); document.setSize(image.length); checkVisibility(); }
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); 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); }
void buildLayout() { final HorizontalLayout horizontalLayout = new HorizontalLayout(); upload = new Upload(); upload.setEnabled(false); upload.setButtonCaption("Bulk Upload"); upload.setReceiver(this); upload.setImmediate(true); upload.setWidthUndefined(); upload.addSucceededListener(this); upload.addFailedListener(this); upload.addStartedListener(this); horizontalLayout.addComponent(upload); horizontalLayout.setComponentAlignment(upload, Alignment.BOTTOM_RIGHT); setCompositionRoot(horizontalLayout); }
protected void addUpload() { this.upload = new Upload(null, receiver); upload.setButtonCaption(i18nManager.getMessage(Messages.UPLOAD_SELECT)); upload.setImmediate(true); 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); }
/** * @param upload The component that will serve this receiver * @param maxFileSize The maximum size of files that will be accepted (in bytes). -1 in case of no limit. */ public InMemoryUploadReceiver(Upload upload, long maxFileSize) { this.upload = upload; this.maxFileSize = maxFileSize; this.notificationManager = ExplorerApp.get().getNotificationManager(); upload.setReceiver(this); upload.addListener((StartedListener) this); upload.addListener((ProgressListener) this); }
@Override protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); setContent(layout); Upload upload = new Upload("Upload CSV", new Upload.Receiver() { @Override public OutputStream receiveUpload(String name, String mime) { tempCSV = new ByteArrayOutputStream(); return tempCSV; } } ); upload.setImmediate(true); upload.addFinishedListener(new Upload.FinishedListener() { @Override public void uploadFinished(Upload.FinishedEvent finishedEvent) { pivotTable.setData(tempCSV.toString()); } }); pivotTable = new PivotTable(); layout.addComponents(upload, pivotTable); }
public VaadinImportDialog(String title) { super(title); inputStream = new CloseablePipedInputStream(); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSpacing(false); upload = new Upload(null, this); horizontalLayout.addComponent(upload); horizontalLayout.setExpandRatio(upload, 1.0F); setContent(horizontalLayout); setModal(true); UI.getCurrent().addWindow(this); addCloseListener(new CloseListener() { private static final long serialVersionUID = 1L; @Override public void windowClose(CloseEvent e) { try { inputStream.close(); } catch (IOException e1) { e1.printStackTrace(); } } }); }
/** * this method gets called immediately after upload is finished */ @Override public void uploadFinished(final Upload.FinishedEvent event) { state.setValue("Idle"); pi.setVisible(false); textualProgress.setVisible(false); cancelButton.setVisible(false); }
/** * this method gets called immediately after upload is started */ @Override public void uploadStarted(final Upload.StartedEvent event) { pi.setValue(0f); pi.setVisible(true); pi.setPollingInterval(500); // hit server frequently to get textualProgress.setVisible(true); // updates to client state.setValue("Uploading"); fileName.setValue(event.getFilename()); cancelButton.setVisible(true); }
public UploadComponent(String buttonCaption, String sessionId, int maxSize, String folderPath) { upload = new Upload(); this.addComponent(upload); this.maxSize = maxSize; upload.setReceiver( this); this.directory = folderPath; upload.setButtonCaption(buttonCaption); upload.addSucceededListener((Upload.SucceededListener) this); upload.addFailedListener((Upload.FailedListener) this); upload.addProgressListener((Upload.ProgressListener) this); upload.addFinishedListener((Upload.FinishedListener) this); processingLayout = new HorizontalLayout(); processingLayout.setSpacing(true); processingLayout.setVisible(false); this.addComponent(processingLayout); progressBar = new ProgressBar(); processingLayout.addComponent(progressBar); cancelProcessing = new Button("cancel", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { cancelled = true; upload.interruptUpload(); } }); processingLayout.addComponent(cancelProcessing); }
private void forms(CssLayout container) { VerticalLayout form = new VerticalLayout(); form.addStyleName(Bootstrap.Forms.FORM.styleName()); form.setSpacing(true); 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); }
private HorizontalLayout buildMainLayout() { // common part: create layout mainLayout = new HorizontalLayout(); mainLayout.setImmediate(false); mainLayout.setWidth("100%"); mainLayout.setHeight("-1px"); mainLayout.setMargin(false); // top-level component properties setWidth("100%"); setHeight("-1px"); // upload_1 uploadFile = new Upload(); uploadFile.setImmediate(false); uploadFile.setWidth("-1px"); uploadFile.setHeight("-1px"); mainLayout.addComponent(uploadFile); // btnRemove removeFile = new Button(); removeFile.setCaption("Borrar"); removeFile.setImmediate(false); removeFile.setWidth("-1px"); removeFile.setHeight("-1px"); mainLayout.addComponent(removeFile); mainLayout.setComponentAlignment(removeFile, Alignment.BOTTOM_LEFT); // btnDownload downloadFile = new Button(); downloadFile.setCaption("Bajar"); downloadFile.setImmediate(false); downloadFile.setWidth("-1px"); downloadFile.setHeight("-1px"); mainLayout.addComponent(downloadFile); mainLayout.setComponentAlignment(downloadFile, Alignment.BOTTOM_LEFT); mainLayout.setExpandRatio(downloadFile, 1.0f); return mainLayout; }
private VerticalLayout buildMainLayout() { // common part: create layout mainLayout = new VerticalLayout(){ @Override public void attach() { super.attach(); ImageField.this.application = getApplication(); } }; mainLayout.setImmediate(false); mainLayout.setWidth("-1px"); mainLayout.setHeight("-1px"); mainLayout.setMargin(false); // top-level component properties setWidth("-1px"); setHeight("-1px"); // hlImage hlImage = buildHlImage(); mainLayout.addComponent(hlImage); // uploadImage uploadImage = new Upload(); uploadImage.setImmediate(false); uploadImage.setWidth("-1px"); uploadImage.setHeight("-1px"); mainLayout.addComponent(uploadImage); mainLayout.setExpandRatio(uploadImage, 1.0f); return mainLayout; }
private HorizontalLayout buildHorizontalLayoutFileToolbox() { // common part: create layout horizontalLayoutFileToolbox = new HorizontalLayout(); horizontalLayoutFileToolbox.setImmediate(false); horizontalLayoutFileToolbox.setWidth("100.0%"); horizontalLayoutFileToolbox.setHeight("-1px"); horizontalLayoutFileToolbox.setMargin(false); // uploadFile uploadFile = new Upload(); uploadFile.setImmediate(false); uploadFile.setWidth("-1px"); uploadFile.setHeight("-1px"); horizontalLayoutFileToolbox.addComponent(uploadFile); // buttonDownloadFile btnDownloadFile = new Button(); btnDownloadFile.setCaption("Bajar"); btnDownloadFile.setImmediate(false); btnDownloadFile.setWidth("-1px"); btnDownloadFile.setHeight("-1px"); horizontalLayoutFileToolbox.addComponent(btnDownloadFile); horizontalLayoutFileToolbox.setComponentAlignment(btnDownloadFile, new Alignment(9)); // btnRemoveFile btnRemoveFile = new Button(); btnRemoveFile.setCaption("Eliminar"); btnRemoveFile.setImmediate(true); btnRemoveFile.setWidth("-1px"); btnRemoveFile.setHeight("-1px"); horizontalLayoutFileToolbox.addComponent(btnRemoveFile); horizontalLayoutFileToolbox.setExpandRatio(btnRemoveFile, 1.0f); horizontalLayoutFileToolbox.setComponentAlignment(btnRemoveFile, new Alignment(9)); return horizontalLayoutFileToolbox; }
protected void initialise(String buttonCaption){ initialise(buttonCaption,new Upload.Receiver(){ private static final long serialVersionUID=-4952934177751492620L; @Override public OutputStream receiveUpload(String filename, String mimeType){ FileOutputStream fos = null; try { file = File.createTempFile("import",".seq"); for(LocalResourceWatcher watcher:theWatchers){ watcher.addLocalResource(file); } fos = new FileOutputStream(file); } catch (IOException e) { msg=new Message("IO error reading uploaded file", e); if(file.exists()){ file.delete(); } return null; } return fos; } }); }
private void initUpload() { this.upload = new Upload("", new Upload.Receiver() { private static final long serialVersionUID = 1L; @Override public OutputStream receiveUpload(final String filename, final String mimeType) { try { /* * Here, we'll stored the uploaded file as a temporary file. * No doubt there's a way to use a ByteArrayOutputStream, a * reader around it, use ProgressListener (and a progress * bar) and a separate reader thread to populate a container * *during* the update. * * This is quick and easy example, though. */ ImportSelectFile.this.tempFile = File.createTempFile("temp", ".csv"); return new FileOutputStream(ImportSelectFile.this.tempFile); } catch (final IOException e) { e.printStackTrace(); return null; } } }); }
private void finishListener() { this.upload.addFinishedListener(new Upload.FinishedListener() { private static final long serialVersionUID = 1L; @Override public void uploadFinished(final Upload.FinishedEvent finishedEvent) { UI ui = UI.getCurrent(); ui.access(() -> { ImportSelectFile.this.selectedFilename = new File(finishedEvent.getFilename()); ImportSelectFile.this.uploadComplete = true; ImportSelectFile.this.progress.setVisible(false); ImportSelectFile.this.progressBar.setValue(1.0f); ImportSelectFile.this.progressBar.setVisible(true); ImportSelectFile.this.progressBar .setCaption("Completed uploading file: " + ImportSelectFile.this.selectedFilename.getName() + " Total size: " + finishedEvent.getLength() + " bytes"); ImportSelectFile.this.completionMessage.setValue( "The upload of File " + ImportSelectFile.this.selectedFilename + " has been completed."); SMNotification.show("The upload has completed. Click 'Next'", Type.TRAY_NOTIFICATION); }); } }); }
public UploadProjectPanel(MideaasUI ui) { super("Upload Project"); upload.addSucceededListener((Upload.SucceededListener) this); upload.addFailedListener((Upload.FailedListener) this); setIcon(Icons.BOX_LABEL); this.setContent(upload); this.setWidth("100%"); this.ui =ui; }
public MusicUploader(IMusicUploader caller) { callback = caller; callback.onUploadFinished(); setCaption(Messages.getString("uploadMusic")); //$NON-NLS-1$ this.upload = new Upload(); upload.setButtonCaption(Messages.getString("upload")); //$NON-NLS-1$ upload.setReceiver(this); upload.addStartedListener(this); upload.addSucceededListener(this); upload.addProgressListener(this); upload.addFailedListener(this); upload.addFinishedListener(this); setResizable(false); setDraggable(false); final VerticalLayout stateLayout = new VerticalLayout(); stateLayout.setSpacing(true); stateLayout.addComponent(upload); final VerticalLayout l = new VerticalLayout(); progressBar.setCaption(Messages.getString("uploading")); //$NON-NLS-1$ l.addComponent(stateLayout); progressBar.setVisible(false); textualProgress.setVisible(false); l.addComponent(progressBar); l.addComponent(textualProgress); setContent(l); setModal(true); l.setMargin(true); }
public Upload getUpload() { return this.upload; }
public UploadInfoWindow(final Upload upload, final ManejadorArchivo lineBreakCounter) { super("Progreso"); this.counter = lineBreakCounter; setWidth(350, Unit.PIXELS); addStyleName("upload-info"); setResizable(true); setDraggable(true); center(); final FormLayout l = new FormLayout(); setContent(l); l.setMargin(true); final HorizontalLayout stateLayout = new HorizontalLayout(); stateLayout.setSpacing(true); stateLayout.addComponent(state); cancelButton = new Button("Cancelar"); cancelButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 6204601183664759576L; @Override public void buttonClick(final ClickEvent event) { upload.interruptUpload(); } }); cancelButton.setVisible(false); cancelButton.setStyleName("small"); stateLayout.addComponent(cancelButton); stateLayout.setCaption("Estado Actual: "); state.setValue("Desocupado"); l.addComponent(stateLayout); fileName.setCaption("Nombre de Archivo: "); l.addComponent(fileName); result.setCaption("Saltos de Líneas Contados: "); l.addComponent(result); progressBar.setCaption("En Curso: "); progressBar.setVisible(false); l.addComponent(progressBar); textualProgress.setVisible(false); l.addComponent(textualProgress); upload.addStartedListener(this); upload.addProgressListener(this); upload.addFailedListener(this); upload.addSucceededListener(this); upload.addFinishedListener(this); }
@AutoGenerated private VerticalLayout buildMainLayout() { // common part: create layout mainLayout = new VerticalLayout(); mainLayout.setImmediate(false); mainLayout.setWidth("-1px"); mainLayout.setHeight("-1px"); mainLayout.setMargin(true); mainLayout.setSpacing(true); // top-level component properties setWidth("-1px"); setHeight("-1px"); // upload upload = new Upload(); upload.setCaption("Upload Xacml Policy File"); upload.setImmediate(false); upload.setWidth("-1px"); upload.setHeight("-1px"); mainLayout.addComponent(upload); // checkBoxImportAttributes checkBoxImportAttributes = new CheckBox(); checkBoxImportAttributes .setCaption("Import attributes into attribute dictionary."); checkBoxImportAttributes.setImmediate(false); checkBoxImportAttributes.setWidth("-1px"); checkBoxImportAttributes.setHeight("-1px"); mainLayout.addComponent(checkBoxImportAttributes); // checkBoxIgnoreStandard checkBoxIgnoreStandard = new CheckBox(); checkBoxIgnoreStandard.setCaption("Ignore Standard Attributes"); checkBoxIgnoreStandard.setImmediate(false); checkBoxIgnoreStandard.setWidth("-1px"); checkBoxIgnoreStandard.setHeight("-1px"); mainLayout.addComponent(checkBoxIgnoreStandard); mainLayout.setComponentAlignment(checkBoxIgnoreStandard, new Alignment( 20)); // checkBoxImportObligations checkBoxImportObligations = new CheckBox(); checkBoxImportObligations .setCaption("Import obligations into obligation dictionary."); checkBoxImportObligations.setImmediate(false); checkBoxImportObligations.setWidth("-1px"); checkBoxImportObligations.setHeight("-1px"); mainLayout.addComponent(checkBoxImportObligations); // checkBoxImportAdvice checkBoxImportAdvice = new CheckBox(); checkBoxImportAdvice .setCaption("Import advice into advice dictionary."); checkBoxImportAdvice.setImmediate(false); checkBoxImportAdvice.setWidth("-1px"); checkBoxImportAdvice.setHeight("-1px"); mainLayout.addComponent(checkBoxImportAdvice); return mainLayout; }
/** * @return the upload */ public Upload getUpload() { return upload; }
@Override protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); ; setContent(layout); Webcam upload = new Webcam(); upload.setReceiver(new Upload.Receiver() { @Override public OutputStream receiveUpload(String filename, String mimeType) { try { receivedImageFile = File.createTempFile( "img" + System.currentTimeMillis(), ".png"); return new FileOutputStream(receivedImageFile); } catch (IOException e) { e.printStackTrace(); } return null; } }); upload.addCaptureSucceededListener(new Webcam.CaptureSucceededListener() { @Override public void captureSucceeded(Webcam.CaptureSucceededEvent event) { // Face detect Mat original = Imgcodecs.imread(receivedImageFile .getAbsolutePath()); Rect[] faces = faceDetect(original); BufferedImage detectedImage = toBufferedImage(original); BufferedImage overlay = loadImage(new File(TROLL_IMAGE)); Graphics2D g = detectedImage.createGraphics(); for (int i = 0; i < faces.length; i++) { Rect rect = faces[i]; g.drawImage(overlay, rect.x, rect.y, rect.x + rect.width, rect.y + rect.height, 0, 0, overlay.getWidth(), overlay.getHeight(), null); } g.dispose(); // remove previous results if (image != null) { layout.removeComponent(image); } // add image image = new DynamicImage(detectedImage); layout.addComponent(image); } }); layout.addComponent(upload); }