diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java index e1fc831..a24a5d5 100644 --- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/GCubeLoggedin.java @@ -1,20 +1,13 @@ package org.gcube.portlets.user.gcubeloggedin.client; +import org.gcube.portlets.user.gcubeloggedin.client.ui.AboutView; 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; @@ -43,105 +36,14 @@ public class GCubeLoggedin implements EntryPoint { RootPanel.get("LoggedinDiv").add(main_panel); loggedinService.getSelectedRE(new AsyncCallback() { - - public void onFailure(Throwable caught) { - } + 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("Layout Loaded, could not read Enviroment Description", true); - else - scope = new HTML("" + vobj.getGroupName() + "", 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("



Loading Environment please wait ...



" + getLoadingHTML() + "

" )); - - loggedinService.getDefaultCommunityURL(new AsyncCallback() { - 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", ""); - } - }); - + main_panel.add(new AboutView(result, loggedinService)); } - }; - 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("
")); - rightPanel.add(bottom); - - body.add(leftPanel); - body.add(rightPanel); - - toReturn.add(body); - return toReturn; - + }); } - - /** * * @return diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java new file mode 100644 index 0000000..a575fd6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.java @@ -0,0 +1,60 @@ +package org.gcube.portlets.user.gcubeloggedin.client.ui; + +import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync; +import org.gcube.portlets.user.gcubeloggedin.shared.VObject; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Document; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.uibinder.client.UiHandler; +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.HTML; +import com.google.gwt.user.client.ui.HTMLPanel; +import com.google.gwt.user.client.ui.Widget; + +public class AboutView extends Composite { + + private static AboutViewUiBinder uiBinder = GWT + .create(AboutViewUiBinder.class); + + interface AboutViewUiBinder extends UiBinder { + } + + public AboutView() { + initWidget(uiBinder.createAndBindUi(this)); + } + + @UiField + Button button; + @UiField + HTMLPanel htmlPanel; + @UiField + HTML description; + + private LoggedinServiceAsync loggedinService; + + public AboutView(VObject vobj, LoggedinServiceAsync loggedinService) { + initWidget(uiBinder.createAndBindUi(this)); + this.loggedinService = loggedinService; + description.setHTML("" + vobj.getDescription()); + } + + @UiHandler("button") + void onClick(ClickEvent e) { + loggedinService.getDefaultCommunityURL(new AsyncCallback() { + 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", ""); + } + }); + } + + +} diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml new file mode 100644 index 0000000..8ade0bd --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/AboutView.ui.xml @@ -0,0 +1,8 @@ + + + + + Change Environment + + \ No newline at end of file diff --git a/src/main/webapp/GCubeLoggedin.css b/src/main/webapp/GCubeLoggedin.css index bb68e22..768a5fd 100644 --- a/src/main/webapp/GCubeLoggedin.css +++ b/src/main/webapp/GCubeLoggedin.css @@ -22,6 +22,11 @@ table { border: 1px solid #DBDBDB; } +.imageVRE { + float: left; + width: 180px; +} + /** Example rules used by the template application (remove for your app) */ h1 { font-size: 2em;