package org.gcube.portlet.user.my_vres.client.widgets; import org.gcube.common.portal.GCubePortalConstants; import org.gcube.portlet.user.my_vres.client.MyVREsServiceAsync; import org.gcube.portlet.user.my_vres.shared.VRE; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Image; /** * * @author Massimiliano Assante - ISTI CNR * */ public class ClickableVRE extends HTML { private final static int WIDTH = 90; private final static int HEIGHT = 100; private String name; private String imageUrl; private int imageWidth = 0; public static final String LOADING_IMAGE = GWT.getModuleBaseURL() + "../images/loading.gif"; public static final String MORE_IMAGE = GWT.getModuleBaseURL() + "../images/More.png"; Image img = new Image(LOADING_IMAGE); public ClickableVRE() { super(); } public ClickableVRE(final MyVREsServiceAsync service) { super.setPixelSize(WIDTH, HEIGHT); setPixelSize(WIDTH, HEIGHT); imageWidth = WIDTH - 25; String html = ""; html = "
"; setHTML(html); setStyleName("vreButton"); addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String html = "
" + "redirecting ..." + "
"; setHTML(html); service.showMoreVREs(new AsyncCallback() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(String result) { Location.assign(result+GCubePortalConstants.VRES_EXPLORE_FRIENDLY_URL); } }); } }); } public ClickableVRE(final VRE vre, final MyVREsServiceAsync service) { super.setPixelSize(WIDTH, HEIGHT); setPixelSize(WIDTH, HEIGHT); imageWidth = WIDTH - 12; name = (vre.getName().length() > 15) ? vre.getName().substring(0, 13) + ".." : vre.getName(); imageUrl = vre.getImageURL(); this.setTitle("Enter"); String html = "
" + name + "
"; html += "
" + "" + "
"; setHTML(html); setStyleName("vreButton"); addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String html = "
" + "redirecting ..." + "
"; setHTML(html); Timer timer = new Timer() { @Override public void run() { Location.assign(vre.getFriendlyURL()); } }; timer.schedule(50); } }); } }