diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java index 3d22550..1edf58b 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java @@ -17,4 +17,6 @@ public interface JoinService extends RemoteService { ArrayList getVREs(); + Boolean joinVRE(Long vreID); + } diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java index 44ec2b9..98df01b 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java @@ -13,4 +13,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback; public interface JoinServiceAsync { void getVREs(AsyncCallback> callback); + + void joinVRE(Long vreID, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/DisplayVRE.java b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/DisplayVRE.java index c79b003..7e2a14e 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/DisplayVRE.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/DisplayVRE.java @@ -2,6 +2,8 @@ package org.gcube.portlets.user.joinvre.client.ui; import java.util.List; +import org.gcube.portlets.user.joinvre.client.JoinService; +import org.gcube.portlets.user.joinvre.client.JoinServiceAsync; import org.gcube.portlets.user.joinvre.shared.VRE; import com.google.gwt.core.client.GWT; @@ -10,6 +12,7 @@ import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTMLPanel; @@ -27,9 +30,13 @@ public class DisplayVRE extends Composite { private static DisplayVREUiBinder uiBinder = GWT.create(DisplayVREUiBinder.class); + private final JoinServiceAsync joinService = GWT.create(JoinService.class); + public static final String vreDefaultImage = GWT.getModuleBaseURL() + "../images/vre-default.png"; public static final String loadingImage = GWT.getModuleBaseURL() + "../images/vre-image-loader.gif"; + public static LoadingPopUp loadingPopUp = new LoadingPopUp(false, true, loadingImage); + public static final String REQUEST_ACCESS = "Request Access"; public static final String FREE_ACCESS = "Free Access"; @@ -40,7 +47,7 @@ public class DisplayVRE extends Composite { @UiField HTMLPanel vreCategories; @UiField Button joinButton; - public DisplayVRE(VRE vre) { + public DisplayVRE(final VRE vre) { Widget widget = uiBinder.createAndBindUi(this); vreImage.setUrl(loadingImage); @@ -51,18 +58,23 @@ public class DisplayVRE extends Composite { vreImage.setUrl(vreDefaultImage); } - vreImage.setTitle(vre.getName()); - vreImage.addClickHandler(new ClickHandler() { - + final String name = vre.getName(); + String vreDescription = vre.getDescription(); + final InfoDialog infoDialog = new InfoDialog(name, vreDescription); + + ClickHandler descriptionHandler = new ClickHandler(){ @Override public void onClick(ClickEvent event) { - // TODO Show Description + infoDialog.show(); } - }); + }; + vreImage.setTitle(vre.getName()); + vreImage.addClickHandler(descriptionHandler); - vreName.setTitle(vre.getName()); - vreName.setText(vre.getName()); + vreName.setTitle(name); + vreName.setText(name); + vreName.addClickHandler(descriptionHandler); List categories = vre.getCategories(); for(int i=0; i() { + + @Override + public void onFailure(Throwable caught) { + loadingPopUp.hide(); + String error = "Error"; + String errorDescription = "Error while trying to join to" + + name + " VRE. Please Try again later. " + + "If the problem persist contact system administrator"; + final InfoDialog infoDialog = new InfoDialog(error, errorDescription); + infoDialog.show(); + } + + @Override + public void onSuccess(Boolean result) { + loadingPopUp.hide(); + Window.open(vre.getFriendlyURL()+"?orgid="+vre.getId(), "_self", ""); + } + + }); + } + }); initWidget(widget); diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/InfoDialog.java b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/InfoDialog.java new file mode 100755 index 0000000..57e2946 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/InfoDialog.java @@ -0,0 +1,67 @@ +package org.gcube.portlets.user.joinvre.client.ui; + +import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog; + +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.ScrollPanel; +import com.google.gwt.user.client.ui.VerticalPanel; + + +/** + * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it + * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ + */ +public class InfoDialog extends GCubeDialog { + private ScrollPanel scroller = new ScrollPanel(); + private VerticalPanel main_panel = null; + + public InfoDialog(String title, String content) { + + // PopupPanel's constructor takes 'auto-hide' as its boolean parameter. + // If this is set, the panel closes itself automatically when the user + // clicks outside of it. + super(true); + super.setText(title); + main_panel = new VerticalPanel(); + main_panel.addStyleName("bgBlank p8 font_family font_12"); + + if (content == null || content.equals("")) + content = "We're sorry, there is no available description yet"; + + scroller.add(new HTML(content)); + + // PopupPanel is a SimplePanel, so you have to set it's widget property to + // whatever you want its contents to be. + Button close = new Button("Close"); + close.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + hide(); + } + }); + main_panel.add(scroller); + main_panel.add(new HTML("
")); + main_panel.add(close); + scroller.setPixelSize(550, 300); + main_panel.setPixelSize(550, 350); + setWidget(main_panel); + } + + public void show() { + super.show(); + center(); +// int left = (Window.getClientWidth() - getOffsetWidth()) / 2 + getBodyScrollLeft(); +// int top = (Window.getClientHeight() - getOffsetHeight()) / 2 + getBodyScrollTop(); +// setPopupPosition(left, top); + } + + private native int getBodyScrollLeft() /*-{ + return $doc.body.scrollLeft; + }-*/; + + private native int getBodyScrollTop() /*-{ + return $doc.body.scrollTop; + }-*/; +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/LoadingPopUp.java b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/LoadingPopUp.java new file mode 100755 index 0000000..77875cf --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/LoadingPopUp.java @@ -0,0 +1,53 @@ +package org.gcube.portlets.user.joinvre.client.ui; + +import com.google.gwt.user.client.ui.DialogBox; +import com.google.gwt.user.client.ui.DockPanel; +import com.google.gwt.user.client.ui.HTML; + +/** + * + */ +public class LoadingPopUp extends DialogBox { + + private static LoadingPopUp singleton = null; + private boolean hidden = true; + private String loading_image = ""; + + public static LoadingPopUp get() { + return singleton; + } + + public LoadingPopUp(boolean autoHide, boolean modal, String loading_image) { + super(autoHide, modal); + this.loading_image = loading_image; + HTML msg = new HTML(setToDisplay(), true); + DockPanel dock = new DockPanel(); + dock.setSpacing(0); + dock.add(msg, DockPanel.NORTH); + dock.setPixelSize(msg.getOffsetWidth(), msg.getOffsetHeight()); + setWidget(dock); + if (singleton == null) singleton = this; + } + + protected String setToDisplay() { + return + "
"+ + ""+ + ""+ + "
"+ + ""+ + "
" ; + } + public void hide() { + super.hide(); + this.hidden = true; + } + public void show() { + super.show(); + this.hidden = false; + } + public boolean isHidden() { + return this.hidden; + } +} + diff --git a/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java b/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java index 6fc2fec..118f148 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java @@ -83,17 +83,20 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService try { if (isWithinPortal()) { - } else { List devsecCategories = new ArrayList(); devsecCategories.add("Development"); - vres.add(new VRE(0, "devsec", "devsec VRE", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false)); + vres.add(new VRE(0, "devsec", "devsec VRE description", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false)); List devVRECategories = new ArrayList(devsecCategories); devVRECategories.add("Sailing"); - vres.add(new VRE(1, "devVRE", "devVRE VRE", "", "", "/group/devVRE", devVRECategories, UserBelonging.NOT_BELONGING, false)); + vres.add(new VRE(1, "devVRE", "devVRE VRE description", "", "", "/group/devVRE", devVRECategories, UserBelonging.NOT_BELONGING, false)); List devmodeategories = new ArrayList(devsecCategories); devmodeategories.add("Climbing"); - vres.add(new VRE(2, "devmode", "devmode VRE", "", "", "/group/devmode", devmodeategories, UserBelonging.NOT_BELONGING, true)); + vres.add(new VRE(2, "devmode", "devmode VRE description", "", "", "/group/devmode", devmodeategories, UserBelonging.NOT_BELONGING, true)); + vres.add(new VRE(3, "devsec", "devsec VRE description", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false)); + vres.add(new VRE(4, "devsec", "devsec VRE description", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false)); + vres.add(new VRE(5, "devsec", "devsec VRE description", "", "", "/group/devsec", devsecCategories, UserBelonging.NOT_BELONGING, false)); + } } catch (Exception e) { _log.error("Error in server get all contacts ", e); @@ -159,4 +162,10 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService _log.debug("Returning Root VO Name: " + toReturn ); return toReturn; } + + @Override + public Boolean joinVRE(Long vreID) { + // Here for future improvement + return new Boolean(true); + } } diff --git a/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java b/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java index 22fc79a..98725df 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java @@ -68,7 +68,6 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable this.categories = categories; } - @Override public String toString() { return "VRE [getName()=" + getName() diff --git a/src/main/webapp/JoinVRE.css b/src/main/webapp/JoinVRE.css index 575cd26..31e29d1 100644 --- a/src/main/webapp/JoinVRE.css +++ b/src/main/webapp/JoinVRE.css @@ -1,18 +1,8 @@ .framed { - width: 200px; - height: 290px; + width: 146px; + height: 240px; padding: 10px; - margin: 10px; - background: #FFF; - border-radius: 6px !important; - -moz-border-radius: 6px !important; - -webkit-border-radius: 6px !important; - border: 1px solid #9b9b9b; -} - -.frame { - padding: 10px; - margin: 10px; + margin: 5px 5px 0 0; background: #FFF; border-radius: 6px !important; -moz-border-radius: 6px !important; @@ -21,19 +11,24 @@ } .vreImageDetails { - width: 200px; + width: 150px; } .vreImage { - border: 1px solid #9b9b9b; border-radius: 6px !important; -moz-border-radius: 6px !important; -webkit-border-radius: 6px !important; - width: 198px; - height: 198px; + width: 146px; + height: 146px; cursor:pointer; } +.vreImage:hover, .vreName:hover { + opacity: 0.6; + filter: alpha(opacity=60); +} + + .vreDetails { padding: 5px; }