Java Code Examples for com.vaadin.ui.Notification

The following are top voted examples for showing how to use com.vaadin.ui.Notification. 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: svgexamples   File: FileExample.java   Source Code and License 6 votes vote down vote up
public FileExample() {
    setCaption("Interactive SVG");
    addComponent(new MLabel(
            "A simple example from an svg file using Embedded component. Unlike with Image component, the SVGs JS etc are active. The example also demonstrates how to provide a trivial server side integration API for the SVG."));
    Embedded svg = new Embedded();
    svg.setWidth("400px");
    svg.setHeight("400px");
    svg.setSource(new ClassResource("/pull.svg"));

    // Expose a JS hook that pull.svg file calls when clicked
    JavaScript.getCurrent().addFunction("callMyVaadinFunction", (JsonArray arguments) -> {
        Notification.show("Message from SVG:" + arguments.getString(0));
    });

    addComponent(svg);
}
 
Example 2
Project: holon-vaadin7   File: ExampleSelectable.java   Source Code and License 6 votes vote down vote up
public void selectable1() {
	// tag::selectable1[]
	SingleSelect<TestData> singleSelect = Components.input.singleSelect(TestData.class).caption("Single select")
			.build(); // <1>

	singleSelect.setValue(new TestData(1)); // <2>
	singleSelect.select(new TestData(1)); // <3>

	singleSelect.clear(); // <4>
	singleSelect.deselectAll(); // <5>

	boolean selected = singleSelect.isSelected(new TestData(1)); // <6>

	singleSelect.addSelectionListener(
			s -> s.getFirstSelectedItem().ifPresent(i -> Notification.show("Selected: " + i.getId()))); // <7>
	// end::selectable1[]
}
 
Example 3
Project: osc-core   File: DeploymentSpecSubView.java   Source Code and License 6 votes vote down vote up
private void conformDeploymentSpec(long dsId) {
    log.info("Syncing DS " + dsId);

    DeploymentSpecDto requestDto = new DeploymentSpecDto();
    requestDto.setId(dsId);

    BaseRequest<DeploymentSpecDto> req = new BaseRequest<DeploymentSpecDto>();
    req.setDto(requestDto);

    try {
        BaseJobResponse response = this.syncDeploymentSpecService.dispatch(req);

        ViewUtil.showJobNotification(response.getJobId(), this.server);
    } catch (Exception e) {
        log.error("Error!", e);
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
    }
}
 
Example 4
Project: osc-core   File: SetNetworkSettingsWindow.java   Source Code and License 6 votes vote down vote up
@Override
public void submitForm() {
    try {
        if (validateForm()) {
            SetNetworkSettingsRequest req = new SetNetworkSettingsRequest();
            req.setDhcp(false);
            req.setHostIpAddress(this.ipAddress.getValue().trim());
            req.setHostDefaultGateway(this.defaultGateway.getValue().trim());
            req.setHostSubnetMask(this.subnetMask.getValue().trim());
            req.setHostDnsServer1(this.dnsServer1.getValue().trim());
            req.setHostDnsServer2(this.dnsServer2.getValue().trim());

            this.setNetworkSettingsService.dispatch(req);

            this.networkLayout.populateNetworkTable();
        }
        close();
    } catch (Exception e) {
        log.error("Failed to update the network settings", e);
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
    }

}
 
Example 5
Project: osc-core   File: DeleteManagerConnectorWindow.java   Source Code and License 6 votes vote down vote up
@Override
public void submitForm() {
    BaseIdRequest delRequest = new BaseIdRequest();
    // Delete MC service has no response so not needed.
    try {
        delRequest.setId(this.mcView.getParentItemId());

        log.info("deleting Manager Connector - "
                + this.mcView.getParentContainer().getItem(this.mcView.getParentItemId()).getItemProperty("name")
                        .getValue().toString());

        BaseJobResponse response = this.deleteApplianceManagerConnectorService.dispatch(delRequest);

        ViewUtil.showJobNotification(response.getJobId(), this.server);

    } catch (Exception e) {
        log.info(e.getMessage());
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
    }
    close();
}
 
Example 6
Project: osc-core   File: DistributedApplianceView.java   Source Code and License 6 votes vote down vote up
@Override
public void populateParentTable() {

    ListResponse<DistributedApplianceDto> res;
    try {
        res = this.listDistributedApplianceService.dispatch(new BaseRequest<>());
        List<DistributedApplianceDto> listResponse = res.getList();
        this.parentContainer.removeAllItems();
        // creating table with list of vendors
        for (DistributedApplianceDto da : listResponse) {
            this.parentContainer.addItem(da.getId(), da);
        }

    } catch (Exception e) {
        log.error("Fail to populate Distributed Appliance table", e);
        ViewUtil.iscNotification("Fail to populate Distributed Appliance table (" + e.getMessage() + ")",
                Notification.Type.ERROR_MESSAGE);
    }

}
 
Example 7
Project: osc-core   File: AddAlarmWindow.java   Source Code and License 6 votes vote down vote up
@Override
public void submitForm() {
    try {
        if (validateForm()) {
            // creating add request with user entered data
            BaseRequest<AlarmDto> request = createRequest();

            // calling add service
            BaseResponse addResponse = this.addAlarmService.dispatch(request);
            log.info("adding new alarm - " + this.alarmName.getValue());

            // adding returned ID to the request DTO object
            request.getDto().setId(addResponse.getId());
            // adding new object to the parent table
            this.alarmView.getParentContainer().addItemAt(0, request.getDto().getId(), request.getDto());
            this.alarmView.parentTableClicked(request.getDto().getId());
            close();
        }
    } catch (Exception e) {
        log.info(e.getMessage());
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
    }

}
 
Example 8
Project: osc-core   File: JobView.java   Source Code and License 6 votes vote down vote up
@Override
public void populateParentTable() {

    ListJobRequest listRequest = null;
    ListResponse<JobRecordDto> res;
    try {
        res = this.listJobService.dispatch(listRequest);
        List<JobRecordDto> listResponse = res.getList();
        this.parentContainer.removeAllItems();
        // creating table with list of jobs
        for (JobRecordDto j : listResponse) {
            this.parentContainer.addItem(j.getId(), j);
        }

    } catch (Exception e) {
        log.error("Fail to populate Jobs table", e);
        ViewUtil.iscNotification("Fail to populate Job table (" + e.getMessage() + ")",
                Notification.Type.ERROR_MESSAGE);
    }

}
 
Example 9
Project: osc-core   File: AdvancedSettingsWindow.java   Source Code and License 6 votes vote down vote up
@Override
public void submitForm() {
    if (validateForm()) {
        try {
            //override all default values with user provided ones...
            this.baseVCWindow.providerAttributes.clear();
            this.baseVCWindow.providerAttributes.put(ATTRIBUTE_KEY_HTTPS, this.providerHttps.getValue().toString());
            this.baseVCWindow.providerAttributes.put(ATTRIBUTE_KEY_RABBITMQ_IP,
                    this.rabbitMQIp.getValue().toString());
            this.baseVCWindow.providerAttributes.put(ATTRIBUTE_KEY_RABBITMQ_USER,
                    this.rabbitMQUserName.getValue().toString());
            this.baseVCWindow.providerAttributes.put(ATTRIBUTE_KEY_RABBITMQ_USER_PASSWORD,
                    this.rabbitMQUserPassword.getValue().toString());
            this.baseVCWindow.providerAttributes.put(ATTRIBUTE_KEY_RABBITMQ_PORT,
                    this.rabbitMQPort.getValue().toString());
            close();
        } catch (Exception e) {
            String msg = "Failed to encrypt rabbit MQ user password";
            LOG.error(msg, e);
            ViewUtil.iscNotification(msg, Notification.Type.ERROR_MESSAGE);
        }
    }
}
 
Example 10
Project: osc-core   File: BaseDeploymentSpecWindow.java   Source Code and License 6 votes vote down vote up
private List<OsNetworkDto> getNetworks() {
    try {
        OsProjectDto selectedProject = (OsProjectDto) this.project.getValue();
        if (selectedProject != null && this.region.getValue() != null) {
            // Calling List Network Service
            BaseOpenStackRequest req = new BaseOpenStackRequest();
            req.setId(this.vsId);
            req.setRegion((String) this.region.getValue());
            req.setProjectName(selectedProject.getName());
            req.setProjectId(selectedProject.getId());

            List<OsNetworkDto> res = this.listNetworkService.dispatch(req).getList();

            return res;
        }
    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
        log.error("Error getting Network List", e);
    }
    return null;
}
 
Example 11
Project: osc-core   File: BaseDeploymentSpecWindow.java   Source Code and License 6 votes vote down vote up
private void populateFloatingPool() {
    this.floatingIpPool.removeAllItems();
    try {
        OsProjectDto selectedProject = (OsProjectDto) this.project.getValue();
        if (selectedProject != null && this.region.getValue() != null) {
            BaseOpenStackRequest req = new BaseOpenStackRequest();
            req.setId(this.vsId);
            req.setProjectName(selectedProject.getName());
            req.setProjectId(selectedProject.getId());
            req.setRegion((String) this.region.getValue());

            List<String> floatingIpPoolList = this.listFloatingIpPoolsService.dispatch(req).getList();

            if (floatingIpPoolList.size() > 0) {
                this.floatingIpPool.addItems(floatingIpPoolList);
            }
        }
    } catch (ExtensionNotPresentException notPresentException) {
        ViewUtil.iscNotification(notPresentException.getMessage(), Notification.Type.WARNING_MESSAGE);
        log.warn("Failed to get IP Pool", notPresentException);
    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
        log.error("Failed to get IP Pool", e);
    }

}
 
Example 12
Project: osc-core   File: ApplianceView.java   Source Code and License 6 votes vote down vote up
@Override
public void populateParentTable() {

    BaseRequest<BaseDto> listRequest = null;
    ListResponse<ApplianceDto> res;
    try {
        res = this.listApplianceService.dispatch(listRequest);
        List<ApplianceDto> listResponse = res.getList();
        this.parentContainer.removeAllItems();
        // creating table with list of vendors
        for (ApplianceDto appliance : listResponse) {
            this.parentContainer.addItem(appliance.getId(), appliance);
        }

    } catch (Exception e) {
        log.error("Fail to populate Appliance table", e);
        ViewUtil.iscNotification("Fail to populate Appliance table (" + e.getMessage() + ")",
                Notification.Type.ERROR_MESSAGE);
    }

}
 
Example 13
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 14
Project: esup-ecandidat   File: FileController.java   Source Code and License 6 votes vote down vote up
/**
 * Teste la démat
 */
public Boolean testDemat(Boolean showNotifIfOk){
	if (fileManager!=null){
		if (!fileManager.testSession()){
			Notification.show(applicationContext.getMessage("parametre.demat.check.ko", null, UI.getCurrent().getLocale()));			
			return false;
		}else{
			if (showNotifIfOk){
				Notification.show(applicationContext.getMessage("parametre.demat.check.ok", null, UI.getCurrent().getLocale()));
			}				
			return true;
		}
	}else{
		Notification.show(applicationContext.getMessage("parametre.demat.check.disable", null, UI.getCurrent().getLocale()));	
		return false;
	}
}
 
Example 15
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 16
Project: osc-core   File: ApplianceUploader.java   Source Code and License 6 votes vote down vote up
@Override
public OutputStream receiveUpload(String filename, String mimeType) {
    if (filename == null || filename.isEmpty()) {
        return null;
    }
    log.info("Start uploading file: " + filename);
    try {
        if (validateZipFile(filename)) {
            this.uploadPath = getUploadPath(true);
            File uploadDirectory = new File(this.uploadPath);
            if (!uploadDirectory.exists()) {
                FileUtils.forceMkdir(uploadDirectory);
            }
            this.file = new File(this.uploadPath + filename);
            return new FileOutputStream(this.file);
        }

    } catch (Exception e) {
        log.error("Error opening file: " + filename, e);
        ViewUtil.iscNotification(VmidcMessages.getString(VmidcMessages_.UPLOAD_COMMON_ERROR) + e.getMessage(),
                Notification.Type.ERROR_MESSAGE);
    }
    return null;
}
 
Example 17
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 18
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 19
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 20
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 21
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 22
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 23
Project: osc-core   File: ManagerConnectorView.java   Source Code and License 6 votes vote down vote up
@Override
public void populateChildTable(BeanItem<ApplianceManagerConnectorDto> parentItem) {
    this.childContainer.removeAllItems();
    if (parentItem != null) {
        try {
            BaseIdRequest listRequest = new BaseIdRequest();
            listRequest.setId(getParentItemId());
            ListResponse<PolicyDto> res = this.listManagerConnectoryPolicyService.dispatch(listRequest);

            for (PolicyDto policy : res.getList()) {
                this.childContainer.addItem(policy.getId(), policy);
            }

        } catch (Exception e) {
            log.error("Fail to populate Policy Table", e);
            ViewUtil.iscNotification("Fail to populate Policy table (" + e.getMessage() + ")",
                    Notification.Type.ERROR_MESSAGE);
        }
    }
}
 
Example 24
Project: osc-core   File: ApplianceUploader.java   Source Code and License 6 votes vote down vote up
@Override
public void uploadFailed(FailedEvent event) {
    if (event.getFilename() == null || event.getFilename().isEmpty()) {
        ViewUtil.iscNotification(VmidcMessages.getString(VmidcMessages_.UPLOAD_APPLIANCE_NOFILE),
                Notification.Type.ERROR_MESSAGE);
    } else if (event.getReason() instanceof UploadInterruptedException) {
        log.warn("Appliance Image upload is cancelled by the user");
    } else {
        ViewUtil.iscNotification(VmidcMessages.getString(VmidcMessages_.UPLOAD_APPLIANCE_FAILED),
                Notification.Type.ERROR_MESSAGE);
    }
    if (this.uploadPath != null) {
        File uploadDirectory = new File(this.uploadPath);
        if (uploadDirectory.exists()) {
            try {
                FileUtils.deleteDirectory(uploadDirectory);
            } catch (IOException e) {
                log.error("Deleting upload directory: " + this.uploadPath
                        + " failed when upload was cancelled by user.", e);
            }
        }
    }
}
 
Example 25
Project: osc-core   File: PluginsLayout.java   Source Code and License 6 votes vote down vote up
private void deletePlugin(PluginApi plugin) {
    final VmidcWindow<OkCancelButtonModel> deleteWindow = WindowUtil.createAlertWindow("Delete Plugin", "Delete Plugin - " + plugin.getSymbolicName());
    deleteWindow.getComponentModel().setOkClickedListener(event -> {
        if (this.importPluginService.isControllerTypeUsed(plugin.getName())) {
            ViewUtil.iscNotification("SDN Controller Plugin '" + plugin.getName() + "' is used.", Notification.Type.ERROR_MESSAGE);
        } else {
            try {
                File origin = plugin.getOrigin();
                if (origin == null) {
                    throw new IllegalStateException(String.format("Install unit %s has no origin file.", plugin.getSymbolicName()));
                }

                // Use Java 7 Files.delete(), as it throws an informative exception when deletion fails
                Files.delete(origin.toPath());
            } catch (Exception e) {
                ViewUtil.showError("Fail to remove Plugin '" + plugin.getSymbolicName() + "'", e);
            }
        }
        deleteWindow.close();
    });
    ViewUtil.addWindow(deleteWindow);
}
 
Example 26
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 27
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 28
Project: osc-core   File: SslCertificateUploader.java   Source Code and License 6 votes vote down vote up
@Override
public void uploadSucceeded(SucceededEvent event) {
    boolean succeeded = true;
    try {
        processCertificateFile();
        log.info("=============== Upload certificate succeeded");
        repaintUpload();
    } catch (Exception ex) {
        succeeded = false;
        log.error("=============== Failed to upload certificate", ex);
        ViewUtil.iscNotification("SSL certificate upload failed. " + ex.getMessage() + " Please use a valid certificate file", Notification.Type.ERROR_MESSAGE);
        repaintUpload();
    }

    if(this.uploadNotifier != null){
        this.uploadNotifier.finishedUpload(succeeded);
    }
}
 
Example 29
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 30
Project: esup-ecandidat   File: SiScolController.java   Source Code and License 6 votes vote down vote up
/**
 * Teste la connexion au WS Apogée
 */
public void testWSSiScolConnnexion() {
	InputWindow inputWindow = new InputWindow(applicationContext.getMessage("version.ws.message", null, UI.getCurrent().getLocale()), applicationContext.getMessage("version.ws.title", null, UI.getCurrent().getLocale()), false, 15);
	inputWindow.addBtnOkListener(text -> {
		if (text instanceof String && !text.isEmpty()) {
			if (text!=null){
				try {
					WSIndividu ind = siScolService.getIndividu(text, null, null);
					String ret = "Pas d'info";
					if(ind!=null){
						ret = "<u>Individu</u> : <br>"+ind+"<br><br><u>Adresse</u> : <br>"+ind.getAdresse()+
								"<br><br><u>Bac</u> : <br>"+ind.getBac()+"<br><br><u>Cursus interne</u> : <br>"+ind.getListCursusInterne();
					}
					
					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);
				}					
			}
		}
	});
	UI.getCurrent().addWindow(inputWindow);
}
 
Example 31
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 32
Project: osc-core   File: PluginsLayout.java   Source Code and License 6 votes vote down vote up
private UploadSucceededListener getUploadSucceededListener() {
    return new UploadSucceededListener() {

        @Override
        public void uploadComplete(String uploadPath) {
            try {
                ImportFileRequest importRequest = new ImportFileRequest(uploadPath);

                PluginsLayout.this.importPluginService.dispatch(importRequest);

                ViewUtil.iscNotification(
                        VmidcMessages.getString(VmidcMessages_.UPLOAD_PLUGIN_SUCCESSFUL), null,
                        Notification.Type.TRAY_NOTIFICATION);
            } catch (Exception e) {
                PluginsLayout.this.log.info(e.getMessage());
                ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }

    };
}
 
Example 33
Project: osc-core   File: DistributedApplianceView.java   Source Code and License 6 votes vote down vote up
@Override
public void populateChildTable(BeanItem<DistributedApplianceDto> parentItem) {
    if (parentItem != null) {
        try {
            DistributedApplianceDto da = parentItem.getBean();
            // creating table with list of vendors
            this.childContainer.removeAllItems();
            for (VirtualSystemDto aVersion : da.getVirtualizationSystems()) {
                this.childContainer.addItem(aVersion.getId(), aVersion);
            }
        } catch (Exception e) {
            log.error("Fail to populate Virtual System table", e);
            ViewUtil.iscNotification("Fail to populate Virtual System table (" + e.getMessage() + ")",
                    Notification.Type.ERROR_MESSAGE);
        }
    } else {
        this.childContainer.removeAllItems();
        ViewUtil.setButtonsEnabled(false, this.childToolbar);
    }
}
 
Example 34
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 35
Project: osc-core   File: BaseDeploymentSpecWindow.java   Source Code and License 6 votes vote down vote up
private void populateNetworks(ComboBox networkComboBox, List<OsNetworkDto> networkList) {
    try {
        networkComboBox.removeAllItems();
        if (networkList != null) {
            // Calling List Network Service
            BeanItemContainer<OsNetworkDto> networkListContainer = new BeanItemContainer<>(OsNetworkDto.class,
                    networkList);

            networkComboBox.setContainerDataSource(networkListContainer);
            networkComboBox.setItemCaptionPropertyId("name");
            if (networkList.size() > 0) {
                networkComboBox.select(networkListContainer.getIdByIndex(0));
            }
        }
    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
        log.error("Error getting Network List", e);
    }
}
 
Example 36
Project: osc-core   File: SslConfigurationLayout.java   Source Code and License 6 votes vote down vote up
private VerticalLayout makeSslUploadContainer(SslCertificateUploader certificateUploader, String title) {
    VerticalLayout sslUploadContainer = new VerticalLayout();
    try {
        certificateUploader.setSizeFull();
        certificateUploader.setUploadNotifier(uploadStatus -> {
            if (uploadStatus) {
                buildSslConfigurationTable();
            }
        });
        sslUploadContainer.addComponent(ViewUtil.createSubHeader(title, null));
        sslUploadContainer.addComponent(certificateUploader);
    } catch (Exception e) {
        log.error("Cannot add upload component. Trust manager factory failed to initialize", e);
        ViewUtil.iscNotification(getString(MAINTENANCE_SSLCONFIGURATION_UPLOAD_INIT_FAILED, new Date()),
                null, Notification.Type.TRAY_NOTIFICATION);
    }
    return sslUploadContainer;
}
 
Example 37
Project: osc-core   File: BaseSecurityGroupInterfaceWindow.java   Source Code and License 6 votes vote down vote up
protected Component getPolicy() {
    try {
        this.policy = new ComboBox("Select Policy");
        this.policy.setTextInputAllowed(false);
        this.policy.setNullSelectionAllowed(false);
        this.policy.setImmediate(true);
        this.policy.setRequired(true);
        this.policy.setRequiredError("Policy cannot be empty");
        populatePolicy();

    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
        log.error("Error populating Policy List combobox", e);
    }

    return this.policy;
}
 
Example 38
Project: osc-core   File: InternalCertReplacementUploader.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("serial")
private void setupOkClickedListener(final VmidcWindow<OkCancelButtonModel> alertWindow) {
    alertWindow.getComponentModel().setOkClickedListener(new Button.ClickListener(){
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                InternalCertReplacementUploader.this.x509TrustManager
                    .replaceInternalCertificate(InternalCertReplacementUploader.this.file, true);
            } catch (Exception e) {
                ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
            } finally {
                alertWindow.close();
                removeUploadedFile();
            }
        }});
}
 
Example 39
Project: osc-core   File: SecurityGroupMembershipInfoWindow.java   Source Code and License 5 votes vote down vote up
private void populateData() {
    try {
        Set<SecurityGroupMemberItemDto> members = this.listSecurityGroupMembersBySgService
                .dispatch(new BaseIdRequest(this.currentSecurityGroup.getId())).getSet();

        if (members.isEmpty()) {
            ViewUtil.iscNotification(null, VmidcMessages.getString(VmidcMessages_.SG_NO_MEMBERS),
                    Type.WARNING_MESSAGE);
        } else {
            for (SecurityGroupMemberItemDto member : members) {
                Object memberItem = this.treeTable
                        .addItem(new Object[] { member.getName(), member.getType(), "", "" }, null);
                this.treeTable.setCollapsed(memberItem, member.getPorts().isEmpty());
                this.treeTable.setChildrenAllowed(memberItem, !member.getPorts().isEmpty());

                for (PortDto port : member.getPorts()) {
                    String ipAddressString = String.join(", ", port.getIpAddresses());
                    String shortId = port.getOpenstackId().length() > OPENSTACK_ID_SHORTENED_LENGTH ?
                            port.getOpenstackId().substring(0, OPENSTACK_ID_SHORTENED_LENGTH) :
                                port.getOpenstackId();
                            Object portItem = this.treeTable.addItem(
                                    new Object[] { shortId, "",
                                            ipAddressString, port.getMacAddress() },
                                    null);
                            this.treeTable.setChildrenAllowed(portItem, false);
                            this.treeTable.setParent(portItem, memberItem);
                }
            }
        }
    } catch (Exception e) {
        log.error("Unable to list security group members for SG ID: " + this.currentSecurityGroup.getId(), e);
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
    }
}
 
Example 40
Project: textfieldformatter   File: DefaultNumeralFieldFormatterUsageUI.java   Source Code and License 5 votes vote down vote up
@Override
public Component getTestComponent() {
	TextField tf = new TextField();
	new NumeralFieldFormatter(tf);
	tf.addValueChangeListener(l -> Notification.show("Value: " + l.getValue()));
	return tf;
}
 
Example 41
Project: esup-ecandidat   File: CentreCandidatureController.java   Source Code and License 5 votes vote down vote up
/**on controle qu'on ne desactive pas ou qu'on ne supprime pas le centre de candidature en cours
 * @param centreCandidature
 */
private void controlDisableOrDeleteCtrCandEnCours(CentreCandidature centreCandidature, Boolean isDelete){
	SecurityCentreCandidature securityCentreCandidature = userController.getCentreCandidature();
	/*Si passage du temoin en service à non et que ce centre est celui en train d'être éditée*/
	if ((!centreCandidature.getTesCtrCand() || isDelete) 
			&& securityCentreCandidature!=null 
			&& securityCentreCandidature.getIdCtrCand().equals(centreCandidature.getIdCtrCand())){
		userController.setCentreCandidature(null);
		MainUI.getCurrent().buildMenuCtrCand();
		Notification.show(applicationContext.getMessage("ctrCand.delete.or.disable.active", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);			
	}
}
 
Example 42
Project: osc-core   File: JobsArchiverPanel.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("serial")
private Button createUpdateScheduleButton() {

    this.updateButton = new Button(this.UPDATE_SCHED_BUTTON_LABEL);

    this.updateButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {

            try {
                BaseRequest<JobsArchiveDto> request = new BaseRequest<JobsArchiveDto>();
                request.setDto(new JobsArchiveDto());
                request.getDto().setId(JobsArchiverPanel.this.dto.getId());
                request.getDto().setAutoSchedule(JobsArchiverPanel.this.autoSchedChkBox.getValue());
                request.getDto().setFrequency(JobsArchiverPanel.this.freqOpt.getValue().toString());
                request.getDto().setThresholdUnit(JobsArchiverPanel.this.thresOpt.getValue().toString());
                request.getDto().setThresholdValue(JobsArchiverPanel.this.archiveThreshold.getValue());

                JobsArchiverPanel.this.updateJobsArchiveService.dispatch(request);
                JobsArchiverPanel.this.archiveService.maybeScheduleArchiveJob();

                ViewUtil.iscNotification(
                        VmidcMessages.getString(VmidcMessages_.MAINTENANCE_JOBSARCHIVE_SUBMIT_SUCCESSFUL), null,
                        Notification.Type.TRAY_NOTIFICATION);

            } catch (Exception e) {

                log.error("Fail to update archive schedule", e);
                ViewUtil.iscNotification(
                        VmidcMessages.getString(VmidcMessages_.MAINTENANCE_JOBSARCHIVE_SUBMIT_FAILED),
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    return this.updateButton;
}
 
Example 43
Project: osc-core   File: DeploymentSpecSubView.java   Source Code and License 5 votes vote down vote up
@Override
public void buttonClicked(ClickEvent event) throws Exception {
    if (event.getButton().getId().equals(ToolbarButtons.ADD.getId())) {
        log.debug("Redirecting to Add Deployment Spec Window");
        ViewUtil.addWindow(new AddDeploymentSpecWindow(getDtoInContext().getId(),
                this.addDeploymentSpecService, this.listAvailabilityZonesService,
                this.listFloatingIpPoolsService, this.listHostService, this.listHostAggregateService,
                this.listNetworkService, this.listRegionService, this.listProjectService, this.server));
    }
    if (event.getButton().getId().equals(ToolbarButtons.EDIT.getId())) {
        log.debug("Redirecting to Update Deployment Spec Window");
        boolean markForDeletion = getTableContainer().getItem(getSelectedItemId()).getBean().isMarkForDeletion();
        if (markForDeletion) {
            ViewUtil.iscNotification("Modification of deleted Deployment Specification is not allowed.",
                    Notification.Type.WARNING_MESSAGE);
        } else {
            ViewUtil.addWindow(
                    new UpdateDeploymentSpecWindow(
                            getTableContainer().getItem(getSelectedItemId()).getBean(),
                            this.updateDeploymentSpecService, this.listAvailabilityZonesService,
                            this.listFloatingIpPoolsService, this.listHostService, this.listHostAggregateService,
                            this.listNetworkService, this.listRegionService, this.listProjectService, this.server));
        }
    }
    if (event.getButton().getId() == ToolbarButtons.DELETE.getId()) {
        log.debug("Redirecting to Delete Deployment Spec Window");
        DeleteWindowUtil.deleteDeploymentSpec(this.deleteDeploymentSpecService, getTableContainer().getItem(getSelectedItemId()).getBean(), this.server);
    }
    if (event.getButton().getId() == ToolbarButtons.CONFORM.getId()) {
        conformDeploymentSpec(getSelectedItemId());
    }
    if (event.getButton().getId() == ToolbarButtons.BACK.getId()) {
        // removing object from the sub view map so it can be garbage collected
        this.currentView.childSubViewMap.put(this.currentView.getKeyforChildSubView(1), null);
        this.currentView.viewSplitter.removeComponent(this.currentView.viewSplitter.getSecondComponent());
        this.currentView.viewSplitter.addComponent(this.currentView.childContainerLayout);
    }
}
 
Example 44
Project: esup-ecandidat   File: FileController.java   Source Code and License 5 votes vote down vote up
/**
 * @param fichier
 * @return true si le fichier existe en base
 * @throws FileException
 */
public Boolean existFileInDb(Fichier fichier) {
	if (fichier == null || fichier.getIdFichier()==null){
		Notification.show(applicationContext.getMessage("pj.gestionnaire.modified", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		return false;
	}
	Boolean exist = fichierRepository.exists(fichier.getIdFichier());
	if (!exist){
		Notification.show(applicationContext.getMessage("pj.gestionnaire.modified", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		return false;
	}
	return true;
}
 
Example 45
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 46
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 47
Project: Persephone   File: UIErrorHandler.java   Source Code and License 5 votes vote down vote up
private void displayErrorNotif(String msg, Throwable t) {
	LOGGER.error(String.format("Error handler: %s", msg), t);
	new Notification(
			msg,
		    t.getMessage(),
		    Notification.Type.ERROR_MESSAGE,
		    false)
		.show(Page.getCurrent());
}
 
Example 48
Project: osc-core   File: BaseSecurityGroupWindow.java   Source Code and License 5 votes vote down vote up
private void populateFromList() {
    try {

        OsProjectDto projectDto = (OsProjectDto) this.project.getValue();
        String region = (String) this.region.getValue();
        String memberType = (String) this.protectionEntityType.getValue();
        boolean isProtectAll = this.protectionTypeOption.getValue() == TYPE_ALL;

        this.itemsContainer.removeAllItems();
        this.itemsTable.removeAllItems();

        if (projectDto != null && StringUtils.isNotEmpty(region) && !isProtectAll) {

            ListOpenstackMembersRequest req = new ListOpenstackMembersRequest();
            if (this.currentSecurityGroup.getId() != null) {
                req.setId(this.currentSecurityGroup.getId());
            }
            req.setParentId(this.currentSecurityGroup.getParentId());
            req.setProjectName(projectDto.getName());
            req.setProjectId(projectDto.getId());
            req.setRegion(region);
            req.setType(memberType.toString());
            if (this.isInitialFromListLoad) {
                req.setCurrentSelectedMembers(null);
            } else {
                req.setCurrentSelectedMembers(getSelectedMembers());
            }
            ListResponse<SecurityGroupMemberItemDto> response = this.listOpenstackMembersService.dispatch(req);
            this.isInitialFromListLoad = false;

            this.itemsContainer.addAll(response.getList());
            updateCountFooter(this.itemsTable, this.itemsContainer.size());

            this.itemsContainer.sort(new Object[] { "name" }, new boolean[] { true });
        }
    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
        log.error("Error getting Servers List", e);
    }
}
 
Example 49
Project: osc-core   File: SetEmailSettingsWindow.java   Source Code and License 5 votes vote down vote up
@Override
public boolean validateForm() {
    try {
        this.smtp.validate();
        this.port.validate();
        this.emailId.validate();
        return true;
    } catch (Exception e) {
        ViewUtil.iscNotification(e.getMessage() + ".", Notification.Type.ERROR_MESSAGE);
    }

    return false;
}
 
Example 50
Project: esup-ecandidat   File: SearchCommissionWindow.java   Source Code and License 5 votes vote down vote up
/**
 * Vérifie les donnée et si c'est ok, fait l'action (renvoie le Commission)
 */
private void performAction(){
	if (commissionListener != null){
		Commission commission = grid.getSelectedItem();
		if (commission==null){
			Notification.show(applicationContext.getMessage("window.search.selectrow", null, Locale.getDefault()), Notification.Type.WARNING_MESSAGE);
			return;
		}else{				
			commissionListener.btnOkClick(commission);
			close();
		}					
	}
}
 
Example 51
Project: esup-ecandidat   File: SearchCtrCandWindow.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 CentreCandidature)
 */
private void performAction(){
	if (centreCandidatureListener != null){
		CentreCandidature ctrCand = grid.getSelectedItem();
		if (ctrCand == null){
			Notification.show(applicationContext.getMessage("window.search.selectrow", null, Locale.getDefault()), Notification.Type.WARNING_MESSAGE);
			return;
		}else{
			centreCandidatureListener.btnOkClick(ctrCand);
			close();
		}					
	}
}
 
Example 52
Project: esup-ecandidat   File: AdminView.java   Source Code and License 5 votes vote down vote up
/**
 * Confirme la fermeture de toutes les sessions associées à un utilisateur
 * @param user
 */
public void confirmKillUser(SessionPresentation user) {
	ConfirmWindow confirmWindow = new ConfirmWindow(applicationContext.getMessage("admin.uiList.confirmKillUser", new Object[]{user.getId()}, UI.getCurrent().getLocale()));
	confirmWindow.addBtnOuiListener(e -> {
		UserDetails details = uiController.getUser(user);
		if (details != null){
			uiController.killUser(details);				
		}else{
			Notification.show(applicationContext.getMessage("admin.uiList.confirmKillUser.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);	
		}
		removeElement(user);
	});
	UI.getCurrent().addWindow(confirmWindow);
}
 
Example 53
Project: osc-core   File: AddDistributedApplianceWindow.java   Source Code and License 5 votes vote down vote up
@Override
public void populateForm() {

    try {
        this.name = new TextField("Name");
        this.name.focus();
        this.name.setImmediate(true);
        this.name.setRequired(true);
        this.name.setRequiredError("Name cannot be empty");

        FormLayout innerForm = new FormLayout();
        innerForm.addComponent(this.name);
        innerForm.addComponent(getManagerConnector());
        innerForm.addComponent(getApplianceDefinition());
        innerForm.setWidth(100, Unit.PERCENTAGE);

        VerticalLayout layout = new VerticalLayout();
        layout.addComponent(innerForm);
        // TODO: Future. Need to dynamically show/hide attributes based on manager type
        getAttributesPanel();
        layout.addComponent(getVirtualSystemPanel());

        this.form.setMargin(true);
        this.form.setWidth(689, Unit.PIXELS);
        this.form.addComponent(layout);

    } catch (Exception e) {
        log.error("Fail to populate Distributed Appliance form", e);
        ViewUtil.iscNotification("Fail to populate Distributed Appliance form (" + e.getMessage() + ")",
                Notification.Type.ERROR_MESSAGE);
    }
}
 
Example 54
Project: esup-ecandidat   File: MainUI.java   Source Code and License 5 votes vote down vote up
/** Vérifie que le centre de candidature en cours d'edition est le même que celui dans la session
 * @param ctrCand
 * @return true si ok
 */
public Boolean checkConcordanceCentreCandidature(CentreCandidature ctrCand) {
	if (idCtrCandEnCours!=null && (ctrCand==null || (ctrCand!=null && !idCtrCandEnCours.equals(ctrCand.getIdCtrCand())))){
		Notification.show(applicationContext.getMessage("ctrCand.change.error", null, getLocale()));
		buildMenuCtrCand();
		return false;
	}
	return true;
}
 
Example 55
Project: osc-core   File: UpdateAlarmWindow.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void submitForm() {
    try {
        if (validateForm()) {
            // creating add alarm with user entered data
            BaseRequest<AlarmDto> request = createRequest();
            request.getDto().setId(this.currentAlarm.getBean().getId());

            log.info("Updating alarm - " + this.alarmName.getValue());

            BaseResponse res = this.updateAlarmService.dispatch(request);
            if (res.getId() == null) {
                ViewUtil.iscNotification("Error updating the alarm", null, Notification.Type.TRAY_NOTIFICATION);
            }

            // updating bean in the table container
            this.alarmView.getParentContainer().getContainerProperty(request.getDto().getId(), "name")
            .setValue(this.alarmName.getValue().trim());
            this.alarmView.getParentContainer().getContainerProperty(request.getDto().getId(), "eventType")
            .setValue(this.eventType.getValue());
            this.alarmView.getParentContainer().getContainerProperty(request.getDto().getId(), "regexMatch")
            .setValue(this.regexMatch.getValue().trim());
            this.alarmView.getParentContainer().getContainerProperty(request.getDto().getId(), "severity")
            .setValue(this.severity.getValue());
            this.alarmView.getParentContainer().getContainerProperty(request.getDto().getId(), "alarmAction")
            .setValue(this.alarmAction.getValue());
            this.alarmView.getParentContainer().getContainerProperty(request.getDto().getId(), "receipientEmail")
            .setValue(this.email.getValue().trim());
            this.alarmView.getParentContainer().getContainerProperty(request.getDto().getId(), "enabledAlarm")
            .setValue(this.enabled.getValue());

            close();
        }
    } catch (Exception e) {
        log.info("Error updating alarm", e);
        ViewUtil.iscNotification(e.getMessage(), Notification.Type.ERROR_MESSAGE);
    }

}
 
Example 56
Project: esup-ecandidat   File: MailController.java   Source Code and License 5 votes vote down vote up
/**
 * Supprime une mail
 * @param mail
 */
public void deleteMail(Mail mail) {
	Assert.notNull(mail, applicationContext.getMessage("assert.notNull", null, UI.getCurrent().getLocale()));
	
	if (typeDecisionRepository.countByMail(mail)>0){
		Notification.show(applicationContext.getMessage("mail.error.delete", new Object[]{TypeDecision.class.getSimpleName()}, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		return;
	}

	/* Verrou */
	if (!lockController.getLockOrNotify(mail, null)) {
		return;
	}

	ConfirmWindow confirmWindow = new ConfirmWindow(applicationContext.getMessage("mail.window.confirmDelete", new Object[]{mail.getCodMail()}, UI.getCurrent().getLocale()), applicationContext.getMessage("mail.window.confirmDeleteTitle", null, UI.getCurrent().getLocale()));
	confirmWindow.addBtnOuiListener(e -> {
		/* Contrôle que le client courant possède toujours le lock */
		if (lockController.getLockOrNotify(mail, null)) {
			mailRepository.delete(mail);
			/* Suppression du lock */
			lockController.releaseLock(mail);
		}
	});
	confirmWindow.addCloseListener(e -> {
		/* Suppression du lock */
		lockController.releaseLock(mail);
	});
	UI.getCurrent().addWindow(confirmWindow);
}
 
Example 57
Project: esup-ecandidat   File: PreferenceController.java   Source Code and License 5 votes vote down vote up
/** Modifie les preferences de vue dans la session
 * @param listeColonne
 * @param listColonneOrder 
 * @param frozen
 */
public void savePrefCandInDb(String listeColonne, String listColonneOrder, Integer frozen, String sortColonne, String sortDirection){
	PreferenceInd pref = preparePreferenceToSaveInDb();
	if (pref == null){
		return;
	}
	pref.setCandColVisiblePref(listeColonne);
	pref.setCandColOrderPref(listColonneOrder);
	pref.setCandColFrozenPref(frozen);
	pref.setCandColSortPref(sortColonne);
	pref.setCandColSortDirectionPref(sortDirection);
	preferenceIndRepository.save(pref);
	savePrefCandInSession(listeColonne, listColonneOrder, frozen, sortColonne, sortDirection, false);
	Notification.show(applicationContext.getMessage("preference.notif.db.ok", null, UI.getCurrent().getLocale()), Type.TRAY_NOTIFICATION);
}
 
Example 58
Project: osc-core   File: InternalCertReplacementUploader.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("serial")
private void setupCancelClickedListener(final VmidcWindow<OkCancelButtonModel> alertWindow) {
    alertWindow.getComponentModel().setCancelClickedListener(new Button.ClickListener(){
        @Override
        public void buttonClick(ClickEvent event) {
            removeUploadedFile();
            alertWindow.close();
            ViewUtil.iscNotification(getString(KEYPAIR_NOT_REPLACED), Notification.Type.WARNING_MESSAGE);
        }});
}
 
Example 59
Project: esup-ecandidat   File: PieceJustifController.java   Source Code and License 5 votes vote down vote up
/** SUpprime une pièce justificative
 * @param pieceJustif
 */
private void deletePj(PieceJustif pieceJustif){
	/* Contrôle que le client courant possède toujours le lock */
	if (lockController.getLockOrNotify(pieceJustif, null)) {				
		try{
			deletePieceJustifDbAndFile(pieceJustif);
			/* Suppression du lock */
			lockController.releaseLock(pieceJustif);
		}catch(Exception ex){
			Notification.show(applicationContext.getMessage("file.error.delete", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
		}
	}
}
 
Example 60
Project: esup-ecandidat   File: CandidatureController.java   Source Code and License 5 votes vote down vote up
/**
 * Enregistre une candidature
 *
 * @param candidature
 * @param isProposition
 * @return la candidature
 */
private Candidature saveCandidature(Candidature candidature, final Boolean isProposition) {
	/* On vérifie */
	List<Candidature> candidatureCheckAllreadyExist = candidatureRepository
			.findByFormationIdFormAndCandidatIdCandidatAndDatAnnulCandIsNull(candidature.getFormation().getIdForm(),
					candidature.getCandidat().getIdCandidat());
	if (candidatureCheckAllreadyExist.size() > 0) {
		Notification.show(applicationContext.getMessage("unexpected.error", null, UI.getCurrent().getLocale()),
				Type.WARNING_MESSAGE);
		return null;
	}

	candidature = candidatureRepository.save(candidature);

	if (isProposition) {
		/* envoi du mail à la commission */
		if (candidature.getFormation().getCommission().getTemAlertPropComm()) {
			mailController.sendMailByCod(candidature.getFormation().getCommission().getMailComm(),
					NomenclatureUtils.MAIL_COMMISSION_ALERT_PROPOSITION, null, candidature, null);
		}
		Notification.show(
				applicationContext.getMessage("candidature.proposition.success", null, UI.getCurrent().getLocale()),
				Type.WARNING_MESSAGE);
	} else {
		/* envoi du mail au candidat */
		mailController.sendMailByCod(candidature.getCandidat().getCompteMinima().getMailPersoCptMin(),
				NomenclatureUtils.MAIL_CANDIDATURE, null, candidature,
				candidature.getCandidat().getLangue().getCodLangue());
		Notification.show(applicationContext.getMessage("candidature.success", null, UI.getCurrent().getLocale()),
				Type.WARNING_MESSAGE);
	}
	return candidature;
}