Subversion Repositories eFlore/Applications.del

Compare Revisions

Ignore whitespace Rev 322 → Rev 323

/trunk/src/org/tela_botanica/del/client/vues/rechercheimages/MoteurRechercheImage.java
File deleted
/trunk/src/org/tela_botanica/del/client/vues/rechercheimages/MoteurRechercheImagePresenteur.java
New file
0,0 → 1,103
package org.tela_botanica.del.client.vues.rechercheimages;
 
import java.util.List;
 
import org.tela_botanica.del.client.cache.CacheClient;
import org.tela_botanica.del.client.composants.moteurrecherche.MoteurRecherchePresenteur;
import org.tela_botanica.del.client.composants.moteurrecherche.MoteurRechercheVue;
import org.tela_botanica.del.client.i18n.I18n;
import org.tela_botanica.del.client.modeles.Protocole;
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
import org.tela_botanica.del.client.navigation.evenement.ajoutdetermination.EvenementAjoutDetermination;
import org.tela_botanica.del.client.navigation.evenement.changementprotocole.EvenementChangementProtocole;
import org.tela_botanica.del.client.navigation.evenement.rechercheimage.EvenementRechercheImage;
import org.tela_botanica.del.client.services.rest.ProtocoleService;
import org.tela_botanica.del.client.utils.MockDatasource;
 
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasChangeHandlers;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.IsWidget;
 
public class MoteurRechercheImagePresenteur {
 
public interface Vue extends IsWidget {
public abstract void ajouterProtocole(String protocole);
public abstract void selectionnerProtocole(int index);
public abstract HasChangeHandlers getListeProtocoles();
public abstract HasWidgets getZoneResultats();
public abstract HasWidgets getZoneRecherche();
}
private Vue vue;
// private final ImageService imageService = MockDatasource.getInstance();
private final ProtocoleService protocoleService = MockDatasource.getInstance();
private List<Protocole> protocoles;
//TODO : passer ça en cache
private String protocoleParDefaut = Protocole.IDENTIFICATION_AUTOMATIQUE;
/**
* Constructeur
* */
public MoteurRechercheImagePresenteur(Vue vue) {
this.vue = vue;
if (CacheClient.getInstance().getProtocoleCourant() == null) {
CacheClient.getInstance().setProtocoleCourant(protocoleService.getProtocole(protocoleParDefaut));
}
}
 
public void go(HasWidgets composite) {
composite.add(vue.asWidget());
gererEvenements();
chargerProtocoles();
chargerMoteurRechercheAvancee();
}
 
private void chargerProtocoles() {
protocoles = protocoleService.getProtocoles();
for (Protocole protocole : protocoles) {
vue.ajouterProtocole(protocole.getNom());
}
vue.selectionnerProtocole(protocoles.indexOf(CacheClient.getInstance().getProtocoleCourant()));
}
 
public void gererEvenements() {
 
vue.getListeProtocoles().addChangeHandler(new ChangeHandler() {
 
@Override
public void onChange(ChangeEvent event) {
Protocole protocoleCourant = (Protocole) event.getSource();
EvenementChangementProtocole evenement = new EvenementChangementProtocole(protocoleCourant);
BusEvenementiel.getInstance().fireEvent(evenement);
}
});
}
public void chargerMoteurRechercheAvancee() {
MoteurRecherchePresenteur presenteurRecherche = new MoteurRecherchePresenteur(new MoteurRechercheVue(I18n.getVocabulary().rechercherImage())) {
public void lancerRecherche(String termeRecherche) {
CacheClient.getInstance().setEspeceRecherche(termeRecherche);
BusEvenementiel.getInstance().fireEvent(new EvenementRechercheImage(getZoneResultats()));
}
};
presenteurRecherche.go(vue.getZoneRecherche());
}
public HasWidgets getZoneResultats() {
return vue.getZoneResultats();
}
}
/trunk/src/org/tela_botanica/del/client/vues/rechercheimages/MoteurRechercheImageVue.java
10,6 → 10,7
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Panel;
17,9 → 18,8
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
 
public class MoteurRechercheImageVue extends Composite implements MoteurRechercheImage.Vue {
public class MoteurRechercheImageVue extends Composite implements MoteurRechercheImagePresenteur.Vue {
 
private final VerticalPanel mainPanel = new VerticalPanel();
private final Panel panneauChargement = new FlowPanel();
 
interface MyUiBinder extends UiBinder<Widget, MoteurRechercheImageVue> {}
26,17 → 26,13
 
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
 
@UiField TextBox nomEspece;
@UiField Panel panneauResultats;
@UiField Button boutonChercher;
@UiField Panel panneauResultats, zoneRecherche;
@UiField Label protocoleLabel;
@UiField ListBox listeProtocoles;
 
// Constructeur
public MoteurRechercheImageVue() {
initWidget(uiBinder.createAndBindUi(this));
nomEspece.setFocus(true);
 
}
 
public Panel getPanneauChargement() {
60,14 → 56,6
this.panneauResultats = panneauResultats;
}
 
public HasClickHandlers getBoutonChercher() {
return boutonChercher;
}
 
public HasKeyPressHandlers getChampEspece() {
return nomEspece;
}
 
public HasChangeHandlers getListeProtocoles() {
return listeProtocoles;
}
81,7 → 69,7
}
 
public String getValeurEspece() {
return nomEspece.getText();
public HasWidgets getZoneRecherche() {
return zoneRecherche;
}
}
/trunk/src/org/tela_botanica/del/client/vues/rechercheimages/MoteurRechercheImageVue.ui.xml
8,11 → 8,10
<ui:style src="rechercheImage.css" />
<g:HTMLPanel>
<g:HTMLPanel styleName="{style.observationsRecherche}">
<g:HTMLPanel>
<g:Label text="{constants.rechercherImage}" styleName="titre" />
<g:HorizontalPanel styleName="{style.moteurRecherche}">
<g:TextBox ui:field="nomEspece" text="apifera"/>
<g:Button text="{constants.rechercherTaxon}" ui:field="boutonChercher" />
<g:HorizontalPanel ui:field="zoneRecherche"/>
<g:Label ui:field="protocoleLabel" text="{constants.protocole}" styleName="{style.labelProtocole}"/>
<g:ListBox ui:field="listeProtocoles" />
</g:HorizontalPanel>
/trunk/src/org/tela_botanica/del/client/vues/rechercheimages/rechercheImage.css
1,4 → 1,4
.observationsRecherche {}
.zoneRecherche{width:100%}
.moteurRecherche {margin-bottom:10px;}
.moteurRecherche button {margin-left:2px; margin-top:-1px}
.labelProtocole {padding:4px 5px 0 15px;}