Subversion Repositories eFlore/Archives.cel-v1

Rev

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

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