Subversion Repositories eFlore/Applications.del

Rev

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

package org.tela_botanica.del.client.composants.presenteur;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.RootPanel;

public abstract class Presenteur {

        private Composite vue;
        private Panel overlay;
        private Panel overlayContenu;
        private PresenteurVue presenteurVue;
        private boolean fenetreModaleOuverte = false;

        // Constructeur
        public Presenteur(Composite vue) {
                presenteurVue = new PresenteurVue();
                this.vue = vue;
        }

        // Afficheur
        public void go() {
                go(null);
        }

        public abstract void go(HasWidgets composite);

        // Gestion des évènements
        protected abstract void gererEvenements();

        protected Composite getVue() {
                return this.vue;
        }

        public void ouvrirFenetreModale(Presenteur presenteurModal) {

                overlay = presenteurVue.overlay;
                overlay.setStyleName("overlay");
                overlay.setVisible(false);
                RootPanel.get().add(overlay);

                overlayContenu = presenteurVue.overlayContenu;
                overlayContenu.setStyleName("overlayContenu");

                Button boutonFermer = presenteurVue.boutonFermer;
                boutonFermer.setStyleName("fermerOverlay");
                boutonFermer.addClickHandler(new ClickHandler() {

                        public void onClick(ClickEvent event) {
                                fermerFenetreModale();
                        }
                });

                presenteurModal.go(overlayContenu);

                RootPanel.get().add(overlayContenu);
                overlayContenu.setVisible(true);

                overlayContenu.add(boutonFermer);
                overlay.setVisible(true);
                
                fenetreModaleOuverte = true;
        }
        
        public boolean fenetreModaleEstOuverte() {
                return fenetreModaleOuverte;
        }

        public void fermerFenetreModale() {
                overlay.clear();
                overlayContenu.clear();
                RootPanel.get().remove(overlay);
                RootPanel.get().remove(overlayContenu);
                fenetreModaleOuverte = false;
        }
}