Java 类com.vaadin.ui.Notification 实例源码

项目:svgexamples    文件:FileExample.java   
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);
}
项目:holon-vaadin7    文件:ExampleSelectable.java   
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[]
}
项目:osc-core    文件:DeploymentSpecSubView.java   
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);
    }
}
项目:osc-core    文件:SetNetworkSettingsWindow.java   
@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);
    }

}
项目:osc-core    文件:DeleteManagerConnectorWindow.java   
@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();
}
项目:osc-core    文件:DistributedApplianceView.java   
@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);
    }

}
项目:osc-core    文件:AddAlarmWindow.java   
@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);
    }

}
项目:osc-core    文件:JobView.java   
@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);
    }

}
项目:osc-core    文件:AdvancedSettingsWindow.java   
@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);
        }
    }
}
项目:osc-core    文件:BaseDeploymentSpecWindow.java   
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;
}
项目:osc-core    文件:BaseDeploymentSpecWindow.java   
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);
    }

}
项目:osc-core    文件:ApplianceView.java   
@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);
    }

}
项目:esup-ecandidat    文件:BatchController.java   
/**
 * 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);
}
项目:esup-ecandidat    文件:FileController.java   
/**
 * 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;
    }
}
项目:esup-ecandidat    文件:CommissionController.java   
/**
 * 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);
}
项目:osc-core    文件:ApplianceUploader.java   
@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;
}
项目:esup-ecandidat    文件:PieceJustifController.java   
/** 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);
}
项目:esup-ecandidat    文件:CandidaturePieceController.java   
/**
 * @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;
}
项目:esup-ecandidat    文件:FileController.java   
/** 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;
    }
}
项目:esup-ecandidat    文件:LockCandidatController.java   
/** 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);
}
项目:esup-ecandidat    文件:UserController.java   
/**
 * 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);
}
项目:esup-ecandidat    文件:UserController.java   
/**
 * 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;
    }
}
项目:osc-core    文件:ManagerConnectorView.java   
@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);
        }
    }
}
项目:osc-core    文件:ApplianceUploader.java   
@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);
            }
        }
    }
}
项目:osc-core    文件:PluginsLayout.java   
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);
}
项目:esup-ecandidat    文件:CandidatParcoursController.java   
/** 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);
}
项目:esup-ecandidat    文件:CandidatParcoursController.java   
/**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);
}
项目:osc-core    文件:SslCertificateUploader.java   
@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);
    }
}
项目:esup-ecandidat    文件:CandidatParcoursController.java   
/**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);
}
项目:esup-ecandidat    文件:SiScolController.java   
/**
 * 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);
}
项目:esup-ecandidat    文件:SiScolController.java   
/** 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);
    }
}
项目:osc-core    文件:PluginsLayout.java   
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);
            }
        }

    };
}
项目:osc-core    文件:DistributedApplianceView.java   
@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);
    }
}
项目:esup-ecandidat    文件:CandidatController.java   
/**
 * 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);
}
项目:osc-core    文件:BaseDeploymentSpecWindow.java   
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);
    }
}
项目:osc-core    文件:SslConfigurationLayout.java   
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;
}
项目:osc-core    文件:BaseSecurityGroupInterfaceWindow.java   
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;
}
项目:osc-core    文件:InternalCertReplacementUploader.java   
@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();
            }
        }});
}
项目:osc-core    文件:SecurityGroupMembershipInfoWindow.java   
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);
    }
}
项目:textfieldformatter    文件:DefaultNumeralFieldFormatterUsageUI.java   
@Override
public Component getTestComponent() {
    TextField tf = new TextField();
    new NumeralFieldFormatter(tf);
    tf.addValueChangeListener(l -> Notification.show("Value: " + l.getValue()));
    return tf;
}