List of usage examples for com.vaadin.ui ProgressBar setValue
public void setValue(float newValue)
From source file:de.uni_tuebingen.qbic.qbicmainportlet.DataHandler.java
License:Open Source License
/** * Method create ProjectBean for project object * /* ww w. j av a 2 s.co m*/ * @param Project project * @return ProjectBean for corresponding project */ @Deprecated ProjectBean createProjectBean(Project project) { ProjectBean newProjectBean = new ProjectBean(); List<Experiment> experiments = this.getOpenBisClient() .getExperimentsOfProjectByIdentifier(project.getIdentifier()); ProgressBar progressBar = new ProgressBar(); progressBar.setValue(this.getOpenBisClient().computeProjectStatus(project)); Date registrationDate = project.getRegistrationDetails().getRegistrationDate(); newProjectBean.setId(project.getIdentifier()); newProjectBean.setCode(project.getCode()); String desc = project.getDescription(); if (desc == null) desc = ""; newProjectBean.setDescription(desc); newProjectBean.setRegistrationDate(registrationDate); newProjectBean.setProgress(progressBar); newProjectBean.setRegistrator(project.getRegistrationDetails().getUserId()); newProjectBean.setContact(project.getRegistrationDetails().getUserEmail()); BeanItemContainer<ExperimentBean> experimentBeans = new BeanItemContainer<ExperimentBean>( ExperimentBean.class); List<String> experiment_identifiers = new ArrayList<String>(); for (Experiment experiment : experiments) { experimentBeans.addBean(this.getExperiment(experiment)); experiment_identifiers.add(experiment.getIdentifier()); } List<DataSet> datasets = (experiment_identifiers.size() > 0) ? getOpenBisClient().getFacade().listDataSetsForExperiments(experiment_identifiers) : new ArrayList<DataSet>(); newProjectBean.setContainsData(datasets.size() != 0); newProjectBean.setExperiments(experimentBeans); newProjectBean.setMembers(this.getOpenBisClient().getSpaceMembers(project.getSpaceCode())); return newProjectBean; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientStatusComponent.java
License:Open Source License
private void initUI() { status = new VerticalLayout(); status.setWidth(100.0f, Unit.PERCENTAGE); status.setMargin(new MarginInfo(true, false, false, true)); status.setSpacing(true);//from w w w . j ava2 s. c o m // status.setSizeFull(); VerticalLayout projectStatus = new VerticalLayout(); projectStatus.setMargin(new MarginInfo(true, false, true, true)); projectStatus.setSpacing(true); experiments = new Grid(); experiments.setReadOnly(true); experiments.setWidth(100.0f, Unit.PERCENTAGE); // experiments.setHeightMode(HeightMode.ROW); status.addComponent(experiments); ProgressBar progressBar = new ProgressBar(); progressBar.setValue(0f); status.addComponent(progressBar); projectStatus.addComponent(status); this.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.85f, Unit.PIXELS); this.setCompositionRoot(projectStatus); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientStatusComponent.java
License:Open Source License
public void updateUI(final ProjectBean currentBean) { BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler .computeIvacPatientStatus(currentBean); int finishedExperiments = 0; status.removeAllComponents();//from w w w . ja va 2 s .c o m status.setWidth(100.0f, Unit.PERCENTAGE); // Generate button caption column final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans); gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() { @Override public Class<String> getType() { return String.class; } @Override public String getValue(Item item, Object itemId, Object propertyId) { String status = null; if ((double) item.getItemProperty("status").getValue() > 0.0) { status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily() + ";color:" + "#2dd085" + "\">&#x" + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>"; } else { status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily() + ";color:" + "#f54993" + "\">&#x" + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>"; } return status.toString(); } }); gpc.removeContainerProperty("identifier"); experiments.setContainerDataSource(gpc); // experiments.setHeaderVisible(false); // experiments.setHeightMode(HeightMode.ROW); experiments.setHeightByRows(gpc.size()); experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS); experiments.getColumn("status").setRenderer(new ProgressBarRenderer()); // experiments.setColumnOrder("started", "code", "description", "status", "download", // "runWorkflow"); experiments.setColumnOrder("started", "code", "description", "status", "workflow"); experiments.getColumn("workflow").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId(); TabSheet parent = (TabSheet) getParent(); PatientView pv = (PatientView) parent.getParent().getParent(); WorkflowComponent wp = pv.getWorkflowComponent(); // TODO WATCH OUT NUMBER OF WORKFLOW TAB IS HARDCODED AT THE MOMENT, NO BETTER SOLUTION // FOUND SO FAR, e.g. get Tab by Name ? // TODO idea get description of item to navigate to the correct workflow ?! if (esb.getDescription().equals("Barcode Generation")) { ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(currentBean.getId()); //TODO navigate to barcode dragon rawwwr // message.add(BarcodeView.navigateToLabel); // state.notifyObservers(message); } else if (esb.getDescription().equals("Variant Annotation")) { /* * ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType"); * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&"); * sb.append("experiment="); sb.append("Q_WF_NGS_VARIANT_ANNOTATION"); * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel); * state.notifyObservers(message); */ Map<String, String> args = new HashMap<String, String>(); args.put("id", currentBean.getId()); args.put("type", "workflowExperimentType"); args.put("experiment", "Q_WF_NGS_VARIANT_ANNOTATION"); parent.setSelectedTab(9); wp.update(args); } else if (esb.getDescription().equals("Epitope Prediction")) { /* * ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType"); * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&"); * sb.append("experiment="); sb.append("Q_WF_NGS_EPITOPE_PREDICTION"); * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel); * state.notifyObservers(message); */ Map<String, String> args = new HashMap<String, String>(); args.put("id", currentBean.getId()); args.put("type", "workflowExperimentType"); args.put("experiment", "Q_WF_NGS_EPITOPE_PREDICTION"); parent.setSelectedTab(9); wp.update(args); } else if (esb.getDescription().equals("HLA Typing")) { /* * ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType"); * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&"); * sb.append("experiment="); sb.append("Q_WF_NGS_HLATYPING"); message.add(sb.toString()); * message.add(WorkflowView.navigateToLabel); state.notifyObservers(message); */ Map<String, String> args = new HashMap<String, String>(); args.put("id", currentBean.getId()); args.put("type", "workflowExperimentType"); args.put("experiment", "Q_WF_NGS_HLATYPING"); parent.setSelectedTab(9); wp.update(args); } else { Notification notif = new Notification("Workflow not (yet) available.", Type.TRAY_NOTIFICATION); // Customize it notif.setDelayMsec(60000); notif.setPosition(Position.MIDDLE_CENTER); // Show it in the page notif.show(Page.getCurrent()); } } })); experiments.getColumn("started").setRenderer(new HtmlRenderer()); ProgressBar progressBar = new ProgressBar(); progressBar.setCaption("Overall Progress"); progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS); progressBar.setStyleName("patientprogress"); status.addComponent(progressBar); status.addComponent(experiments); status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER); status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER); /** * Defined Experiments for iVac - Barcodes available -> done with project creation (done) - * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION) */ for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) { ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next(); finishedExperiments += statusBean.getStatus(); // statusBean.setDownload("Download"); statusBean.setWorkflow("Run"); } progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size()); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java
License:Open Source License
void updateProjectStatus() { BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler .computeIvacPatientStatus(currentBean); int finishedExperiments = 0; status.removeAllComponents();// w w w . j ava 2s . c o m status.setWidth(100.0f, Unit.PERCENTAGE); // Generate button caption column final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans); gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() { @Override public Class<String> getType() { return String.class; } @Override public String getValue(Item item, Object itemId, Object propertyId) { String status = null; if ((double) item.getItemProperty("status").getValue() > 0.0) { status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily() + ";color:" + "#2dd085" + "\">&#x" + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>"; } else { status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily() + ";color:" + "#f54993" + "\">&#x" + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>"; } return status.toString(); } }); gpc.removeContainerProperty("identifier"); experiments.setContainerDataSource(gpc); // experiments.setHeaderVisible(false); experiments.setHeightMode(HeightMode.ROW); experiments.setHeightByRows(gpc.size()); experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS); experiments.getColumn("status").setRenderer(new ProgressBarRenderer()); experiments.setColumnOrder("started", "code", "description", "status", "download", "runWorkflow"); ButtonRenderer downloadRenderer = new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId(); if (esb.getDescription().equals("Barcode Generation")) { new Notification("Download of Barcodes not available.", "<br/>Please create barcodes by clicking 'Run'.", Type.WARNING_MESSAGE, true) .show(Page.getCurrent()); } else if (esb.getIdentifier() == null || esb.getIdentifier().isEmpty()) { new Notification("No data available for download.", "<br/>Please do the analysis by clicking 'Run' first.", Type.WARNING_MESSAGE, true) .show(Page.getCurrent()); } else { ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); StringBuilder sb = new StringBuilder("type="); sb.append("experiment"); sb.append("&"); sb.append("id="); // sb.append(currentBean.getId()); sb.append(esb.getIdentifier()); message.add(sb.toString()); message.add(DatasetView.navigateToLabel); state.notifyObservers(message); } } }); experiments.getColumn("download").setRenderer(downloadRenderer); experiments.getColumn("runWorkflow").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId(); // TODO idea get description of item to navigate to the correct workflow ?! if (esb.getDescription().equals("Barcode Generation")) { ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(currentBean.getId()); // TODO link to barcode dragon // message.add(BarcodeView.navigateToLabel); // state.notifyObservers(message); } else { ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType"); sb.append("&"); sb.append("id="); sb.append("Q_WF_MS_PEPTIDEID"); sb.append("&"); sb.append("project="); sb.append(currentBean.getId()); message.add(sb.toString()); message.add(WorkflowView.navigateToLabel); state.notifyObservers(message); } } })); experiments.getColumn("started").setRenderer(new HtmlRenderer()); ProgressBar progressBar = new ProgressBar(); progressBar.setCaption("Overall Progress"); progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS); progressBar.setStyleName("patientprogress"); status.addComponent(progressBar); status.addComponent(experiments); status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER); status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER); /** * Defined Experiments for iVac - Barcodes available -> done with project creation (done) - * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION) */ for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) { ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next(); // HorizontalLayout experimentStatusRow = new HorizontalLayout(); // experimentStatusRow.setSpacing(true); finishedExperiments += statusBean.getStatus(); // statusBean.setDownload("Download"); statusBean.setWorkflow("Run"); /* * if ((Integer) pairs.getValue() == 0) { Label statusLabel = new Label(pairs.getKey() + ": " * + FontAwesome.TIMES.getHtml(), ContentMode.HTML); statusLabel.addStyleName("redicon"); * experimentStatusRow.addComponent(statusLabel); * statusContent.addComponent(experimentStatusRow); } * * else { * * Label statusLabel = new Label(pairs.getKey() + ": " + FontAwesome.CHECK.getHtml(), * ContentMode.HTML); statusLabel.addStyleName("greenicon"); * experimentStatusRow.addComponent(statusLabel); * statusContent.addComponent(experimentStatusRow); * * finishedExperiments += (Integer) pairs.getValue(); } * experimentStatusRow.addComponent(runWorkflow); * * } */ } progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size()); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java
License:Open Source License
/** * //w w w. j a v a 2 s. c o m * @param statusValues * @return */ public VerticalLayout initProjectStatus() { status = new VerticalLayout(); status.setWidth(100.0f, Unit.PERCENTAGE); status.setMargin(new MarginInfo(true, false, true, true)); status.setSpacing(true); // status.setCaption("Project Status"); // status.setIcon(FontAwesome.CHECK_SQUARE); status.setSizeFull(); VerticalLayout projectStatus = new VerticalLayout(); projectStatus.setCaption("Status"); projectStatus.setMargin(new MarginInfo(true, false, true, true)); projectStatus.setSpacing(true); experiments = new Grid(); experiments.setReadOnly(true); experiments.setWidth(100.0f, Unit.PERCENTAGE); status.addComponent(experiments); ProgressBar progressBar = new ProgressBar(); progressBar.setValue(0f); status.addComponent(progressBar); projectStatus.addComponent(status); return projectStatus; }
From source file:dhbw.clippinggorilla.userinterface.windows.PasswordRecoveryWindow.java
public void changeWindow() { String errorMsg;// ww w . jav a2s . com if (emailOrUsername.getValue().contains("@")) { errorMsg = UserUtils.checkEmailOnFormalCorrectness(emailOrUsername.getValue().toLowerCase()); } else { errorMsg = UserUtils.checkUsernameOnFormalCorrectness(emailOrUsername.getValue()); } if (errorMsg.isEmpty()) { VaadinUtils.middleInfoNotification(Language.get(Word.IF_USER_EXIST_CHECK_MAIL)); try { String stringEmailOrUsername = emailOrUsername.getValue(); if (stringEmailOrUsername.contains("@")) { stringEmailOrUsername = stringEmailOrUsername.toLowerCase(); } String token = UserUtils.initiateForgottenPasswordRecovery(stringEmailOrUsername); forms.removeAllComponents(); TextField resetCode = new TextField(Language.get(Word.RESET_CODE)); resetCode.setMaxLength(6); resetCode.addValueChangeListener(e -> { if (resetCode.getValue().length() > 5) { resetCode.setComponentError(null); setError(resetCode, false); } else { resetCode.setComponentError(new UserError(Language.get(Word.RESET_CODE_SIX_CHARS), AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(Language.get(Word.RESET_CODE_SIX_CHARS)); setError(resetCode, true); } }); ProgressBar strength = new ProgressBar(); PasswordField pw1 = new PasswordField(Language.get(Word.PASSWORD)); pw1.setMaxLength(51); pw1.addValueChangeListener(e -> { String pwErrorMsg = UserUtils.checkPassword(e.getValue()); strength.setValue(UserUtils.calculatePasswordStrength(e.getValue())); if (!pwErrorMsg.isEmpty()) { pw1.setComponentError(new UserError(pwErrorMsg, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.ERROR)); VaadinUtils.infoNotification(pwErrorMsg); setError(pw1, true); } else { pw1.setComponentError(null); setError(pw1, false); } }); strength.setWidth("184px"); strength.setHeight("1px"); PasswordField pw2 = new PasswordField(Language.get(Word.PASSWORD_AGAIN)); pw2.setMaxLength(51); pw2.addValueChangeListener(e -> { String pwErrorMsg = UserUtils.checkSecondPassword(pw1.getValue(), e.getValue()); if (!pwErrorMsg.isEmpty()) { pw2.setComponentError(new UserError(pwErrorMsg, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.ERROR)); VaadinUtils.infoNotification(pwErrorMsg); setError(pw2, true); } else { pw2.setComponentError(null); setError(pw2, false); } }); send.setCaption(Language.get(Word.RESET)); send.setEnabled(false); sendListener.remove(); send.addClickListener(ce -> { try { UserUtils.executeForgottenPasswordRecovery(emailOrUsername.getValue(), resetCode.getValue(), token, pw1.getValue(), pw2.getValue()); VaadinUtils.infoNotification(Language.get(Word.RESET_SUCCESSFUL)); close(); } catch (PasswordChangeException ex) { VaadinUtils.infoNotification(Language.get(Word.RESET_FAILED)); } }); forms.addComponents(resetCode, pw1, strength, pw2); center(); } catch (UserNotFoundException e) { VaadinUtils.errorNotification(Language.get(Word.RESET_FAILED)); } } else { VaadinUtils.infoNotification(errorMsg); } }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildUserTab(User user) { HorizontalLayout root = new HorizontalLayout(); root.setCaption(Language.get(Word.PROFILE)); root.setIcon(VaadinIcons.USER);/*w w w .j ava2s . com*/ root.setWidth("100%"); root.setSpacing(true); root.setMargin(true); FormLayout details = new FormLayout(); details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(details); firstNameField = new TextField(Language.get(Word.FIRST_NAME)); firstNameField.setValue(user.getFirstName()); firstNameField.setMaxLength(20); firstNameField.addValueChangeListener(event -> { String firstNameError = UserUtils.checkName(event.getValue()); if (!firstNameError.isEmpty()) { firstNameField.setComponentError(new UserError(firstNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(firstNameError); saveButton.setEnabled(setError(firstNameField, true)); } else { firstNameField.setComponentError(null); boolean enabled = setError(firstNameField, false); saveButton.setEnabled(enabled); } }); setError(firstNameField, false); lastNameField = new TextField(Language.get(Word.LAST_NAME)); lastNameField.setValue(user.getLastName()); lastNameField.setMaxLength(20); lastNameField.addValueChangeListener(event -> { String lastNameError = UserUtils.checkName(event.getValue()); if (!lastNameError.isEmpty()) { lastNameField.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(lastNameError); saveButton.setEnabled(setError(lastNameField, true)); } else { lastNameField.setComponentError(null); saveButton.setEnabled(setError(lastNameField, false)); } }); setError(lastNameField, false); usernameField = new TextField(Language.get(Word.USERNAME)); usernameField.setValue(user.getUsername()); usernameField.setMaxLength(20); usernameField.addValueChangeListener(event -> { if (!event.getValue().equals(user.getUsername())) { String userNameError = UserUtils.checkUsername(event.getValue()); if (!userNameError.isEmpty()) { usernameField.setComponentError(new UserError(userNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(userNameError); saveButton.setEnabled(setError(usernameField, true)); } else { usernameField.setComponentError(null); saveButton.setEnabled(setError(usernameField, false)); } } else { usernameField.setComponentError(null); saveButton.setEnabled(setError(usernameField, false)); } }); setError(usernameField, false); emailField = new TextField(Language.get(Word.EMAIL)); emailField.setValue(user.getEmail()); emailField.setMaxLength(256); emailField.addValueChangeListener(event -> { if (!event.getValue().equals(user.getEmail())) { String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase()); if (!email1Error.isEmpty()) { emailField.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(email1Error); saveButton.setEnabled(setError(emailField, true)); } else { emailField.setComponentError(null); saveButton.setEnabled(setError(emailField, false)); } } else { emailField.setComponentError(null); saveButton.setEnabled(setError(emailField, false)); } }); setError(emailField, false); oldPasswordField = new PasswordField(Language.get(Word.OLD_PASSWORD)); oldPasswordField.setValue(""); oldPasswordField.setMaxLength(51); oldPasswordField.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password1Error = UserUtils.checkPassword(event.getValue()); if (!password1Error.isEmpty()) { oldPasswordField.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); saveButton.setEnabled(setError(oldPasswordField, true)); } else { oldPasswordField.setComponentError(null); saveButton.setEnabled(setError(oldPasswordField, false)); } } else { oldPasswordField.setComponentError(null); saveButton.setEnabled(setError(oldPasswordField, false)); } }); setError(oldPasswordField, false); ProgressBar strength = new ProgressBar(); password1Field = new PasswordField(Language.get(Word.PASSWORD)); password1Field.setValue(""); password1Field.setMaxLength(51); password1Field.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password1Error = UserUtils.checkPassword(event.getValue()); strength.setValue(UserUtils.calculatePasswordStrength(event.getValue())); if (!password1Error.isEmpty()) { password1Field.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); saveButton.setEnabled(setError(password1Field, true)); } else { password1Field.setComponentError(null); saveButton.setEnabled(setError(password1Field, false)); } } else { password1Field.setComponentError(null); saveButton.setEnabled(setError(password1Field, false)); } }); setError(password1Field, false); strength.setWidth("184px"); strength.setHeight("1px"); password2Field = new PasswordField(Language.get(Word.PASSWORD_AGAIN)); password2Field.setValue(""); password2Field.setMaxLength(51); password2Field.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password2Error = UserUtils.checkPassword(event.getValue()) + UserUtils.checkSecondPassword(password1Field.getValue(), event.getValue()); if (!password2Error.isEmpty()) { password2Field.setComponentError(new UserError(password2Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password2Error); saveButton.setEnabled(setError(password2Field, true)); } else { password2Field.setComponentError(null); saveButton.setEnabled(setError(password2Field, false)); } } else { password2Field.setComponentError(null); saveButton.setEnabled(setError(password2Field, false)); } }); setError(password2Field, false); details.addComponents(firstNameField, lastNameField, usernameField, emailField, oldPasswordField, password1Field, strength, password2Field); return root; }
From source file:dhbw.clippinggorilla.userinterface.windows.RegisterWindow.java
public RegisterWindow() { setModal(true);/* w w w. ja v a 2 s . c o m*/ setResizable(false); setDraggable(false); setCaption(Language.get(Word.REGISTER)); addCloseShortcut(KeyCode.ENTER, null); Button save = new Button(Language.get(Word.REGISTER)); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setMargin(false); windowLayout.setSizeUndefined(); FormLayout forms = new FormLayout(); forms.setMargin(true); forms.setSizeUndefined(); TextField firstName = new TextField(Language.get(Word.FIRST_NAME)); firstName.focus(); firstName.setMaxLength(20); firstName.addValueChangeListener(event -> { String firstNameError = UserUtils.checkName(event.getValue()); if (!firstNameError.isEmpty()) { firstName.setComponentError(new UserError(firstNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(firstNameError); save.setEnabled(setError(firstName, true)); } else { firstName.setComponentError(null); boolean enabled = setError(firstName, false); save.setEnabled(enabled); } }); forms.addComponent(firstName); TextField lastName = new TextField(Language.get(Word.LAST_NAME)); lastName.setMaxLength(20); lastName.addValueChangeListener(event -> { String lastNameError = UserUtils.checkName(event.getValue()); if (!lastNameError.isEmpty()) { lastName.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(lastNameError); save.setEnabled(setError(lastName, true)); } else { lastName.setComponentError(null); save.setEnabled(setError(lastName, false)); } }); forms.addComponent(lastName); TextField userName = new TextField(Language.get(Word.USERNAME)); userName.setMaxLength(20); userName.addValueChangeListener(event -> { String userNameError = UserUtils.checkUsername(event.getValue()); if (!userNameError.isEmpty()) { userName.setComponentError(new UserError(userNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(userNameError); save.setEnabled(setError(userName, true)); } else { userName.setComponentError(null); save.setEnabled(setError(userName, false)); } }); forms.addComponent(userName); TextField email1 = new TextField(Language.get(Word.EMAIL)); email1.setMaxLength(256); email1.addValueChangeListener(event -> { String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase()); if (!email1Error.isEmpty()) { email1.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(email1Error); save.setEnabled(setError(email1, true)); } else { email1.setComponentError(null); save.setEnabled(setError(email1, false)); } }); forms.addComponent(email1); TextField email2 = new TextField(Language.get(Word.EMAIL_AGAIN)); email2.setMaxLength(256); email2.addValueChangeListener(event -> { String email2Error = UserUtils.checkEmail(event.getValue().toLowerCase()) + UserUtils.checkSecondEmail(email1.getValue().toLowerCase(), event.getValue().toLowerCase()); if (!email2Error.isEmpty()) { email2.setComponentError(new UserError(email2Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(email2Error); save.setEnabled(setError(email2, true)); } else { email2.setComponentError(null); save.setEnabled(setError(email2, false)); } }); forms.addComponent(email2); ProgressBar strength = new ProgressBar(); PasswordField password1 = new PasswordField(Language.get(Word.PASSWORD)); password1.setMaxLength(51); password1.addValueChangeListener(event -> { String password1Error = UserUtils.checkPassword(event.getValue()); strength.setValue(UserUtils.calculatePasswordStrength(event.getValue())); if (!password1Error.isEmpty()) { password1.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); save.setEnabled(setError(password1, true)); } else { password1.setComponentError(null); save.setEnabled(setError(password1, false)); } }); forms.addComponent(password1); strength.setWidth("184px"); strength.setHeight("1px"); forms.addComponent(strength); PasswordField password2 = new PasswordField(Language.get(Word.PASSWORD_AGAIN)); password2.setMaxLength(51); password2.addValueChangeListener(event -> { String password2Error = UserUtils.checkPassword(event.getValue()) + UserUtils.checkSecondPassword(password1.getValue(), event.getValue()); if (!password2Error.isEmpty()) { password2.setComponentError(new UserError(password2Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password2Error); save.setEnabled(setError(password2, true)); } else { password2.setComponentError(null); save.setEnabled(setError(password2, false)); } }); forms.addComponent(password2); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Unit.PERCENTAGE); Label placeholder = new Label(); Button cancel = new Button(Language.get(Word.CANCEL)); cancel.setIcon(VaadinIcons.CLOSE); cancel.addClickListener(ce -> { close(); }); cancel.setClickShortcut(KeyCode.ESCAPE, null); save.setEnabled(false); save.setIcon(VaadinIcons.CHECK); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addClickListener(ce -> { try { User user = UserUtils.registerUser(userName.getValue(), password1.getValue(), password2.getValue(), email1.getValue().toLowerCase(), email2.getValue().toLowerCase(), firstName.getValue(), lastName.getValue()); UserUtils.setCurrentUser(user); close(); UI.getCurrent().addWindow(ActivateWindow.get()); } catch (UserCreationException ex) { Log.error("Registration failed", ex); VaadinUtils.errorNotification(Language.get(Word.REG_FAILED)); } }); save.setClickShortcut(KeyCode.ENTER, null); footer.addComponents(placeholder, cancel, save); footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1); footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER); windowLayout.addComponent(forms); windowLayout.addComponent(footer); setContent(windowLayout); }
From source file:org.vaadin.easyuploads.MultiFileUploadExt.java
License:Open Source License
private ProgressBar createProgressIndicator() { ProgressBar progressIndicator = new ProgressBar(); progressIndicator.setValue(0f); return progressIndicator; }
From source file:org.vaadin.easyuploads.MultiFileUploadExt.java
License:Open Source License
@Override public void drop(DragAndDropEvent event) { DragAndDropWrapper.WrapperTransferable transferable = (DragAndDropWrapper.WrapperTransferable) event .getTransferable();//from w w w. ja va2 s . c o m Html5File[] files = transferable.getFiles(); for (final Html5File html5File : files) { final ProgressBar pi = new ProgressBar(); pi.setCaption(html5File.getFileName()); progressBars.addComponent(pi); final FileBuffer receiver = createReceiver(); html5File.setStreamVariable(new StreamVariable() { private static final long serialVersionUID = 1L; private String name; private String mime; @Override public OutputStream getOutputStream() { return receiver.receiveUpload(name, mime); } @Override public boolean listenProgress() { return true; } @Override public void onProgress(StreamVariable.StreamingProgressEvent event) { float p = (float) event.getBytesReceived() / (float) event.getContentLength(); pi.setValue(p); } @Override public void streamingStarted(StreamVariable.StreamingStartEvent event) { name = event.getFileName(); mime = event.getMimeType(); UI.getCurrent().setPollInterval(300); } @Override public void streamingFinished(StreamVariable.StreamingEndEvent event) { progressBars.removeComponent(pi); handleFile(receiver.getFile(), html5File.getFileName(), html5File.getType(), html5File.getFileSize()); receiver.setValue(null); } @Override public void streamingFailed(StreamVariable.StreamingErrorEvent event) { progressBars.removeComponent(pi); } @Override public boolean isInterrupted() { return false; } }); } }