2,18 → 2,36 |
|
|
|
import java.util.Iterator; |
|
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.ListeReferentielCommune; |
import org.tela_botanica.client.modeles.ReferentielCommune; |
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; |
import com.gwtext.client.core.Position; |
import com.gwtext.client.data.ArrayReader; |
import com.gwtext.client.data.FieldDef; |
import com.gwtext.client.data.MemoryProxy; |
import com.gwtext.client.data.RecordDef; |
import com.gwtext.client.data.Store; |
import com.gwtext.client.data.StringFieldDef; |
import com.gwtext.client.widgets.Button; |
import com.gwtext.client.widgets.Panel; |
import com.gwtext.client.widgets.form.ComboBox; |
import com.gwtext.client.widgets.form.DateField; |
import com.gwtext.client.widgets.form.FormPanel; |
import com.gwtext.client.widgets.form.TextField; |
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter; |
import com.gwtext.client.widgets.layout.ColumnLayout; |
import com.gwtext.client.widgets.layout.ColumnLayoutData; |
import com.gwtext.client.widgets.layout.FormLayout; |
import com.gwtext.client.data.Record; |
|
/** |
* Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable |
20,7 → 38,7 |
* @author aurelien |
* |
*/ |
public class FormulaireSaisieObservationVue extends Panel { |
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable { |
|
|
/** |
30,15 → 48,40 |
|
|
private TextField nameAssistant = null; |
private LocationAssistantVue locationAssistant = null; |
private DateField date = null; |
private DateField date = null; |
private TextField lieudit = null; |
private TextField station = null; |
private TextField milieu = null; |
private TextField comment = null; |
private ComboBox commune = null; |
|
private boolean selectionCommune=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; |
|
|
|
|
/** |
* Booleen d'instanciation |
*/ |
88,10 → 131,140 |
panneauSecondeColonne.setLayout(new FormLayout()); |
panneauSecondeColonne.setBorder(false); |
|
/* |
// creation du store |
FieldDef defCommune = new StringFieldDef("commune"); |
FieldDef defDepartement = new StringFieldDef("departement"); |
|
locationAssistant = new LocationAssistantVue(obs); |
panneauPremierColonne.add(locationAssistant); |
|
FieldDef[] defTab = { defCommune, defDepartement}; |
|
RecordDef rd = new RecordDef(defTab); |
|
|
store = new Store(rd); |
|
//store.load();*/ |
|
commune=new ComboBox("Commune","commune",275 ); |
|
|
//commune.setStore(store); |
|
final String resultTpl = "<div class=\"search-item\">{commune}</div>"; |
|
|
commune.setTpl(resultTpl); |
commune.setMode(ComboBox.REMOTE); |
// commune.setPageSize(10); // Ne fonctionne pas |
commune.setItemSelector("div.search-item"); |
|
|
//commune.setDisplayField("title"); |
|
commune.setTypeAhead(true); |
commune.setLoadingText("Recherche..."); |
|
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); |
|
|
|
station = new TextField("Station", "station", 275); |
station.setAllowBlank(true); |
panneauPremierColonne.add(station); |
119,9 → 292,8 |
milieu.setAllowBlank(true); |
panneauSecondeColonne.add(milieu); |
|
|
|
|
|
panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5)); |
panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5)); |
|
182,8 → 354,60 |
{ |
this.setDisabled(false) ; |
} |
|
public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) { |
// |
|
|
// si l'on a reçu une liste de commune |
if(nouvelleDonnees instanceof ListeReferentielCommune) |
{ |
|
ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ; |
Object[][] communeData = 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();) |
{ |
|
ReferentielCommune ref=(ReferentielCommune) data.get(it.next()); |
|
communeData[i][0]= ref.getCommune(); |
communeData[i][1]= ref.getDepartement(); |
|
|
i++ ; |
} |
|
// creation du store |
FieldDef defCommune = new StringFieldDef("commune"); |
FieldDef defDepartement = new StringFieldDef("departement"); |
|
|
FieldDef[] defTab = { defCommune, defDepartement}; |
|
RecordDef rd = new RecordDef(defTab); |
|
final MemoryProxy dataProxy = new MemoryProxy(communeData); |
final ArrayReader reader = new ArrayReader(rd); |
|
store=new Store(dataProxy,reader); |
store.load() ; |
|
commune.setStore(store); |
|
|
|
} |
} |
|
|
public void obtenirListeReferentielCommune() { |
observationMediateur.obtenirListeReferentielCommune(this,commune.getText()); |
|
} |
|
|
|
|