Example usage for com.vaadin.server FontAwesome TIMES

List of usage examples for com.vaadin.server FontAwesome TIMES

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome TIMES.

Prototype

FontAwesome TIMES

To view the source code for com.vaadin.server FontAwesome TIMES.

Click Source Link

Usage

From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientStatusComponent.java

License:Open Source License

public void updateUI(final ProjectBean currentBean) {
    BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler
            .computeIvacPatientStatus(currentBean);

    int finishedExperiments = 0;
    status.removeAllComponents();/*from   www.  j  a  v a  2s .c o  m*/
    status.setWidth(100.0f, Unit.PERCENTAGE);

    // Generate button caption column
    final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans);
    gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() {

        @Override
        public Class<String> getType() {
            return String.class;
        }

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            String status = null;

            if ((double) item.getItemProperty("status").getValue() > 0.0) {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily()
                        + ";color:" + "#2dd085" + "\">&#x"
                        + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>";
            } else {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily()
                        + ";color:" + "#f54993" + "\">&#x"
                        + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>";
            }

            return status.toString();
        }
    });
    gpc.removeContainerProperty("identifier");

    experiments.setContainerDataSource(gpc);
    // experiments.setHeaderVisible(false);
    // experiments.setHeightMode(HeightMode.ROW);
    experiments.setHeightByRows(gpc.size());
    experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);

    experiments.getColumn("status").setRenderer(new ProgressBarRenderer());
    // experiments.setColumnOrder("started", "code", "description", "status", "download",
    // "runWorkflow");
    experiments.setColumnOrder("started", "code", "description", "status", "workflow");

    experiments.getColumn("workflow").setRenderer(new ButtonRenderer(new RendererClickListener() {
        @Override
        public void click(RendererClickEvent event) {
            ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId();
            TabSheet parent = (TabSheet) getParent();
            PatientView pv = (PatientView) parent.getParent().getParent();
            WorkflowComponent wp = pv.getWorkflowComponent();

            // TODO WATCH OUT NUMBER OF WORKFLOW TAB IS HARDCODED AT THE MOMENT, NO BETTER SOLUTION
            // FOUND SO FAR, e.g. get Tab by Name ?

            // TODO idea get description of item to navigate to the correct workflow ?!
            if (esb.getDescription().equals("Barcode Generation")) {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                message.add(currentBean.getId());
                //TODO navigate to barcode dragon rawwwr
                //          message.add(BarcodeView.navigateToLabel);
                //          state.notifyObservers(message);
            } else if (esb.getDescription().equals("Variant Annotation")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_VARIANT_ANNOTATION");
                 * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel);
                 * state.notifyObservers(message);
                 */

                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_VARIANT_ANNOTATION");
                parent.setSelectedTab(9);
                wp.update(args);

            } else if (esb.getDescription().equals("Epitope Prediction")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_EPITOPE_PREDICTION");
                 * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel);
                 * state.notifyObservers(message);
                 */
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_EPITOPE_PREDICTION");
                parent.setSelectedTab(9);
                wp.update(args);
            } else if (esb.getDescription().equals("HLA Typing")) {
                /*
                 * ArrayList<String> message = new ArrayList<String>(); message.add("clicked");
                 * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType");
                 * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&");
                 * sb.append("experiment="); sb.append("Q_WF_NGS_HLATYPING"); message.add(sb.toString());
                 * message.add(WorkflowView.navigateToLabel); state.notifyObservers(message);
                 */
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", currentBean.getId());
                args.put("type", "workflowExperimentType");
                args.put("experiment", "Q_WF_NGS_HLATYPING");
                parent.setSelectedTab(9);
                wp.update(args);
            }

            else {
                Notification notif = new Notification("Workflow not (yet) available.", Type.TRAY_NOTIFICATION);
                // Customize it
                notif.setDelayMsec(60000);
                notif.setPosition(Position.MIDDLE_CENTER);
                // Show it in the page
                notif.show(Page.getCurrent());
            }
        }
    }));

    experiments.getColumn("started").setRenderer(new HtmlRenderer());

    ProgressBar progressBar = new ProgressBar();
    progressBar.setCaption("Overall Progress");
    progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);
    progressBar.setStyleName("patientprogress");

    status.addComponent(progressBar);
    status.addComponent(experiments);
    status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);
    status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER);

    /**
     * Defined Experiments for iVac - Barcodes available -> done with project creation (done) -
     * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status
     * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction
     * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION)
     */

    for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) {
        ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next();

        finishedExperiments += statusBean.getStatus();

        // statusBean.setDownload("Download");
        statusBean.setWorkflow("Run");
    }

    progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size());
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java

License:Open Source License

void updateProjectStatus() {

    BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler
            .computeIvacPatientStatus(currentBean);

    int finishedExperiments = 0;
    status.removeAllComponents();//ww  w  .  j  a va  2s.c  o  m
    status.setWidth(100.0f, Unit.PERCENTAGE);

    // Generate button caption column
    final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans);
    gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() {

        @Override
        public Class<String> getType() {
            return String.class;
        }

        @Override
        public String getValue(Item item, Object itemId, Object propertyId) {
            String status = null;

            if ((double) item.getItemProperty("status").getValue() > 0.0) {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily()
                        + ";color:" + "#2dd085" + "\">&#x"
                        + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>";
            } else {
                status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily()
                        + ";color:" + "#f54993" + "\">&#x"
                        + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>";
            }

            return status.toString();
        }
    });
    gpc.removeContainerProperty("identifier");

    experiments.setContainerDataSource(gpc);
    // experiments.setHeaderVisible(false);
    experiments.setHeightMode(HeightMode.ROW);
    experiments.setHeightByRows(gpc.size());
    experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);

    experiments.getColumn("status").setRenderer(new ProgressBarRenderer());
    experiments.setColumnOrder("started", "code", "description", "status", "download", "runWorkflow");

    ButtonRenderer downloadRenderer = new ButtonRenderer(new RendererClickListener() {
        @Override
        public void click(RendererClickEvent event) {
            ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId();

            if (esb.getDescription().equals("Barcode Generation")) {
                new Notification("Download of Barcodes not available.",
                        "<br/>Please create barcodes by clicking 'Run'.", Type.WARNING_MESSAGE, true)
                                .show(Page.getCurrent());
            } else if (esb.getIdentifier() == null || esb.getIdentifier().isEmpty()) {
                new Notification("No data available for download.",
                        "<br/>Please do the analysis by clicking 'Run' first.", Type.WARNING_MESSAGE, true)
                                .show(Page.getCurrent());
            } else {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                StringBuilder sb = new StringBuilder("type=");
                sb.append("experiment");
                sb.append("&");
                sb.append("id=");
                // sb.append(currentBean.getId());
                sb.append(esb.getIdentifier());
                message.add(sb.toString());
                message.add(DatasetView.navigateToLabel);
                state.notifyObservers(message);
            }

        }

    });

    experiments.getColumn("download").setRenderer(downloadRenderer);

    experiments.getColumn("runWorkflow").setRenderer(new ButtonRenderer(new RendererClickListener() {
        @Override
        public void click(RendererClickEvent event) {
            ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId();

            // TODO idea get description of item to navigate to the correct workflow ?!
            if (esb.getDescription().equals("Barcode Generation")) {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                message.add(currentBean.getId());
                // TODO link to barcode dragon
                // message.add(BarcodeView.navigateToLabel);
                // state.notifyObservers(message);
            } else {
                ArrayList<String> message = new ArrayList<String>();
                message.add("clicked");
                StringBuilder sb = new StringBuilder("type=");
                sb.append("workflowExperimentType");
                sb.append("&");
                sb.append("id=");
                sb.append("Q_WF_MS_PEPTIDEID");
                sb.append("&");
                sb.append("project=");
                sb.append(currentBean.getId());
                message.add(sb.toString());
                message.add(WorkflowView.navigateToLabel);
                state.notifyObservers(message);
            }
        }
    }));

    experiments.getColumn("started").setRenderer(new HtmlRenderer());

    ProgressBar progressBar = new ProgressBar();
    progressBar.setCaption("Overall Progress");
    progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS);
    progressBar.setStyleName("patientprogress");

    status.addComponent(progressBar);
    status.addComponent(experiments);
    status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER);
    status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER);

    /**
     * Defined Experiments for iVac - Barcodes available -> done with project creation (done) -
     * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status
     * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction
     * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION)
     */

    for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) {
        ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next();

        // HorizontalLayout experimentStatusRow = new HorizontalLayout();
        // experimentStatusRow.setSpacing(true);

        finishedExperiments += statusBean.getStatus();

        // statusBean.setDownload("Download");
        statusBean.setWorkflow("Run");

        /*
         * if ((Integer) pairs.getValue() == 0) { Label statusLabel = new Label(pairs.getKey() + ": "
         * + FontAwesome.TIMES.getHtml(), ContentMode.HTML); statusLabel.addStyleName("redicon");
         * experimentStatusRow.addComponent(statusLabel);
         * statusContent.addComponent(experimentStatusRow); }
         * 
         * else {
         * 
         * Label statusLabel = new Label(pairs.getKey() + ": " + FontAwesome.CHECK.getHtml(),
         * ContentMode.HTML); statusLabel.addStyleName("greenicon");
         * experimentStatusRow.addComponent(statusLabel);
         * statusContent.addComponent(experimentStatusRow);
         * 
         * finishedExperiments += (Integer) pairs.getValue(); }
         * experimentStatusRow.addComponent(runWorkflow);
         * 
         * }
         */
    }

    progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size());
}

From source file:fr.univlorraine.mondossierweb.views.EtatCivilView.java

License:Apache License

private void renseignerPanelContact() {

    VerticalLayout contactLayout = new VerticalLayout();

    /* Layout pour afficher les erreurs */
    VerticalLayout erreursLayout = new VerticalLayout();
    contactLayout.addComponent(erreursLayout);
    erreursLayout.setVisible(false);//  w w  w  .java 2s  . co  m

    /* Layout avec les champ 'Portable' et 'Email personnel' */
    FormLayout formContactLayout = new FormLayout();
    formContactLayout.setSpacing(true);
    formContactLayout.setMargin(true);

    String captionTelPortable = applicationContext.getMessage(NAME + ".portable.title", null, getLocale());
    fieldTelPortable = new TextField(captionTelPortable, MainUI.getCurrent().getEtudiant().getTelPortable());
    formatTextField(fieldTelPortable);
    fieldTelPortable.setMaxLength(15);
    formContactLayout.addComponent(fieldTelPortable);

    if (userController.isEtudiant()) {
        String captionMailPerso = applicationContext.getMessage(NAME + ".mailperso.title", null, getLocale());
        fieldMailPerso = new TextField(captionMailPerso, MainUI.getCurrent().getEtudiant().getEmailPerso());
        formatTextField(fieldMailPerso);
        fieldMailPerso.setMaxLength(200);
        formContactLayout.addComponent(fieldMailPerso);
    }

    contactLayout.addComponent(formContactLayout);

    /* Si user tudiant , modifications autorise des coordonnes de contact
     * et si l'tudiant possde une addresse annuelle, on affiche les boutons de modification */
    if (userController.isEtudiant() && configController.isModificationCoordonneesPersoAutorisee()
            && MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {
        //Layout pour les boutons de modification
        HorizontalLayout btnLayout = new HorizontalLayout();
        btnLayout.setSizeFull();
        btnLayout.setSpacing(true);
        btnLayout.setMargin(true);

        //Bouton pour valider la modification
        btnValidModifCoordonneesPerso = new Button(
                applicationContext.getMessage(NAME + ".bouton.validercoordonnees", null, getLocale()));
        btnValidModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_FRIENDLY);
        btnValidModifCoordonneesPerso.setIcon(FontAwesome.CHECK);
        btnValidModifCoordonneesPerso.addClickListener(e -> {
            erreursLayout.removeAllComponents();
            List<String> retour = etudiantController.updateContact(fieldTelPortable.getValue(),
                    fieldMailPerso.getValue(), MainUI.getCurrent().getEtudiant().getCod_etu());
            //si modif ok
            if (retour != null && retour.size() == 1 && retour.get(0).equals("OK")) {
                etudiantController.recupererEtatCivil();
                renseignerPanelContact();
            } else {
                //affichage erreurs
                if (retour != null && retour.size() > 0) {
                    String errorMsg = "";
                    for (String erreur : retour) {
                        if (!errorMsg.equals(""))
                            errorMsg = errorMsg + "<br />";
                        errorMsg = errorMsg + erreur;
                    }
                    Label labelErreur = new Label(errorMsg);
                    labelErreur.setContentMode(ContentMode.HTML);
                    labelErreur.setStyleName(ValoTheme.LABEL_FAILURE);
                    erreursLayout.addComponent(labelErreur);
                }
                erreursLayout.setVisible(true);
            }
        });
        btnValidModifCoordonneesPerso.setVisible(false);
        btnLayout.addComponent(btnValidModifCoordonneesPerso);
        btnLayout.setComponentAlignment(btnValidModifCoordonneesPerso, Alignment.MIDDLE_CENTER);

        //Bouton pour annuler la modification
        btnAnnulerModifCoordonneesPerso = new Button(
                applicationContext.getMessage(NAME + ".bouton.annulercoordonnees", null, getLocale()));
        btnAnnulerModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_DANGER);
        btnAnnulerModifCoordonneesPerso.setIcon(FontAwesome.TIMES);
        btnAnnulerModifCoordonneesPerso.addClickListener(e -> {
            erreursLayout.removeAllComponents();
            fieldMailPerso.setValue(MainUI.getCurrent().getEtudiant().getEmailPerso());
            fieldMailPerso.setEnabled(false);
            fieldMailPerso.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            fieldTelPortable.setValue(MainUI.getCurrent().getEtudiant().getTelPortable());
            fieldTelPortable.setEnabled(false);
            fieldTelPortable.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            btnValidModifCoordonneesPerso.setVisible(false);
            btnAnnulerModifCoordonneesPerso.setVisible(false);
            btnModifCoordonneesPerso.setVisible(true);

        });
        btnAnnulerModifCoordonneesPerso.setVisible(false);
        btnLayout.addComponent(btnAnnulerModifCoordonneesPerso);
        btnLayout.setComponentAlignment(btnAnnulerModifCoordonneesPerso, Alignment.MIDDLE_CENTER);

        //Bouton pour activer la modification des donnes
        btnModifCoordonneesPerso = new Button(
                applicationContext.getMessage(NAME + ".bouton.modifiercoordonnees", null, getLocale()));
        btnModifCoordonneesPerso.setStyleName(ValoTheme.BUTTON_PRIMARY);
        btnModifCoordonneesPerso.setIcon(FontAwesome.EDIT);
        btnModifCoordonneesPerso.addClickListener(e -> {
            fieldMailPerso.setEnabled(true);
            fieldMailPerso.removeStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            fieldTelPortable.setEnabled(true);
            fieldTelPortable.removeStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
            btnValidModifCoordonneesPerso.setVisible(true);
            btnAnnulerModifCoordonneesPerso.setVisible(true);
            btnModifCoordonneesPerso.setVisible(false);
        });
        btnLayout.addComponent(btnModifCoordonneesPerso);
        btnLayout.setComponentAlignment(btnModifCoordonneesPerso, Alignment.MIDDLE_CENTER);
        contactLayout.addComponent(btnLayout);
    }

    panelContact.setContent(contactLayout);

}

From source file:fr.univlorraine.mondossierweb.views.RechercheArborescenteView.java

License:Apache License

/**
 * Initialise la vue//from   w  ww  . j av a  2  s .  co m
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (userController.isEnseignant()) {
        /* Style */
        setMargin(false);
        setSpacing(false);
        setSizeFull();

        if (listeBoutonFavoris != null) {
            listeBoutonFavoris.clear();
        } else {
            listeBoutonFavoris = new LinkedList<ReferencedButton>();
        }

        liste_types_favoris = new LinkedList<String>();
        liste_types_favoris.add(Utils.CMP);
        liste_types_favoris.add(Utils.ELP);
        liste_types_favoris.add(Utils.VET);

        liste_types_inscrits = new LinkedList<String>();
        liste_types_inscrits.add(Utils.ELP);
        liste_types_inscrits.add(Utils.VET);

        liste_types_deplier = new LinkedList<String>();
        liste_types_deplier.add(Utils.ELP);
        liste_types_deplier.add(Utils.VET);

        recuperationDesfavoris();

        HorizontalLayout btnLayout = new HorizontalLayout();
        btnLayout.setMargin(false);
        btnLayout.setSpacing(false);
        btnLayout.setWidth("100%");

        comboBoxAnneeUniv = new ComboBox(applicationContext.getMessage(NAME + ".anneeuniv", null, getLocale()));
        comboBoxAnneeUniv.setPageLength(5);
        comboBoxAnneeUniv.setTextInputAllowed(false);
        comboBoxAnneeUniv.setNullSelectionAllowed(false);
        //Initialisation de la liste des annes
        List<String> lanneeUniv = rechercheArborescenteController.recupererLesDernieresAnneeUniversitaire();
        if (lanneeUniv != null && lanneeUniv.size() > 0) {
            for (String anneeUniv : lanneeUniv) {
                comboBoxAnneeUniv.addItem(anneeUniv);
                int anneenplusun = Integer.parseInt(anneeUniv) + 1;
                comboBoxAnneeUniv.setItemCaption(anneeUniv, anneeUniv + "/" + anneenplusun);
            }
            if (annee == null) {
                annee = etudiantController.getAnneeUnivEnCours(MainUI.getCurrent());
                //annee = lanneeUniv.get(0);
            }
        }
        comboBoxAnneeUniv.setValue(annee);
        comboBoxAnneeUniv.setStyleName(ValoTheme.COMBOBOX_SMALL);
        comboBoxAnneeUniv.addValueChangeListener(e -> changerAnnee((String) comboBoxAnneeUniv.getValue()));

        reinitButton = new Button();
        reinitButton.setDescription(
                applicationContext.getMessage(NAME + ".reinitbutton.description", null, getLocale()));
        reinitButton.addClickListener(e -> {
            initFromScratch();
        });
        reinitButton.setStyleName(ValoTheme.BUTTON_DANGER);
        reinitButton.setIcon(FontAwesome.TIMES);
        if (!StringUtils.hasText(code)) {
            reinitButton.setVisible(false);
        }
        labelLigneSelectionneeLabel = new Label();
        labelLigneSelectionneeLabel
                .setValue(applicationContext.getMessage(NAME + ".ligneselectionnee", null, getLocale()));
        labelLigneSelectionneeLabel.addStyleName("label-align-right");
        labelLigneSelectionneeLabel.setVisible(false);

        HorizontalLayout btnLeftLayout = new HorizontalLayout();
        btnLeftLayout.setWidth("100%");
        btnLeftLayout.setMargin(true);
        btnLeftLayout.addComponent(comboBoxAnneeUniv);
        btnLeftLayout.setComponentAlignment(comboBoxAnneeUniv, Alignment.MIDDLE_LEFT);
        /*btnLeftLayout.addComponent(reinitButton);
        btnLeftLayout.setComponentAlignment(reinitButton, Alignment.BOTTOM_RIGHT);*/
        btnLeftLayout.addComponent(labelLigneSelectionneeLabel);
        btnLeftLayout.setComponentAlignment(labelLigneSelectionneeLabel, Alignment.MIDDLE_CENTER);
        btnLayout.addComponent(btnLeftLayout);

        ligneSelectionneeLabel = new Label();
        //ligneSelectionneeLabel.setCaption(applicationContext.getMessage(NAME+".ligneselectionnee", null, getLocale()));
        ligneSelectionneeLabel.setVisible(false);
        elpLayout = new FormLayout();
        elpLayout.setMargin(false);
        vetElpSelectionneLabel = new Label();
        vetElpSelectionneLabel.setVisible(false);
        elpLayout.addComponent(vetElpSelectionneLabel);
        elpLayout.setVisible(false);
        VerticalLayout ligneLayout = new VerticalLayout();
        ligneLayout.addComponent(ligneSelectionneeLabel);
        ligneLayout.addComponent(elpLayout);

        HorizontalLayout rightLayout = new HorizontalLayout();
        rightLayout.setSizeFull();
        rightLayout.setSpacing(true);
        rightLayout.setMargin(true);
        rightLayout.addComponent(ligneLayout);
        rightLayout.setComponentAlignment(ligneLayout, Alignment.MIDDLE_LEFT);
        rightLayout.addComponent(reinitButton);
        rightLayout.setComponentAlignment(reinitButton, Alignment.MIDDLE_RIGHT);
        rightLayout.setExpandRatio(ligneLayout, 1);
        btnLayout.addComponent(rightLayout);
        btnLayout.setComponentAlignment(rightLayout, Alignment.MIDDLE_LEFT);

        addComponent(btnLayout);

        if (code != null && type != null) {
            Label elementRecherche = new Label(code + " " + type);
            elementRecherche.addStyleName(ValoTheme.LABEL_H1);
            //addComponent(elementRecherche);

        }

        table = new TreeTable();
        table.setSizeFull();
        table.setStyleName("scrollabletable");
        table.setSelectable(true);

        initComposantes();

        //gestion du style pour les lignes en favori
        table.setCellStyleGenerator(new CellStyleGenerator() {
            @Override
            public String getStyle(final Table source, final Object itemId, final Object propertyId) {
                String style = null;
                if (propertyId == null && markedRows.contains(itemId)) {
                    style = "marked";
                }
                return style;
            }
        });

        table.addItemClickListener(new ItemClickListener() {

            @Override
            public void itemClick(ItemClickEvent event) {
                selectionnerLigne(event.getItemId());
            }

        });

        //gestion du clic sur la fleche pour dplier une entre
        table.addExpandListener(new ExpandListener() {
            private static final long serialVersionUID = 8532342540008245348L;

            @Override
            public void nodeExpand(ExpandEvent event) {
                if (event != null && event.getItemId() != null && hc != null
                        && hc.getItem(event.getItemId()) != null
                        && hc.getItem(event.getItemId()).getItemProperty(TYPE_PROPERTY) != null) {
                    selectionnerLigne(event.getItemId());
                    deplierNoeud((String) event.getItemId(), true);
                }
            }
        });

        VerticalLayout tableVerticalLayout = new VerticalLayout();
        tableVerticalLayout.setMargin(new MarginInfo(false, true, true, true));
        tableVerticalLayout.setSizeFull();
        tableVerticalLayout.addComponent(table);
        tableVerticalLayout.setExpandRatio(table, 1);
        addComponent(tableVerticalLayout);
        setExpandRatio(tableVerticalLayout, 1);

    }
}

From source file:fr.univlorraine.mondossierweb.views.RechercheMobileView.java

License:Apache License

/**
 * Initialise la vue//from   ww w. j av a  2  s .  c  om
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI && userController.isEnseignant()) {
        // On rinitialise la vue
        removeAllComponents();

        // Style
        setSizeFull();
        addStyleName("v-noscrollableelement");

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        returnButton = new Button();
        returnButton.setIcon(FontAwesome.ARROW_LEFT);
        returnButton.setStyleName("v-nav-button");
        returnButton.addClickListener(e -> {
            MdwTouchkitUI.getCurrent().backFromSearch();
        });
        navbar.addComponent(returnButton);
        navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);

        //Title
        Label labelTrombi = new Label(applicationContext.getMessage(NAME + ".title.label", null, getLocale()));
        labelTrombi.setStyleName("v-label-navbar");
        navbar.addComponent(labelTrombi);
        navbar.setComponentAlignment(labelTrombi, Alignment.MIDDLE_CENTER);

        navbar.setExpandRatio(labelTrombi, 1);
        addComponent(navbar);

        //BOUTON DE RECHERCHE
        btnRecherche = new Button();
        btnRecherche.setIcon(FontAwesome.SEARCH);
        btnRecherche.setStyleName(ValoTheme.BUTTON_PRIMARY);
        btnRecherche.addStyleName("v-popover-button");
        btnRecherche.addStyleName("v-button-without-padding");
        btnRecherche.setEnabled(true);
        btnRecherche.addClickListener(e -> search(false));

        //CHAMP DE RECHERCHE
        champRechercheLayout = new HorizontalLayout();
        champRechercheLayout.setWidth("100%");
        mainVerticalLayout = new VerticalLayout();
        mainVerticalLayout.setImmediate(true);
        mainVerticalLayout.setSizeFull();

        //Init connexion  ES, pour gain perf au premiere lettre tapes
        if (ElasticSearchService.initConnexion(true)) {

            //Cration du champ autoComplete
            champRecherche = new AutoComplete();
            champRecherche.setWidth(100, Unit.PERCENTAGE);
            champRecherche.setEnabled(true);
            champRecherche.setImmediate(true);
            champRecherche.focus();
            champRecherche.setTextChangeEventMode(TextChangeEventMode.EAGER);
            champRecherche.addTextChangeListener(new TextChangeListener() {
                @Override
                public void textChange(TextChangeEvent event) {
                    /*if(event.getText()!=null){
                    resetButton.setIcon(FontAwesome.TIMES);
                    }*/

                    champRecherche.showChoices(quickSearch(event.getText()), mainVerticalLayout, btnRecherche,
                            true);

                }
            });
            champRecherche.setImmediate(true);
            champRecherche.addShortcutListener(
                    new ShortcutListener("Enter Shortcut", ShortcutAction.KeyCode.ENTER, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                //Si on tait sur une ligne propose sous le champ de recherche
                                if (champRecherche.getSelectedItem() > 0) {
                                    //On remplie d'abord le champ avec la ligne slectionne
                                    champRecherche.setValue(champRecherche.getChoices()
                                            .getItem(champRecherche.getSelectedItem()).getItemProperty("lib")
                                            .getValue().toString());
                                }
                                search(false);
                            }
                        }
                    });

            champRecherche.addShortcutListener(
                    new ShortcutListener("Bottom Arrow", ShortcutAction.KeyCode.ARROW_DOWN, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                if (champRecherche.getChoices().getItemIds() != null) {
                                    champRecherche.getChoicesPopup().setVisible(true);
                                    champRecherche.getChoices().setValue(champRecherche.getNextItem());

                                }
                            }
                        }
                    });

            champRecherche.addShortcutListener(
                    new ShortcutListener("Top Arrow", ShortcutAction.KeyCode.ARROW_UP, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                if (champRecherche.getChoices().getItemIds() != null) {
                                    champRecherche.getChoicesPopup().setVisible(true);
                                    Integer champSelectionne = champRecherche.getPreviousItem();
                                    if (champSelectionne > 0) {
                                        champRecherche.getChoices().setValue(champSelectionne);
                                    } else {
                                        champRecherche.getChoices().setValue(null);
                                    }

                                }
                            }
                        }
                    });

            champRechercheLayout.addComponent(champRecherche);
            champRechercheLayout.setComponentAlignment(champRecherche, Alignment.MIDDLE_LEFT);

            //BOUTON RESET
            champRecherche.addStyleName("textfield-resetable");
            resetButton = new Button();
            resetButton.setIcon(FontAwesome.TIMES);
            resetButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
            resetButton.addStyleName("v-popover-button");
            resetButton.addStyleName("v-button-without-padding");
            resetButton.addStyleName("btn-reset");
            resetButton.addClickListener(e -> {
                champRecherche.setValue("");
                //search1.setValue("");
                resetButton.setIcon(FontAwesome.TIMES);
                champRecherche.focus();
            });
            champRechercheLayout.addComponent(resetButton);
            champRechercheLayout.setComponentAlignment(resetButton, Alignment.MIDDLE_LEFT);

            //Ajout du bouton de recherche au layout
            champRechercheLayout.addComponent(btnRecherche);
            mainVerticalLayout.addComponent(champRechercheLayout);
            mainVerticalLayout.setComponentAlignment(champRechercheLayout, Alignment.MIDDLE_LEFT);
            champRechercheLayout.setMargin(true);
            champRechercheLayout.setExpandRatio(champRecherche, 1);

            HorizontalLayout checkBoxVetLayout = new HorizontalLayout();
            Label etapeLabel = new Label(
                    applicationContext.getMessage(NAME + ".etapes.checkbox", null, getLocale()));
            etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxVetLayout.addComponent(etapeLabel);

            HorizontalLayout checkBoxElpLayout = new HorizontalLayout();
            Label elpLabel = new Label(
                    applicationContext.getMessage(NAME + ".elps.checkbox", null, getLocale()));
            elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxElpLayout.addComponent(elpLabel);

            HorizontalLayout checkBoxEtuLayout = new HorizontalLayout();
            Label etuLabel = new Label(
                    applicationContext.getMessage(NAME + ".etudiants.checkbox", null, getLocale()));
            etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxEtuLayout.addComponent(etuLabel);

            checkBoxVetLayout.setSizeFull();
            checkBoxElpLayout.setSizeFull();
            checkBoxEtuLayout.setSizeFull();

            if (casesAcocherVet) {
                checkBoxVetLayout.setStyleName("layout-checkbox-checked");
                etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxVetLayout.setStyleName("layout-checkbox-unchecked");
                etapeLabel.addStyleName("label-line-through");
            }

            if (casesAcocherElp) {
                checkBoxElpLayout.setStyleName("layout-checkbox-checked");
                elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxElpLayout.setStyleName("layout-checkbox-unchecked");
                elpLabel.addStyleName("label-line-through");
            }

            if (casesAcocherEtudiant) {
                checkBoxEtuLayout.setStyleName("layout-checkbox-checked");
                etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxEtuLayout.setStyleName("layout-checkbox-unchecked");
                etuLabel.addStyleName("label-line-through");
            }

            checkBoxVetLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherVet) {
                        casesAcocherVet = false;
                        checkBoxVetLayout.setStyleName("layout-checkbox-unchecked");
                        etapeLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherVet = true;
                        checkBoxVetLayout.setStyleName("layout-checkbox-checked");
                        etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            checkBoxElpLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherElp) {
                        casesAcocherElp = false;
                        checkBoxElpLayout.setStyleName("layout-checkbox-unchecked");
                        elpLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherElp = true;
                        checkBoxElpLayout.setStyleName("layout-checkbox-checked");
                        elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            checkBoxEtuLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherEtudiant) {
                        casesAcocherEtudiant = false;
                        checkBoxEtuLayout.setStyleName("layout-checkbox-unchecked");
                        etuLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherEtudiant = true;
                        checkBoxEtuLayout.setStyleName("layout-checkbox-checked");
                        etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            HorizontalLayout checkBoxLayout = new HorizontalLayout();
            checkBoxLayout.setWidth("100%");
            checkBoxLayout.setHeight("50px");
            checkBoxLayout.setMargin(true);
            checkBoxLayout.setSpacing(true);
            checkBoxLayout.addComponent(checkBoxVetLayout);
            checkBoxLayout.addComponent(checkBoxElpLayout);
            checkBoxLayout.addComponent(checkBoxEtuLayout);

            mainVerticalLayout.addComponent(checkBoxLayout);

            //TABLE DE RESULTATS
            rrContainer = new HierarchicalContainer();
            rrContainer.addContainerProperty("lib", String.class, "");
            rrContainer.addContainerProperty("code", String.class, "");
            rrContainer.addContainerProperty("type", String.class, "");
            tableResultats = new TreeTable();
            tableResultats.setWidth("100%");
            tableResultats.setSelectable(false);
            tableResultats.setMultiSelect(false);
            tableResultats.setImmediate(true);
            columnHeaders = new String[FIELDS_ORDER.length];
            for (int fieldIndex = 0; fieldIndex < FIELDS_ORDER.length; fieldIndex++) {
                columnHeaders[fieldIndex] = applicationContext
                        .getMessage("result.table." + FIELDS_ORDER[fieldIndex], null, Locale.getDefault());
            }

            tableResultats.addGeneratedColumn("type", new DisplayTypeColumnGenerator());
            tableResultats.addGeneratedColumn("lib", new DisplayNameColumnGenerator());
            tableResultats.setContainerDataSource(rrContainer);
            tableResultats.setVisibleColumns(FIELDS_ORDER);
            tableResultats.setStyleName("nohscrollabletable");
            tableResultats.setColumnHeaders(columnHeaders);
            tableResultats.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
            tableResultats.setColumnWidth("type", 100);

            /*mainVerticalLayout.addComponent(searchBoxFilter);
            mainVerticalLayout.setComponentAlignment(searchBoxFilter, Alignment.MIDDLE_RIGHT);*/
            VerticalLayout tableVerticalLayout = new VerticalLayout();
            tableVerticalLayout.setMargin(true);
            tableVerticalLayout.setSizeFull();
            tableVerticalLayout.addComponent(tableResultats);
            mainVerticalLayout.addComponent(tableVerticalLayout);
            mainVerticalLayout.setExpandRatio(tableVerticalLayout, 1);
            tableResultats.setVisible(false);

            addComponent(mainVerticalLayout);
            setExpandRatio(mainVerticalLayout, 1);
        } else {
            //Message fonctionnalit indisponible
            addComponent(
                    new Label(applicationContext.getMessage(NAME + ".indisponible.message", null, getLocale()),
                            ContentMode.HTML));
        }
    }
}

From source file:fr.univlorraine.mondossierweb.views.RechercheRapideView.java

License:Apache License

/**
 * Initialise la vue/*w  w w . j  av  a2 s  . c o m*/
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (userController.isEnseignant()) {

        /* Style */
        setMargin(true);
        setSpacing(true);

        mainVerticalLayout = new VerticalLayout();
        champRechercheLayout = new HorizontalLayout();
        mainVerticalLayout.setImmediate(true);
        mainVerticalLayout.setSizeFull();

        //BOUTON DE RECHERCHE
        btnRecherche = new Button(
                applicationContext.getMessage("buttonChercher.label", null, Locale.getDefault()));
        btnRecherche.setIcon(FontAwesome.SEARCH);
        btnRecherche.setEnabled(true);
        btnRecherche.addClickListener(e -> search(false));

        //Init connexion  ES, pour gain perf au premiere lettre tapes
        if (ElasticSearchService.initConnexion(true)) {

            //CHAMP DE RECHERCHE
            champRecherche = new AutoComplete();
            champRecherche.setWidth(700, Unit.PIXELS); //540
            champRecherche.setEnabled(true);
            champRecherche.setImmediate(true);
            champRecherche.focus();
            champRecherche.setTextChangeEventMode(TextChangeEventMode.EAGER);
            champRecherche.addTextChangeListener(new TextChangeListener() {
                @Override
                public void textChange(TextChangeEvent event) {
                    if (event.getText() != null) {
                        resetButton.setIcon(FontAwesome.TIMES);
                    }
                    champRecherche.showChoices(quickSearch(event.getText()), mainVerticalLayout, btnRecherche,
                            false);

                }
            });
            champRecherche.setImmediate(true);
            champRecherche.addShortcutListener(
                    new ShortcutListener("Enter Shortcut", ShortcutAction.KeyCode.ENTER, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                //Si on tait sur une ligne propose sous le champ de recherche
                                if (champRecherche.getSelectedItem() > 0) {
                                    //On remplie d'abord le champ avec la ligne slectionne
                                    champRecherche.setValue(champRecherche.getChoices()
                                            .getItem(champRecherche.getSelectedItem()).getItemProperty("lib")
                                            .getValue().toString());
                                }
                                search(false);
                            }
                        }
                    });

            champRecherche.addShortcutListener(
                    new ShortcutListener("Bottom Arrow", ShortcutAction.KeyCode.ARROW_DOWN, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                if (champRecherche != null && champRecherche.getChoices() != null
                                        && champRecherche.getChoices().getItemIds() != null) {
                                    champRecherche.getChoicesPopup().setVisible(true);
                                    champRecherche.getChoices().setValue(champRecherche.getNextItem());

                                }
                            }
                        }
                    });

            champRecherche.addShortcutListener(
                    new ShortcutListener("Top Arrow", ShortcutAction.KeyCode.ARROW_UP, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                if (champRecherche.getChoices().getItemIds() != null) {
                                    champRecherche.getChoicesPopup().setVisible(true);
                                    Integer champSelectionne = champRecherche.getPreviousItem();
                                    if (champSelectionne > 0) {
                                        champRecherche.getChoices().setValue(champSelectionne);
                                    } else {
                                        champRecherche.getChoices().setValue(null);
                                    }

                                }
                            }
                        }
                    });

            //champRecherche.addBlurListener(e -> champRecherche.getChoicesPopup().setVisible(false));

            HorizontalLayout layoutBordure = new HorizontalLayout();
            layoutBordure.setWidth("100px");
            champRechercheLayout.addComponent(layoutBordure);
            champRechercheLayout.setComponentAlignment(layoutBordure, Alignment.MIDDLE_LEFT);

            /*champRechercheLayout.addComponent(search1);
            champRechercheLayout.setComponentAlignment(search1, Alignment.MIDDLE_LEFT);*/

            champRechercheLayout.addComponent(champRecherche);
            champRechercheLayout.setComponentAlignment(champRecherche, Alignment.MIDDLE_LEFT);

            //BOUTON RESET
            champRecherche.addStyleName("textfield-resetable");
            resetButton = new Button();
            resetButton.setIcon(FontAwesome.TIMES);
            resetButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
            resetButton.addStyleName("btn-reset");
            resetButton.addClickListener(e -> {
                champRecherche.setValue("");
                //search1.setValue("");
                resetButton.setIcon(FontAwesome.TIMES);
                champRecherche.focus();
            });
            champRechercheLayout.addComponent(resetButton);
            champRechercheLayout.setComponentAlignment(resetButton, Alignment.MIDDLE_LEFT);

            //Ajout du bouton de recherche au layout
            champRechercheLayout.addComponent(btnRecherche);
            mainVerticalLayout.addComponent(champRechercheLayout);
            mainVerticalLayout.setComponentAlignment(champRechercheLayout, Alignment.MIDDLE_LEFT);
            champRechercheLayout.setMargin(true);

            casesAcocherComposantes = new CheckBox("Composantes");
            casesAcocherComposantes.setValue(true);
            casesAcocherComposantes.setStyleName(ValoTheme.CHECKBOX_SMALL);
            casesAcocherComposantes.addValueChangeListener(e -> tuneSearch());
            casesAcocherVet = new CheckBox("Etapes");
            casesAcocherVet.setValue(true);
            casesAcocherVet.setStyleName(ValoTheme.CHECKBOX_SMALL);
            casesAcocherVet.addValueChangeListener(e -> tuneSearch());
            casesAcocherElp = new CheckBox("Elments pdagogiques");
            casesAcocherElp.setValue(true);
            casesAcocherElp.setStyleName(ValoTheme.CHECKBOX_SMALL);
            casesAcocherElp.addValueChangeListener(e -> tuneSearch());
            casesAcocherEtudiant = new CheckBox("Etudiants");
            casesAcocherEtudiant.setValue(true);
            casesAcocherEtudiant.setStyleName(ValoTheme.CHECKBOX_SMALL);
            casesAcocherEtudiant.addValueChangeListener(e -> tuneSearch());

            HorizontalLayout checkBoxLayout = new HorizontalLayout();
            checkBoxLayout.setMargin(true);
            checkBoxLayout.setSpacing(true);
            checkBoxLayout.addComponent(casesAcocherComposantes);
            checkBoxLayout.addComponent(casesAcocherVet);
            checkBoxLayout.addComponent(casesAcocherElp);
            checkBoxLayout.addComponent(casesAcocherEtudiant);

            mainVerticalLayout.addComponent(checkBoxLayout);

            //TABLE DE RESULTATS
            rrContainer = new HierarchicalContainer();
            rrContainer.addContainerProperty("lib", String.class, "");
            rrContainer.addContainerProperty("code", String.class, "");
            rrContainer.addContainerProperty("info", String.class, "");
            rrContainer.addContainerProperty("type", String.class, "");
            tableResultats = new TreeTable();
            tableResultats.setSizeFull();
            tableResultats.setSelectable(false);
            tableResultats.setMultiSelect(false);
            tableResultats.setImmediate(true);
            columnHeaders = new String[FIELDS_ORDER.length];
            for (int fieldIndex = 0; fieldIndex < FIELDS_ORDER.length; fieldIndex++) {
                columnHeaders[fieldIndex] = applicationContext
                        .getMessage("result.table." + FIELDS_ORDER[fieldIndex], null, Locale.getDefault());
            }
            tableResultats.addGeneratedColumn("lib", new DisplayNameColumnGenerator());
            tableResultats.addGeneratedColumn("type", new DisplayTypeColumnGenerator());
            tableResultats.setContainerDataSource(rrContainer);
            tableResultats.setVisibleColumns(FIELDS_ORDER);
            tableResultats.setColumnHeaders(columnHeaders);
            /*mainVerticalLayout.addComponent(searchBoxFilter);
            mainVerticalLayout.setComponentAlignment(searchBoxFilter, Alignment.MIDDLE_RIGHT);*/
            VerticalLayout tableVerticalLayout = new VerticalLayout();
            tableVerticalLayout.setMargin(new MarginInfo(false, true, true, true));
            tableVerticalLayout.setSizeFull();
            tableVerticalLayout.addComponent(tableResultats);
            mainVerticalLayout.addComponent(tableVerticalLayout);
            mainVerticalLayout.setExpandRatio(tableVerticalLayout, 1);
            tableResultats.setVisible(false);

            addComponent(mainVerticalLayout);
            setSizeFull();
        } else {

            //Message fonctionnalit indisponible
            addComponent(
                    new Label(applicationContext.getMessage(NAME + ".indisponible.message", null, getLocale()),
                            ContentMode.HTML));
        }
    }
}

From source file:fr.univlorraine.mondossierweb.views.windows.ConfirmWindow.java

License:Apache License

/**
 * Cre une fentre de confirmation/*from  w w w .  jav  a2s . co m*/
 * @param message
 * @param titre
 */
public ConfirmWindow(String message, String titre) {
    /* Style */
    setWidth(400, Unit.PIXELS);
    setModal(true);
    setResizable(false);
    setClosable(false);

    /* Layout */
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);

    /* Titre */
    if (titre == null) {
        titre = applicationContext.getMessage("confirmWindow.defaultTitle", null, getLocale());
    }
    setCaption(titre);

    /* Texte */
    if (message == null) {
        message = applicationContext.getMessage("confirmWindow.defaultQuestion", null, getLocale());
    }
    Label textLabel = new Label(message);
    layout.addComponent(textLabel);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    btnNon.setCaption(applicationContext.getMessage("confirmWindow.btnNon", null, getLocale()));
    btnNon.setIcon(FontAwesome.TIMES);
    btnNon.addClickListener(e -> close());
    buttonsLayout.addComponent(btnNon);
    buttonsLayout.setComponentAlignment(btnNon, Alignment.MIDDLE_LEFT);

    btnOui.setCaption(applicationContext.getMessage("confirmWindow.btnOui", null, getLocale()));
    btnOui.setIcon(FontAwesome.CHECK);
    btnOui.addStyleName(ValoTheme.BUTTON_PRIMARY);
    btnOui.addClickListener(e -> close());
    buttonsLayout.addComponent(btnOui);
    buttonsLayout.setComponentAlignment(btnOui, Alignment.MIDDLE_RIGHT);

    /* Centre la fentre */
    center();
}

From source file:fr.univlorraine.mondossierweb.views.windows.HelpBasicWindow.java

License:Apache License

/**
 * Cre une fentre de confirmation//from w  w w .  ja  v  a  2 s. co m
 * @param message
 * @param titre
 */
public HelpBasicWindow(String message, String titre, boolean displayLienContact) {
    /* Style */
    setWidth(900, Unit.PIXELS);
    setModal(true);
    setResizable(false);
    setClosable(false);

    /* Layout */
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(false);
    setContent(layout);

    /* Titre */
    setCaption(titre);

    // Lien de contact
    if (displayLienContact) {
        String mailContact = configController.getAssistanceContactMail();
        if (StringUtils.hasText(mailContact)) {
            Button contactBtn = new Button(
                    applicationContext.getMessage(NAME + ".btnContact", null, getLocale()),
                    FontAwesome.ENVELOPE);
            contactBtn.addStyleName(ValoTheme.BUTTON_LINK);
            BrowserWindowOpener contactBwo = new BrowserWindowOpener("mailto:" + mailContact);
            contactBwo.extend(contactBtn);
            layout.addComponent(contactBtn);
            layout.setComponentAlignment(contactBtn, Alignment.TOP_RIGHT);
        }
    }

    /* Texte */
    Label textLabel = new Label(message, ContentMode.HTML);
    layout.addComponent(textLabel);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    btnFermer.setCaption(applicationContext.getMessage("helpWindow.btnFermer", null, getLocale()));
    btnFermer.setIcon(FontAwesome.TIMES);
    btnFermer.addClickListener(e -> close());
    buttonsLayout.addComponent(btnFermer);
    buttonsLayout.setComponentAlignment(btnFermer, Alignment.MIDDLE_RIGHT);

    /* Centre la fentre */
    center();
}

From source file:fr.univlorraine.mondossierweb.views.windows.HelpWindow.java

License:Apache License

/**
 * Cre une fentre de confirmation/*from  www.j  av a2s . c  om*/
 * @param message
 * @param titre
 */
public HelpWindow(String message, String titre, boolean displayCheckBox) {
    /* Style */
    setWidth(900, Unit.PIXELS);
    setModal(true);
    setResizable(false);
    setClosable(false);

    /* Layout */
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);

    /* Titre */
    if (titre == null) {
        titre = applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale());
    }
    setCaption(titre);

    /* Texte */
    Label textLabel = new Label(message, ContentMode.HTML);
    layout.addComponent(textLabel);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    if (displayCheckBox) {
        checkBox.setCaption(applicationContext.getMessage("helpWindow.checkBox.message", null, getLocale()));
        buttonsLayout.addComponent(checkBox);
        buttonsLayout.setComponentAlignment(checkBox, Alignment.MIDDLE_RIGHT);
    }

    btnFermer.setCaption(applicationContext.getMessage("helpWindow.btnFermer", null, getLocale()));
    btnFermer.setIcon(FontAwesome.TIMES);
    btnFermer.addClickListener(e -> close());
    buttonsLayout.addComponent(btnFermer);
    buttonsLayout.setComponentAlignment(btnFermer, Alignment.MIDDLE_RIGHT);
    if (displayCheckBox) {
        buttonsLayout.setExpandRatio(checkBox, 1);
    }

    /* Centre la fentre */
    center();
}

From source file:fr.univlorraine.mondossierweb.views.windows.ModificationAdressesWindow.java

License:Apache License

/**
 * Cre une fentre de confirmation//from w w w  .  j  a v  a 2 s .  co m
 * @param message
 * @param titre
 */
public ModificationAdressesWindow(Etudiant etudiant) {
    /* Style */
    //setWidth(900, Unit.PIXELS);
    setModal(true);
    setResizable(false);
    setClosable(false);

    /* Layout */
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    setContent(layout);

    /* Titre */
    setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale()));

    /* Layout pour afficher les erreurs */
    VerticalLayout erreursLayout = new VerticalLayout();
    layout.addComponent(erreursLayout);
    erreursLayout.setVisible(false);

    HorizontalLayout panelslayout = new HorizontalLayout();
    panelslayout.setMargin(true);
    panelslayout.setSpacing(true);
    layout.addComponent(panelslayout);

    /* Panel adresse annuelle */
    Panel adressesAnnuellePanel = new Panel(
            applicationContext.getMessage(NAME + ".panel.adresseannuelle.title", null, getLocale()) + " "
                    + MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAnnee());

    FormLayout formAdresseAnnuelleLayout = new FormLayout();
    formAdresseAnnuelleLayout.setSpacing(true);
    formAdresseAnnuelleLayout.setMargin(true);

    //TypeHebergement
    String captionHebergement = applicationContext.getMessage(NAME + ".typehebergement", null, getLocale());
    TypeHebergementDTO[] hebergements = adresseController.getTypesHebergement();
    lhebergement = new NativeSelect();
    lhebergement.setCaption(captionHebergement);
    lhebergement.setNullSelectionAllowed(false);
    lhebergement.setRequired(true);
    lhebergement.setWidth("326px");
    for (TypeHebergementDTO h : hebergements) {
        lhebergement.addItem(h.getCodTypeHebergement());
        lhebergement.setItemCaption(h.getCodTypeHebergement(), h.getLibWebTypeHebergement());
    }
    lhebergement.setValue(etudiant.getAdresseAnnuelle().getType());
    lhebergement.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            String selectedValue = (String) event.getProperty().getValue();

            //Si un hbergement autre que la Domicile parental a t choisi
            if (!selectedValue.equals(COD_HEBERG_DOMICILE_PARENTAL)) {
                activeFormulaireAdresseAnnuelle();

            } else {
                desactiveFormulaireAdresseAnnuelle();
            }
        }
    });

    formAdresseAnnuelleLayout.addComponent(lhebergement);

    //labelChoixHebergement
    labelChoixHebergement = new Label(
            applicationContext.getMessage(NAME + ".labelhebergement", null, getLocale()));
    formAdresseAnnuelleLayout.addComponent(labelChoixHebergement);

    //AdresseAnnuelle1
    fieldAnnu1 = new TextField(applicationContext.getMessage(NAME + ".annu1", null, getLocale()));
    fieldAnnu1.setValue(etudiant.getAdresseAnnuelle().getAdresse1());
    fieldAnnu1.setNullRepresentation("");
    fieldAnnu1.setWidth("326px");
    fieldAnnu1.setMaxLength(32);
    fieldAnnu1.setRequired(true);
    formAdresseAnnuelleLayout.addComponent(fieldAnnu1);

    //AdresseAnnuelle2
    fieldAnnu2 = new TextField(applicationContext.getMessage(NAME + ".annu2", null, getLocale()));
    fieldAnnu2.setValue(etudiant.getAdresseAnnuelle().getAdresse2());
    fieldAnnu2.setNullRepresentation("");
    fieldAnnu2.setWidth("326px");
    fieldAnnu2.setMaxLength(32);
    formAdresseAnnuelleLayout.addComponent(fieldAnnu2);

    //AdresseAnnuelle3
    fieldAnnu3 = new TextField(applicationContext.getMessage(NAME + ".annu3", null, getLocale()));
    fieldAnnu3.setValue(etudiant.getAdresseAnnuelle().getAdresse3());
    fieldAnnu3.setNullRepresentation("");
    fieldAnnu3.setWidth("326px");
    fieldAnnu3.setMaxLength(32);
    formAdresseAnnuelleLayout.addComponent(fieldAnnu3);

    //Liste des Pays
    String captionPays = applicationContext.getMessage(NAME + ".pays1", null, getLocale());
    PaysDTO[] pays = adresseController.getPays();
    lpays1 = new NativeSelect();
    lpays1.setCaption(captionPays);
    lpays1.setNullSelectionAllowed(false);
    lpays1.setRequired(true);
    lpays1.setWidth("326px");
    for (PaysDTO p : pays) {
        lpays1.addItem(p.getCodePay());
        lpays1.setItemCaption(p.getCodePay(), p.getLibPay());
    }
    lpays1.setValue(etudiant.getAdresseAnnuelle().getCodPays());
    lpays1.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            String selectedValue = (String) event.getProperty().getValue();

            //Si un pays autre que France a t choisi
            if (!selectedValue.equals(COD_PAY_FRANCE)) {
                activerChampPourAdresseAnnuelleEtranger();
            } else {
                activerChampPourAdresseAnnuelleEnFrance();
            }
        }
    });
    formAdresseAnnuelleLayout.addComponent(lpays1);

    //Ville pour adresse  l'tranger
    fieldVilleEtranger1 = new TextField(
            applicationContext.getMessage(NAME + ".villeetranger1", null, getLocale()));
    fieldVilleEtranger1.setValue(etudiant.getAdresseAnnuelle().getAdresseetranger());
    fieldVilleEtranger1.setNullRepresentation("");
    fieldVilleEtranger1.setWidth("326px");
    fieldVilleEtranger1.setMaxLength(5);
    fieldVilleEtranger1.setRequired(true);
    formAdresseAnnuelleLayout.addComponent(fieldVilleEtranger1);

    //codePostal1 pour adresses en france
    fieldCodePostal1 = new TextField(applicationContext.getMessage(NAME + ".codepostal1", null, getLocale()));
    fieldCodePostal1.setValue(etudiant.getAdresseAnnuelle().getCodePostal());
    fieldCodePostal1.setNullRepresentation("");
    fieldCodePostal1.setWidth("326px");
    fieldCodePostal1.setMaxLength(5);
    fieldCodePostal1.setRequired(true);
    //fieldCodePostal1.setTextChangeEventMode(TextChangeEventMode.EAGER);
    fieldCodePostal1.addTextChangeListener(new TextChangeListener() {
        @Override
        public void textChange(TextChangeEvent event) {
            updateListeVillesAnnuelle(event.getText());
        }
    });

    formAdresseAnnuelleLayout.addComponent(fieldCodePostal1);

    //Ville pour adresse en france
    List<CommuneDTO> villes1 = adresseController.getVilles(etudiant.getAdresseAnnuelle().getCodePostal());
    lville1 = new NativeSelect();
    lville1.setCaption(applicationContext.getMessage(NAME + ".ville1", null, getLocale()));
    lville1.setNullSelectionAllowed(false);
    lville1.setRequired(true);
    lville1.setWidth("326px");
    for (CommuneDTO v : villes1) {
        lville1.addItem(v.getLibCommune());
        lville1.setItemCaption(v.getLibCommune(), v.getLibCommune());
    }
    codePostalVillesAnnu = etudiant.getAdresseAnnuelle().getCodePostal();
    lville1.setValue(etudiant.getAdresseAnnuelle().getVille());
    lville1.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            updateCodePostalVilleAnnuelle();
        }
    });
    formAdresseAnnuelleLayout.addComponent(lville1);

    //activation des champs utiles en fonction de l'adresse de l'tudiant avant la modification
    if (etudiant.getAdresseAnnuelle().getCodPays().equals(COD_PAY_FRANCE)) {
        activerChampPourAdresseAnnuelleEnFrance();
    } else {
        activerChampPourAdresseAnnuelleEtranger();
    }

    //Tlphone1
    fieldTelephone1 = new TextField(applicationContext.getMessage(NAME + ".tel1", null, getLocale()));
    fieldTelephone1.setValue(etudiant.getAdresseAnnuelle().getNumerotel());
    fieldTelephone1.setNullRepresentation("");
    fieldTelephone1.setWidth("326px");
    fieldTelephone1.setMaxLength(15);
    fieldTelephone1.setRequired(false);
    formAdresseAnnuelleLayout.addComponent(fieldTelephone1);

    //ajout du panel adresse Annuelle
    adressesAnnuellePanel.setContent(formAdresseAnnuelleLayout);
    panelslayout.addComponent(adressesAnnuellePanel);

    //Si un hbergement autre que la Domicile parental a t choisi
    if (!etudiant.getAdresseAnnuelle().getType().equals(COD_HEBERG_DOMICILE_PARENTAL)) {
        activeFormulaireAdresseAnnuelle();
    } else {
        desactiveFormulaireAdresseAnnuelle();
    }

    /* Panel adresse fixe */
    Panel adressesFixePanel = new Panel(
            applicationContext.getMessage(NAME + ".panel.adressefixe.title", null, getLocale()));

    FormLayout formAdresseFixeLayout = new FormLayout();
    formAdresseFixeLayout.setSpacing(true);
    formAdresseFixeLayout.setMargin(true);

    //AdresseFixe1
    fieldFixe1 = new TextField(applicationContext.getMessage(NAME + ".fixe1", null, getLocale()));
    fieldFixe1.setValue(etudiant.getAdresseFixe().getAdresse1());
    fieldFixe1.setNullRepresentation("");
    fieldFixe1.setWidth("326px");
    fieldFixe1.setMaxLength(32);
    fieldFixe1.setRequired(true);
    formAdresseFixeLayout.addComponent(fieldFixe1);

    //AdresseFixe2
    fieldFixe2 = new TextField(applicationContext.getMessage(NAME + ".fixe2", null, getLocale()));
    fieldFixe2.setValue(etudiant.getAdresseFixe().getAdresse2());
    fieldFixe2.setNullRepresentation("");
    fieldFixe2.setWidth("326px");
    fieldFixe2.setMaxLength(32);
    formAdresseFixeLayout.addComponent(fieldFixe2);

    //AdresseFixe3
    fieldFixe3 = new TextField(applicationContext.getMessage(NAME + ".fixe3", null, getLocale()));
    fieldFixe3.setValue(etudiant.getAdresseFixe().getAdresse3());
    fieldFixe3.setNullRepresentation("");
    fieldFixe3.setWidth("326px");
    fieldFixe3.setMaxLength(32);
    formAdresseFixeLayout.addComponent(fieldFixe3);

    //Liste des Pays
    lpays2 = new NativeSelect();
    lpays2.setCaption(captionPays);
    lpays2.setNullSelectionAllowed(false);
    lpays2.setRequired(true);
    lpays2.setWidth("326px");
    for (PaysDTO p : pays) {
        lpays2.addItem(p.getCodePay());
        lpays2.setItemCaption(p.getCodePay(), p.getLibPay());
    }
    lpays2.setValue(etudiant.getAdresseFixe().getCodPays());
    lpays2.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            String selectedValue = (String) event.getProperty().getValue();

            //Si un pays autre que France a t choisi
            if (!selectedValue.equals(COD_PAY_FRANCE)) {
                activerChampPourAdresseFixeEtranger();
            } else {
                activerChampPourAdresseFixeEnFrance();
            }
        }
    });
    formAdresseFixeLayout.addComponent(lpays2);

    //Ville pour adresse  l'tranger
    fieldVilleEtranger2 = new TextField(
            applicationContext.getMessage(NAME + ".villeetranger2", null, getLocale()));
    fieldVilleEtranger2.setValue(etudiant.getAdresseFixe().getAdresseetranger());
    fieldVilleEtranger2.setNullRepresentation("");
    fieldVilleEtranger2.setWidth("326px");
    fieldVilleEtranger2.setMaxLength(5);
    fieldVilleEtranger2.setRequired(true);
    formAdresseFixeLayout.addComponent(fieldVilleEtranger2);

    //codePostal2 pour adresses en france
    fieldCodePostal2 = new TextField(applicationContext.getMessage(NAME + ".codepostal2", null, getLocale()));
    fieldCodePostal2.setValue(etudiant.getAdresseFixe().getCodePostal());
    fieldCodePostal2.setNullRepresentation("");
    fieldCodePostal2.setWidth("326px");
    fieldCodePostal2.setMaxLength(5);
    fieldCodePostal2.setRequired(true);
    //fieldCodePostal1.setTextChangeEventMode(TextChangeEventMode.EAGER);
    fieldCodePostal2.addTextChangeListener(new TextChangeListener() {
        @Override
        public void textChange(TextChangeEvent event) {
            updateListeVillesFixe(event.getText());
        }
    });

    formAdresseFixeLayout.addComponent(fieldCodePostal2);

    //Ville pour adresse en france
    List<CommuneDTO> villes2 = adresseController.getVilles(etudiant.getAdresseFixe().getCodePostal());
    lville2 = new NativeSelect();
    lville2.setCaption(applicationContext.getMessage(NAME + ".ville2", null, getLocale()));
    lville2.setNullSelectionAllowed(false);
    lville2.setRequired(true);
    lville2.setWidth("326px");
    for (CommuneDTO v : villes2) {
        lville2.addItem(v.getLibCommune());
        lville2.setItemCaption(v.getLibCommune(), v.getLibCommune());
    }
    codePostalVillesFixe = etudiant.getAdresseFixe().getCodePostal();
    lville2.setValue(etudiant.getAdresseFixe().getVille());
    lville2.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            updateCodePostalVilleFixe();
        }
    });
    formAdresseFixeLayout.addComponent(lville2);

    //activation des champs utiles en fonction de l'adresse de l'tudiant avant la modification
    if (etudiant.getAdresseFixe().getCodPays().equals(COD_PAY_FRANCE)) {
        activerChampPourAdresseFixeEnFrance();
    } else {
        activerChampPourAdresseFixeEtranger();
    }

    //Tlphone2
    fieldTelephone2 = new TextField(applicationContext.getMessage(NAME + ".tel2", null, getLocale()));
    fieldTelephone2.setValue(etudiant.getAdresseFixe().getNumerotel());
    fieldTelephone2.setNullRepresentation("");
    fieldTelephone2.setWidth("326px");
    fieldTelephone2.setMaxLength(15);
    fieldTelephone2.setRequired(false);
    formAdresseFixeLayout.addComponent(fieldTelephone2);

    //ajout du panel adresse fixe
    adressesFixePanel.setContent(formAdresseFixeLayout);
    panelslayout.addComponent(adressesFixePanel);

    /* Boutons */
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setSpacing(true);

    btnValider.setCaption(applicationContext.getMessage(NAME + ".btnValider", null, getLocale()));
    btnValider.setIcon(FontAwesome.CHECK);
    btnValider.addStyleName(ValoTheme.BUTTON_PRIMARY);
    btnValider.addClickListener(e -> {

        Adresse adresseAnnuelle = new Adresse();
        adresseAnnuelle.setType(lhebergement.getValue().toString());
        adresseAnnuelle.setAdresse1(fieldAnnu1.getValue());
        adresseAnnuelle.setAdresse2(fieldAnnu2.getValue());
        adresseAnnuelle.setAdresse3(fieldAnnu3.getValue());
        adresseAnnuelle.setCodPays(lpays1.getValue().toString());
        adresseAnnuelle.setCodePostal(fieldCodePostal1.getValue());
        adresseAnnuelle.setVille((lville1.getValue() == null) ? null : lville1.getValue().toString());
        adresseAnnuelle.setAdresseetranger(fieldVilleEtranger1.getValue());
        adresseAnnuelle.setNumerotel(fieldTelephone1.getValue());

        Adresse adresseFixe = new Adresse();
        adresseFixe.setAdresse1(fieldFixe1.getValue());
        adresseFixe.setAdresse2(fieldFixe2.getValue());
        adresseFixe.setAdresse3(fieldFixe3.getValue());
        adresseFixe.setCodPays(lpays2.getValue().toString());
        adresseFixe.setCodePostal(fieldCodePostal2.getValue());
        adresseFixe.setVille((lville2.getValue() == null) ? null : lville2.getValue().toString());
        adresseFixe.setAdresseetranger(fieldVilleEtranger2.getValue());
        adresseFixe.setNumerotel(fieldTelephone2.getValue());

        erreursLayout.removeAllComponents();
        List<String> retour = adresseController.majAdresses(adresseAnnuelle, adresseFixe);
        if (retour != null && retour.size() == 1 && retour.get(0).equals("OK")) {
            //ajout maj vue adresse
            etudiantController.recupererAdresses();
            close();
        } else {
            //affichage erreurs
            if (retour != null && retour.size() > 0) {
                String errorMsg = "";
                for (String erreur : retour) {
                    if (!errorMsg.equals(""))
                        errorMsg = errorMsg + "<br />";
                    errorMsg = errorMsg + erreur;
                }
                Label labelErreur = new Label(errorMsg);
                labelErreur.setContentMode(ContentMode.HTML);
                labelErreur.setStyleName(ValoTheme.LABEL_FAILURE);
                erreursLayout.addComponent(labelErreur);
            }
            erreursLayout.setVisible(true);
        }

    });
    buttonsLayout.addComponent(btnValider);
    buttonsLayout.setComponentAlignment(btnValider, Alignment.MIDDLE_CENTER);

    btnAnnuler.setCaption(
            applicationContext.getMessage("modificationAdressesWindow.btnAnnuler", null, getLocale()));
    btnAnnuler.setIcon(FontAwesome.TIMES);
    btnAnnuler.addStyleName(ValoTheme.BUTTON_DANGER);
    btnAnnuler.addClickListener(e -> close());
    buttonsLayout.addComponent(btnAnnuler);
    buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_CENTER);

    layout.addComponent(buttonsLayout);

    /* Centre la fentre */
    center();
}