diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index dcfb6eb..7397c4c 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -3,6 +3,12 @@
+
+ uses
+
+
+ uses
+
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 f4d426c..18db272 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
@@ -7,7 +7,6 @@ import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
@@ -16,21 +15,14 @@ import com.google.gwt.user.client.ui.VerticalPanel;
* Entry point classes define onModuleLoad()
.
*/
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(AboutView.getLoadingHTML());
// Associate the new panel with the HTML host page.
RootPanel.get("LoggedinDiv").add(main_panel);
diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java
index dbdf8d0..728e0d2 100644
--- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java
+++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinService.java
@@ -11,4 +11,6 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("LoggedinServiceImpl")
public interface LoggedinService extends RemoteService {
VObject getSelectedRE(String portalURL);
+
+ String saveVREDescription(String toSave);
}
diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java
index 2992d6f..30335ad 100644
--- a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java
+++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/LoggedinServiceAsync.java
@@ -9,4 +9,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
*/
public interface LoggedinServiceAsync {
void getSelectedRE(String portalURL, AsyncCallback callback);
+
+ void saveVREDescription(String toSave, AsyncCallback callback);
}
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
index 4950aa0..20af5c2 100644
--- 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
@@ -31,13 +31,15 @@ public class AboutView extends Composite {
public AboutView() {
initWidget(uiBinder.createAndBindUi(this));
}
-
+
private String vreDescription;
@UiField Image vreImage;
@UiField Heading vreName;
@UiField HTML description;
@UiField Button seeMore;
+ @UiField Button editButton;
@UiField Hero mainPanel;
+ private EditDescriptionModal mod;
public AboutView(VObject vobj, LoggedinServiceAsync loggedinService) {
initWidget(uiBinder.createAndBindUi(this));
@@ -52,7 +54,11 @@ public class AboutView extends Composite {
description.addStyleName("vre-description");
seeMore.setVisible(true);
seeMore.setText(SEE_MORE);
+ if (vobj.isManager()) {
+ editButton.setVisible(true);
+ }
}
+ mod = new EditDescriptionModal(vobj.getName(), vobj.getDescription());
}
boolean open = false;
@UiHandler("seeMore")
@@ -69,6 +75,13 @@ public class AboutView extends Composite {
}
}
+ @UiHandler("editButton")
+ void onEditButton(ClickEvent e) {
+ mod.show();
+ }
+
+
+
/**
*
* @return
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
index 5172a33..7873ce0 100644
--- 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
@@ -12,7 +12,7 @@
See more
- Unregister from this group
+ Edit VRE Description (VRE-Managers only)
diff --git a/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/EditDescriptionModal.java b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/EditDescriptionModal.java
new file mode 100644
index 0000000..e884b4a
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/gcubeloggedin/client/ui/EditDescriptionModal.java
@@ -0,0 +1,108 @@
+package org.gcube.portlets.user.gcubeloggedin.client.ui;
+
+import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
+import org.gcube.portlets.user.gcubeloggedin.client.LoggedinServiceAsync;
+import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
+
+import com.github.gwtbootstrap.client.ui.Button;
+import com.github.gwtbootstrap.client.ui.Icon;
+import com.github.gwtbootstrap.client.ui.Modal;
+import com.github.gwtbootstrap.client.ui.Paragraph;
+import com.github.gwtbootstrap.client.ui.TextArea;
+import com.github.gwtbootstrap.client.ui.constants.IconType;
+import com.google.gwt.core.client.GWT;
+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.Location;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Widget;
+
+public class EditDescriptionModal extends Composite {
+ private final LoggedinServiceAsync loggedinService = GWT.create(LoggedinService.class);
+ private static EditDescriptionModalUiBinder uiBinder = GWT
+ .create(EditDescriptionModalUiBinder.class);
+
+ interface EditDescriptionModalUiBinder extends
+ UiBinder {
+ }
+
+ private String currDescription;
+
+ @UiField Modal modal;
+ @UiField TextArea text2Edit;
+ @UiField Button cancel;
+ @UiField Button save;
+ @UiField Icon loading;
+ @UiField Paragraph loadingContainer;
+ @UiField Paragraph loadingText;
+
+
+ public EditDescriptionModal(String vreName, String currDescription) {
+ initWidget(uiBinder.createAndBindUi(this));
+ modal.setTitle(vreName + " description/abstract");
+ text2Edit.setBlockLevel(true);
+ text2Edit.setVisibleLines(10);
+ this.currDescription = currDescription;
+ }
+
+ public void show() {
+ text2Edit.setText(transformDescription(currDescription));
+ text2Edit.setVisible(true);
+ loadingContainer.setVisible(false);
+ save.setVisible(true);
+ modal.show();
+ }
+
+ @UiHandler("cancel")
+ void onCancelButton(ClickEvent e) {
+ modal.hide();
+ }
+
+
+ @UiHandler("save")
+ void onSaveButton(ClickEvent e) {
+ final String vreDescription = text2Edit.getText();
+ text2Edit.setText("");
+ text2Edit.setVisible(false);
+ loadingContainer.setVisible(true);
+ ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback() {
+ @Override
+ public void onSuccess(Boolean result) {
+ doSave(vreDescription);
+ }
+ @Override
+ public void onFailure(Throwable caught) {
+ loadingText.setText("Ops, some problems occurred, please try again in a while or report the problem.");
+ }
+ });
+ }
+
+ private void doSave(String toSave) {
+ loggedinService.saveVREDescription(toSave, new AsyncCallback() {
+ @Override
+ public void onFailure(Throwable caught) {
+ loadingText.setText("Ops, some problems occurred, please try again in a while or report the problem.");
+ }
+
+ @Override
+ public void onSuccess(String result) {
+ loading.setIcon(IconType.CHECK_SIGN);
+ loading.setSpin(false);
+ loadingText.setText("Saving successful, please refresh the page to see your changes.");
+ save.setVisible(false);
+ }
+ });
+
+ }
+
+ private String transformDescription(String VREDescription) {
+ String toReturn = VREDescription;
+ // replace all the line breaks by
+ toReturn = toReturn.replaceAll("