You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
4.9 KiB
Java
159 lines
4.9 KiB
Java
package org.gcube.portlets.user.gcubeloggedin.client;
|
|
|
|
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
|
|
|
import com.google.gwt.core.client.EntryPoint;
|
|
import com.google.gwt.core.client.GWT;
|
|
import com.google.gwt.dom.client.Style.Unit;
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
import com.google.gwt.user.client.Window;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
|
import com.google.gwt.user.client.ui.Button;
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
import com.google.gwt.user.client.ui.Image;
|
|
import com.google.gwt.user.client.ui.RootPanel;
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
|
|
/**
|
|
* Entry point classes define <code>onModuleLoad()</code>.
|
|
*/
|
|
public class GCubeLoggedin implements EntryPoint {
|
|
|
|
|
|
/**
|
|
* Create a remote service proxy to talk to the server-side Greeting service.
|
|
*/
|
|
private final LoggedinServiceAsync loggedinService = GWT.create(LoggedinService.class);
|
|
private ServiceDefTarget endpoint = (ServiceDefTarget) loggedinService;
|
|
private VerticalPanel main_panel = new VerticalPanel();
|
|
/**
|
|
* This is the entry point method.
|
|
*/
|
|
public void onModuleLoad() {
|
|
main_panel.setWidth("100%");
|
|
|
|
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL()+"LoggedinServiceImpl");
|
|
main_panel.add(new HTML("<div style=\"height: 450px; text-align:center; vertical-align:text-top;\"><p><br /><br />Loading Environment please wait ...</p><p><br /><br /> " + getLoadingHTML() + "</p></div>" ));
|
|
|
|
// Associate the new panel with the HTML host page.
|
|
RootPanel.get("LoggedinDiv").add(main_panel);
|
|
|
|
loggedinService.getSelectedRE(new AsyncCallback<VObject>() {
|
|
|
|
public void onFailure(Throwable caught) {
|
|
}
|
|
|
|
public void onSuccess(VObject result) {
|
|
main_panel.clear();
|
|
main_panel.add(getShowLoadedEnvPanel(result));
|
|
}
|
|
|
|
});
|
|
|
|
//TEST
|
|
//main_panel.add(getShowLoadedEnvPanel(new VObject("ciccio", "ciccio", "dddd", "", "", null)));
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param vobj
|
|
* @return
|
|
*/
|
|
private VerticalPanel getShowLoadedEnvPanel(VObject vobj) {
|
|
|
|
VerticalPanel toReturn = new VerticalPanel();
|
|
HorizontalPanel header = new HorizontalPanel();
|
|
|
|
HTML scope;
|
|
if (vobj == null)
|
|
scope = new HTML("<strong>Layout Loaded, could not read Enviroment Description</strong>", true);
|
|
else
|
|
scope = new HTML("<strong>" + vobj.getGroupName() + "</strong>", true);
|
|
header.add(scope);
|
|
|
|
/**
|
|
* listener to go back and select another VRE/VO
|
|
*/
|
|
ClickHandler listener = new ClickHandler() {
|
|
public void onClick(ClickEvent event) {
|
|
main_panel.clear();
|
|
main_panel.add(new HTML("<div style=\"height: 450px; text-align:center; vertical-align:text-top;\"><p><br /><br />Loading Environment please wait ...</p><p><br /><br /> " + getLoadingHTML() + "</p></div>" ));
|
|
|
|
loggedinService.getDefaultCommunityURL(new AsyncCallback<String>() {
|
|
public void onFailure(Throwable arg0) {
|
|
Window.alert("We're sorry we couldn't reach the server, try again later ... " + arg0.getMessage());
|
|
}
|
|
public void onSuccess(String url) {
|
|
Window.open(url, "_self", "");
|
|
}
|
|
});
|
|
|
|
}
|
|
};
|
|
HorizontalPanel topper = new HorizontalPanel();
|
|
topper.getElement().getStyle().setMarginTop(20, Unit.PX);
|
|
topper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
|
|
topper.setWidth("100%");
|
|
Button selectAnotherTop = new Button("Change Environment");
|
|
selectAnotherTop.setWidth("150px");
|
|
selectAnotherTop.addClickHandler(listener);
|
|
|
|
topper.add(selectAnotherTop);
|
|
|
|
HorizontalPanel body = new HorizontalPanel();
|
|
|
|
VerticalPanel leftPanel = new VerticalPanel();
|
|
VerticalPanel rightPanel = new VerticalPanel();
|
|
|
|
if (vobj != null) {
|
|
leftPanel.add(new Image(vobj.getImageURL()));
|
|
rightPanel.setWidth("100%");
|
|
leftPanel.add(topper);
|
|
HTML desc = new HTML(vobj.getDescription());
|
|
desc.setStyleName("description");
|
|
rightPanel.add(desc);
|
|
rightPanel.setWidth("100%");
|
|
}
|
|
leftPanel.getElement().getStyle().setMarginRight(10, Unit.PX);
|
|
leftPanel.setStyleName("framed");
|
|
rightPanel.getElement().getStyle().setPaddingLeft(10, Unit.PX);
|
|
rightPanel.setStyleName("framed");
|
|
|
|
|
|
HorizontalPanel bottom = new HorizontalPanel();
|
|
bottom.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
|
|
bottom.setWidth("100%");
|
|
Button selectAnother = new Button("Change Environment");
|
|
selectAnother.addClickHandler(listener);
|
|
//bottom.add(selectAnother);
|
|
rightPanel.add(new HTML("<br />"));
|
|
rightPanel.add(bottom);
|
|
|
|
body.add(leftPanel);
|
|
body.add(rightPanel);
|
|
|
|
toReturn.add(body);
|
|
return toReturn;
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
*
|
|
* @return
|
|
*/
|
|
private String getLoadingHTML() {
|
|
return
|
|
"<center><table border='0'>"+
|
|
"<tr>"+
|
|
"<td>"+
|
|
"<img src='" + UIConstants.LOADING_IMAGE + "'>"+
|
|
"</td></tr>"+
|
|
"</table></center>" ;
|
|
}
|
|
}
|