Subversion Repositories eFlore/Archives.cel-v1

Rev

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

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