List of usage examples for com.vaadin.ui ProgressBar setVisible
@Override public void setVisible(boolean visible)
From source file:com.esofthead.mycollab.mobile.module.project.ui.form.field.ProjectFormAttachmentUploadField.java
License:Open Source License
public ProjectFormAttachmentUploadField() { resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class); currentPollInterval = UI.getCurrent().getPollInterval(); receiver = createReceiver();/* w ww. j ava2s. co m*/ attachmentBtn = new MultiUpload(); attachmentBtn.setButtonCaption("Select File(s)"); attachmentBtn.setImmediate(true); MultiUploadHandler handler = new MultiUploadHandler() { private LinkedList<ProgressBar> indicators; @Override public void streamingStarted(StreamVariable.StreamingStartEvent event) { } @Override public void streamingFinished(StreamVariable.StreamingEndEvent event) { String tempName = event.getFileName(); final String fileName; int index = tempName.lastIndexOf("."); if (index > 0) { String fileExt = tempName.substring(index + 1, tempName.length()); fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis() + "." + fileExt; } else { fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis(); } if (!indicators.isEmpty()) { rowWrap.replaceComponent(indicators.remove(0), MobileAttachmentUtils.renderAttachmentFieldRow( MobileAttachmentUtils.constructContent(fileName, attachmentPath), new Button.ClickListener() { private static final long serialVersionUID = 581451358291203810L; @Override public void buttonClick(Button.ClickEvent event) { fileStores.remove(fileName); } })); } if (indicators.size() == 0) { UI.getCurrent().setPollInterval(currentPollInterval); } File file = receiver.getFile(); receiveFile(file, fileName, event.getMimeType(), event.getBytesReceived()); receiver.setValue(null); } @Override public void streamingFailed(StreamVariable.StreamingErrorEvent event) { if (!indicators.isEmpty()) { Label uploadResult = new Label("Upload failed! File: " + event.getFileName()); uploadResult.setStyleName("upload-status"); rowWrap.replaceComponent(indicators.remove(0), uploadResult); } } @Override public void onProgress(StreamVariable.StreamingProgressEvent event) { long readBytes = event.getBytesReceived(); long contentLength = event.getContentLength(); float f = (float) readBytes / (float) contentLength; indicators.get(0).setValue(f); } @Override public OutputStream getOutputStream() { MultiUpload.FileDetail next = attachmentBtn.getPendingFileNames().iterator().next(); return receiver.receiveUpload(next.getFileName(), next.getMimeType()); } @Override public void filesQueued(Collection<MultiUpload.FileDetail> pendingFileNames) { UI.getCurrent().setPollInterval(500); if (indicators == null) { indicators = new LinkedList<ProgressBar>(); } for (MultiUpload.FileDetail f : pendingFileNames) { ProgressBar pi = new ProgressBar(); pi.setValue(0f); pi.setStyleName("upload-progress"); pi.setWidth("100%"); rowWrap.addComponentAsFirst(pi); pi.setEnabled(true); pi.setVisible(true); indicators.add(pi); } } @Override public boolean isInterrupted() { return false; } }; attachmentBtn.setHandler(handler); fileStores = new HashMap<String, File>(); constructUI(); }
From source file:com.esofthead.mycollab.mobile.module.project.ui.ProjectCommentInput.java
License:Open Source License
private void prepareUploadField() { receiver = createReceiver();//from w w w .j av a 2 s . co m uploadField = new MultiUpload(); uploadField.setButtonCaption(""); uploadField.setImmediate(true); MultiUploadHandler handler = new MultiUploadHandler() { private LinkedList<ProgressBar> indicators; @Override public void streamingStarted(StreamVariable.StreamingStartEvent event) { } @Override public void streamingFinished(StreamVariable.StreamingEndEvent event) { String fileName = event.getFileName(); int index = fileName.lastIndexOf("."); if (index > 0) { String fileExt = fileName.substring(index + 1, fileName.length()); fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis() + "." + fileExt; } if (!indicators.isEmpty()) { statusWrapper.replaceComponent(indicators.remove(0), createAttachmentRow(fileName)); } if (indicators.size() == 0) { UI.getCurrent().setPollInterval(currentPollInterval); } File file = receiver.getFile(); receiveFile(file, fileName, event.getMimeType(), event.getBytesReceived()); receiver.setValue(null); } @Override public void streamingFailed(StreamVariable.StreamingErrorEvent event) { if (!indicators.isEmpty()) { Label uploadResult = new Label("Upload failed! File: " + event.getFileName()); uploadResult.setStyleName("upload-status"); statusWrapper.replaceComponent(indicators.remove(0), uploadResult); } } @Override public void onProgress(StreamVariable.StreamingProgressEvent event) { long readBytes = event.getBytesReceived(); long contentLength = event.getContentLength(); float f = (float) readBytes / (float) contentLength; indicators.get(0).setValue(f); } @Override public OutputStream getOutputStream() { MultiUpload.FileDetail next = uploadField.getPendingFileNames().iterator().next(); return receiver.receiveUpload(next.getFileName(), next.getMimeType()); } @Override public void filesQueued(Collection<MultiUpload.FileDetail> pendingFileNames) { UI.getCurrent().setPollInterval(500); if (indicators == null) { indicators = new LinkedList<ProgressBar>(); } for (MultiUpload.FileDetail f : pendingFileNames) { ProgressBar pi = new ProgressBar(); pi.setValue(0f); pi.setStyleName("upload-progress"); pi.setWidth("100%"); statusWrapper.addComponent(pi); pi.setEnabled(true); pi.setVisible(true); indicators.add(pi); } } @Override public boolean isInterrupted() { return false; } }; uploadField.setHandler(handler); }
From source file:com.peergreen.webconsole.core.notifier.NotifierService.java
License:Open Source License
/** * Show current task// www. ja v a 2 s .c o m */ protected void showTask() { if (currentTask == null) { currentTask = tasks.peek(); for (final Map.Entry<UI, HorizontalLayout> taskBar : tasksBars.entrySet()) { UI ui = taskBar.getKey(); if (isUIAvailable(ui)) { ui.access(new Runnable() { @Override public void run() { taskBar.getValue().removeAllComponents(); if (currentTask != null) { ProgressBar progressBar = new ProgressBar(); progressBar.setIndeterminate(true); progressBar.setVisible(true); taskBar.getValue().addComponent(progressBar); taskBar.getValue() .addComponent(new Label(currentTask.getMessage(), ContentMode.HTML)); } } }); } } } }
From source file:control.BarcodeController.java
License:Open Source License
/** * Initializes all listeners/*from w w w .j av a2s .com*/ */ @SuppressWarnings("serial") public void init(WizardBarcodeView bw) { view = bw; /** * Button listeners */ Button.ClickListener cl = new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String src = event.getButton().getCaption(); if (src.startsWith("Print Barcodes")) { view.enablePrint(false); String project = view.getProjectCode(); logger.info("Sending print command for project " + project + " barcodes"); Printer p = view.getPrinter(); creator.printBarcodeFolderForProject(project, p.getHostname(), p.getName(), new PrintReadyRunnable(view)); Styles.notification("Barcodes printing", "Barcodes have been sent to the printer.", NotificationType.DEFAULT); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } view.enablePrint(true); } if (src.equals("Prepare Barcodes")) { if (expSelected()) { view.creationPressed(); Iterator<Extension> it = view.getDownloadButton().getExtensions().iterator(); if (it.hasNext()) view.getDownloadButton().removeExtension(it.next()); barcodeBeans = getBarcodeInfoFromSelections(view.getSelectedExperiments(), view.getSelectedSamples()); // boolean overwrite = view.getOverwrite(); String project = view.getProjectCode(); ProgressBar bar = view.getProgressBar(); bar.setVisible(true); sortBeans(barcodeBeans); if (view.getTabs().getSelectedTab() instanceof BarcodePreviewComponent) { logger.info("Preparing barcodes (tubes) for project " + project); creator.findOrCreateTubeBarcodesWithProgress(barcodeBeans, bar, view.getProgressInfo(), new TubeBarcodesReadyRunnable(view, creator, barcodeBeans)); } else { logger.info("Preparing barcodes (sheet) for project " + project); String projectID = "/" + view.getSpaceCode() + "/" + project; String name = dbManager.getProjectName(projectID); creator.findOrCreateSheetBarcodesWithProgress(barcodeBeans, bar, view.getProgressInfo(), new SheetBarcodesReadyRunnable(project, name, dbManager.getPersonForProject(projectID, "PI"), dbManager.getPersonForProject(projectID, "Contact"), view, creator, barcodeBeans)); } } else Styles.notification("Can't create Barcodes", "Please select at least one group of Sampes from the table!", NotificationType.DEFAULT); } } }; for (Button b : view.getButtons()) b.addClickListener(cl); /** * Space selection listener */ ValueChangeListener spaceSelectListener = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { view.resetProjects(); String space = view.getSpaceCode(); if (space != null) { List<String> projects = new ArrayList<String>(); for (Project p : openbis.getProjectsOfSpace(space)) { String code = p.getCode(); String name = dbManager.getProjectName("/" + space + "/" + code); if (name != null && name.length() > 0) { if (name.length() >= 80) name = name.substring(0, 80) + "..."; code += " (" + name + ")"; } projects.add(code); } view.setProjectCodes(projects); } } }; ComboBox space = view.getSpaceBox(); if (space != null) space.addValueChangeListener(spaceSelectListener); /** * Project selection listener */ ValueChangeListener projectSelectListener = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { view.resetExperiments(); String project = view.getProjectCode(); view.setAvailableTubes(0); view.resetPrinters(); view.enablePrep(projSelected()); if (project != null) { if (project.contains(" ")) project = project.split(" ")[0]; reactToProjectSelection(project); } } }; ComboBox project = view.getProjectBox(); if (project != null) project.addValueChangeListener(projectSelectListener); /** * Experiment selection listener */ ValueChangeListener expSelectListener = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { barcodeBeans = null; view.resetOptions(); view.resetSamples(); view.enablePrep(projSelected());// && optionSelected()); if (expSelected()) { List<Sample> sampleList = new ArrayList<Sample>(); Map<Sample, String> types = new HashMap<Sample, String>(); for (ExperimentBarcodeSummary exp : view.getSelectedExperiments()) { String type = exp.getBio_Type(); for (Sample s : exp.getSamples()) { sampleList.add(s); types.put(s, type); } } view.setSamples(sampleList, types); if (tubesSelected()) view.enableTubeLabelPreview(getUsefulSample()); } else view.disablePreview(); } }; view.getExperimentTable().addValueChangeListener(expSelectListener); ValueChangeListener sampSelectListener = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { barcodeBeans = null; view.resetOptions(); view.enablePrep(expSelected()); if (expSelected() && tubesSelected()) view.enableTubeLabelPreview(getUsefulSample()); } }; view.getSampleTable().addValueChangeListener(sampSelectListener); SelectedTabChangeListener tabListener = new SelectedTabChangeListener() { @Override public void selectedTabChange(SelectedTabChangeEvent event) { view.resetOptions(); view.enablePrep(projSelected()); if (tubesSelected() && expSelected()) view.enableTubeLabelPreview(getUsefulSample()); else view.disablePreview(); } }; view.getTabs().addSelectedTabChangeListener(tabListener); }
From source file:org.hip.vif.admin.admin.ui.UpgradeView.java
License:Open Source License
/** UpgradeView constructor. * * @param inVersionInstance String the instance's version (i.e. the version of the tables) * @param inVersionSoftware String the version according to the installed version * @param inThread {@link UpgradeTask} the thread managing the upgrade */ public UpgradeView(final String inVersionInstance, final String inVersionSoftware, final UpgradeThread inThread) { final IMessages lMessages = Activator.getMessages(); final VerticalLayout lLayout = initLayout(lMessages, "admin.menu.upgrade"); //$NON-NLS-1$ final Label lFeedbackMsg = new Label( String.format(TMPL_FEEDBACK, lMessages.getMessage("admin.upgrade.feedback.failure")), //$NON-NLS-1$ ContentMode.HTML);//from w w w . j a v a2s .c o m lFeedbackMsg.setVisible(false); lLayout.addComponent(lFeedbackMsg); final Label lFailures = new Label("", ContentMode.HTML); //$NON-NLS-1$ lLayout.addComponent(lFailures); lFailures.setVisible(false); final LabelValueTable lTable = new LabelValueTable(); lTable.addRow(lMessages.getMessage("admin.upgrade.version.instance"), inVersionInstance); //$NON-NLS-1$ lTable.addRow(lMessages.getMessage("admin.upgrade.version.app"), inVersionSoftware); //$NON-NLS-1$ lLayout.addComponent(lTable); lLayout.addComponent(RiplaViewHelper.createSpacer()); final Button lUpgrade = new Button(lMessages.getMessage("admin.menu.upgrade")); //$NON-NLS-1$ lLayout.addComponent(lUpgrade); lLayout.addComponent(RiplaViewHelper.createSpacer()); final ProgressBar lProgress = new ProgressBar(new Float(0.0)); lProgress.setWidth(200, Unit.PIXELS); lProgress.setVisible(false); lLayout.addComponent(lProgress); lUpgrade.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent inEvent) { lProgress.setVisible(true); lProgress.setEnabled(true); lUpgrade.setEnabled(false); UI.getCurrent().setPollInterval(POLL_RUN); final Collection<IVIFUpgrade> lFailed = inThread.upgrade(inVersionInstance, inVersionSoftware, lProgress); lProgress.setVisible(false); if (lFailed.isEmpty()) { lFeedbackMsg.setVisible(false); lFailures.setVisible(false); } else { lFeedbackMsg.setVisible(true); lFailures.setPropertyDataSource( new ObjectProperty<String>(renderFailures(lFailed), String.class)); lFailures.setVisible(true); } lUpgrade.setEnabled(true); } }); }
From source file:org.vaadin.easyuploads.MultiFileUploadExt.java
License:Open Source License
private void prepareUpload() { final FileBuffer receiver = createReceiver(); upload = new MultiUpload(); MultiUploadHandlerExt handler = new MultiUploadHandlerExt() { private static final long serialVersionUID = 1L; private LinkedList<ProgressBar> indicators; @Override/* w ww .j av a2 s .c o m*/ public void streamingStarted(StreamVariable.StreamingStartEvent event) { } @Override public void streamingFinished(StreamVariable.StreamingEndEvent event) { if (!indicators.isEmpty()) { progressBars.removeComponent(indicators.remove(0)); } if (indicators.size() == 0) { UI.getCurrent().setPollInterval(-1); } File file = receiver.getFile(); String candidateFileName = event.getFileName(); if (!StringUtils.isValidFileName(candidateFileName)) { String extension = FilenameUtils.getExtension(candidateFileName); candidateFileName = StringUtils.generateSoftUniqueId(); if (!"".equals(extension)) { candidateFileName += "." + extension; } } handleFile(file, candidateFileName, event.getMimeType(), event.getBytesReceived()); receiver.setValue(null); } @Override public void streamingFailed(StreamVariable.StreamingErrorEvent event) { for (ProgressBar progressIndicator : indicators) { progressBars.removeComponent(progressIndicator); } UI.getCurrent().setPollInterval(-1); } @Override public void onProgress(StreamVariable.StreamingProgressEvent event) { long readBytes = event.getBytesReceived(); long contentLength = event.getContentLength(); float f = (float) readBytes / (float) contentLength; indicators.get(0).setValue(f); } @Override public OutputStream getOutputStream() { MultiUpload.FileDetail next = upload.getPendingFileNames().iterator().next(); return receiver.receiveUpload(next.getFileName(), next.getMimeType()); } @Override public void filesQueued(Collection<MultiUpload.FileDetail> pendingFiles) { UI.getCurrent().setPollInterval(1000); if (indicators == null) { indicators = new LinkedList<>(); } for (MultiUpload.FileDetail f : pendingFiles) { ProgressBar pi = createProgressIndicator(); progressBars.addComponent(pi); pi.setCaption(f.getFileName()); pi.setEnabled(true); pi.setVisible(true); indicators.add(pi); } } @Override public boolean isInterrupted() { return false; } }; upload.setHandler(handler); upload.setButtonCaption(uploadButtonCaption); uploads.addComponent(upload); }