added More VREs category and handler/button

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/my-vres@128760 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-05-21 08:21:06 +00:00
parent 39d32821da
commit 3f36eba430
7 changed files with 65 additions and 3 deletions

View File

@ -16,4 +16,6 @@ public interface MyVREsService extends RemoteService {
LinkedHashMap<String, ArrayList<VRE>> getUserVREs();
void loadLayout(String scope, String URL);
String showMoreVREs();
}

View File

@ -15,4 +15,6 @@ public interface MyVREsServiceAsync {
void getUserVREs(
AsyncCallback<LinkedHashMap<String, ArrayList<VRE>>> callback);
void showMoreVREs(AsyncCallback<String> callback);
}

View File

@ -9,6 +9,7 @@ import org.gcube.portlet.user.my_vres.shared.VRE;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
@ -25,6 +26,7 @@ import com.google.gwt.user.client.ui.VerticalPanel;
*/
public class VresPanel extends Composite {
public static final String loading = GWT.getModuleBaseURL() + "../images/loading.gif";
private static final String ADD_OTHER = "Add More";
private final MyVREsServiceAsync myVREsService = GWT.create(MyVREsService.class);
private FlowPanel flowPanel;
private VerticalPanel mainPanel = new VerticalPanel();
@ -87,6 +89,7 @@ public class VresPanel extends Composite {
ClickableVRE vreButton = new ClickableVRE(vre, myVREsService);
flowPanel.add(vreButton);
}
mainPanel.add(flowPanel);
}
}
@ -94,9 +97,29 @@ public class VresPanel extends Composite {
if (! hasAtLeastOneVRE(cachedVREs)) {
mainPanel.add(new NoVresPanel());
imagesPanel.clear();
} else {
addMoreVREsButton();
}
}
private void addMoreVREsButton() {
SimplePanel catPanel = new SimplePanel();
catPanel.setStyleName("category-panel");
HTML categ = new HTML(ADD_OTHER);
categ.setStyleName("category-name");
catPanel.add(categ);
mainPanel.add(catPanel);
FlowPanel flowPanel = new FlowPanel();
flowPanel.setWidth("100%");
flowPanel.setStyleName("flowPanel");
ClickableVRE vreButton = new ClickableVRE(myVREsService);
flowPanel.add(vreButton);
mainPanel.add(flowPanel);
}
private boolean hasAtLeastOneVRE(LinkedHashMap<String, ArrayList<VRE>> cachedVREs) {
for (String cat : cachedVREs.keySet())

View File

@ -1,5 +1,6 @@
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;
@ -7,7 +8,6 @@ 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;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
@ -16,7 +16,6 @@ import com.google.gwt.user.client.ui.Image;
/**
*
* @author Massimiliano Assante - ISTI CNR
* @version 1.0 Jun 2012
*
*/
public class ClickableVRE extends HTML {
@ -29,11 +28,36 @@ public class ClickableVRE extends HTML {
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 = "<div class=\"more-vre\"></div>";
setHTML(html);
setStyleName("vreButton");
addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
service.showMoreVREs(new AsyncCallback<String>() {
@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);

View File

@ -10,6 +10,7 @@ import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlet.user.my_vres.client.MyVREsService;
import org.gcube.portlet.user.my_vres.shared.UserBelonging;
@ -30,7 +31,6 @@ import com.liferay.portal.service.UserLocalServiceUtil;
/**
* The server side implementation of the RPC service.
* @author Massimiliano Assante - ISTI CNR
* @version 1.0 Jun 2012
*/
@SuppressWarnings("serial")
public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsService {
@ -53,6 +53,10 @@ public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsSer
}
return SessionManager.getInstance().getASLSession(sessionID, user);
}
@Override
public String showMoreVREs() {
return PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest());
}
/**
*
* @return true if you're running into the portal, false if in development
@ -231,4 +235,5 @@ public class MyVREsServiceImpl extends RemoteServiceServlet implements MyVREsSer
return toReturn;
}
}

View File

@ -94,6 +94,12 @@ a.vrelink:hover {
background-repeat: no-repeat;
}
.more-vre {
width: 100%;
height: 100px;
background: url(images/More.png) 50% 50% no-repeat;
}
.item-vre {
background-image: url("images/vres.png");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B