Subversion Repositories eFlore/Applications.cel

Rev

Rev 2621 | Rev 2649 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.client.vues;

import org.tela_botanica.client.CarnetEnLigneMediateur;
import org.tela_botanica.client.i18n.Msg;
import org.tela_botanica.client.interfaces.Rafraichissable;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.form.FormPanel;

public class FenetreLicenceVue extends com.gwtext.client.widgets.Window implements Rafraichissable {
        
                CarnetEnLigneMediateur cm = null;
                
                private CheckBox accepterLicence = new CheckBox();
                private Button validerAcceptationLicence = new Button(Msg.get("valider"));
                private Button annulerAcceptationLicence = new Button(Msg.get("Refuser"));
                
                // C'est moche mais ça évite de la transmettre du serveur ou de créer un fichier de config pour la licence
                // Todo afficher un texte provenant d'une url
                private String licence = Msg.get("licence");
                
           
            public FenetreLicenceVue(CarnetEnLigneMediateur cm) {
                
               super();
               
               this.cm = cm;
               setTitle(Msg.get("acceptation-licence"));
               Panel conteneurHtml = new Panel();
               conteneurHtml.setHtml(licence);
               conteneurHtml.setHeight(230);
               conteneurHtml.setAutoScroll(true);
               HTML conteneurLicence = new HTML();
               conteneurHtml.add(conteneurLicence);
               //licence = Configuration.getLicence();
               setConstrain(true);
               
               conteneurLicence.setHTML(licence);
               
               this.add(conteneurHtml);
               
               Panel conteneurCheckbox = new Panel();
               conteneurCheckbox.setBorder(false);
               conteneurCheckbox.setHeader(false);
               
               Label labelCheckboxAccepterLicence = new Label();
               labelCheckboxAccepterLicence.setStyleName("display:inline");
               
               accepterLicence.setText("   "+Msg.get("lu-accepte-licence"));
               accepterLicence.setStyleName("accepter_licence");
               
               FormPanel conteneurCheckboxEtValidation = new FormPanel();
               conteneurCheckboxEtValidation.setHeader(false);
               
               conteneurCheckboxEtValidation.setHeight(70);
               
               conteneurCheckboxEtValidation.add(accepterLicence);
               conteneurCheckboxEtValidation.add(labelCheckboxAccepterLicence);
               
               conteneurCheckboxEtValidation.addButton(validerAcceptationLicence);
               
               validerAcceptationLicence.setDisabled(true);
               
               conteneurCheckboxEtValidation.addButton(annulerAcceptationLicence);
               
               this.add(conteneurCheckboxEtValidation);
               
               this.setClosable(false);
               
               this.setHeight(320);
               
               ajouterListenerBoutons();
            }
            
            public void ajouterListenerBoutons() {
                
                accepterLicence.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
                                
                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> event) {
                                        validerAcceptationLicence.setDisabled(!event.getValue());
                                }
                        });
                
                validerAcceptationLicence.addListener(new ButtonListenerAdapter() {
                                
                                @Override
                                public void onClick(Button button, EventObject e) {

                                        cm.rafraichir("licence_acceptee", false);
                                }
                        });
                
                annulerAcceptationLicence.addListener(new ButtonListenerAdapter() {
                                
                                @Override
                                public void onClick(Button button, EventObject e) {

                                        cm.rafraichir("licence_refusee", false);
                                }
                        });
            }

                @Override
                public void rafraichir(Object nouvelleDonnees,
                                boolean repandreRaffraichissement) {
                        // TODO Auto-generated method stub
                        
                }
}