git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@113442 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
98f4fac6ba
commit
584979bc23
|
@ -17,4 +17,6 @@ public interface JoinService extends RemoteService {
|
|||
|
||||
ArrayList<VRE> getVREs();
|
||||
|
||||
Boolean joinVRE(Long vreID);
|
||||
|
||||
}
|
||||
|
|
|
@ -13,4 +13,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||
public interface JoinServiceAsync {
|
||||
|
||||
void getVREs(AsyncCallback<ArrayList<VRE>> callback);
|
||||
|
||||
void joinVRE(Long vreID, AsyncCallback<Boolean> callback);
|
||||
}
|
||||
|
|
|
@ -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<String> categories = vre.getCategories();
|
||||
for(int i=0; i<categories.size(); i++){
|
||||
|
@ -79,6 +91,33 @@ public class DisplayVRE extends Composite {
|
|||
joinButton.setStyleName("freeAccessButton", true);
|
||||
}
|
||||
joinButton.setStyleName("joinButton", true);
|
||||
joinButton.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
loadingPopUp.show();
|
||||
joinService.joinVRE(vre.getId(), new AsyncCallback<Boolean>() {
|
||||
|
||||
@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);
|
||||
|
|
|
@ -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("<hr align=\"left\" size=\"1\" width=\"100%\" color=\"gray\" noshade>"));
|
||||
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;
|
||||
}-*/;
|
||||
}
|
|
@ -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
|
||||
"<center><table border='0'>"+
|
||||
"<tr>"+
|
||||
"<td>"+
|
||||
"<img src='" + this.loading_image + "'>"+
|
||||
"</td></tr>"+
|
||||
"</table></center>" ;
|
||||
}
|
||||
public void hide() {
|
||||
super.hide();
|
||||
this.hidden = true;
|
||||
}
|
||||
public void show() {
|
||||
super.show();
|
||||
this.hidden = false;
|
||||
}
|
||||
public boolean isHidden() {
|
||||
return this.hidden;
|
||||
}
|
||||
}
|
||||
|
|
@ -83,17 +83,20 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
|||
try {
|
||||
if (isWithinPortal()) {
|
||||
|
||||
|
||||
} else {
|
||||
List<String> devsecCategories = new ArrayList<String>();
|
||||
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<String> devVRECategories = new ArrayList<String>(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<String> devmodeategories = new ArrayList<String>(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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable
|
|||
this.categories = categories;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VRE [getName()=" + getName()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue