| 775 | 
           jpm | 
           1 | 
           package org.tela_botanica.client.vues;
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           import org.tela_botanica.client.Mediateur;
  | 
        
        
            | 
            | 
           4 | 
           import org.tela_botanica.client.images.Images;
  | 
        
        
            | 
            | 
           5 | 
              | 
        
        
            | 
            | 
           6 | 
           import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
  | 
        
        
            | 
            | 
           7 | 
           import com.extjs.gxt.ui.client.event.ButtonEvent;
  | 
        
        
            | 
            | 
           8 | 
           import com.extjs.gxt.ui.client.event.SelectionListener;
  | 
        
        
            | 
            | 
           9 | 
           import com.extjs.gxt.ui.client.widget.button.Button;
  | 
        
        
            | 
            | 
           10 | 
           import com.extjs.gxt.ui.client.widget.button.ButtonBar;
  | 
        
        
            | 
            | 
           11 | 
           import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
  | 
        
        
            | 
            | 
           12 | 
           import com.google.gwt.user.client.ui.AbstractImagePrototype;
  | 
        
        
            | 
            | 
           13 | 
              | 
        
        
            | 
            | 
           14 | 
           public class FormulaireBarreValidation extends ButtonBar {
  | 
        
        
            | 
            | 
           15 | 
              | 
        
        
            | 
            | 
           16 | 
           	private SelectionListener<ButtonEvent> ecouteur = null;
  | 
        
        
            | 
            | 
           17 | 
              | 
        
        
            | 
            | 
           18 | 
           	public static final String CODE_BOUTON_VALIDER = "VA";
  | 
        
        
            | 
            | 
           19 | 
           	public static final String CODE_BOUTON_APPLIQUER = "AP";
  | 
        
        
            | 
            | 
           20 | 
           	public static final String CODE_BOUTON_ANNULER = "AN";
  | 
        
        
            | 
            | 
           21 | 
              | 
        
        
            | 
            | 
           22 | 
           	public FormulaireBarreValidation(SelectionListener<ButtonEvent> ecouteurCourrant) {
  | 
        
        
            | 
            | 
           23 | 
           		ecouteur = ecouteurCourrant;
  | 
        
        
            | 
            | 
           24 | 
           		creerBarreOutilsValidation();
  | 
        
        
            | 
            | 
           25 | 
           	}
  | 
        
        
            | 
            | 
           26 | 
              | 
        
        
            | 
            | 
           27 | 
           	private void creerBarreOutilsValidation() {
  | 
        
        
            | 
            | 
           28 | 
           		this.setAlignment(HorizontalAlignment.LEFT);
  | 
        
        
           | 1630 | 
           aurelien | 
           29 | 
              | 
        
        
           | 775 | 
           jpm | 
           30 | 
           		this.add(new FillToolItem());
  | 
        
        
           | 1630 | 
           aurelien | 
           31 | 
           		Button appliquer = creerBouton(CODE_BOUTON_APPLIQUER);
  | 
        
        
            | 
            | 
           32 | 
           		this.add(appliquer);
  | 
        
        
            | 
            | 
           33 | 
           		appliquer.setToolTip(Mediateur.i18nC.indicationAppliquer());
  | 
        
        
            | 
            | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
           		Button annuler = creerBouton(CODE_BOUTON_ANNULER);
  | 
        
        
            | 
            | 
           36 | 
           		annuler.setToolTip(Mediateur.i18nC.indicationAnnuler());
  | 
        
        
            | 
            | 
           37 | 
           		this.add(annuler);
  | 
        
        
            | 
            | 
           38 | 
              | 
        
        
            | 
            | 
           39 | 
           		Button valider = creerBouton(CODE_BOUTON_VALIDER);
  | 
        
        
            | 
            | 
           40 | 
           		valider.setToolTip(Mediateur.i18nC.indicationValider());
  | 
        
        
            | 
            | 
           41 | 
           		this.add(valider);
  | 
        
        
           | 775 | 
           jpm | 
           42 | 
           	}
  | 
        
        
            | 
            | 
           43 | 
              | 
        
        
            | 
            | 
           44 | 
           	private Button creerBouton(final String code) {
  | 
        
        
            | 
            | 
           45 | 
           		String nom = getNom(code);
  | 
        
        
            | 
            | 
           46 | 
              | 
        
        
            | 
            | 
           47 | 
           		Button bouton = new Button(nom);
  | 
        
        
            | 
            | 
           48 | 
           		bouton.setData("code", code);
  | 
        
        
            | 
            | 
           49 | 
           		bouton.setIcon(getIcone(code));
  | 
        
        
            | 
            | 
           50 | 
           		bouton.addSelectionListener(ecouteur);
  | 
        
        
            | 
            | 
           51 | 
              | 
        
        
            | 
            | 
           52 | 
           		return bouton;
  | 
        
        
            | 
            | 
           53 | 
           	}
  | 
        
        
            | 
            | 
           54 | 
              | 
        
        
            | 
            | 
           55 | 
           	private AbstractImagePrototype getIcone(final String code) {
  | 
        
        
            | 
            | 
           56 | 
           		AbstractImagePrototype icone = null;
  | 
        
        
            | 
            | 
           57 | 
           		if (code.equals(CODE_BOUTON_VALIDER)) {
  | 
        
        
            | 
            | 
           58 | 
           			icone = Images.ICONES.valider();
  | 
        
        
            | 
            | 
           59 | 
           		} else if (code.equals(CODE_BOUTON_APPLIQUER)) {
  | 
        
        
            | 
            | 
           60 | 
           			icone = Images.ICONES.appliquer();
  | 
        
        
            | 
            | 
           61 | 
           		} else if (code.equals(CODE_BOUTON_ANNULER)) {
  | 
        
        
            | 
            | 
           62 | 
           			icone = Images.ICONES.annuler();
  | 
        
        
            | 
            | 
           63 | 
           		}
  | 
        
        
            | 
            | 
           64 | 
           		return icone;
  | 
        
        
            | 
            | 
           65 | 
           	}
  | 
        
        
            | 
            | 
           66 | 
              | 
        
        
            | 
            | 
           67 | 
           	private String getNom(final String code) {
  | 
        
        
            | 
            | 
           68 | 
           		String nom = null;
  | 
        
        
            | 
            | 
           69 | 
           		if (code.equals(CODE_BOUTON_VALIDER)) {
  | 
        
        
            | 
            | 
           70 | 
           			nom = Mediateur.i18nC.valider();
  | 
        
        
            | 
            | 
           71 | 
           		} else if (code.equals(CODE_BOUTON_APPLIQUER)) {
  | 
        
        
            | 
            | 
           72 | 
           			nom = Mediateur.i18nC.appliquer();
  | 
        
        
            | 
            | 
           73 | 
           		} else if (code.equals(CODE_BOUTON_ANNULER)) {
  | 
        
        
            | 
            | 
           74 | 
           			nom = Mediateur.i18nC.annuler();
  | 
        
        
            | 
            | 
           75 | 
           		}
  | 
        
        
            | 
            | 
           76 | 
           		return nom;
  | 
        
        
            | 
            | 
           77 | 
           	}
  | 
        
        
            | 
            | 
           78 | 
           }
  |