Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 25 | Rev 27 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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