Subversion Repositories eFlore/Archives.cel-v1

Compare Revisions

Ignore whitespace Rev 24 → Rev 25

/trunk/src/org/tela_botanica/client/InfoPopup.java
New file
0,0 → 1,84
/*
* Copyright 2006 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.tela_botanica.client;
 
 
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.HTTPRequest;
import com.google.gwt.user.client.ResponseTextHandler;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.PopupPanel;
 
/**
* Composite permet de wrapper des Widget pour creer un nouveau Widget cf methode initWidget()
*/
 
public class InfoPopup extends PopupPanel {
private Mediator mediator=null;
private Image image = new Image();
public InfoPopup(final Mediator med) {
 
super(true);
mediator=med;
mediator.registerInfoPopup(this);
add(image);
 
}
 
public void setImage(String url) {
if (url.compareTo("null")!=0) {
setPopupPosition(mediator.getLeftPanel().getAbsoluteLeft()+10, mediator.getLeftPanel().getAbsoluteTop() + (mediator.getLeftPanel().getOffsetHeight()/2));
show();
image.setUrl(url);
}
else {
hide();
}
 
}
 
public void setImageUrl(String value) {
HTTPRequest.asyncGet(mediator.getServiceBaseUrl() + "/NameImage/" + value,
new ResponseTextHandler() {
 
public void onCompletion(String strcomplete) {
 
JSONValue jsonValue = JSONParser.parse(strcomplete);
JSONArray jsonArray;
 
if ((jsonArray = jsonValue.isArray()) != null) {
// Url Image
setImage(((JSONString) jsonArray.get(0)).stringValue());
}
}
 
});
}
 
}