Java Code Examples for com.vaadin.ui.Notification.Type

The following are top voted examples for showing how to use com.vaadin.ui.Notification.Type. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: esup-ecandidat   File: CandidatParcoursController.java   Source Code and License 7 votes vote down vote up
/**Supprime un cursus
 * @param candidat
 * @param cursus
 * @param listener
 */
public void deleteCursusPostBac(Candidat candidat,	CandidatCursusPostBac cursus, CandidatCursusExterneListener listener) {
	Assert.notNull(cursus, applicationContext.getMessage("assert.notNull", null, UI.getCurrent().getLocale()));
	/* Verrou --> normalement le lock est géré en amont mais on vérifie qd même*/
	String lockError = candidatController.getLockError(candidat.getCompteMinima(), ConstanteUtils.LOCK_CURSUS_EXTERNE);
	if (lockError!=null) {
		Notification.show(lockError, Type.ERROR_MESSAGE);
		return;
	}
	
	ConfirmWindow confirmWindow = new ConfirmWindow(applicationContext.getMessage("cursusexterne.confirmDelete", null, UI.getCurrent().getLocale()), applicationContext.getMessage("cursusexterne.confirmDeleteTitle", null, UI.getCurrent().getLocale()));
	confirmWindow.addBtnOuiListener(e -> {
		candidatCursusPostBacRepository.delete(cursus);
		candidat.getCandidatCursusPostBacs().remove(cursus);			
		listener.cursusModified(candidat.getCandidatCursusPostBacs());
	});
	UI.getCurrent().addWindow(confirmWindow);
}
 
Example 2
Project: osc-core   File: SetEmailSettingsWindow.java   Source Code and License 7 votes vote down vote up
@Override
public void submitForm() {
    try {
        if (validateForm()) {
            BaseRequest<EmailSettingsDto> request = new BaseRequest<EmailSettingsDto>();
            request.setDto(getDto());
            this.setEmailSettingsService.dispatch(request);
            this.emailLayout.populateEmailtable();
            close();
        }
    } catch (Exception e) {
        log.error("Failed to update the email settings", e);
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
    }

}
 
Example 3
Project: osc-core   File: SetEmailSettingsWindow.java   Source Code and License 6 votes vote down vote up
@Override
public void validateSettings() {
    try {
        if (validateForm()) {

            // Validate Email settings by sending an Email From and To the same email ID provided
            EmailSettingsDto dto = getDto();
            this.setEmailSettingsService.validateEmailSettings(new BaseRequest<>(dto));

            // If every things is correct attempt to send an email..
            this.setEmailSettingsService.sentTestEmail(dto.getMailServer(), dto.getPort(), dto.getEmailId(), dto.getPassword(),
                    dto.getEmailId());
            ViewUtil.iscNotification("Info: ",
                    "Email validation successful. You will be receiving an email shortly.", Type.HUMANIZED_MESSAGE);
        }
    } catch (Exception ex) {
        ViewUtil.iscNotification(
                "Email settings are incorrect. Please re-try again with correct information " + ex.getMessage(),
                Type.ERROR_MESSAGE);

        log.error("Failed to send email to the interested user(s): ", ex);

    }

}
 
Example 4
Project: holon-vaadin7   File: NotificationValidationStatusHandler.java   Source Code and License 6 votes vote down vote up
@Override
public void validationStatusChange(ValidationStatusEvent<?> statusChangeEvent) {
	if (statusChangeEvent.isInvalid()) {

		String error = showAllErrors
				? statusChangeEvent.getErrorMessages().stream().collect(Collectors.joining("<br/>"))
				: statusChangeEvent.getErrorMessage();

		if (error == null || error.trim().equals("")) {
			error = "Validation error";
		}

		if (notification != null) {
			notification.setCaption(error);
			notification.show(Page.getCurrent());
		} else {
			Notification.show(error, Type.ERROR_MESSAGE);
		}

	}
}
 
Example 5
Project: spring-cloud-microservices-docker   File: ContactForm.java   Source Code and License 6 votes vote down vote up
public void save(Button.ClickEvent event) {
    try {
        // Commit the fields from UI to DAO
        formFieldBindings.commit();

        // Save DAO to backend with direct synchronous service API
        getUI().userClient.createUser(contact);

        String msg = String.format("Saved '%s %s'.",
                contact.getFirstName(),
                contact.getLastName());
        Notification.show(msg, Type.TRAY_NOTIFICATION);
        getUI().refreshContacts();
    } catch (FieldGroup.CommitException e) {
        // Validation exceptions could be shown here
    }
}
 
Example 6
Project: esup-ecandidat   File: CtrCandPreferenceViewWindow.java   Source Code and License 6 votes vote down vote up
/**
 * @param maxColumn
 * @return le nombre de colonne gelees
 */
private Integer getFrozen(Integer maxColumn){
	if (tfFrozen.getValue()==null || tfFrozen.getValue().equals("")){
		Notification.show(applicationContext.getMessage("preference.col.frozen.error", new Object[]{0,maxColumn}, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		return null;
	}
	try{
		Integer frozen = Integer.valueOf(tfFrozen.getValue());
		if (frozen<0 || frozen>maxColumn){
			Notification.show(applicationContext.getMessage("preference.col.frozen.error", new Object[]{0,maxColumn}, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		}
		return frozen;
	}catch (Exception ex){
		Notification.show(applicationContext.getMessage("preference.col.frozen.error", new Object[]{0,maxColumn}, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		return null;
	}		
}
 
Example 7
Project: esup-ecandidat   File: AdminView.java   Source Code and License 6 votes vote down vote up
/** Supprime un verrou
 * @param lockItem le verrou a supprimer
 */
public void confirmRemoveLock(SessionPresentation lockItem) {
	Item item = uisContainer.getItem(lockItem);
	String textLock = lockItem.getId();
	if (item!=null && lockItem.getInfo()!=null){
		textLock = lockItem.getInfo();
	}
	
	ConfirmWindow confirmWindow = new ConfirmWindow(applicationContext.getMessage("admin.uiList.confirmRemoveLock", new Object[]{textLock}, UI.getCurrent().getLocale()));
	confirmWindow.addBtnOuiListener(e -> {
		Object lock = lockController.getLockBySessionItem(lockItem);
		if (lock != null){
			lockController.removeLock(lock);				
		}else{
			Notification.show(applicationContext.getMessage("admin.uiList.confirmKillUI.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);			
		}			
		majContainer();
	});
	UI.getCurrent().addWindow(confirmWindow);
}
 
Example 8
Project: esup-ecandidat   File: AdminView.java   Source Code and License 6 votes vote down vote up
/**
 * Confirme la fermeture d'une session
 * @param session la session a kill
 */
public void confirmKillSession(SessionPresentation session) {
	SessionPresentation user = (SessionPresentation) uisContainer.getParent(session);		
	String userName = applicationContext.getMessage("user.notconnected", null, UI.getCurrent().getLocale());
	if (user != null){
		userName = user.getId();
	}
	
	ConfirmWindow confirmWindow = new ConfirmWindow(applicationContext.getMessage("admin.uiList.confirmKillSession", new Object[]{session.getId(), userName}, UI.getCurrent().getLocale()));
	confirmWindow.addBtnOuiListener(e -> {
		VaadinSession vaadinSession = uiController.getSession(session);			
		Collection<SessionPresentation> listeUI = null;
		if (uisContainer.getChildren(session) != null){
			listeUI = (Collection<SessionPresentation>) uisContainer.getChildren(session);
		}			
		if (vaadinSession != null){
			uiController.killSession(vaadinSession, listeUI);
		}else{
			Notification.show(applicationContext.getMessage("admin.uiList.confirmKillSession.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		}
		removeElement(session);
	});
	UI.getCurrent().addWindow(confirmWindow);
}
 
Example 9
Project: esup-ecandidat   File: BatchController.java   Source Code and License 6 votes vote down vote up
/**
 * Lancement immediat du batch
 * 
 * @param batch
 */
public void runImmediatly(Batch batch) {
	ConfirmWindow win = new ConfirmWindow(applicationContext.getMessage("batch.immediat.ok",
			new Object[] { batch.getCodBatch() }, UI.getCurrent().getLocale()));
	win.addBtnOuiListener(e -> {
		BatchHisto histo = batchHistoRepository.findByBatchCodBatchAndStateBatchHisto(batch.getCodBatch(),
				ConstanteUtils.BATCH_RUNNING);
		if (histo == null) {
			batch.setTemIsLaunchImediaBatch(true);
			batchRepository.saveAndFlush(batch);
			Notification.show(
					applicationContext.getMessage("batch.immediat.launch", null, UI.getCurrent().getLocale()),
					Type.WARNING_MESSAGE);
		} else {
			Notification.show(
					applicationContext.getMessage("batch.immediat.nok", null, UI.getCurrent().getLocale()),
					Type.WARNING_MESSAGE);
		}
	});
	UI.getCurrent().addWindow(win);
}
 
Example 10
Project: esup-ecandidat   File: BatchController.java   Source Code and License 6 votes vote down vote up
/**
 * Lancement immediat du batch
 * 
 * @param batch
 */
public void cancelRunImmediatly(Batch batch) {
	ConfirmWindow win = new ConfirmWindow(applicationContext.getMessage("batch.immediat.cancel",
			new Object[] { batch.getCodBatch() }, UI.getCurrent().getLocale()));
	win.addBtnOuiListener(e -> {
		BatchHisto histo = batchHistoRepository.findByBatchCodBatchAndStateBatchHisto(batch.getCodBatch(),
				ConstanteUtils.BATCH_RUNNING);
		if (histo == null) {
			batch.setTemIsLaunchImediaBatch(false);
			batchRepository.saveAndFlush(batch);
			Notification.show(
					applicationContext.getMessage("batch.immediat.cancel.ok", null, UI.getCurrent().getLocale()),
					Type.WARNING_MESSAGE);
		} else {
			Notification.show(
					applicationContext.getMessage("batch.immediat.cancel.nok", null, UI.getCurrent().getLocale()),
					Type.WARNING_MESSAGE);
		}
	});
	UI.getCurrent().addWindow(win);
}
 
Example 11
Project: esup-ecandidat   File: CommissionController.java   Source Code and License 6 votes vote down vote up
/**
 * AJoute un fichier à la commission
 *
 * @param commission
 */
public void addFileToSignataire(final Commission commission) {
	/* Verrou */
	if (!lockController.getLockOrNotify(commission, null)) {
		return;
	}
	String user = userController.getCurrentUserLogin();
	String cod = ConstanteUtils.TYPE_FICHIER_SIGN_COMM + "_" + commission.getIdComm();
	UploadWindow uw = new UploadWindow(cod, ConstanteUtils.TYPE_FICHIER_GESTIONNAIRE, null, false, true);
	uw.addUploadWindowListener(file -> {
		if (file == null) {
			return;
		}
		Fichier fichier = fileController.createFile(file, user, ConstanteUtils.TYPE_FICHIER_GESTIONNAIRE);
		commission.setFichier(fichier);
		commissionRepository.save(commission);
		Notification.show(applicationContext.getMessage("window.upload.success", new Object[] {file.getFileName()},
				UI.getCurrent().getLocale()), Type.TRAY_NOTIFICATION);
		uw.close();
	});
	uw.addCloseListener(e -> lockController.releaseLock(commission));
	UI.getCurrent().addWindow(uw);
}
 
Example 12
Project: esup-ecandidat   File: CommissionController.java   Source Code and License 6 votes vote down vote up
/**
 * Supprime un fichier d'une commission
 *
 * @param commission
 */
public void deleteFileToSignataire(final Commission commission) {
	/* Verrou */
	if (!lockController.getLockOrNotify(commission, null)) {
		return;
	}
	if (!fileController.isModeFileStockageOk(commission.getFichier(), true)) {
		return;
	}
	Fichier fichier = commission.getFichier();
	if (fichier == null) {
		Notification.show(applicationContext.getMessage("file.error", null, UI.getCurrent().getLocale()),
				Type.WARNING_MESSAGE);
		lockController.releaseLock(commission);
		return;
	}
	ConfirmWindow confirmWindow = new ConfirmWindow(
			applicationContext.getMessage("file.window.confirmDelete", new Object[] {fichier.getNomFichier()},
					UI.getCurrent().getLocale()),
			applicationContext.getMessage("file.window.confirmDeleteTitle", null, UI.getCurrent().getLocale()));
	confirmWindow.addBtnOuiListener(file -> {
		removeFileToCommission(commission, fichier);
	});
	confirmWindow.addCloseListener(e -> lockController.releaseLock(commission));
	UI.getCurrent().addWindow(confirmWindow);
}
 
Example 13
Project: esup-ecandidat   File: CandidaturePieceController.java   Source Code and License 6 votes vote down vote up
/**
 * @param listePj
 * @param notification
 * @return true si les pieces de la candidatures permettent de transmettre le
 *         dossier
 */
public Boolean isOkToTransmettreCandidatureStatutPiece(List<PjPresentation> listePj, Boolean notification) {
	for (PjPresentation pj : listePj) {
		if (pj.getCodStatut() == null) {
			if (notification) {
				Notification.show(applicationContext.getMessage("candidature.validPJ.erreur.pj",
						new Object[] { pj.getLibPj() }, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
			}
			return false;
		} else if (pj.getCodStatut().equals(NomenclatureUtils.TYP_STATUT_PIECE_ATTENTE)) {
			if (notification) {
				Notification.show(applicationContext.getMessage("candidature.validPJ.erreur.pj.attente",
						new Object[] { pj.getLibPj() }, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
			}
			return false;
		} else if (pj.getCodStatut().equals(NomenclatureUtils.TYP_STATUT_PIECE_REFUSE)) {
			if (notification) {
				Notification.show(applicationContext.getMessage("candidature.validPJ.erreur.pj.refus",
						new Object[] { pj.getLibPj() }, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
			}
			return false;
		}
	}
	return true;
}
 
Example 14
Project: esup-ecandidat   File: LockCandidatController.java   Source Code and License 6 votes vote down vote up
/** Supprime tous les locks
 * @param listeLock
 * @param listener
 */
public void deleteAllLock(List<LockCandidat> listeLock, LockCandidatListener listener){
	ConfirmWindow confirmWindow = new ConfirmWindow(applicationContext.getMessage("lock.candidat.all.window.confirmDelete", null, UI.getCurrent().getLocale()), applicationContext.getMessage("lock.candidat.window.confirmDeleteTitle", null, UI.getCurrent().getLocale()));
	confirmWindow.addBtnOuiListener(e -> {
		Boolean allLockDeleted = true;
		for (LockCandidat lock : listeLock){
			if (!lockCandidatRepository.exists(lock.getId())){
				/* Contrôle que le lock existe encore */
				allLockDeleted = false;						
			}else{
				lockCandidatRepository.delete(lock.getId());
			}
		}
		
		if (!allLockDeleted){
			Notification.show(applicationContext.getMessage("lock.candidat.all.error.delete", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		}else{
			Notification.show(applicationContext.getMessage("lock.candidat.all.delete.ok", null, UI.getCurrent().getLocale()), Type.TRAY_NOTIFICATION);
		}
		
		listener.lockCandidatAllDeleted();
	});
	UI.getCurrent().addWindow(confirmWindow);
}
 
Example 15
Project: holon-vaadin   File: NotificationValidationStatusHandler.java   Source Code and License 6 votes vote down vote up
@Override
public void validationStatusChange(ValidationStatusEvent<?> statusChangeEvent) {
	if (statusChangeEvent.isInvalid()) {

		String error = showAllErrors
				? statusChangeEvent.getErrorMessages().stream().collect(Collectors.joining("<br/>"))
				: statusChangeEvent.getErrorMessage();

		if (error == null || error.trim().equals("")) {
			error = "Validation error";
		}

		if (notification != null) {
			notification.setCaption(error);
			notification.show(Page.getCurrent());
		} else {
			Notification.show(error, Type.ERROR_MESSAGE);
		}

	}
}
 
Example 16
Project: esup-ecandidat   File: UserController.java   Source Code and License 6 votes vote down vote up
/**
 * Change le rôle de l'utilisateur courant
 * 
 * @param username
 *            le nom de l'utilisateur a prendre
 */
public void switchToUser(String username) {
	Assert.hasText(username, applicationContext.getMessage("assert.hasText", null, UI.getCurrent().getLocale()));

	/* Vérifie que l'utilisateur existe */
	try {
		UserDetails details = userDetailsService.loadUserByUsername(username);
		if (details == null || details.getAuthorities() == null || details.getAuthorities().size() == 0) {
			Notification.show(applicationContext.getMessage("admin.switchUser.usernameNotFound",
					new Object[] { username }, UI.getCurrent().getLocale()), Notification.Type.WARNING_MESSAGE);
			return;
		}
	} catch (UsernameNotFoundException unfe) {
		Notification.show(applicationContext.getMessage("admin.switchUser.usernameNotFound",
				new Object[] { username }, UI.getCurrent().getLocale()), Notification.Type.WARNING_MESSAGE);
		return;
	}
	String switchToUserUrl = MethodUtils.formatSecurityPath(loadBalancingController.getApplicationPath(false),
			ConstanteUtils.SECURITY_SWITCH_PATH) + "?" + SwitchUserFilter.SPRING_SECURITY_SWITCH_USERNAME_KEY + "="
			+ username;
	Page.getCurrent().open(switchToUserUrl, null);
}
 
Example 17
Project: esup-ecandidat   File: UserController.java   Source Code and License 6 votes vote down vote up
/**
 * Valide le mot de passe candidat
 * 
 * @param password
 *            le mot de passe
 * @param correctHash
 *            le hash correct
 * @return true si le mot de passe correspond
 */
private Boolean validPwdCandidat(String password, CompteMinima cptMin) {
	if (testController.isTestMode()) {
		return true;
	}
	try {
		PasswordHashService passwordHashUtils = PasswordHashService.getImplementation(cptMin.getTypGenCptMin());
		if (!passwordHashUtils.validatePassword(password, cptMin.getPwdCptMin())) {
			Notification.show(applicationContext.getMessage("compteMinima.connect.pwd.error", null,
					UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
			return false;
		} else {
			return true;
		}
	} catch (CustomException e) {
		Notification.show(
				applicationContext.getMessage("compteMinima.connect.pwd.error", null, UI.getCurrent().getLocale()),
				Type.WARNING_MESSAGE);
		return false;
	}
}
 
Example 18
Project: esup-ecandidat   File: CandidatParcoursController.java   Source Code and License 6 votes vote down vote up
/** Edition du bac
 */
public void editBac(Candidat candidat, CandidatBacListener listener) {
	/* Verrou --> normalement le lock est géré en amont mais on vérifie qd même*/
	String lockError = candidatController.getLockError(candidat.getCompteMinima(), ConstanteUtils.LOCK_BAC);
	if (lockError!=null) {
		Notification.show(lockError, Type.ERROR_MESSAGE);
		return;
	}
		
	CandidatBacOuEqu bac = candidat.getCandidatBacOuEqu();
	Boolean edition = true;
	if (bac == null){
		bac = new CandidatBacOuEqu();
		bac.setTemUpdatableBac(true);
		bac.setIdCandidat(candidat.getIdCandidat());
		bac.setCandidat(candidat);
		edition = false;
	}
	
	CandidatBacWindow window = new CandidatBacWindow(bac, edition);
	window.addBacWindowListener(e->{
		listener.bacModified(e);
	});
	UI.getCurrent().addWindow(window);
}
 
Example 19
Project: esup-ecandidat   File: CandidatParcoursController.java   Source Code and License 6 votes vote down vote up
/** Edition d'un cursus
 */
public void editCursusPostBac(Candidat candidat, CandidatCursusPostBac cursus, CandidatCursusExterneListener listener) {
	/* Verrou --> normalement le lock est géré en amont mais on vérifie qd même*/
	String lockError = candidatController.getLockError(candidat.getCompteMinima(), ConstanteUtils.LOCK_CURSUS_EXTERNE);
	if (lockError!=null) {
		Notification.show(lockError, Type.ERROR_MESSAGE);
		return;
	}

	Boolean nouveau = false;
	if (cursus==null){
		cursus = new CandidatCursusPostBac();
		cursus.setCandidat(candidat);
		nouveau = true;
	}
	
	CandidatCursusExterneWindow window = new CandidatCursusExterneWindow(cursus,nouveau);
	window.addCursusPostBacWindowListener(e->{
		candidat.addCursusPostBac(e);
		listener.cursusModified(candidat.getCandidatCursusPostBacs());
	});
	UI.getCurrent().addWindow(window);
}
 
Example 20
Project: esup-ecandidat   File: CandidatParcoursController.java   Source Code and License 6 votes vote down vote up
/** Edition d'une formation pro
 */
public void editFormationPro(Candidat candidat, CandidatCursusPro cursus, CandidatFormationProListener listener) {
	/* Verrou --> normalement le lock est géré en amont mais on vérifie qd même*/
	String lockError = candidatController.getLockError(candidat.getCompteMinima(), ConstanteUtils.LOCK_FORMATION_PRO);
	
	if (lockError!=null) {
		Notification.show(lockError, Type.ERROR_MESSAGE);
		return;
	}

	Boolean nouveau = false;
	if (cursus==null){
		cursus = new CandidatCursusPro();
		cursus.setCandidat(candidat);
		nouveau = true;
	}
	
	CandidatCursusProWindow window = new CandidatCursusProWindow(cursus,nouveau);
	window.addCursusProWindowListener(e->{
		candidat.addCursusPro(e);
		listener.formationProModified(candidat.getCandidatCursusPros());
	});
	UI.getCurrent().addWindow(window);
}
 
Example 21
Project: esup-ecandidat   File: CandidatParcoursController.java   Source Code and License 6 votes vote down vote up
/**Supprime un cursus pro
 * @param candidat
 * @param cursus
 * @param listener
 */
public void deleteFormationPro(Candidat candidat, CandidatCursusPro cursus, CandidatFormationProListener listener) {
	Assert.notNull(cursus, applicationContext.getMessage("assert.notNull", null, UI.getCurrent().getLocale()));
	/* Verrou --> normalement le lock est géré en amont mais on vérifie qd même*/
	String lockError = candidatController.getLockError(candidat.getCompteMinima(), ConstanteUtils.LOCK_FORMATION_PRO);
	if (lockError!=null) {
		Notification.show(lockError, Type.ERROR_MESSAGE);
		return;
	}
	
	ConfirmWindow confirmWindow = new ConfirmWindow(applicationContext.getMessage("formationPro.confirmDelete", null, UI.getCurrent().getLocale()), applicationContext.getMessage("formationPro.confirmDeleteTitle", null, UI.getCurrent().getLocale()));
	confirmWindow.addBtnOuiListener(e -> {
		candidatCursusProRepository.delete(cursus);
		candidat.getCandidatCursusPros().remove(cursus);			
		listener.formationProModified(candidat.getCandidatCursusPros());
	});
	UI.getCurrent().addWindow(confirmWindow);
}
 
Example 22
Project: holon-vaadin   File: ExampleInput.java   Source Code and License 6 votes vote down vote up
public void input5() {
	// tag::input5[]
	Input<String> stringInput = Components.input.string().build();
	ValidatableInput<String> validatableInput = ValidatableInput.from(stringInput); // <1>

	validatableInput.addValidator(Validator.email()); // <2>
	validatableInput.addValidator(Validator.max(100)); // <3>

	validatableInput.setValidationStatusHandler(e -> { // <4>
		if (e.isInvalid()) {
			Notification.show(e.getErrorMessage(), Type.ERROR_MESSAGE);
		}
	});

	validatableInput.validate(); // <5>

	validatableInput.setValidateOnValueChange(true); // <6>
	// end::input5[]
}
 
Example 23
Project: esup-ecandidat   File: CandidatParcoursController.java   Source Code and License 6 votes vote down vote up
/**Supprime un stage
 * @param candidat
 * @param stage
 * @param listener
 */
public void deleteStage(Candidat candidat,	CandidatStage stage, CandidatStageListener listener) {
	Assert.notNull(stage, applicationContext.getMessage("assert.notNull", null, UI.getCurrent().getLocale()));
	/* Verrou --> normalement le lock est géré en amont mais on vérifie qd même*/
	String lockError = candidatController.getLockError(candidat.getCompteMinima(), ConstanteUtils.LOCK_STAGE);
	if (lockError!=null) {
		Notification.show(lockError, Type.ERROR_MESSAGE);
		return;
	}
	
	ConfirmWindow confirmWindow = new ConfirmWindow(applicationContext.getMessage("stage.confirmDelete", null, UI.getCurrent().getLocale()), applicationContext.getMessage("stage.confirmDeleteTitle", null, UI.getCurrent().getLocale()));
	confirmWindow.addBtnOuiListener(e -> {
		candidatStageRepository.delete(stage);
		candidat.getCandidatStage().remove(stage);
		listener.stageModified(candidat.getCandidatStage());
	});
	UI.getCurrent().addWindow(confirmWindow);
}
 
Example 24
Project: esup-ecandidat   File: CandidatureCtrCandController.java   Source Code and License 6 votes vote down vote up
/**
 * @param listeCandidature
 * @param bean
 * @return modifie un tag
 */
public boolean editTag(final List<Candidature> listeCandidature, final Candidature bean) {
	if (checkLockListCandidature(listeCandidature)) {
		return false;
	}
	String user = userController.getCurrentUserLogin();

	for (Candidature candidature : listeCandidature) {
		Assert.notNull(candidature,
				applicationContext.getMessage("assert.notNull", null, UI.getCurrent().getLocale()));
		/* Verrou */
		if (!lockCandidatController.getLockOrNotifyCandidature(candidature)) {
			continue;
		}
		candidature.setTag(bean.getTag());
		candidature.setUserModCand(user);
		candidature = candidatureRepository.save(candidature);
		Notification.show(
				applicationContext.getMessage("candidature.action.tag.notif", null, UI.getCurrent().getLocale()),
				Type.TRAY_NOTIFICATION);
	}
	return true;
}
 
Example 25
Project: vaadin-fluent-api   File: FNotificationTest.java   Source Code and License 6 votes vote down vote up
@Test
public void test() {
    FNotification notif = new FNotification("", Type.WARNING_MESSAGE).withCaption("My notif")
                                                                     .withDelayMsec(3000)
                                                                     .withDescription("description")
                                                                     .withHtmlContentAllowed(true)
                                                                     .withIcon(VaadinIcons.ARCHIVE)
                                                                     .withPosition(Position.TOP_RIGHT)
                                                                     .withStyleName("test");

    assertEquals("My notif", notif.getCaption());
    assertEquals(3000, notif.getDelayMsec());
    assertEquals("description", notif.getDescription());
    assertTrue(notif.isHtmlContentAllowed());
    assertEquals(VaadinIcons.ARCHIVE, notif.getIcon());
    assertEquals(Position.TOP_RIGHT, notif.getPosition());
    assertEquals("test", notif.getStyleName());
}
 
Example 26
Project: esup-ecandidat   File: SiScolController.java   Source Code and License 6 votes vote down vote up
/** Teste du WS d'info de fichiers
 * @param codEtu
 * @param codTpj
 */
public void testWSPJSiScolInfo(String codEtu, String codTpj){		
	try {
		if (urlWsPjApogee == null){
			Notification.show(applicationContext.getMessage("version.ws.pj.noparam", new Object[]{ConstanteUtils.WS_APOGEE_PJ_SERVICE}, UI.getCurrent().getLocale()),Type.WARNING_MESSAGE);
			return;
		}
		WSPjInfo info = siScolService.getPjInfoFromApogee(null, codEtu, codTpj);
		String ret = "Pas d'info";
		if(info != null){
			ret = "<u>PJ Information</u> : <br>"+info;
		}
		
		UI.getCurrent().addWindow(new InfoWindow(applicationContext.getMessage("version.ws.result", null, UI.getCurrent().getLocale()), ret, 500, 70));
	} catch (Exception e) {
		Notification.show(applicationContext.getMessage("version.ws.error", null, UI.getCurrent().getLocale()),Type.WARNING_MESSAGE);
	}
}
 
Example 27
Project: esup-ecandidat   File: SiScolController.java   Source Code and License 6 votes vote down vote up
/** Test de téléchargement de fichiers
 * @param codEtu
 * @param codTpj
 * @return le fichier
 */
public OnDemandFile testWSPJSiScolFile(String codEtu, String codTpj) {
	try{
		if (urlWsPjApogee == null){
			Notification.show(applicationContext.getMessage("version.ws.pj.noparam", new Object[]{ConstanteUtils.WS_APOGEE_PJ_SERVICE}, UI.getCurrent().getLocale()),Type.WARNING_MESSAGE);
			return null;
		}
		WSPjInfo info = siScolService.getPjInfoFromApogee(null, codEtu, codTpj);
		if (info == null){
			return null;
		}
		return new OnDemandFile(info.getNomFic(), siScolService.getPjFichierFromApogee(info.getCodAnu(), codEtu, codTpj));
	}catch(Exception e){
		Notification.show(applicationContext.getMessage("version.ws.error", null, UI.getCurrent().getLocale()),Type.WARNING_MESSAGE);
		return null;
	}
	
}
 
Example 28
Project: esup-ecandidat   File: CandidatController.java   Source Code and License 6 votes vote down vote up
/**
 * Edite l'adresse d'un candidat
 *
 * @param cptMin
 * @param listener
 */
public void editAdresse(final CompteMinima cptMin, final AdresseListener listener) {
	/* Verrou --> normalement le lock est géré en amont mais on vérifie qd même */
	String lockError = getLockError(cptMin, ConstanteUtils.LOCK_ADRESSE);
	if (lockError != null) {
		Notification.show(lockError, Type.ERROR_MESSAGE);
		return;
	}
	Candidat candidat = cptMin.getCandidat();
	Adresse adresse = candidat.getAdresse();
	if (adresse == null) {
		adresse = new Adresse();
	}

	CandidatAdresseWindow window = new CandidatAdresseWindow(adresse);
	window.addAdresseWindowListener(e -> {
		listener.adresseModified(saveAdresse(candidat, e));
	});
	UI.getCurrent().addWindow(window);
}
 
Example 29
Project: esup-ecandidat   File: CandidatController.java   Source Code and License 6 votes vote down vote up
/**
 * @param cptMin
 * @return false si la ressource est lockée
 */
public Boolean isLockedForImportApo(final CompteMinima cptMin) {
	Boolean isLock = isRessourceLocked(cptMin, ConstanteUtils.LOCK_INFOS_PERSO);
	if (!isLock) {
		isLock = isRessourceLocked(cptMin, ConstanteUtils.LOCK_BAC);
	}
	if (!isLock) {
		isLock = isRessourceLocked(cptMin, ConstanteUtils.LOCK_ADRESSE);
	}
	if (isLock) {
		Notification.show(applicationContext.getMessage("lock.message.candidat", null, UI.getCurrent().getLocale()),
				Type.WARNING_MESSAGE);
		return true;
	}
	return false;
}
 
Example 30
Project: esup-ecandidat   File: CandidatController.java   Source Code and License 6 votes vote down vote up
/**
 * Verifie que le supannEtuId saisi n'est pas déjà existant
 *
 * @param supannEtuId
 * @param cptMin
 * @return true si pas présent, false sinon
 */
public Boolean isSupannEtuIdPresent(final String supannEtuId, final CompteMinima cptMin) {
	if (supannEtuId == null || supannEtuId.equals("")) {
		return false;
	} else {
		Campagne campagneEnCours = campagneController.getCampagneActive();
		if (campagneEnCours == null) {
			return false;
		}
		List<CompteMinima> liste = compteMinimaRepository.findBySupannEtuIdCptMinAndIdCptMinNotAndCampagneCodCamp(
				supannEtuId, cptMin.getIdCptMin(), campagneEnCours.getCodCamp());
		if (liste.size() > 0) {
			Notification.show(applicationContext.getMessage("candidat.etuid.allready.present", null,
					UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
			return true;
		}
	}
	return false;
}
 
Example 31
Project: esup-ecandidat   File: CandidatController.java   Source Code and License 6 votes vote down vote up
/**
 * Verifie que le login saisi n'est pas déjà existant
 *
 * @param login
 * @param cptMin
 * @return true si pas présent, false sinon
 */
public Boolean isLoginPresent(final String login, final CompteMinima cptMin) {
	if (login == null || login.equals("")) {
		return false;
	} else {
		Campagne campagneEnCours = campagneController.getCampagneActive();
		if (campagneEnCours == null) {
			return false;
		}
		List<CompteMinima> liste = compteMinimaRepository
				.findByLoginCptMinIgnoreCaseAndIdCptMinNotAndCampagneCodCamp(login, cptMin.getIdCptMin(),
						campagneEnCours.getCodCamp());
		if (liste.size() > 0) {
			Notification.show(applicationContext.getMessage("candidat.login.allready.present", null,
					UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
			return true;
		}
	}
	return false;
}
 
Example 32
Project: esup-ecandidat   File: PieceJustifController.java   Source Code and License 6 votes vote down vote up
/** AJoute un fichier à une pièce justif
 * @param pieceJustif
 */
public void addFileToPieceJustificative(PieceJustif pieceJustif) {
	/* Verrou */
	if (!lockController.getLockOrNotify(pieceJustif, null)) {
		return;
	}
	String user = userController.getCurrentUserLogin();
	String cod = ConstanteUtils.TYPE_FICHIER_PJ_GEST+"_"+pieceJustif.getIdPj();
	UploadWindow uw = new UploadWindow(cod,ConstanteUtils.TYPE_FICHIER_GESTIONNAIRE, null, false, false);
	uw.addUploadWindowListener(file->{
		if (file == null){
			return;
		}
		Fichier fichier = fileController.createFile(file,user,ConstanteUtils.TYPE_FICHIER_GESTIONNAIRE);
		pieceJustif.setFichier(fichier);
		pieceJustifRepository.save(pieceJustif);
		Notification.show(applicationContext.getMessage("window.upload.success", new Object[]{file.getFileName()}, UI.getCurrent().getLocale()), Type.TRAY_NOTIFICATION);
		uw.close();
	});
	uw.addCloseListener(e->lockController.releaseLock(pieceJustif));
	UI.getCurrent().addWindow(uw);
}
 
Example 33
Project: esup-ecandidat   File: DroitProfilController.java   Source Code and License 6 votes vote down vote up
/**
 * Ajoute un profil à un admin
 */
public void addProfilToUser(Boolean modeAdmin){
	String typRole = NomenclatureUtils.DROIT_PROFIL_GESTION_CANDIDAT;
	if (modeAdmin){
		typRole = NomenclatureUtils.DROIT_PROFIL_ADMIN;
	}
	DroitProfilIndividuWindow window = new DroitProfilIndividuWindow(typRole);
	window.addDroitProfilIndividuListener((individu,droit)->{
		Individu ind = individuController.saveIndividu(individu);
		if (droitProfilIndRepository.findByDroitProfilCodProfilAndIndividuLoginInd(droit.getCodProfil(),individu.getLoginInd()).size()==0){
			droitProfilIndRepository.saveAndFlush(new DroitProfilInd(ind,droit));
		}else{
			Notification.show(applicationContext.getMessage("droitprofilind.allready", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		}
	});
	UI.getCurrent().addWindow(window);
}
 
Example 34
Project: esup-ecandidat   File: FormulaireController.java   Source Code and License 6 votes vote down vote up
/**
 * Teste la connexion à LimeSurvey
 */
public void testConnexionLS(){
	InputWindow inputWindow = new InputWindow(applicationContext.getMessage("version.ls.message", null, UI.getCurrent().getLocale()), applicationContext.getMessage("version.ls.title", null, UI.getCurrent().getLocale()), false, 15);
	inputWindow.addBtnOkListener(text -> {
		if (text instanceof String && !text.isEmpty()) {
			if (text!=null){
				try {
					Integer idForm = Integer.valueOf(text);
					List<SurveyReponse> listeReponse = getListeReponseDedoublonne(limeSurveyRest.exportResponse(idForm, "fr"));
					String nbRep = applicationContext.getMessage("version.ls.resultTxt", new Object[]{listeReponse.size()}, UI.getCurrent().getLocale());
					UI.getCurrent().addWindow(new InfoWindow(applicationContext.getMessage("version.ls.result", null, UI.getCurrent().getLocale()),nbRep , 400, 30));
				} catch (Exception e) {
					Notification.show(applicationContext.getMessage("version.ls.error", null, UI.getCurrent().getLocale()),Type.WARNING_MESSAGE);
				}					
			}
		}
	});
	UI.getCurrent().addWindow(inputWindow);
}
 
Example 35
Project: esup-ecandidat   File: FileController.java   Source Code and License 6 votes vote down vote up
/** Renvoie l'inputstream d'un fichier (creation d'une seconde methode pour traiter dans un batch et desactiver la notif
 * @param fichier
 * @return l'InputStream d'un fichier
 */
public InputStream getInputStreamFromFichier(Fichier fichier, Boolean showNotif){
	Boolean isBackoffice = false;
	if (fichier.getTypFichier().equals(ConstanteUtils.TYPE_FICHIER_GESTIONNAIRE)){
		isBackoffice = true;
	}
	if (!isModeFileStockageOk(fichier, isBackoffice)){			
		return null;
	}
	try {			
		if (isModeStockagePrincipalOk(fichier, isBackoffice)){
			return fileManager.getInputStreamFromFile(fichier, true);
		}else if (isModeStockageSecondaireOk(fichier, isBackoffice)){
			return fileManagerSecondaire.getInputStreamFromFile(fichier, true);
		}
		return null;
	} catch (FileException e) {
		if (showNotif){
			Notification.show(e.getMessage(), Type.WARNING_MESSAGE);
		}
		return null;
	}
}
 
Example 36
Project: esup-ecandidat   File: OffreFormationView.java   Source Code and License 5 votes vote down vote up
/** Verifie que l'item a bien été chargé
 * @param item
 * @return true si ok
 */
private Boolean checkReloadOdf(Item item){		
	if (item == null){
		Notification.show(applicationContext.getMessage("odf.error.load", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		tree.removeAllItems();
		hlFilter.setVisible(false);
		noFormationLabel.setVisible(true);
		//si une erreur est détectée, on demande un rechargement du cache!
		cacheController.reloadOdf(false);
		return false;
	}
	return true;
}
 
Example 37
Project: esup-ecandidat   File: SearchFormationApoWindow.java   Source Code and License 5 votes vote down vote up
/**
 * Vérifie els donnée et si c'est ok, fait l'action (renvoie le AnneeUni)
 */
private void performAction(){
	if (vetListener != null){
		Vet vet = grid.getSelectedItem();
		if (vet==null){
			Notification.show(applicationContext.getMessage("window.search.selectrow", null, Locale.getDefault()), Notification.Type.WARNING_MESSAGE);
			return;
		}else{
			vetListener.btnOkClick(vet);
			close();
		}					
	}
}
 
Example 38
Project: esup-ecandidat   File: SearchFormationApoWindow.java   Source Code and License 5 votes vote down vote up
/**
 * Effectue la recherche
 * @param codCgeUserApo 
 * @param codCgeUser 
 */
private void performSearch(){
	if (searchBox.getValue().equals(null) || searchBox.getValue().equals("") || searchBox.getValue().length()<ConstanteUtils.NB_MIN_CAR_FORM){
		Notification.show(applicationContext.getMessage("window.search.morethan", new Object[]{ConstanteUtils.NB_MIN_CAR_FORM}, Locale.getDefault()), Notification.Type.WARNING_MESSAGE);
	}else{
		grid.removeAll();
		try {
			grid.addItems(formationController.getVetByCGE(searchBox.getValue()));
		} catch (SiScolException e) {
			Notification.show(applicationContext.getMessage("siscol.connect.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
			close();
		}
	}
}
 
Example 39
Project: esup-ecandidat   File: CandidatInfoPersoWindow.java   Source Code and License 5 votes vote down vote up
/** Valide l'ine
 * @param natField
 * @param ineField
 * @param candidat 
 * @param candidat
 * @return true si l'ine est ok
 */
private Boolean validateIneField(Candidat candidat){
	try {			
		validateField(natField);
		validateField(ineField);
		validateField(cleIneField);
		
		/*Passage des champs en maj*/
		toUpperCase(ineField);
		toUpperCase(cleIneField);
		
		if (
				(ineField.getValue()!=null && !ineField.getValue().equals("") && (cleIneField.getValue()==null || cleIneField.getValue().equals("")))
				||
				(cleIneField.getValue()!=null && !cleIneField.getValue().equals("") && (ineField.getValue()==null || ineField.getValue().equals("")))
			){
			Notification.show(applicationContext.getMessage("infoperso.ine.incomplet", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
			return false;
		}
		if (!demoController.getDemoMode() && !MethodUtils.checkStudentINE(ineField.getValue(), cleIneField.getValue())){
			Notification.show(applicationContext.getMessage("infoperso.ine.not.conform", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
			return false;
		}
		
		
		if (!demoController.getDemoMode() && candidatController.isINEPresent(ineField.getValue(), cleIneField.getValue(), candidat)){
			return false;
		}
       } catch (InvalidValueException e) {
       	return false;
       }
	return true;		
}
 
Example 40
Project: esup-ecandidat   File: AdminView.java   Source Code and License 5 votes vote down vote up
/**
 * Confirme la fermeture d'une UI
 * @param uiItem l'UI a kill
 */
public void confirmKillUI(SessionPresentation uiItem) {
	ConfirmWindow confirmWindow = new ConfirmWindow(applicationContext.getMessage("admin.uiList.confirmKillUI", null, UI.getCurrent().getLocale()));
	confirmWindow.addBtnOuiListener(e -> {
		MainUI ui = uiController.getUI(uiItem);			
		if (ui != null){
			uiController.killUI(ui);
		}else{
			Notification.show(applicationContext.getMessage("admin.uiList.confirmKillUI.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);			
		}
		removeElement(uiItem);
	});
	UI.getCurrent().addWindow(confirmWindow);
}