Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 28 | Details | Compare with Previous | 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;
26 ddelon 27
import com.google.gwt.user.client.ui.VerticalPanel;
25 ddelon 28
 
29
/**
30
 * Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget()
31
 */
32
 
33
public class InfoPopup extends PopupPanel   {
34
 
35
  private Mediator mediator=null;
26 ddelon 36
  private Image imageTop = new Image();
37
  private Image imageBottom = new Image();
25 ddelon 38
 
39
  public InfoPopup(final Mediator med) {
40
 
41
   super(true);
42
 
43
   mediator=med;
44
 
26 ddelon 45
   imageBottom.setPixelSize(150,150);
46
   imageTop.setPixelSize(150,150);
25 ddelon 47
 
26 ddelon 48
 //  HorizontalPanel panel = new    HorizontalPanel();
49
   VerticalPanel panel = new    VerticalPanel();
25 ddelon 50
 
26 ddelon 51
   panel.add(imageTop);
52
   panel.add(imageBottom);
25 ddelon 53
 
26 ddelon 54
   add(panel);
25 ddelon 55
 
56
  }
57
 
58
 
59
  public void setImageUrl(String value) {
60
 
61
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/NameImage/" + value,
62
				new ResponseTextHandler() {
63
 
64
					public void onCompletion(String strcomplete) {
65
 
66
						JSONValue jsonValue = JSONParser.parse(strcomplete);
67
						JSONArray jsonArray;
68
 
69
						if ((jsonArray = jsonValue.isArray()) != null) {
70
							// Url Image
26 ddelon 71
							setImageTop(((JSONString) jsonArray.get(0)).stringValue());
25 ddelon 72
						}
73
					}
74
 
75
				});
26 ddelon 76
 
77
 
78
		HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/NameMap/" + value,
79
				new ResponseTextHandler() {
80
 
81
					public void onCompletion(String strcomplete) {
82
 
83
						JSONValue jsonValue = JSONParser.parse(strcomplete);
84
						JSONArray jsonArray;
85
 
86
						if ((jsonArray = jsonValue.isArray()) != null) {
87
							// Url Image
88
							setImageBottom(((JSONString) jsonArray.get(0)).stringValue());
89
						}
90
					}
91
 
92
				});
93
  }
94
 
95
 
96
  public void setImageTop(String url) {
97
		if (url.compareTo("null")!=0) {
98
 
29 ddelon 99
		  setPopupPosition(mediator.getWestContainer().getAbsoluteLeft()+10, mediator.getWestContainer().getAbsoluteTop()  + (mediator.getWestContainer().getOffsetHeight()/3) +20);
26 ddelon 100
		  show();
101
		  imageTop.setUrl(url);
25 ddelon 102
		}
26 ddelon 103
		else  {
104
		  hide();
105
		}
25 ddelon 106
 
26 ddelon 107
	}
108
 
109
 
110
  public void setImageBottom(String url) {
111
		if (url.compareTo("null")!=0) {
29 ddelon 112
		  setPopupPosition(mediator.getWestContainer().getAbsoluteLeft()+10, mediator.getWestContainer().getAbsoluteTop()  + (mediator.getWestContainer().getOffsetHeight()/3) +20);
26 ddelon 113
		  show();
114
		  imageBottom.setUrl(url);
115
		}
116
		else  {
117
		  hide();
118
		}
119
 
120
	}
121
 
122
 
25 ddelon 123
}