Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 12 | Go to most recent revision | Show entire file | Regard 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 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
    
Line 239... Line 280...
239
  );
280
    
Line 240... Line 281...
240
 
281
    buttonPanel.add(addButton);
241
    
282
    buttonPanel.add(updateButton);
-
 
283
    
Line -... Line 284...
-
 
284
 
-
 
285
	 inner.setWidth("100%");
Line 242... Line -...
242
	
-
 
243
 
-
 
Line 244... Line -...
244
	 inner.setWidth("100%");
-
 
Line -... Line 286...
-
 
286
 
Line 245... Line -...
245
 
-
 
Line -... Line 287...
-
 
287
	 outer.add(inner);
Line -... Line 288...
-
 
288
	 outer.setCellWidth(inner, "100%");
-
 
289
	 outer.setSpacing(20);
-
 
290
	 
-
 
291
	outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
-
 
292
    outer.add(buttonPanel);
-
 
293
 
246
	 outer.add(inner);
294
 
-
 
295
 
Line 247... Line -...
247
	 outer.setCellWidth(inner, "100%");
-
 
Line -... Line 296...
-
 
296
	 
-
 
297
    initWidget(outer);
-
 
298
   
-
 
299
    
Line -... Line 300...
-
 
300
  }
-
 
301
 
248
	 
302
	/*
Line -... Line 303...
-
 
303
	 * Numero d'ordre du relevé affiché
-
 
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
	 */
249
 
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) {
250
 
349
								nameAssistant.setValue(ann);
-
 
350
							}
-
 
351
							
251
		Button close = new Button("Cacher");
352
							// Commune
Line 252... Line 353...
252
		close.addClickListener(this);
353
							String aloc=((JSONString) jsonArray .get(6)).stringValue();
Line -... Line 354...
-
 
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();
253
 
363
							
-
 
364
//							Date 
254
		outer.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
365
							if (adate.compareTo("0000-00-00 00:00:00")!=0) {
255
 
366
								date.setText(adate); 
-
 
367
							}
-
 
368
							else {
256
 
369
								date.setText(""); 
257
		outer.add(close);
370
							}
Line 258... Line -...
258
 
-
 
259
	 
-
 
260
    initWidget(outer);
-
 
261
   
371
 
Line 262... Line -...
262
   setPixelSize(1000,200);
-
 
263
 
-
 
264
    
-
 
Line 265... Line 372...
265
  }
372
 
266
  
-
 
267
	public void onClick(Widget sender) {
-
 
268
		hide();
-
 
269
	}
373
							String astation=((JSONString) jsonArray .get(9)).stringValue();
Line 270... Line -...
270
  
-
 
271
  
-
 
272
	public void show() {
-
 
273
		
374
							
Line -... Line 375...
-
 
375
//							Station 
274
	    DOM.setStyleAttribute(getElement(), "backgroundColor", "white");
376
							if (astation.compareTo("null")!=0) {