Subversion Repositories eFlore/Applications.cel

Rev

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

package org.tela_botanica.client.interfaces;

import org.tela_botanica.client.image.ImageMediateur;

import com.gwtext.client.core.EventObject;

import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.event.KeyListener;
import com.gwtext.client.widgets.event.WindowListenerAdapter;
import com.gwtext.client.widgets.form.TextField;

public class IdVue extends Window implements Rafraichissable {

        private ImageMediateur iMediateur;
        private TextField champId = null;
        private Button ok = null;

        public IdVue(ImageMediateur im) {
                super("Identification");

                iMediateur = im;

                champId = new TextField();
                ok = new Button("OK");

                add(champId);
                add(ok);

                setSize(156, 75);
                setClosable(false);
                setModal(true);
                this.setCloseAction(HIDE);

                ajouterListeners();
        }

        private void ajouterListeners() {

                // gestion du clic sur le bouton
                ok.addListener(new ButtonListenerAdapter() {

                        public void onClick(Button button, EventObject e) {

                                valider();
                        }

                });

                // gestion de la touche entrée
                champId.addKeyListener(EventObject.ENTER, new KeyListener() {

                        public void onKey(int key, EventObject e) {

                                valider();
                        }

                });

                this.addListener(new WindowListenerAdapter() {

                        public void onClose(Panel panel) {

                        }

                });

        }

        public ImageMediateur getIMediateur() {
                return iMediateur;
        }

        protected void valider() {

                String id = champId.getText();
                getIMediateur().setIdentifiant("" + id.hashCode());
                getIMediateur().changerUtilisateur();
                this.close();

        }

        public void rafraichir(Object nouvelleDonnees,
                        boolean repandreRaffraichissement) {

        }

}