Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 12 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12 Rev 13
Line 15... Line 15...
15
 */
15
 */
16
package org.tela_botanica.client;
16
package org.tela_botanica.client;
Line 17... Line 17...
17
 
17
 
Line -... Line 18...
-
 
18
import java.util.Date;
-
 
19
 
-
 
20
import com.google.gwt.json.client.JSONArray;
18
import java.util.Date;
21
import com.google.gwt.json.client.JSONParser;
19
 
22
import com.google.gwt.json.client.JSONString;
-
 
23
import com.google.gwt.json.client.JSONValue;
20
import com.google.gwt.user.client.DOM;
24
import com.google.gwt.user.client.HTTPRequest;
21
import com.google.gwt.user.client.Element;
25
import com.google.gwt.user.client.ResponseTextHandler;
-
 
26
import com.google.gwt.user.client.ui.Button;
22
import com.google.gwt.user.client.ui.Button;
27
import com.google.gwt.user.client.ui.ChangeListener;
23
import com.google.gwt.user.client.ui.ChangeListener;
28
import com.google.gwt.user.client.ui.CheckBox;
24
import com.google.gwt.user.client.ui.ClickListener;
29
import com.google.gwt.user.client.ui.ClickListener;
25
import com.google.gwt.user.client.ui.Composite;
30
import com.google.gwt.user.client.ui.Composite;
26
import com.google.gwt.user.client.ui.Grid;
31
import com.google.gwt.user.client.ui.Grid;
27
import com.google.gwt.user.client.ui.HTML;
32
import com.google.gwt.user.client.ui.HTML;
28
import com.google.gwt.user.client.ui.HorizontalPanel;
33
import com.google.gwt.user.client.ui.HorizontalPanel;
29
import com.google.gwt.user.client.ui.KeyboardListener;
-
 
30
import com.google.gwt.user.client.ui.PopupPanel;
34
import com.google.gwt.user.client.ui.KeyboardListener;
31
import com.google.gwt.user.client.ui.RootPanel;
-
 
32
import com.google.gwt.user.client.ui.TextBox;
35
import com.google.gwt.user.client.ui.PopupPanel;
33
import com.google.gwt.user.client.ui.UIObject;
36
import com.google.gwt.user.client.ui.TextBox;
Line 34... Line 37...
34
import com.google.gwt.user.client.ui.VerticalPanel;
37
import com.google.gwt.user.client.ui.VerticalPanel;
35
import com.google.gwt.user.client.ui.Widget;
38
import com.google.gwt.user.client.ui.Widget;
36
 
39
 
Line 37... Line 40...
37
/**
40
/**
Line 38... Line 41...
38
 * Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget()
41
 * Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget()
39
 */
42
 */
40
 
43
 
41
public class EntryPanel extends Composite  implements ClickListener {
44
public class EntryPanel extends Composite   {
42
	
45
	
43
  private NameAssistant nameAssistant = null;
46
  private NameAssistant nameAssistant = null;
44
  private LocationAssistant locationAssistant = null;
47
  private LocationAssistant locationAssistant = null;
45
  TextBox date = new TextBox();
48
  TextBox date = new TextBox();
Line -... Line 49...
-
 
49
  TextBox complementLocation = new TextBox();
-
 
50
  TextBox comment = new TextBox();
-
 
51
  Button dateSelector = new Button("...");
-
 
52
  boolean visible=false;
-
 
53
  Mediator mediator=null;
46
  TextBox complementLocation = new TextBox();
54
 
Line 47... Line 55...
47
  TextBox comment = new TextBox();
55
  private String serviceBaseUrl = null;
Line 48... Line 56...
48
  Button dateSelector = new Button("...");
56
  
Line 65... Line 73...
65
   mediator.registerDate(date);
73
   mediator.registerDate(date);
66
   mediator.registerComment(comment);
74
   mediator.registerComment(comment);
67
   mediator.registerComplementLocation(complementLocation);
75
   mediator.registerComplementLocation(complementLocation);
Line -... Line 76...
-
 
76
   
-
 
77
   
-
 
78
   user=mediator.getUser();
-
 
79
   serviceBaseUrl = mediator.getServiceBaseUrl();
Line 68... Line 80...
68
   
80
 
Line 69... Line 81...
69
   
81
   
Line 70... Line 82...
70
   
82
   
Line 119... Line 131...
119
    	   }
131
    	   }
120
    	   else {
132
    	   else {
121
    		visible=true; 
133
    		visible=true; 
122
    	    choicesPopup.show();
134
    	    choicesPopup.show();
123
	        choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
135
	        choicesPopup.setPopupPosition(dateSelector.getAbsoluteLeft(),
124
	        dateSelector.getAbsoluteTop()  + dateSelector.getOffsetHeight());
136
	        dateSelector.getAbsoluteTop()  - dateSelector.getOffsetHeight() - choicesPopup.getOffsetHeight());
125
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
137
	        choicesPopup.setWidth(dateSelector.getOffsetWidth() + "px");
126
    	   }
138
    	   }
127
       }
139
       }
Line 128... Line 140...
128
     
140
     
Line 236... Line 248...
236
		  }
248
		  }
Line 237... Line 249...
237
		  
249
		  
238
		  }
250
		  }
Line -... Line 251...
-
 
251
  );
-
 
252
 
-
 
253
   
-
 
254
    Button addButton = new Button("Ajout");
-
 
255
    Button updateButton = new Button("Modification");
-
 
256
 
-
 
257
    addButton.addClickListener(
-
 
258
    
-
 
259
    		new ClickListener() {
-
 
260
    			
-
 
261
    			  public void onClick(Widget w) {
-
 
262
    				     mediator.onAddInventoryItem(); 
-
 
263
    			  }
-
 
264
    		}
-
 
265
    );
-
 
266
    
-
 
267
    HorizontalPanel buttonPanel = new HorizontalPanel();
-
 
268
   
-
 
269
    
-
 
270
    updateButton.addClickListener(
-
 
271
    	    
-
 
272
    		new ClickListener() {
-
 
273
    			
-
 
274
    			  public void onClick(Widget w) {
-
 
275
    				     mediator.onModifyInventoryItem(ordre); 
-
 
276
    			  }
-
 
277
    		}
-
 
278
    );
-
 
279
    
-
 
280
    
Line 239... Line -...
239
  );
-
 
Line 240... Line 281...
240
 
281
    buttonPanel.add(addButton);
Line 241... Line 282...
241
    
282
    buttonPanel.add(updateButton);
242
	
283
    
-
 
284
 
Line -... Line 285...
-
 
285
	 inner.setWidth("100%");
-
 
286
 
Line 243... Line -...
243
 
-
 
244
	 inner.setWidth("100%");
-
 
245
 
-
 
246
	 outer.add(inner);
-
 
247
	 outer.setCellWidth(inner, "100%");
-
 
248
	 
-
 
249
 
-
 
Line 250... Line 287...
250
 
287
	 outer.add(inner);
Line 251... Line -...
251
		Button close = new Button("Cacher");
-
 
252
		close.addClickListener(this);
-
 
Line 253... Line 288...
253
 
288
	 outer.setCellWidth(inner, "100%");
254
		outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
289
	 outer.setSpacing(20);
255
 
-
 
256
 
-
 
257
		outer.add(close);
290
	 
258
 
-
 
259
	 
-
 
260
    initWidget(outer);
291
	outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
261
   
292
    outer.add(buttonPanel);
262
   setPixelSize(1000,200);
-
 
263
 
-
 
264
    
-
 
265
  }
-
 
266
  
293
 
Line 267... Line 294...
267
	public void onClick(Widget sender) {
294
 
268
		hide();
-
 
269
	}
295
 
270
  
296
	 
Line -... Line 297...
-
 
297
    initWidget(outer);
-
 
298
   
-
 
299
    
-
 
300
  }
-
 
301
 
Line 271... Line -...
271
  
-
 
272
	public void show() {
-
 
273
		
302
	/*
274
	    DOM.setStyleAttribute(getElement(), "backgroundColor", "white");
-
 
275
	    this.setOpacity(this,85);
303
	 * Numero d'ordre du relevé affiché
276
		RootPanel.get().remove(this);
-
 
277
		RootPanel.get().add(this,200,200);
-
 
278
	}
-
 
279
	
-
 
280
	public void hide() {
-
 
281
	    this.setOpacity(RootPanel.get(),100);
-
 
282
		RootPanel.get().remove(this);
-
 
283
	}
-
 
284
 
304
	 * 
-
 
305
	 */
-
 
306
	
-
 
307
	public void setOrdre(String ordre) {
-
 
308
		this.ordre = ordre;
-
 
309
	}
-
 
310
 
-
 
311
 
-
 
312
	/*
-
 
313
	 * Numero d'ordre du relevé affiché
-
 
314
	 * 
-
 
315
	 */
-
 
316
	
-
 
317
	public String getOrdre() {
-
 
318
		return this.ordre;
-
 
319
	}
-
 
320
 
-
 
321
 
-
 
322
  
-
 
323
  /**
-
 
324
	 * Mise a jour de l'affichage a partir de données deja saisie
-
 
325
	 * 
-
 
326
	 */
-
 
327
 
-
 
328
	public void update() {
-
 
329
 
-
 
330
		HTTPRequest.asyncGet(serviceBaseUrl + "/Inventory/" + user + "/" + ordre, 
-
 
331
 
-
 
332
		new ResponseTextHandler() {
-
 
333
 
-
 
334
			public void onCompletion(String str) {
-
 
335
 
-
 
336
				JSONValue jsonValue = JSONParser.parse(str);
-
 
337
				JSONArray jsonArray;
-
 
338
				
-
 
339
				
-
 
340
				if ((jsonArray = jsonValue.isArray()) != null) {
-
 
341
							// Nom saisi
-
 
342
							nameAssistant.setText(((JSONString) jsonArray.get(0)).stringValue());
-
 
343
							
-
 
344
							// Numero nomenclatural
-
 
345
						
-
 
346
							String ann=((JSONString) jsonArray .get(3)).stringValue();
-
 
347
							
-
 
348
							if (ann.compareTo("0")!=0) {
-
 
349
								nameAssistant.setValue(ann);
-
 
350
							}
-
 
351
							
-
 
352
							// Commune
-
 
353
							String aloc=((JSONString) jsonArray .get(6)).stringValue();
-
 
354
							
-
 
355
							if (aloc.compareTo("000null")!=0) {
-
 
356
								locationAssistant.setText(aloc);
-
 
357
							}
-
 
358
							else { 
-
 
359
								locationAssistant.setText("");
-
 
360
							}
-
 
361
							
-
 
362
							String adate=((JSONString) jsonArray .get(8)).stringValue();
-
 
363
							
-
 
364
//							Date 
-
 
365
							if (adate.compareTo("0000-00-00 00:00:00")!=0) {
-
 
366
								date.setText(adate); 
-
 
367
							}
-
 
368
							else {
-
 
369
								date.setText(""); 
-
 
370
							}
-
 
371
 
-
 
372
 
-
 
373
							String astation=((JSONString) jsonArray .get(9)).stringValue();
-
 
374
							
-
 
375
//							Station 
-
 
376
							if (astation.compareTo("null")!=0) {
-
 
377
								complementLocation.setText(astation); 
-
 
378
							}
-
 
379
							else {
-
 
380
								complementLocation.setText(""); 
-
 
381
							}
-
 
382
							
-
 
383
 
-
 
384
							String acomment=((JSONString) jsonArray .get(10)).stringValue();
-
 
385
//							Notes
-
 
386
							if (acomment.compareTo("null")!=0) {
285
	
387
								comment.setText(acomment); 
286
	private void setOpacity(UIObject e, int percentage) {
388
							}