Subversion Repositories eFlore/Applications.cel

Rev

Rev 2392 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1940 aurelien 1
package org.tela_botanica.client.util;
2
 
3
import java.util.ArrayList;
4
import java.util.Iterator;
1945 aurelien 5
import java.util.List;
2602 aurelien 6
import java.util.Map;
7
 
8
import org.tela_botanica.client.cel2;
1940 aurelien 9
import org.tela_botanica.client.interfaces.Rafraichissable;
10
import org.tela_botanica.client.modeles.dao.ListeReferentielChampsEtendusDAO;
1943 aurelien 11
import org.tela_botanica.client.modeles.objets.Configuration;
2602 aurelien 12
import org.tela_botanica.client.util.autocompletion.AutoCompletionComboBox;
1940 aurelien 13
 
2392 aurelien 14
import com.google.gwt.core.client.Callback;
2602 aurelien 15
import com.google.gwt.http.client.Response;
1940 aurelien 16
import com.google.gwt.user.client.Timer;
17
import com.gwtext.client.core.EventCallback;
18
import com.gwtext.client.core.EventObject;
19
import com.gwtext.client.core.Ext;
20
import com.gwtext.client.core.ListenerConfig;
21
import com.gwtext.client.data.ArrayReader;
22
import com.gwtext.client.data.FieldDef;
23
import com.gwtext.client.data.MemoryProxy;
24
import com.gwtext.client.data.Record;
25
import com.gwtext.client.data.RecordDef;
26
import com.gwtext.client.data.Store;
27
import com.gwtext.client.data.StringFieldDef;
28
import com.gwtext.client.widgets.Component;
2392 aurelien 29
import com.gwtext.client.widgets.ToolTip;
1940 aurelien 30
import com.gwtext.client.widgets.form.ComboBox;
1945 aurelien 31
import com.gwtext.client.widgets.form.Field;
1940 aurelien 32
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
33
 
2602 aurelien 34
public class ChampSaisieEtendu extends AutoCompletionComboBox {
1940 aurelien 35
 
36
		private String cle = null;
37
		private String label = null;
38
 
2392 aurelien 39
		private String description = null;
40
		private ToolTip tpDesc = null;
41
 
2602 aurelien 42
		public ChampSaisieEtendu(String label, String cle, String urlRequete) {
2392 aurelien 43
 
2602 aurelien 44
			super(label, urlRequete);
1940 aurelien 45
			this.cle =cle;
46
			this.label = label;
47
 
2392 aurelien 48
			// A activer pour télécharger la description
49
			// si jamais on le décide
50
			addListener(new ComboBoxListenerAdapter() {
1940 aurelien 51
				@Override
52
				public void onRender(Component component) {
2392 aurelien 53
					ChampSaisieEtendu.this.getEl().addListener("mouseover", new EventCallback() {
54
						@Override
55
						public void execute(EventObject e) {
56
							if(description == null) {
57
								telechargerEtAfficherDescriptionDistante();
58
							} else {
59
								afficherDescription(description);
60
							}
61
						}
62
					});
1940 aurelien 63
				}
64
			});
65
		}
66
 
2392 aurelien 67
		private void telechargerEtAfficherDescriptionDistante() {
68
			ListeReferentielChampsEtendusDAO.telechargerDescriptionWikini(cle, new Callback<String, String>() {
69
				@Override
70
				public void onSuccess(String description) {
71
					ChampSaisieEtendu.this.description = description;
72
					afficherDescription(description);
73
				}
74
 
75
				@Override
76
				public void onFailure(String description) {
77
					afficherDescription(description);
78
				}
79
			});
80
		}
81
 
82
		private void afficherDescription(String description) {
83
			if(!description.trim().isEmpty()) {
84
				if(tpDesc == null) {
85
					tpDesc = new ToolTip(description);
86
					tpDesc.applyTo(this.getElement());
87
					tpDesc.showAt(ChampSaisieEtendu.this.getEl().getX(), ChampSaisieEtendu.this.getEl().getY());
88
				} else {
89
					tpDesc.show();
90
				}
91
			}
92
		}
93
 
2602 aurelien 94
		public String getCle() {
95
			return cle;
1940 aurelien 96
		}
97
 
2602 aurelien 98
		public String getLabel() {
99
			return label;
1940 aurelien 100
		}
2602 aurelien 101
 
102
		@Override
103
		protected Map<String, String> parserResultatRequete(Response response) {
104
			return ListeReferentielChampsEtendusDAO.parserRetourListeValeursChampsEtendus(response);
1940 aurelien 105
		}
2602 aurelien 106
 
107
		@Override
108
		protected void onModificationValeur() {
109
			// TODO Auto-generated method stub
1940 aurelien 110
		}
1943 aurelien 111
 
2602 aurelien 112
		@Override
113
		protected void onSelectionValeur() {
114
			// TODO Auto-generated method stub
1943 aurelien 115
		}
2602 aurelien 116
 
1967 aurelien 117
		@Override
2602 aurelien 118
		protected void onValidationSaisie() {
119
			// TODO Auto-generated method stub
120
 
1967 aurelien 121
		}
122
}