13,18 → 13,22 |
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.core.Template; |
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.SimpleStore; |
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.Toolbar; |
import com.gwtext.client.widgets.event.ButtonListenerAdapter; |
import com.gwtext.client.widgets.form.ComboBox; |
import com.gwtext.client.widgets.form.DateField; |
61,12 → 65,14 |
private ComboBox espece = null; |
private String numeroNom = null; |
|
private Button boutonOK = new Button("Ok"); |
private Button boutonOK = new Button("Créer"); |
private Button boutonAnnuler = new Button("Annuler"); |
|
private boolean selectionCommune=false; |
private boolean selectionEspece=false; |
|
private boolean modification = false ; |
private Toolbar bt = null ; |
|
private final int KEY_ALT = 18; |
private final int KEY_BACKSPACE = 8; |
85,8 → 91,13 |
private final int KEY_TAB = 9; |
private final int KEY_UP = 38; |
|
/** |
* Combobox permettant de selectionner le mode |
* modification ou bien création |
*/ |
private ComboBox selecteurMode = new ComboBox(); |
|
|
Store storeMode = null ; |
|
/** |
* Booleen d'instanciation |
96,6 → 107,7 |
/** |
* Constructeur sans argument (privé car ne doit pas être utilisé) |
*/ |
@SuppressWarnings("unused") |
private FormulaireSaisieObservationVue() |
{ |
super() ; |
211,14 → 223,43 |
|
panneauFormulaire.add(panneauIntermediaire); |
|
/*final Template tp = new Template("<div class=\"x-combo-list-item\">" |
+ "{nom_mode}" + "<div class=\"x-clear\"></div></div>"); |
tp.compile();*/ |
|
Object[][] mode = {{"création",false} , {"modification", true} }; |
storeMode = new SimpleStore(new String[] { "nom_mode", "mode" }, |
mode); |
storeMode.load(); |
selecteurMode.setStore(storeMode); |
selecteurMode.setDisplayField("nom_mode") ; |
selecteurMode.setLabel("mode ") ; |
selecteurMode.setForceSelection(true) ; |
selecteurMode.setValue("création") ; |
selecteurMode.setEditable(false) ; |
|
bt = new Toolbar() ; |
bt.addSpacer() ; |
bt.addText("Mode de saisie ") ; |
bt.addField(selecteurMode) ; |
|
panneauFormulaire.addButton(boutonOK); |
|
|
panneauFormulaire.addButton(boutonAnnuler); |
|
|
selecteurMode.addListener(new ComboBoxListenerAdapter() { |
|
public void onSelect(ComboBox comboBox, Record record, int index) { |
|
// et on met la valeur à jour dans la combobox |
comboBox.setValue(record.getAsString("nom_mode")); |
setModification(record.getAsString("mode")) ; |
} |
|
}); |
|
this.add(panneauFormulaire) ; |
this.setBottomToolbar(bt) ; |
|
|
this.setAutoHeight(true); |
380,10 → 421,17 |
|
public void onClick(Button button, EventObject e) { |
|
ajouterObservation(); |
if(modification) |
{ |
modifierObservation() ; |
} |
else |
{ |
ajouterObservation(); |
} |
|
|
} |
|
|
}); |
|
505,7 → 553,11 |
|
} |
|
|
if(nouvelleDonnees instanceof Observation) |
{ |
Observation obs = (Observation)nouvelleDonnees ; |
afficherDetailsObservation(obs) ; |
} |
|
} |
|
535,5 → 587,88 |
observationMediateur.ajouterObservation(obs); |
} |
|
private void modifierObservation() { |
// TODO appeler le médiateur et mettre en place la modif |
|
} |
|
|
public void afficherDetailsObservation(Observation obs) |
{ |
viderChampsObservation() ; |
|
if(!obs.getDate().equals("null") && !obs.getDate().equals("000null")) { |
String[] dateEtHeure = obs.getDate().split(" ", 2); |
date.setRawValue(dateEtHeure[0]) ; |
} |
if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) { |
lieudit.setValue(obs.getLieudit()) ; |
} |
if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) { |
station.setValue(obs.getStation()) ; |
} |
if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) { |
milieu.setValue(obs.getMilieu()) ; |
} |
if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) { |
comment.setValue(obs.getCommentaire()) ; |
} |
if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) { |
commune.setValue(obs.getLocalite()) ; |
} |
if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) { |
departement = obs.getIdentifiantLocalite(); |
} |
if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) { |
espece.setValue(obs.getNomSaisi()) ; |
} |
if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) { |
numeroNom = obs.getNumeroNomenclaturalSaisi() ; |
} |
} |
|
public void viderChampsObservation() |
{ |
|
date.reset() ; |
lieudit.reset() ; |
station.reset() ; |
milieu.reset(); |
comment.reset(); |
commune.reset(); |
departement = ""; |
espece.reset(); |
numeroNom = "" ; |
|
} |
|
private void setModification(String mode) |
{ |
if(mode.equals("true")) { |
|
boutonOK.setText("Modifier") ; |
setTitle("Modification") ; |
modification = true ; |
} |
else |
{ |
|
boutonOK.setText("Créer") ; |
setTitle("Saisir") ; |
modification = false ; |
} |
|
} |
|
|
/** |
* renvoie vrai si on est en mode modification, faux si on est en mode création |
* @return |
*/ |
public boolean getModification() |
{ |
return modification ; |
} |
|
|
} |