Subversion Repositories eFlore/Applications.cel

Rev

Rev 307 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 307 Rev 315
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
2
 
2
 
3
import org.tela_botanica.client.CarnetEnLigneMediateur;
3
import org.tela_botanica.client.CarnetEnLigneMediateur;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
5
 
-
 
6
import com.google.gwt.core.client.JavaScriptObject;
-
 
7
import com.google.gwt.user.client.ui.Button;
-
 
8
import com.google.gwt.user.client.ui.ClickListener;
-
 
9
import com.google.gwt.user.client.ui.Widget;
5
import com.gwtext.client.core.EventCallback;
10
import com.gwtext.client.core.EventCallback;
6
import com.gwtext.client.core.EventObject;
11
import com.gwtext.client.core.EventObject;
-
 
12
import com.gwtext.client.core.RegionPosition;
7
import com.gwtext.client.data.ArrayReader;
13
import com.gwtext.client.data.ArrayReader;
8
import com.gwtext.client.data.FieldDef;
14
import com.gwtext.client.data.FieldDef;
9
import com.gwtext.client.data.MemoryProxy;
15
import com.gwtext.client.data.MemoryProxy;
10
import com.gwtext.client.data.Record;
16
import com.gwtext.client.data.Record;
11
import com.gwtext.client.data.RecordDef;
17
import com.gwtext.client.data.RecordDef;
12
import com.gwtext.client.data.Store;
18
import com.gwtext.client.data.Store;
13
import com.gwtext.client.data.StringFieldDef;
19
import com.gwtext.client.data.StringFieldDef;
-
 
20
import com.gwtext.client.widgets.BoxComponent;
-
 
21
import com.gwtext.client.widgets.Component;
14
import com.gwtext.client.widgets.Panel;
22
import com.gwtext.client.widgets.Panel;
15
import com.gwtext.client.widgets.Window;
23
import com.gwtext.client.widgets.Window;
-
 
24
import com.gwtext.client.widgets.event.ButtonListener;
16
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
25
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
17
import com.gwtext.client.widgets.form.ComboBox;
26
import com.gwtext.client.widgets.form.ComboBox;
-
 
27
import com.gwtext.client.widgets.form.Field;
-
 
28
import com.gwtext.client.widgets.form.event.ComboBoxCallback;
-
 
29
import com.gwtext.client.widgets.form.event.ComboBoxListener;
18
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
30
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
-
 
31
import com.gwtext.client.widgets.layout.BorderLayout;
-
 
32
import com.gwtext.client.widgets.layout.BorderLayoutData;
19
import com.gwtext.client.widgets.layout.HorizontalLayout;
33
import com.gwtext.client.widgets.layout.HorizontalLayout;
20
import com.gwtext.client.widgets.layout.RowLayout;
34
import com.gwtext.client.widgets.layout.RowLayout;
-
 
35
import com.gwtext.client.widgets.menu.Menu;
21
 
36
 
22
public class ListeUtilisateurAdminVue extends Window implements Rafraichissable {
37
public class ListeUtilisateurAdminVue extends Window implements Rafraichissable {
23
 
38
 
24
	private CarnetEnLigneMediateur cMediateur = null ;
39
	private CarnetEnLigneMediateur cMediateur = null ;
25
	private ComboBox listeUtil = null ;
40
	private ComboBox listeUtil = null ;
26
	private Store storeUtil = null ;
41
	private Store storeUtil = null ;
27
	private com.gwtext.client.widgets.Button OK = null;
42
	private com.gwtext.client.widgets.Button OK = null;
28
	private com.gwtext.client.widgets.Button annuler = null;
43
	private com.gwtext.client.widgets.Button annuler = null;
29
	private boolean selectionUtilisateur =false;
44
	private boolean selectionUtilisateur =false;
30
	public String utilisateur = null;
45
	public String utilisateur = null;
31
	
46
	
32
	private final int KEY_ALT = 18;
47
	private final int KEY_ALT = 18;
33
	private final int KEY_BACKSPACE = 8;
48
	private final int KEY_BACKSPACE = 8;
34
	private final int KEY_CTRL = 17;
49
	private final int KEY_CTRL = 17;
35
	private final int KEY_DELETE = 46;
50
	private final int KEY_DELETE = 46;
36
	private final int KEY_DOWN = 40;
51
	private final int KEY_DOWN = 40;
37
	private final int KEY_END = 35;
52
	private final int KEY_END = 35;
38
	private final int KEY_ENTER = 13;
53
	private final int KEY_ENTER = 13;
39
	private final int KEY_ESCAPE = 27;
54
	private final int KEY_ESCAPE = 27;
40
	private final int KEY_HOME = 36;
55
	private final int KEY_HOME = 36;
41
	private final int KEY_LEFT = 37;
56
	private final int KEY_LEFT = 37;
42
	private final int KEY_PAGEDOWN = 34;
57
	private final int KEY_PAGEDOWN = 34;
43
	private final int KEY_PAGEUP = 33;
58
	private final int KEY_PAGEUP = 33;
44
	private final int KEY_RIGHT = 39;
59
	private final int KEY_RIGHT = 39;
45
	private final int KEY_SHIFT = 16;
60
	private final int KEY_SHIFT = 16;
46
	private final int KEY_TAB = 9;
61
	private final int KEY_TAB = 9;
47
	private final int KEY_UP = 38;
62
	private final int KEY_UP = 38;
48
	
63
	
49
	public ListeUtilisateurAdminVue(CarnetEnLigneMediateur cMed) {
64
	public ListeUtilisateurAdminVue(CarnetEnLigneMediateur cMed) {
50
		super("Choisissez un utilisateur") ;
65
		super("Choisir un utilisateur") ;
51
		
66
		
52
		this.cMediateur = cMed;
67
		this.cMediateur = cMed;
53
		
68
		
54
		listeUtil=new ComboBox("Utilisateurs","utilisateur",280);  
69
		listeUtil=new ComboBox("Utilisateurs","utilisateur",280);  
55
		
70
		
56
		this.setLayout(new RowLayout());
71
		this.setLayout(new RowLayout());
57
		
72
		
58
		final String resultTplUtil = "<div class=\"search-item-utilisateur\">{utilisateur}</div>";  
73
		final String resultTplUtil = "<div class=\"search-item-utilisateur\">{utilisateur}</div>";  
59
		
74
		
60
		utilisateur = cMediateur.getUtilisateur().getIdentite();
75
		utilisateur = cMediateur.getUtilisateur().getIdentite();
61
 
76
 
62
		
77
		
63
		listeUtil.setTpl(resultTplUtil);
78
		listeUtil.setTpl(resultTplUtil);
64
		listeUtil.setMode(ComboBox.REMOTE);
79
		listeUtil.setMode(ComboBox.REMOTE);
65
		// commune.setPageSize(10); // Ne fonctionne pas 
80
		// commune.setPageSize(10); // Ne fonctionne pas 
66
		listeUtil.setItemSelector("div.search-item-utilisateur");
81
		listeUtil.setItemSelector("div.search-item-utilisateur");
67
		listeUtil.setTypeAhead(true);  
82
		listeUtil.setTypeAhead(true);  
68
		listeUtil.setHideTrigger(true);
83
		listeUtil.setHideTrigger(true);
69
		
84
		
70
		listeUtil.setDisplayField("utilisateur");
85
		listeUtil.setDisplayField("utilisateur");
71
		
86
		
72
		listeUtil.setLoadingText("Recherche..."); 
87
		listeUtil.setLoadingText("Recherche..."); 
73
		listeUtil.setValue(utilisateur);
88
		listeUtil.setValue(utilisateur);
74
		
89
		
75
		OK= new com.gwtext.client.widgets.Button("OK");
90
		OK= new com.gwtext.client.widgets.Button("OK");
76
		annuler = new com.gwtext.client.widgets.Button("Annuler");
91
		annuler = new com.gwtext.client.widgets.Button("Annuler");
77
		
92
		
78
		Panel boutonPanel = new Panel();
93
		Panel boutonPanel = new Panel();
79
		boutonPanel.setLayout(new HorizontalLayout(0));
94
		boutonPanel.setLayout(new HorizontalLayout(0));
80
			
95
			
81
		add(listeUtil);
96
		add(listeUtil);
82
		
97
		
83
		boutonPanel.add(OK);
98
		boutonPanel.add(OK);
84
		boutonPanel.add(annuler);
99
		boutonPanel.add(annuler);
85
		
100
		
86
		add(boutonPanel);
101
		add(boutonPanel);
87
		
102
		
88
		this.setSize(300, 75);
103
		this.setSize(300, 75);
89
		
104
		
90
		OK.addListener(new ButtonListenerAdapter() {
105
		OK.addListener(new ButtonListenerAdapter() {
91
 
106
 
92
			public void onClick(com.gwtext.client.widgets.Button button,
107
			public void onClick(com.gwtext.client.widgets.Button button,
93
					EventObject e) {
108
					EventObject e) {
94
	    		if(valider()) {
109
	    		if(valider()) {
95
	    			cMediateur.changerIdentite(listeUtil.getValue());
110
	    			cMediateur.changerIdentite(listeUtil.getValue());
96
	    			close();
111
	    			close();
97
	    		}
112
	    		}
98
			}
113
			}
99
		});
114
		});
100
		
115
		
101
		annuler.addListener(new ButtonListenerAdapter() {
116
		annuler.addListener(new ButtonListenerAdapter() {
102
 
117
 
103
			public void onClick(com.gwtext.client.widgets.Button button,
118
			public void onClick(com.gwtext.client.widgets.Button button,
104
					EventObject e) {
119
					EventObject e) {
105
				close();
120
				close();
106
			}
121
			}
107
		});
122
		});
-
 
123
		
-
 
124
		final ListeUtilisateurAdminVue l = this ;
108
		
125
		
109
		listeUtil.addKeyPressListener(new EventCallback() {
126
		listeUtil.addKeyPressListener(new EventCallback() {
110
 
127
 
111
			public void execute(EventObject e) {
128
			public void execute(EventObject e) {
112
				
129
				
113
				switch(e.getKey()) {
130
				switch(e.getKey()) {
114
	    	      
131
	    	      
115
					case KEY_ALT:
132
					case KEY_ALT:
116
	    	        case KEY_CTRL:
133
	    	        case KEY_CTRL:
117
	    	        case KEY_DOWN:
134
	    	        case KEY_DOWN:
118
	    	        case KEY_END:
135
	    	        case KEY_END:
119
	    	        case KEY_ESCAPE:
136
	    	        case KEY_ESCAPE:
120
	    	        case KEY_HOME:
137
	    	        case KEY_HOME:
121
	    	        case KEY_LEFT:
138
	    	        case KEY_LEFT:
122
	    	        case KEY_PAGEDOWN:
139
	    	        case KEY_PAGEDOWN:
123
	    	        case KEY_PAGEUP:
140
	    	        case KEY_PAGEUP:
124
	    	        case KEY_RIGHT:
141
	    	        case KEY_RIGHT:
125
	    	        case KEY_SHIFT:
142
	    	        case KEY_SHIFT:
126
	    	        case KEY_TAB:
143
	    	        case KEY_TAB:
127
	    	        case KEY_UP:
144
	    	        case KEY_UP:
128
	    	    	
145
	    	    	
129
	    	        break;
146
	    	        break;
130
	    		
147
	    		
131
	    	    	case KEY_ENTER:
148
	    	    	case KEY_ENTER:
132
	    	    	  
149
	    	    	  
133
		    	    	 if(selectionUtilisateur) {
150
		    	    	 if(selectionUtilisateur) {
134
		    	    		 utilisateur = listeUtil.getValue();
151
		    	    		 utilisateur = listeUtil.getValue();
135
		    	    		 selectionUtilisateur=false;
152
		    	    		 selectionUtilisateur=false;
136
		    	    	 }
153
		    	    	 }
137
		    	    	else {
154
		    	    	else {
138
		    	    		if(valider()) {
155
		    	    		if(valider()) {
139
		    	    			cMediateur.changerIdentite(utilisateur);
156
		    	    			cMediateur.changerIdentite(utilisateur);
140
		    	    		} else {
157
		    	    		} else {
141
		    	    			cMediateur.changerIdentite(utilisateur);
158
		    	    			cMediateur.changerIdentite(utilisateur);
142
		    	    		}
159
		    	    		}
143
	    	    			close();
160
	    	    			close();
144
		    	    	 }
161
		    	    	 }
145
		    	    break;  
162
		    	    break;  
146
		    	    
163
		    	    
147
		    	    default:
164
		    	    default:
148
		    	    	obtenirListeUtilisateur();
165
		    	    	obtenirListeUtilisateur();
149
		    	    break;
166
		    	    break;
150
				}
167
				}
151
			}
168
			}
152
		});
169
		});
153
		
170
		
154
		listeUtil.addListener(new ComboBoxListenerAdapter() {
171
		listeUtil.addListener(new ComboBoxListenerAdapter() {
155
 
172
 
156
			public void onSelect(ComboBox comboBox, Record record, int index) {
173
			public void onSelect(ComboBox comboBox, Record record, int index) {
157
				
174
				
158
				utilisateur = record.getAsString("utilisateur");
175
				utilisateur = record.getAsString("utilisateur");
159
				listeUtil.setValue(utilisateur);
176
				listeUtil.setValue(utilisateur);
160
				
177
				
161
			}
178
			}
162
		});
179
		});
163
	}
180
	}
164
	
181
	
165
	public void rafraichir(Object nouvelleDonnees,
182
	public void rafraichir(Object nouvelleDonnees,
166
			boolean repandreRaffraichissement) {
183
			boolean repandreRaffraichissement) {
167
		
184
		
168
		if(nouvelleDonnees instanceof String[][]) {
185
		if(nouvelleDonnees instanceof String[][]) {
169
		
186
		
170
			Object[][] utilData = (Object[][])nouvelleDonnees ;
187
			Object[][] utilData = (Object[][])nouvelleDonnees ;
171
			
188
			
172
			FieldDef defUtil = new StringFieldDef("utilisateur");
189
			FieldDef defUtil = new StringFieldDef("utilisateur");
173
			FieldDef[] defTab = {defUtil};
190
			FieldDef[] defTab = {defUtil};
174
			
191
			
175
			RecordDef rd = new RecordDef(defTab);
192
			RecordDef rd = new RecordDef(defTab);
176
			
193
			
177
			final MemoryProxy dataProxy = new MemoryProxy(utilData);
194
			final MemoryProxy dataProxy = new MemoryProxy(utilData);
178
			final ArrayReader reader = new ArrayReader(rd);		
195
			final ArrayReader reader = new ArrayReader(rd);		
179
			
196
			
180
			storeUtil =new Store(dataProxy,reader);
197
			storeUtil =new Store(dataProxy,reader);
181
			storeUtil.load() ;
198
			storeUtil.load() ;
182
	
199
	
183
			listeUtil.setStore(storeUtil);
200
			listeUtil.setStore(storeUtil);
184
			listeUtil.expand();
201
			listeUtil.expand();
185
		
202
		
186
		}
203
		}
187
		
204
		
188
	}
205
	}
189
	
206
	
190
	private boolean valider() {
207
	private boolean valider() {
191
		if(listeUtil.getValue() != null) {
208
		if(listeUtil.getValue() != null) {
192
			return true;
209
			return true;
193
		}
210
		}
194
		return false;
211
		return false;
195
	}
212
	}
196
	
213
	
197
	public void obtenirListeUtilisateur() {
214
	public void obtenirListeUtilisateur() {
198
		
215
		
199
		String valeur = listeUtil.getRawValue();
216
		String valeur = listeUtil.getRawValue();
200
    	cMediateur.obtenirListeUtilisateurs(valeur,this) ;
217
    	cMediateur.obtenirListeUtilisateurs(valeur,this) ;
201
	}
218
	}
202
 
219
 
203
	public void focusChampUtilisateur() {
220
	public void focusChampUtilisateur() {
204
		listeUtil.focus();
221
		listeUtil.focus();
205
	}
222
	}
206
 
-
 
207
}
223
 
-
 
224
}