Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 26 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
25 ddelon 1
/*
2
 * Copyright 2006 Google Inc.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
 * use this file except in compliance with the License. You may obtain a copy of
6
 * the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 * License for the specific language governing permissions and limitations under
14
 * the License.
15
 */
16
package org.tela_botanica.client;
17
 
18
 
19
import com.google.gwt.json.client.JSONArray;
20
import com.google.gwt.json.client.JSONParser;
21
import com.google.gwt.json.client.JSONString;
22
import com.google.gwt.json.client.JSONValue;
23
import com.google.gwt.user.client.HTTPRequest;
24
import com.google.gwt.user.client.ResponseTextHandler;
25
import com.google.gwt.user.client.ui.Image;
26
import com.google.gwt.user.client.ui.PopupPanel;
27
 
28
/**
29
 * Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget()
30
 */
31
 
32
public class InfoPopup extends PopupPanel   {
33
 
34
  private Mediator mediator=null;
35
  private Image image = new Image();
36
 
37
  public InfoPopup(final Mediator med) {
38
 
39
   super(true);
40
 
41
   mediator=med;
42
 
43
 
44
   mediator.registerInfoPopup(this);
45
 
46
 
47
   add(image);
48
 
49
 
50
  }
51
 
52
  public void setImage(String url) {
53
		if (url.compareTo("null")!=0) {
54
		  setPopupPosition(mediator.getLeftPanel().getAbsoluteLeft()+10, mediator.getLeftPanel().getAbsoluteTop()  + (mediator.getLeftPanel().getOffsetHeight()/2));
55
		  show();
56
		  image.setUrl(url);
57
		}
58
		else  {
59
		  hide();
60
		}
61
 
62
	}
63
 
64
 
65
  public void setImageUrl(String value) {
66
 
67
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/NameImage/" + value,
68
				new ResponseTextHandler() {
69
 
70
					public void onCompletion(String strcomplete) {
71
 
72
						JSONValue jsonValue = JSONParser.parse(strcomplete);
73
						JSONArray jsonArray;
74
 
75
						if ((jsonArray = jsonValue.isArray()) != null) {
76
							// Url Image
77
							setImage(((JSONString) jsonArray.get(0)).stringValue());
78
						}
79
					}
80
 
81
				});
82
		}
83
 
84
}