Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 13 → Rev 20

/trunk/src/org/tela_botanica/client/vues/FormulaireSaisieObservationVue.java
6,11 → 6,12
 
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ListeReferentielCommune;
import org.tela_botanica.client.modeles.ListeReferentielNom;
import org.tela_botanica.client.modeles.ReferentielCommune;
import org.tela_botanica.client.modeles.ReferentielNom;
import org.tela_botanica.client.observation.ObservationMediateur;
 
 
import com.google.gwt.user.client.Window;
import com.gwtext.client.core.EventCallback;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.ListenerConfig;
23,6 → 24,7
import com.gwtext.client.data.StringFieldDef;
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.ComboBox;
import com.gwtext.client.widgets.form.DateField;
import com.gwtext.client.widgets.form.FormPanel;
47,7 → 49,7
private ObservationMediateur observationMediateur = null;
private TextField nameAssistant = null;
 
private DateField date = null;
private TextField lieudit = null;
private TextField station = null;
54,33 → 56,34
private TextField milieu = null;
private TextField comment = null;
private ComboBox commune = null;
private ComboBox espece = null;
 
private Button boutonOK = new Button("Ok");
private Button boutonAnnuler = new Button("Annuler");
 
private boolean selectionCommune=false;
private boolean selectionEspece=false;
public static final int KEY_ALT = 18;
public static final int KEY_BACKSPACE = 8;
public static final int KEY_CTRL = 17;
public static final int KEY_DELETE = 46;
public static final int KEY_DOWN = 40;
public static final int KEY_END = 35;
public static final int KEY_ENTER = 13;
public static final int KEY_ESCAPE = 27;
public static final int KEY_HOME = 36;
public static final int KEY_LEFT = 37;
public static final int KEY_PAGEDOWN = 34;
public static final int KEY_PAGEUP = 33;
public static final int KEY_RIGHT = 39;
public static final int KEY_SHIFT = 16;
public static final int KEY_TAB = 9;
public static final int KEY_UP = 38;
/**
* Store combobox communes
*/
private Store store = null;
private final int KEY_ALT = 18;
private final int KEY_BACKSPACE = 8;
private final int KEY_CTRL = 17;
private final int KEY_DELETE = 46;
private final int KEY_DOWN = 40;
private final int KEY_END = 35;
private final int KEY_ENTER = 13;
private final int KEY_ESCAPE = 27;
private final int KEY_HOME = 36;
private final int KEY_LEFT = 37;
private final int KEY_PAGEDOWN = 34;
private final int KEY_PAGEUP = 33;
private final int KEY_RIGHT = 39;
private final int KEY_SHIFT = 16;
private final int KEY_TAB = 9;
private final int KEY_UP = 38;
 
 
/**
* Booleen d'instanciation
146,22 → 149,17
//store.load();*/
 
commune=new ComboBox("Commune","commune",275 );
//commune.setStore(store);
final String resultTpl = "<div class=\"search-item\">{commune}</div>";
final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";
 
commune.setTpl(resultTpl);
commune.setTpl(resultTplCommune);
commune.setMode(ComboBox.REMOTE);
// commune.setPageSize(10); // Ne fonctionne pas
commune.setItemSelector("div.search-item");
//commune.setDisplayField("title");
commune.setItemSelector("div.search-item-commune");
commune.setTypeAhead(true);
commune.setLoadingText("Recherche...");
168,99 → 166,9
commune.setHideTrigger(true);
/*
final String resultTpl = "<div class=\"search-item\"><h3><span>{lastPost:date(\"M j, Y\")}"
+ "<br/>by {author}</span>{title}</h3>{excerpt}</div>";
commune.setTpl(resultTpl);
*/
//commune.setMode(ComboBox.REMOTE);
/*
commune.setTitle("ExtJS Forums");
commune.setHideLabel(true);
commune.setItemSelector("div.search-item");
*/
commune.addListener(new ComboBoxListenerAdapter() {
public void onSelect(ComboBox comboBox, Record record, int index) {
commune.setValue(record.getAsString("commune"));
selectionCommune=true;
}
});
// Selection parmi la liste déroulante
ListenerConfig listenerConfig=new ListenerConfig();
listenerConfig.setDelay(10);
listenerConfig.setStopPropagation(false);
listenerConfig.setStopEvent(false);
 
commune.addKeyPressListener(new EventCallback() {
public void execute(EventObject e) {
switch(e.getKey()) {
case KEY_ALT:
case KEY_CTRL:
case KEY_DOWN:
case KEY_END:
case KEY_ESCAPE:
case KEY_HOME:
case KEY_LEFT:
case KEY_PAGEDOWN:
case KEY_PAGEUP:
case KEY_RIGHT:
case KEY_SHIFT:
case KEY_TAB:
case KEY_UP:
break;
case KEY_ENTER:
if (selectionCommune) {
selectionCommune=false;
}
else {
// lancer mise a jour
}
break;
default:
obtenirListeReferentielCommune();
break;
}
 
}
}, listenerConfig
);
 
 
 
panneauPremierColonne.add(commune);
 
271,13 → 179,29
date = new DateField("Date", "date", 100);
date.setAllowBlank(true);
date.setFormat("d/m/yyyy") ;
date.setFormat("d/m/Y") ;
panneauPremierColonne.add(date);
nameAssistant = new TextField("Espèce", "espece", 275);
nameAssistant.setAllowBlank(false);
panneauPremierColonne.add(nameAssistant);
 
espece=new ComboBox("Espèce","nom",275 );
final String resultTplEspece = "<div class=\"search-item-espece\">{nom}</div>";
 
espece.setTpl(resultTplEspece);
espece.setMode(ComboBox.REMOTE);
// commune.setPageSize(10); // Ne fonctionne pas
espece.setItemSelector("div.search-item-espece");
espece.setTypeAhead(true);
espece.setLoadingText("Recherche...");
espece.setHideTrigger(true);
 
 
panneauPremierColonne.add(espece);
comment = new TextField("Notes", "comment", 275);
comment.setAllowBlank(true);
panneauPremierColonne.add(comment);
299,10 → 223,10
panneauFormulaire.add(panneauIntermediaire);
Button boutonOK = new Button("Ok");
panneauFormulaire.addButton(boutonOK);
Button boutonAnnuler = new Button("Annuler");
panneauFormulaire.addButton(boutonAnnuler);
311,7 → 235,6
this.setAutoHeight(true);
// on ajoute les listeners
ajouterListeners() ;
322,6 → 245,154
private void ajouterListeners()
{
// Listener completion communne
commune.addListener(new ComboBoxListenerAdapter() {
public void onSelect(ComboBox comboBox, Record record, int index) {
commune.setValue(record.getAsString("commune"));
selectionCommune=true;
}
});
ListenerConfig listenerConfigCommune=new ListenerConfig();
listenerConfigCommune.setDelay(10);
listenerConfigCommune.setStopPropagation(false);
listenerConfigCommune.setStopEvent(false);
 
commune.addKeyPressListener(new EventCallback() {
public void execute(EventObject e) {
switch(e.getKey()) {
case KEY_ALT:
case KEY_CTRL:
case KEY_DOWN:
case KEY_END:
case KEY_ESCAPE:
case KEY_HOME:
case KEY_LEFT:
case KEY_PAGEDOWN:
case KEY_PAGEUP:
case KEY_RIGHT:
case KEY_SHIFT:
case KEY_TAB:
case KEY_UP:
break;
case KEY_ENTER:
if (selectionCommune) {
selectionCommune=false;
}
else {
// lancer mise a jour
}
break;
default:
obtenirListeReferentielCommune();
break;
}
 
}
}, listenerConfigCommune
);
// Listener completion espece
 
espece.addListener(new ComboBoxListenerAdapter() {
public void onSelect(ComboBox comboBox, Record record, int index) {
espece.setValue(record.getAsString("nom"));
selectionEspece=true;
}
});
 
ListenerConfig listenerConfigEspece=new ListenerConfig();
listenerConfigEspece.setDelay(10);
listenerConfigEspece.setStopPropagation(false);
listenerConfigEspece.setStopEvent(false);
 
espece.addKeyPressListener(new EventCallback() {
public void execute(EventObject e) {
switch(e.getKey()) {
case KEY_ALT:
case KEY_CTRL:
case KEY_DOWN:
case KEY_END:
case KEY_ESCAPE:
case KEY_HOME:
case KEY_LEFT:
case KEY_PAGEDOWN:
case KEY_PAGEUP:
case KEY_RIGHT:
case KEY_SHIFT:
case KEY_TAB:
case KEY_UP:
break;
case KEY_ENTER:
if (selectionEspece) {
selectionEspece=false;
}
else {
// lancer mise a jour
}
break;
default:
obtenirListeReferentielNom();
break;
}
 
}
}, listenerConfigEspece
);
 
 
boutonOK.addListener(new ButtonListenerAdapter() {
public void onClick(Button button, EventObject e) {
observationMediateur.ajouterObservation(this);
}
});
 
// on ajoute un écouteur
/*validerInfo.addListener(new ButtonListenerAdapter() {
 
392,7 → 463,7
final MemoryProxy dataProxy = new MemoryProxy(communeData);
final ArrayReader reader = new ArrayReader(rd);
store=new Store(dataProxy,reader);
Store store=new Store(dataProxy,reader);
store.load() ;
commune.setStore(store);
400,13 → 471,73
}
// si l'on a reçu une liste de nom
if(nouvelleDonnees instanceof ListeReferentielNom)
{
ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
Object[][] nomData = new Object[data.size()][2];
int i = 0 ;
// on la parse et on récupère les informations quiç nous interessent
for (Iterator it = data.keySet().iterator(); it.hasNext();)
{
ReferentielNom ref=(ReferentielNom) data.get(it.next());
nomData[i][0]= ref.getNom();
nomData[i][1]= ref.getNumeroNom();
i++ ;
}
// creation du store
FieldDef defNom = new StringFieldDef("nom");
FieldDef defNumeroNom = new StringFieldDef("numeroNom");
FieldDef[] defTab = { defNom, defNumeroNom};
RecordDef rd = new RecordDef(defTab);
final MemoryProxy dataProxy = new MemoryProxy(nomData);
final ArrayReader reader = new ArrayReader(rd);
Store store=new Store(dataProxy,reader);
store.load() ;
espece.setStore(store);
}
 
}
 
public void obtenirListeReferentielCommune() {
observationMediateur.obtenirListeReferentielCommune(this,commune.getText());
String com=commune.getText().replaceAll(" ","/");
com=com.replaceAll("%","");
observationMediateur.obtenirListeReferentielCommune(this,com);
}
 
public void obtenirListeReferentielNom() {
String esp=espece.getText().replaceAll(" ","/");
esp=esp.replaceAll("%","");
observationMediateur.obtenirListeReferentielNom(this,esp);
}