Search in sources :

Example 1 with PopupView

use of com.vaadin.ui.PopupView in project opencms-core by alkacon.

the class CmsToolBar method createDropDown.

/**
 * Creates a drop down menu.<p>
 *
 * @param buttonHtml the button HTML
 * @param content the drop down content
 * @param title the button title
 *
 * @return the component
 */
public static Component createDropDown(String buttonHtml, Component content, String title) {
    PopupView pv = new PopupView(buttonHtml, content);
    pv.setDescription(title);
    pv.addStyleName(OpenCmsTheme.NAVIGATOR_DROPDOWN);
    pv.setHideOnMouseOut(false);
    return pv;
}
Also used : PopupView(com.vaadin.ui.PopupView)

Example 2 with PopupView

use of com.vaadin.ui.PopupView in project opencms-core by alkacon.

the class CmsToolBar method createQuickLaunchDropDown.

/**
 * Creates the app select drop down.<p>
 *
 * @return the drop down component
 */
private Component createQuickLaunchDropDown() {
    PopupView pv = new PopupView(new PopupView.Content() {

        private static final long serialVersionUID = 1L;

        public String getMinimizedValueAsHTML() {
            return getDropDownButtonHtml(FontOpenCms.APPS);
        }

        public Component getPopupComponent() {
            CmsObject cms = A_CmsUI.getCmsObject();
            Locale locale = UI.getCurrent().getLocale();
            HorizontalLayout layout = new HorizontalLayout();
            layout.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
            layout.addStyleName(OpenCmsTheme.QUICK_LAUNCH);
            layout.setSpacing(false);
            layout.setMargin(true);
            for (I_CmsWorkplaceAppConfiguration config : OpenCms.getWorkplaceAppManager().getQuickLaunchConfigurations(cms)) {
                layout.addComponent(CmsDefaultAppButtonProvider.createAppButton(cms, config, locale));
            }
            return layout;
        }
    });
    pv.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_QUICK_LAUNCH_TITLE_0));
    pv.addStyleName(OpenCmsTheme.NAVIGATOR_DROPDOWN);
    pv.setHideOnMouseOut(false);
    return pv;
}
Also used : Locale(java.util.Locale) CmsObject(org.opencms.file.CmsObject) PopupView(com.vaadin.ui.PopupView) I_CmsWorkplaceAppConfiguration(org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration) Component(com.vaadin.ui.Component) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 3 with PopupView

use of com.vaadin.ui.PopupView in project opencms-core by alkacon.

the class CmsToolBar method createUserInfoDropDown.

/**
 * Creates the user info drop down.<p>
 *
 * @return the drop down component
 */
private Component createUserInfoDropDown() {
    PopupView pv = new PopupView(new PopupView.Content() {

        private static final long serialVersionUID = 1L;

        public String getMinimizedValueAsHTML() {
            CmsObject cms = A_CmsUI.getCmsObject();
            return getDropDownButtonHtml(new ExternalResource(OpenCms.getWorkplaceAppManager().getUserIconHelper().getSmallIconPath(cms, cms.getRequestContext().getCurrentUser())));
        }

        public Component getPopupComponent() {
            return new CmsUserInfo(new I_UploadListener() {

                public void onUploadFinished(List<String> uploadedFiles) {
                    handleUpload(uploadedFiles);
                }
            }, getDialogContext());
        }
    });
    pv.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_USER_INFO_TITLE_0));
    pv.addStyleName(OpenCmsTheme.NAVIGATOR_DROPDOWN);
    pv.setHideOnMouseOut(false);
    pv.addStyleName(OpenCmsTheme.USER_INFO);
    return pv;
}
Also used : CmsObject(org.opencms.file.CmsObject) I_UploadListener(org.opencms.ui.components.CmsUploadButton.I_UploadListener) PopupView(com.vaadin.ui.PopupView) List(java.util.List) Component(com.vaadin.ui.Component) ExternalResource(com.vaadin.server.ExternalResource)

Example 4 with PopupView

use of com.vaadin.ui.PopupView in project esup-ecandidat by EsupPortail.

the class CtrCandFormationView method init.

/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setSizeFull();
    setMargin(true);
    setSpacing(true);
    /* Récupération du centre de canidature en cours */
    securityCtrCandFonc = userController.getCtrCandFonctionnalite(NomenclatureUtils.FONCTIONNALITE_GEST_FORMATION);
    if (securityCtrCandFonc.hasNoRight()) {
        return;
    }
    /* Titre */
    HorizontalLayout hlTitle = new HorizontalLayout();
    hlTitle.setSpacing(true);
    addComponent(hlTitle);
    Label titleParam = new Label(applicationContext.getMessage("formation.title", new Object[] { securityCtrCandFonc.getCtrCand().getLibCtrCand() }, UI.getCurrent().getLocale()));
    titleParam.addStyleName(StyleConstants.VIEW_TITLE);
    hlTitle.addComponent(titleParam);
    PopupView puv = new PopupView(applicationContext.getMessage("formation.table.flagEtat.tooltip", null, UI.getCurrent().getLocale()), getLegendLayout());
    hlTitle.addComponent(puv);
    hlTitle.setComponentAlignment(puv, Alignment.MIDDLE_LEFT);
    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    addComponent(buttonsLayout);
    /* Nouvelle formation */
    OneClickButton btnNew = new OneClickButton(applicationContext.getMessage("formation.btnNouveau", null, UI.getCurrent().getLocale()), FontAwesome.PLUS);
    btnNew.setEnabled(true);
    btnNew.addClickListener(e -> {
        formationController.editNewFormation(securityCtrCandFonc);
    });
    buttonsLayout.addComponent(btnNew);
    buttonsLayout.setComponentAlignment(btnNew, Alignment.MIDDLE_LEFT);
    /* Edition de formation */
    OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
    btnEdit.setEnabled(false);
    btnEdit.addClickListener(e -> {
        Formation f = getFormation();
        if (f instanceof Formation) {
            formationController.editFormation(f, securityCtrCandFonc);
        }
    });
    buttonsLayout.addComponent(btnEdit);
    buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_CENTER);
    /* Edition de dates */
    // 
    OneClickButton btnEditDate = new OneClickButton(applicationContext.getMessage("formation.btnEditDate", null, UI.getCurrent().getLocale()), FontAwesome.CALENDAR);
    btnEditDate.setDescription(applicationContext.getMessage("formation.btnEditDate.desc", null, UI.getCurrent().getLocale()));
    btnEditDate.setEnabled(false);
    btnEditDate.addClickListener(e -> {
        formationController.editDates(getFormations(), securityCtrCandFonc.getCtrCand());
    });
    buttonsLayout.addComponent(btnEditDate);
    buttonsLayout.setComponentAlignment(btnEditDate, Alignment.MIDDLE_CENTER);
    /* Edition des pièces */
    OneClickButton btnEditPieceComp = new OneClickButton(applicationContext.getMessage("formation.btnEditPiece", null, UI.getCurrent().getLocale()), FontAwesome.FILE_TEXT_O);
    btnEditPieceComp.setEnabled(false);
    btnEditPieceComp.addClickListener(e -> {
        formationController.editPieceCompFormation(getFormations(), securityCtrCandFonc.getCtrCand());
    });
    buttonsLayout.addComponent(btnEditPieceComp);
    buttonsLayout.setComponentAlignment(btnEditPieceComp, Alignment.MIDDLE_CENTER);
    /* Suppression formation */
    OneClickButton btnDelete = new OneClickButton(applicationContext.getMessage("btnDelete", null, UI.getCurrent().getLocale()), FontAwesome.TRASH_O);
    btnDelete.setEnabled(false);
    btnDelete.addClickListener(e -> {
        Formation f = getFormation();
        if (f instanceof Formation) {
            formationController.deleteFormation(f);
        }
    });
    buttonsLayout.addComponent(btnDelete);
    buttonsLayout.setComponentAlignment(btnDelete, Alignment.MIDDLE_RIGHT);
    OneClickButton btnExport = new OneClickButton(FontAwesome.FILE_EXCEL_O);
    /* Export de la liste des formations */
    btnExport.setDescription(applicationContext.getMessage("btnExport", null, UI.getCurrent().getLocale()));
    btnExport.setDisableOnClick(true);
    new OnDemandFileDownloader(new OnDemandStreamFile() {

        @Override
        public OnDemandFile getOnDemandFile() {
            @SuppressWarnings("unchecked") List<Formation> listeForm = (List<Formation>) formationGrid.getContainerDataSource().getItemIds();
            if (listeForm.size() == 0) {
                btnExport.setEnabled(true);
                return null;
            }
            /* Téléchargement */
            OnDemandFile file = formationController.generateExport(listeForm, securityCtrCandFonc);
            if (file != null) {
                btnExport.setEnabled(true);
                return file;
            }
            btnExport.setEnabled(true);
            return null;
        }
    }, btnExport);
    buttonsLayout.addComponent(btnExport);
    buttonsLayout.setComponentAlignment(btnExport, Alignment.MIDDLE_RIGHT);
    /* Table des formations */
    formationGrid.initColumn(FIELDS_ORDER, "formation.table.", Formation_.codForm.getName());
    formationGrid.setSelectionMode(SelectionMode.MULTI);
    formationGrid.addItems(formationController.getFormationsByCtrCand(securityCtrCandFonc));
    formationGrid.getColumn(Formation.FLAG_COLUMN_NAME).setRenderer(new ImageRenderer(), new StringToThemeRessourceConverter());
    formationGrid.setCellDescriptionGenerator(new CellDescriptionGenerator() {

        @Override
        public String getDescription(final CellReference cell) {
            Formation f = (Formation) cell.getItemId();
            if (cell.getPropertyId().equals(Formation.FLAG_COLUMN_NAME)) {
                try {
                    String code = null;
                    if (cell.getPropertyId().equals(Formation.FLAG_COLUMN_NAME)) {
                        code = f.getFlagEtat();
                        if (code != null) {
                            return applicationContext.getMessage("formation.table.flagEtat.tooltip." + code, null, UI.getCurrent().getLocale());
                        }
                    }
                } catch (Exception e) {
                }
            }
            return null;
        }
    });
    formationGrid.removeFilterCells(Formation.FLAG_COLUMN_NAME);
    formationGrid.setColumnsWidth(62, Formation.FLAG_COLUMN_NAME);
    formationGrid.setColumnsWidth(130, Formation_.codForm.getName());
    formationGrid.setColumnsWidth(143, Formation_.temDematForm.getName());
    formationGrid.setColumnsWidth(100, Formation_.tesForm.getName());
    formationGrid.setColumnsWidth(200, Formation.DAT_VOEUX_COLUMN_NAME);
    formationGrid.setColumnsWidth(260, Formation_.commission.getName() + "." + Commission_.libComm.getName());
    formationGrid.addSelectionListener(e -> {
        /*
			 * Les boutons d'édition et de suppression de formation sont actifs seulement si
			 * une formation est sélectionnée.
			 */
        Integer nb = formationGrid.getSelectedRows().size();
        btnEdit.setEnabled(nb == 1);
        btnDelete.setEnabled(nb == 1);
        btnEditPieceComp.setEnabled(nb >= 1);
        btnEditDate.setEnabled(nb >= 1);
    });
    formationGrid.addItemClickListener(e -> {
        /* Suivant le mode de slection de la grid on fait un traitement */
        MultiSelectionModel selection = (MultiSelectionModel) formationGrid.getSelectionModel();
        selection.deselectAll();
        try {
            selection.select(e.getItemId());
        } catch (Exception e1) {
            return;
        }
    });
    addComponent(formationGrid);
    setExpandRatio(formationGrid, 1);
    formationGrid.setSizeFull();
    /* Gestion du readOnly */
    if (securityCtrCandFonc.isWrite()) {
        formationGrid.addItemClickListener(e -> {
            if (e.isDoubleClick()) {
                formationGrid.select(e.getItemId());
                btnEdit.click();
            }
        });
        buttonsLayout.setVisible(true);
    } else {
        buttonsLayout.setVisible(false);
    }
    /* Inscrit la vue aux mises à jour de formation */
    formationEntityPusher.registerEntityPushListener(this);
}
Also used : OnDemandStreamFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileUtils.OnDemandStreamFile) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) OnDemandFileDownloader(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileDownloader) MultiSelectionModel(com.vaadin.ui.Grid.MultiSelectionModel) Label(com.vaadin.ui.Label) PopupView(com.vaadin.ui.PopupView) OnDemandFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFile) StringToThemeRessourceConverter(fr.univlorraine.ecandidat.vaadin.components.GridConverter.StringToThemeRessourceConverter) CellReference(com.vaadin.ui.Grid.CellReference) CellDescriptionGenerator(com.vaadin.ui.Grid.CellDescriptionGenerator) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ImageRenderer(com.vaadin.ui.renderers.ImageRenderer) List(java.util.List) Formation(fr.univlorraine.ecandidat.entities.ecandidat.Formation) PostConstruct(javax.annotation.PostConstruct)

Example 5 with PopupView

use of com.vaadin.ui.PopupView in project esup-ecandidat by EsupPortail.

the class CandidatureViewTemplate method init.

/**
 * Initialise la vue
 */
/**
 * @param modeModification
 * @param typGestionCandidature
 * @param isCanceled
 * @param isArchived
 */
public void init(final Boolean modeModification, final String typGestionCandidature, final Boolean isCanceled, final Boolean isArchived) {
    modeModif = modeModification;
    /* Style */
    setSizeFull();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    addComponent(layout);
    /* Titre */
    final HorizontalLayout hlTitle = new HorizontalLayout();
    hlTitle.setWidth(100, Unit.PERCENTAGE);
    hlTitle.setSpacing(true);
    titleView.setSizeUndefined();
    titleView.addStyleName(StyleConstants.VIEW_TITLE);
    hlTitle.addComponent(titleView);
    /* PopUp Légende */
    pvLegende = new PopupView(applicationContext.getMessage("legend.popup.link", null, UI.getCurrent().getLocale()), null);
    pvLegende.setVisible(false);
    hlTitle.addComponent(pvLegende);
    hlTitle.setComponentAlignment(pvLegende, Alignment.MIDDLE_LEFT);
    final Label spacer1 = new Label();
    spacer1.setWidth(100, Unit.PERCENTAGE);
    hlTitle.addComponent(spacer1);
    hlTitle.setExpandRatio(spacer1, 1);
    /* Label du nombre de candidatures */
    nbCandidatureLabel.setSizeUndefined();
    nbCandidatureLabel.addStyleName(ValoTheme.LABEL_COLORED);
    nbCandidatureLabel.addStyleName(StyleConstants.LABEL_ITALIC);
    hlTitle.addComponent(nbCandidatureLabel);
    hlTitle.setComponentAlignment(nbCandidatureLabel, Alignment.BOTTOM_RIGHT);
    final Label labelSpaceNb = new Label(" - ");
    labelSpaceNb.setSizeUndefined();
    labelSpaceNb.addStyleName(ValoTheme.LABEL_COLORED);
    labelSpaceNb.addStyleName(StyleConstants.LABEL_ITALIC);
    hlTitle.addComponent(labelSpaceNb);
    hlTitle.setComponentAlignment(labelSpaceNb, Alignment.BOTTOM_RIGHT);
    nbCandidatureLabelSelected.setSizeUndefined();
    nbCandidatureLabelSelected.addStyleName(ValoTheme.LABEL_COLORED);
    nbCandidatureLabelSelected.addStyleName(StyleConstants.LABEL_MORE_BOLD);
    nbCandidatureLabelSelected.addStyleName(StyleConstants.LABEL_ITALIC);
    hlTitle.addComponent(nbCandidatureLabelSelected);
    hlTitle.setComponentAlignment(nbCandidatureLabelSelected, Alignment.BOTTOM_RIGHT);
    layout.addComponent(hlTitle);
    /* Les droits sur les candidatures */
    final List<DroitFonctionnalite> listeDroitFonc = droitProfilController.getCandidatureFonctionnalite(typGestionCandidature, null);
    Boolean droitOpenCandidature = false;
    final Authentication auth = userController.getCurrentAuthentication();
    if (MethodUtils.isGestionCandidatureCtrCand(typGestionCandidature)) {
        /* Récupération du centre de candidature en cours */
        securityCtrCandFonc = userController.getCtrCandFonctionnalite(NomenclatureUtils.FONCTIONNALITE_GEST_CANDIDATURE, auth);
        if (securityCtrCandFonc.hasNoRight()) {
            return;
        }
        /* Verification que l'utilisateur a le droit d'ouvrir la candidature */
        final SecurityCtrCandFonc openCandidatureFonc = userController.getCtrCandFonctionnalite(NomenclatureUtils.FONCTIONNALITE_GEST_FENETRE_CAND, auth);
        if (!openCandidatureFonc.hasNoRight()) {
            droitOpenCandidature = true;
        }
        /* Chooser de commissions */
        final List<Commission> liste = commissionController.getCommissionsEnServiceByCtrCand(securityCtrCandFonc.getCtrCand(), securityCtrCandFonc.getIsGestAllCommission(), securityCtrCandFonc.getListeIdCommission(), isArchived);
        liste.sort(Comparator.comparing(Commission::getGenericLibelleAlternatif));
        cbCommission.setWidth(500, Unit.PIXELS);
        cbCommission.setItemCaptionPropertyId(ConstanteUtils.GENERIC_LIBELLE_ALTERNATIF);
        cbCommission.setTextInputAllowed(true);
        cbCommission.filterListValue(liste);
        cbCommission.setFilteringMode(FilteringMode.CONTAINS);
        cbCommission.setItemCaptionMode(ItemCaptionMode.PROPERTY);
        cbCommission.setPageLength(25);
        if (liste.size() > 0) {
            final Integer idCommEnCours = preferenceController.getPrefCandIdComm();
            if (idCommEnCours != null) {
                if (!cbCommission.setCommissionValue(idCommEnCours)) {
                    cbCommission.setValue(liste.get(0));
                }
            } else {
                cbCommission.setValue(liste.get(0));
            }
        }
        cbCommission.addValueChangeListener(e -> {
            majContainer();
            preferenceController.setPrefCandIdComm(getCommission());
        });
        /* Filtrage */
        final Panel panelCommission = new Panel();
        panelCommission.setWidth(100, Unit.PERCENTAGE);
        final HorizontalLayout filtreLayout = new HorizontalLayout();
        filtreLayout.setMargin(true);
        layout.addComponent(panelCommission);
        filtreLayout.setSpacing(true);
        final Label labelFiltre = new Label(applicationContext.getMessage("candidature.change.commission", null, UI.getCurrent().getLocale()));
        filtreLayout.addComponent(labelFiltre);
        filtreLayout.setComponentAlignment(labelFiltre, Alignment.MIDDLE_LEFT);
        filtreLayout.addComponent(cbCommission);
        filtreLayout.setComponentAlignment(cbCommission, Alignment.BOTTOM_LEFT);
        // popup astuce
        final PopupView pvAstuce = new PopupView(createPopUpAstuce());
        filtreLayout.addComponent(pvAstuce);
        filtreLayout.setComponentAlignment(pvAstuce, Alignment.MIDDLE_LEFT);
        panelCommission.setContent(filtreLayout);
    } else if (MethodUtils.isGestionCandidatureCommission(typGestionCandidature)) {
        /* Récupération de la commission en cours en cours */
        securityCommissionFonc = userController.getCommissionFonctionnalite(NomenclatureUtils.FONCTIONNALITE_GEST_CANDIDATURE, auth);
        if (securityCommissionFonc.hasNoRight()) {
            return;
        }
        /* Verification que l'utilisateur a le droit d'ouvrir la candidature */
        final SecurityCommissionFonc openCandidatureFonc = userController.getCommissionFonctionnalite(NomenclatureUtils.FONCTIONNALITE_GEST_FENETRE_CAND, auth);
        if (!openCandidatureFonc.hasNoRight()) {
            droitOpenCandidature = true;
        }
    }
    /* Mise a jour des listes utilisées */
    listeAlertesSva = alertSvaController.getAlertSvaEnService();
    listeTags = tagController.getTagEnServiceByCtrCand(getCentreCandidature());
    final Boolean droitOpenCandidatureFinal = droitOpenCandidature;
    /* Boutons */
    final HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);
    /* Bouton d'ouverture de candidature */
    btnOpen.setCaption(applicationContext.getMessage("btnOpen", null, UI.getCurrent().getLocale()));
    btnOpen.setEnabled(false);
    btnOpen.addClickListener(e -> {
        final Candidature candidature = getCandidatureSelected();
        if (droitOpenCandidatureFinal && candidature != null) {
            candidatureController.openCandidatureGestionnaire(candidature, isCanceled, isArchived, listeDroitFonc);
        }
    });
    buttonsLayout.addComponent(btnOpen);
    buttonsLayout.setComponentAlignment(btnOpen, Alignment.MIDDLE_LEFT);
    if (modeModif && listeDroitFonc.stream().filter(e -> !e.getCodFonc().equals(NomenclatureUtils.FONCTIONNALITE_GEST_FENETRE_CAND)).count() > 0) {
        /* Bouton d'action */
        btnAction.setCaption(applicationContext.getMessage("btnAction", null, UI.getCurrent().getLocale()));
        btnAction.setEnabled(false);
        btnAction.addClickListener(e -> {
            final List<Candidature> listeCheck = getListeCandidatureSelected();
            if (listeCheck.size() == 0) {
                Notification.show(applicationContext.getMessage("candidature.noselected", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
            } else if (listeCheck.size() > ConstanteUtils.SIZE_MAX_EDITION_MASSE) {
                Notification.show(applicationContext.getMessage("candidature.toomuchselected", new Object[] { ConstanteUtils.SIZE_MAX_EDITION_MASSE }, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
                return;
            } else {
                candidatureCtrCandController.editActionCandidatureMasse(listeCheck, listeDroitFonc, getCentreCandidature(), this);
            }
        });
        buttonsLayout.addComponent(btnAction);
        buttonsLayout.setComponentAlignment(btnAction, Alignment.MIDDLE_CENTER);
    }
    /* Les options */
    final HorizontalLayout hlOption = new HorizontalLayout();
    hlOption.setSpacing(true);
    buttonsLayout.addComponent(hlOption);
    buttonsLayout.setComponentAlignment(hlOption, Alignment.MIDDLE_RIGHT);
    /* Export de la liste de candidature */
    btnExport.setDescription(applicationContext.getMessage("btnExport", null, UI.getCurrent().getLocale()));
    btnExport.addClickListener(e -> {
        @SuppressWarnings("unchecked") final List<Candidature> listeCand = (List<Candidature>) candidatureGrid.getContainerDataSource().getItemIds();
        if (listeCand.size() == 0) {
            return;
        }
        final CtrCandExportWindow window = new CtrCandExportWindow(getCommission(), listeCand);
        UI.getCurrent().addWindow(window);
    });
    hlOption.addComponent(btnExport);
    /* Filtres de comboBox perso */
    final String libFilterNull = applicationContext.getMessage("filter.null", null, UI.getCurrent().getLocale());
    final String libFilterExceptAtt = applicationContext.getMessage("filter.except.attente", null, UI.getCurrent().getLocale());
    final List<ComboBoxFilterPresentation> listeCbFilter = new ArrayList<>();
    /* Filtre de tag */
    listeCbFilter.add(new ComboBoxFilterPresentation(Candidature_.tags.getName(), getComboBoxFilterTag(), getNullTag(), TypeFilter.LIST_CONTAINS));
    /* Les filtres sur les Strings */
    listeCbFilter.add(new ComboBoxFilterPresentation(Candidature_.typeStatut.getName() + "." + TypeStatut_.libTypStatut.getName(), libFilterExceptAtt, tableRefController.getTypeStatutEnAttente().getLibTypStatut(), getComboBoxTypStatut(libFilterExceptAtt)));
    listeCbFilter.add(new ComboBoxFilterPresentation(Candidature_.typeTraitement.getName() + "." + TypeTraitement_.libTypTrait.getName(), libFilterExceptAtt, tableRefController.getTypeTraitementEnAttente().getLibTypTrait(), getComboBoxTypTrait(libFilterExceptAtt)));
    listeCbFilter.add(new ComboBoxFilterPresentation(LAST_TYPE_DECISION_PREFIXE + TypeDecisionCandidature_.typeDecision.getName() + "." + TypeDecision_.libTypDec.getName(), getComboBoxTypDec(libFilterNull), libFilterNull, TypeFilter.EQUALS));
    listeCbFilter.add(new ComboBoxFilterPresentation(Candidature_.siScolCatExoExt.getName() + "." + SiScolCatExoExt.DISPLAY_LIB_FIELD, getComboBoxCatExoExt(libFilterNull), libFilterNull, TypeFilter.EQUALS));
    /* La colonne de tag n'est plus automatiquement visibles si aucun tags en service */
    final String[] fieldsOrderVisibletoUse = (listeTags.size() != 0) ? FIELDS_ORDER_VISIBLE : (String[]) ArrayUtils.removeElement(FIELDS_ORDER_VISIBLE, Candidature_.tags.getName());
    /* Les préférences */
    final Integer frozen = preferenceController.getPrefCandFrozenColonne(1);
    final String[] visibleColonne = preferenceController.getPrefCandColonnesVisible(fieldsOrderVisibletoUse, FIELDS_ORDER);
    final String[] orderColonne = preferenceController.getPrefCandColonnesOrder(FIELDS_ORDER);
    final List<SortOrder> sortColonne = preferenceController.getPrefCandSortColonne(FIELDS_ORDER);
    /* Bouton de modification de preferences */
    final OneClickButton btnPref = new OneClickButton(FontAwesome.COG);
    btnPref.setDescription(applicationContext.getMessage("preference.view.btn", null, UI.getCurrent().getLocale()));
    btnPref.addClickListener(e -> {
        final CtrCandPreferenceViewWindow window = new CtrCandPreferenceViewWindow(candidatureGrid.getColumns(), candidatureGrid.getFrozenColumnCount(), FIELDS_ORDER.length, candidatureGrid.getSortOrder());
        window.addPreferenceViewListener(new PreferenceViewListener() {

            @Override
            public void saveInSession(final String valeurColonneVisible, final String valeurColonneOrder, final Integer frozenCols, final List<SortOrder> listeSortOrder) {
                preferenceController.savePrefCandInSession(valeurColonneVisible, valeurColonneOrder, frozenCols, listeSortOrder, true);
                candidatureGrid.setFrozenColumnCount(frozenCols);
                candidatureGrid.sort(listeSortOrder);
            }

            @Override
            public void saveInDb(final String valeurColonneVisible, final String valeurColonneOrder, final Integer frozenCols, final List<SortOrder> listeSortOrder) {
                preferenceController.savePrefCandInDb(valeurColonneVisible, valeurColonneOrder, frozenCols, listeSortOrder);
                candidatureGrid.setFrozenColumnCount(frozenCols);
                candidatureGrid.sort(listeSortOrder);
            }

            @Override
            public void initPref() {
                preferenceController.initPrefCand();
                candidatureGrid.setFrozenColumnCount(1);
                candidatureGrid.initColumn(FIELDS_ORDER, FIELDS_ORDER_VISIBLE, FIELDS_ORDER, "candidature.table.", preferenceController.getDefaultSortOrder(), listeCbFilter);
                candidatureGrid.sort();
            }
        });
        UI.getCurrent().addWindow(window);
    });
    /* Download du dossier */
    btnDownload.setEnabled(false);
    final Integer nb = parametreController.getNbDownloaMultipliedMax();
    if (nb.equals(1)) {
        btnDownload.setDescription(applicationContext.getMessage("candidature.download.btn", null, UI.getCurrent().getLocale()));
    } else {
        btnDownload.setDescription(applicationContext.getMessage("candidature.download.multiple.btn", new Object[] { nb }, UI.getCurrent().getLocale()));
    }
    new OnDemandFileDownloader(new OnDemandStreamFile() {

        @Override
        public OnDemandFile getOnDemandFile() {
            final OnDemandFile file = candidatureController.downlaodMultipleDossier(getListeCandidatureSelected(), getCommission());
            if (file != null) {
                btnDownload.setEnabled(true);
                return file;
            }
            btnDownload.setEnabled(true);
            return null;
        }
    }, btnDownload);
    /* Download des PJ */
    btnDownloadPj.setEnabled(false);
    btnDownloadPj.setDescription(applicationContext.getMessage("candidature.download.pj.btn", new Object[] { nb }, UI.getCurrent().getLocale()));
    btnDownloadPj.addClickListener(e -> {
        UI.getCurrent().addWindow(new CtrCandDownloadPJWindow(getCommission(), getListeCandidatureSelected()));
    });
    hlOption.addComponent(btnExport);
    hlOption.addComponent(btnDownload);
    hlOption.addComponent(btnDownloadPj);
    hlOption.addComponent(btnPref);
    /* Grid des candidatures */
    candidatureGrid.initColumn(FIELDS_ORDER, visibleColonne, orderColonne, "candidature.table.", sortColonne, listeCbFilter);
    /* Ajout des colonnes gelées */
    candidatureGrid.setFrozenColumnCount(frozen);
    /* Ajout du flag */
    candidatureGrid.setColumnConverter(Candidature_.tags.getName(), new TagsToHtmlSquareConverter());
    candidatureGrid.setColumnRenderer(Candidature_.tags.getName(), new HtmlRenderer());
    /* Formatage monnétaire */
    candidatureGrid.setColumnConverter(Candidature_.mntChargeCand.getName(), new BigDecimalMonetaireToStringConverter());
    candidatureGrid.setColumnRenderer(Candidature_.mntChargeCand.getName(), new HtmlRenderer());
    /* Mise a jour des données lors du filtre */
    candidatureGrid.addFilterListener(() -> {
        deselectFilter();
    });
    /* Mode de selection de la grid */
    if (modeModif) {
        candidatureGrid.setSelectionMode(SelectionMode.MULTI);
        final MultiSelectionModel selection = (MultiSelectionModel) candidatureGrid.getSelectionModel();
        selection.setSelectionLimit(ConstanteUtils.SIZE_MAX_EDITION_MASSE);
        candidatureGrid.addSelectionListener(e -> {
            if (candidatureGrid.getSelectedRows().size() == ConstanteUtils.SIZE_MAX_EDITION_MASSE) {
                Notification.show(applicationContext.getMessage("candidature.maxselected", new Object[] { ConstanteUtils.SIZE_MAX_EDITION_MASSE }, UI.getCurrent().getLocale()), Type.TRAY_NOTIFICATION);
            }
        });
    } else {
        candidatureGrid.setSelectionMode(SelectionMode.SINGLE);
    }
    /* Selection de la grid */
    candidatureGrid.addSelectionListener(e -> {
        setButtonState(droitOpenCandidatureFinal, listeDroitFonc);
        majNbCandidatures();
    });
    /* CLique sur un item */
    candidatureGrid.addItemClickListener(e -> {
        /* Suivant le mode de slection de la grid on fait un traitement */
        if (modeModif) {
            final MultiSelectionModel selection = (MultiSelectionModel) candidatureGrid.getSelectionModel();
            selection.deselectAll();
            try {
                selection.select(e.getItemId());
            } catch (final Exception e1) {
                Notification.show(applicationContext.getMessage("candidature.select.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
                majContainer();
                return;
            }
            setButtonState(droitOpenCandidatureFinal, listeDroitFonc);
            if (droitOpenCandidatureFinal && e.isDoubleClick()) {
                if (e.getItemId() instanceof Candidature) {
                    candidatureController.openCandidatureGestionnaire((Candidature) e.getItemId(), isCanceled, isArchived, listeDroitFonc);
                }
            }
            majNbCandidatures();
        } else {
            final SingleSelectionModel selection = (SingleSelectionModel) candidatureGrid.getSelectionModel();
            try {
                selection.select(e.getItemId());
            } catch (final Exception e1) {
                Notification.show(applicationContext.getMessage("candidature.select.error", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
                majContainer();
                return;
            }
            setButtonState(droitOpenCandidatureFinal, listeDroitFonc);
            if (e.isDoubleClick()) {
                if (droitOpenCandidatureFinal && e.getItemId() instanceof Candidature) {
                    candidatureController.openCandidatureGestionnaire((Candidature) e.getItemId(), isCanceled, isArchived, listeDroitFonc);
                }
            }
            majNbCandidatures();
        }
    });
    /* Ajustement de la taille de colonnes */
    candidatureGrid.setColumnWidth(Candidature_.candidat.getName() + "." + Candidat_.compteMinima.getName() + "." + CompteMinima_.numDossierOpiCptMin.getName(), 120);
    candidatureGrid.setColumnWidth(Candidature_.candidat.getName() + "." + Candidat_.nomPatCandidat.getName(), 130);
    candidatureGrid.setColumnWidth(Candidature_.candidat.getName() + "." + Candidat_.prenomCandidat.getName(), 120);
    candidatureGrid.setColumnWidth(Candidature_.formation.getName() + "." + Formation_.codForm.getName(), 130);
    candidatureGrid.setColumnWidth(Candidature_.formation.getName() + "." + Formation_.libForm.getName(), 200);
    candidatureGrid.setColumnWidth(LAST_TYPE_DECISION_PREFIXE + TypeDecisionCandidature_.commentTypeDecCand.getName(), 120);
    candidatureGrid.setColumnWidth(LAST_TYPE_DECISION_PREFIXE + TypeDecisionCandidature_.motivationAvis.getName() + "." + MotivationAvis_.libMotiv.getName(), 120);
    candidatureGrid.setColumnWidth(Candidature_.typeStatut.getName() + "." + TypeStatut_.libTypStatut.getName(), 145);
    candidatureGrid.setColumnWidth(Candidature_.typeTraitement.getName() + "." + TypeTraitement_.libTypTrait.getName(), 157);
    candidatureGrid.setColumnWidth(Candidature_.temAcceptCand.getName(), 151);
    candidatureGrid.setColumnWidth(Candidature_.tags.getName(), 100);
    candidatureGrid.setColumnWidth(Candidature_.datNewConfirmCand.getName(), 210);
    candidatureGrid.setColumnWidth(Candidature_.datNewRetourCand.getName(), 180);
    layout.addComponent(candidatureGrid);
    layout.setExpandRatio(candidatureGrid, 1);
    candidatureGrid.setSizeFull();
    /* Ajoute les alertes SVA */
    addAlertSva(isCanceled, isArchived);
    /* Ajoute la légende */
    addLegend();
}
Also used : Panel(com.vaadin.ui.Panel) CommissionController(fr.univlorraine.ecandidat.controllers.CommissionController) PreferenceController(fr.univlorraine.ecandidat.controllers.PreferenceController) Opi_(fr.univlorraine.ecandidat.entities.ecandidat.Opi_) CtrCandExportWindow(fr.univlorraine.ecandidat.views.windows.CtrCandExportWindow) OnDemandStreamFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileUtils.OnDemandStreamFile) CandidatureController(fr.univlorraine.ecandidat.controllers.CandidatureController) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) PreferenceViewListener(fr.univlorraine.ecandidat.views.windows.CtrCandPreferenceViewWindow.PreferenceViewListener) CentreCandidature(fr.univlorraine.ecandidat.entities.ecandidat.CentreCandidature) Map(java.util.Map) Page(com.vaadin.server.Page) CompteMinima_(fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima_) GridFormatting(fr.univlorraine.ecandidat.vaadin.components.GridFormatting) ItemCaptionMode(com.vaadin.ui.AbstractSelect.ItemCaptionMode) ValoTheme(com.vaadin.ui.themes.ValoTheme) OnDemandFileDownloader(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileDownloader) PopupView(com.vaadin.ui.PopupView) Candidature_(fr.univlorraine.ecandidat.entities.ecandidat.Candidature_) ConstanteUtils(fr.univlorraine.ecandidat.utils.ConstanteUtils) Position(com.vaadin.shared.Position) FilteringMode(com.vaadin.shared.ui.combobox.FilteringMode) MethodUtils(fr.univlorraine.ecandidat.utils.MethodUtils) SecurityCtrCandFonc(fr.univlorraine.ecandidat.services.security.SecurityCtrCandFonc) TypeDecisionCandidature_(fr.univlorraine.ecandidat.entities.ecandidat.TypeDecisionCandidature_) Resource(javax.annotation.Resource) StyleConstants(fr.univlorraine.ecandidat.StyleConstants) TypeDecisionCandidature(fr.univlorraine.ecandidat.entities.ecandidat.TypeDecisionCandidature) RowStyleGenerator(com.vaadin.ui.Grid.RowStyleGenerator) TypeTraitement_(fr.univlorraine.ecandidat.entities.ecandidat.TypeTraitement_) BeanItemContainer(com.vaadin.data.util.BeanItemContainer) SingleSelectionModel(com.vaadin.ui.Grid.SingleSelectionModel) List(java.util.List) Type(com.vaadin.ui.Notification.Type) TagsToHtmlSquareConverter(fr.univlorraine.ecandidat.vaadin.components.GridConverter.TagsToHtmlSquareConverter) OnDemandFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFile) TypeDecisionController(fr.univlorraine.ecandidat.controllers.TypeDecisionController) LocalDate(java.time.LocalDate) TypeFilter(fr.univlorraine.ecandidat.utils.bean.presentation.ComboBoxFilterPresentation.TypeFilter) AdresseController(fr.univlorraine.ecandidat.controllers.AdresseController) Candidature(fr.univlorraine.ecandidat.entities.ecandidat.Candidature) SortOrder(com.vaadin.data.sort.SortOrder) UserController(fr.univlorraine.ecandidat.controllers.UserController) Authentication(org.springframework.security.core.Authentication) SelectionMode(com.vaadin.ui.Grid.SelectionMode) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) DroitProfilController(fr.univlorraine.ecandidat.controllers.DroitProfilController) TypeDecision_(fr.univlorraine.ecandidat.entities.ecandidat.TypeDecision_) StreamResource(com.vaadin.server.StreamResource) ContentMode(com.vaadin.shared.ui.label.ContentMode) BeanItem(com.vaadin.data.util.BeanItem) VerticalLayout(com.vaadin.ui.VerticalLayout) ComboBox(com.vaadin.ui.ComboBox) TableRefController(fr.univlorraine.ecandidat.controllers.TableRefController) HashMap(java.util.HashMap) AlertSva(fr.univlorraine.ecandidat.entities.ecandidat.AlertSva) BigDecimalMonetaireToStringConverter(fr.univlorraine.ecandidat.vaadin.components.GridConverter.BigDecimalMonetaireToStringConverter) Content(com.vaadin.ui.PopupView.Content) Tag_(fr.univlorraine.ecandidat.entities.ecandidat.Tag_) CtrCandDownloadPJWindow(fr.univlorraine.ecandidat.views.windows.CtrCandDownloadPJWindow) ArrayList(java.util.ArrayList) FontAwesome(com.vaadin.server.FontAwesome) CacheController(fr.univlorraine.ecandidat.controllers.CacheController) NomenclatureUtils(fr.univlorraine.ecandidat.utils.NomenclatureUtils) Notification(com.vaadin.ui.Notification) Formation_(fr.univlorraine.ecandidat.entities.ecandidat.Formation_) Label(com.vaadin.ui.Label) Candidat_(fr.univlorraine.ecandidat.entities.ecandidat.Candidat_) CtrCandPreferenceViewWindow(fr.univlorraine.ecandidat.views.windows.CtrCandPreferenceViewWindow) SiScolCatExoExt(fr.univlorraine.ecandidat.entities.ecandidat.SiScolCatExoExt) MotivationAvis_(fr.univlorraine.ecandidat.entities.ecandidat.MotivationAvis_) CandidatureMasseListener(fr.univlorraine.ecandidat.utils.ListenerUtils.CandidatureMasseListener) TypeStatut_(fr.univlorraine.ecandidat.entities.ecandidat.TypeStatut_) RowReference(com.vaadin.ui.Grid.RowReference) TagController(fr.univlorraine.ecandidat.controllers.TagController) TagImageSource(fr.univlorraine.ecandidat.vaadin.components.TagImageSource) Tag(fr.univlorraine.ecandidat.entities.ecandidat.Tag) ComboBoxCommission(fr.univlorraine.ecandidat.vaadin.form.combo.ComboBoxCommission) ApplicationContext(org.springframework.context.ApplicationContext) DroitFonctionnalite(fr.univlorraine.ecandidat.entities.ecandidat.DroitFonctionnalite) Commission(fr.univlorraine.ecandidat.entities.ecandidat.Commission) ParametreController(fr.univlorraine.ecandidat.controllers.ParametreController) ChronoUnit(java.time.temporal.ChronoUnit) AlertSvaController(fr.univlorraine.ecandidat.controllers.AlertSvaController) HorizontalLayout(com.vaadin.ui.HorizontalLayout) CandidatureCtrCandController(fr.univlorraine.ecandidat.controllers.CandidatureCtrCandController) SecurityCommissionFonc(fr.univlorraine.ecandidat.services.security.SecurityCommissionFonc) CandidaturePieceController(fr.univlorraine.ecandidat.controllers.CandidaturePieceController) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) ComboBoxFilterPresentation(fr.univlorraine.ecandidat.utils.bean.presentation.ComboBoxFilterPresentation) Comparator(java.util.Comparator) ArrayUtils(org.apache.commons.lang.ArrayUtils) Component(com.vaadin.ui.Component) MultiSelectionModel(com.vaadin.ui.Grid.MultiSelectionModel) OnDemandStreamFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileUtils.OnDemandStreamFile) SingleSelectionModel(com.vaadin.ui.Grid.SingleSelectionModel) MultiSelectionModel(com.vaadin.ui.Grid.MultiSelectionModel) Label(com.vaadin.ui.Label) ComboBoxCommission(fr.univlorraine.ecandidat.vaadin.form.combo.ComboBoxCommission) Commission(fr.univlorraine.ecandidat.entities.ecandidat.Commission) ArrayList(java.util.ArrayList) CentreCandidature(fr.univlorraine.ecandidat.entities.ecandidat.CentreCandidature) TypeDecisionCandidature(fr.univlorraine.ecandidat.entities.ecandidat.TypeDecisionCandidature) Candidature(fr.univlorraine.ecandidat.entities.ecandidat.Candidature) OnDemandFile(fr.univlorraine.ecandidat.vaadin.components.OnDemandFile) SecurityCommissionFonc(fr.univlorraine.ecandidat.services.security.SecurityCommissionFonc) HorizontalLayout(com.vaadin.ui.HorizontalLayout) CtrCandDownloadPJWindow(fr.univlorraine.ecandidat.views.windows.CtrCandDownloadPJWindow) CtrCandExportWindow(fr.univlorraine.ecandidat.views.windows.CtrCandExportWindow) CtrCandPreferenceViewWindow(fr.univlorraine.ecandidat.views.windows.CtrCandPreferenceViewWindow) List(java.util.List) ArrayList(java.util.ArrayList) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) OnDemandFileDownloader(fr.univlorraine.ecandidat.vaadin.components.OnDemandFileDownloader) PopupView(com.vaadin.ui.PopupView) SortOrder(com.vaadin.data.sort.SortOrder) PreferenceViewListener(fr.univlorraine.ecandidat.views.windows.CtrCandPreferenceViewWindow.PreferenceViewListener) ComboBoxFilterPresentation(fr.univlorraine.ecandidat.utils.bean.presentation.ComboBoxFilterPresentation) Panel(com.vaadin.ui.Panel) BigDecimalMonetaireToStringConverter(fr.univlorraine.ecandidat.vaadin.components.GridConverter.BigDecimalMonetaireToStringConverter) Authentication(org.springframework.security.core.Authentication) TagsToHtmlSquareConverter(fr.univlorraine.ecandidat.vaadin.components.GridConverter.TagsToHtmlSquareConverter) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) SecurityCtrCandFonc(fr.univlorraine.ecandidat.services.security.SecurityCtrCandFonc) DroitFonctionnalite(fr.univlorraine.ecandidat.entities.ecandidat.DroitFonctionnalite)

Aggregations

PopupView (com.vaadin.ui.PopupView)5 Component (com.vaadin.ui.Component)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 List (java.util.List)3 MultiSelectionModel (com.vaadin.ui.Grid.MultiSelectionModel)2 Label (com.vaadin.ui.Label)2 OnDemandFile (fr.univlorraine.ecandidat.vaadin.components.OnDemandFile)2 OnDemandFileDownloader (fr.univlorraine.ecandidat.vaadin.components.OnDemandFileDownloader)2 OnDemandStreamFile (fr.univlorraine.ecandidat.vaadin.components.OnDemandFileUtils.OnDemandStreamFile)2 OneClickButton (fr.univlorraine.ecandidat.vaadin.components.OneClickButton)2 CmsObject (org.opencms.file.CmsObject)2 SortOrder (com.vaadin.data.sort.SortOrder)1 BeanItem (com.vaadin.data.util.BeanItem)1 BeanItemContainer (com.vaadin.data.util.BeanItemContainer)1 ExternalResource (com.vaadin.server.ExternalResource)1 FontAwesome (com.vaadin.server.FontAwesome)1 Page (com.vaadin.server.Page)1 StreamResource (com.vaadin.server.StreamResource)1 Position (com.vaadin.shared.Position)1 FilteringMode (com.vaadin.shared.ui.combobox.FilteringMode)1