Subversion Repositories eFlore/Archives.cel-v1

Rev

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