added feature for editing VRE Text

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-loggedin@128598 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Massimiliano Assante 8 years ago
parent 75782b29d0
commit abba2f43e5

@ -3,6 +3,12 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<dependent-module archiveName="gcube-widgets-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="session-checker-1.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/session-checker/session-checker">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="gcube-loggedin"/>
</wb-module>

@ -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 <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(AboutView.getLoadingHTML());
// Associate the new panel with the HTML host page.
RootPanel.get("LoggedinDiv").add(main_panel);

@ -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);
}

@ -9,4 +9,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
*/
public interface LoggedinServiceAsync {
void getSelectedRE(String portalURL, AsyncCallback<VObject> callback);
void saveVREDescription(String toSave, AsyncCallback<String> callback);
}

@ -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

@ -12,7 +12,7 @@
<b:ControlGroup>
<b:Paragraph>
<b:Button type="LINK" visible="false" ui:field="seeMore">See more</b:Button>
<b:Button type="LINK" visible="false" ui:field="leaveButton">Unregister from this group</b:Button>
<b:Button type="LINK" visible="false" ui:field="editButton">Edit VRE Description (VRE-Managers only)</b:Button>
</b:Paragraph>
</b:ControlGroup>
</b:Caption>

@ -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<Widget, EditDescriptionModal> {
}
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<Boolean>() {
@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<String>() {
@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 <br/>
toReturn = toReturn.replaceAll("<script","");
toReturn = toReturn.replaceAll("</script","");
return VREDescription;
}
}

@ -0,0 +1,18 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<g:HTMLPanel>
<b:Modal ui:field="modal" backdrop="STATIC"
keyboard="true" animation="true">
<b:TextArea ui:field="text2Edit">Modal Content!</b:TextArea>
<b:Paragraph ui:field="loadingContainer" styleName="loading-text" visible="false">
<b:Paragraph ui:field="loadingText">Saving VRE Description please wait ... </b:Paragraph>
<b:Icon type="COG" size="FOUR_TIMES" spin="true" ui:field="loading"/>
</b:Paragraph>
<b:ModalFooter>
<b:Button type="DEFAULT" ui:field="cancel">Close</b:Button>
<b:Button icon="FILE" type="PRIMARY" ui:field="save">Save</b:Button>
</b:ModalFooter>
</b:Modal>
</g:HTMLPanel>
</ui:UiBinder>

@ -14,6 +14,8 @@ import org.gcube.portlets.user.gcubeloggedin.shared.VObject.UserBelongingClient;
import org.gcube.portlets.user.gcubeloggedin.shared.VREClient;
import org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
@ -49,7 +51,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
return SessionManager.getInstance().getASLSession(sessionID, user);
}
/**
* return the current selected VRE
*/
@ -69,7 +71,7 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
+ " <li> approximately <b><i>25 collections</i></b>, i.e. set of D4Science Information Objects including Earth images, AquaMaps, Graphs on catch statistics;</li> "
+ " <li> approximately <b><i>66 metadata collections</i></b>, i.e. set of Metadata Objects describing the Information Objects through various features and schemas;</li> "
+ " <li> approximately <b><i>58 other resources</i></b> including transformation programs, index types, etc.</li></ul></div>"
, "http://placehold.it/300x200", "", UserBelongingClient.BELONGING, false, true);
, "http://placehold.it/300x200", "", UserBelongingClient.BELONGING, false, true, true);
}
_log.trace("getting Selected Research Environment");
GroupManager gm = new LiferayGroupManager();
@ -105,21 +107,12 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
//set the description for the vre
if (currSite.getDescription() != null)
desc = currSite.getDescription();
System.out.println(" **** debuggaaa");
Boolean isRequestBasedGroup = false;
Boolean isMandatory = false;
try {
isMandatory = (Boolean) gm.readCustomAttr(currSite.getGroupId(), org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys.MANDATORY.getKeyName());
isRequestBasedGroup = currSite.isRequestBasedGroup();
} catch (Exception e) {
isMandatory = false;
isRequestBasedGroup = false;
return new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, isMandatory, isRequestBasedGroup);
}
VREClient vre = new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, isMandatory, isRequestBasedGroup);
return vre;
return new VREClient(name, "", desc, logoURL, "", UserBelongingClient.BELONGING, false, false, isCurrUserVREManager());
}
//TODO: implement this through UM
private boolean isCurrUserVREManager() {
return true;
}
protected static ArrayList<String> getAdministratorsEmails(String scope) {
@ -161,4 +154,19 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
}
return adminEmailsList;
}
@Override
public String saveVREDescription(String toSave) {
try {
String scope = getASLSession().getScope();
GroupManager gm = new LiferayGroupManager();
long groupId = gm.getGroupIdFromInfrastructureScope(scope);
return gm.updateGroupDescription(groupId, toSave);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

@ -23,7 +23,7 @@ public class VOClient extends VObject implements Comparable<VOClient>, Serializa
String imageURL,
String friendlyURL,
UserBelongingClient userBelonging) {
super(name, groupName, description, imageURL, friendlyURL, userBelonging, true, true);
super(name, groupName, description, imageURL, friendlyURL, userBelonging, true, true, false);
// TODO Auto-generated constructor stub
}
@ -35,7 +35,7 @@ public class VOClient extends VObject implements Comparable<VOClient>, Serializa
String friendlyURL,
UserBelongingClient userBelonging,
boolean isRoot, List<VREClient> vres) {
super(name, groupName, description, imageURL, friendlyURL, userBelonging, true, true);
super(name, groupName, description, imageURL, friendlyURL, userBelonging, true, true, false);
this.isRoot = isRoot;
this.vres = vres;
}

@ -18,6 +18,7 @@ public class VObject implements Serializable {
private boolean mandatory;
private boolean uponRequest;
private boolean isManager;
private UserBelongingClient userBelonging;
@ -26,7 +27,7 @@ public class VObject implements Serializable {
public VObject(String name, String groupName, String description,
String imageURL, String friendlyURL, UserBelongingClient userBelonging, boolean mandatory,
boolean uponRequest) {
boolean uponRequest, boolean isManager) {
this.name = name;
this.groupName = groupName;
this.description = description;
@ -35,6 +36,7 @@ public class VObject implements Serializable {
this.mandatory = mandatory;
this.uponRequest = uponRequest;
this.userBelonging = userBelonging;
this.isManager = isManager;
}
@ -92,5 +94,22 @@ public class VObject implements Serializable {
public void setUponRequest(boolean uponRequest) {
this.uponRequest = uponRequest;
}
public boolean isManager() {
return isManager;
}
public void setManager(boolean isManager) {
this.isManager = isManager;
}
@Override
public String toString() {
return "VObject [name=" + name + ", groupName=" + groupName
+ ", description=" + description + ", imageURL=" + imageURL
+ ", friendlyURL=" + friendlyURL + ", mandatory=" + mandatory
+ ", uponRequest=" + uponRequest + ", isManager=" + isManager
+ ", userBelonging=" + userBelonging + "]";
}
}

@ -1,22 +1,16 @@
package org.gcube.portlets.user.gcubeloggedin.shared;
/**
*
* @author massi
*
*/
@SuppressWarnings("serial")
public class VREClient extends VObject {
public VREClient() {
super();
// TODO Auto-generated constructor stub
}
public VREClient(String name, String groupName, String description, String imageURL, String friendlyURL,
UserBelongingClient userBelonging, boolean isMandatory, boolean isUponRequest) {
super(name, groupName, description, imageURL, friendlyURL, userBelonging, isMandatory, isUponRequest);
// TODO Auto-generated constructor stub
UserBelongingClient userBelonging, boolean isMandatory, boolean isUponRequest, boolean isManager) {
super(name, groupName, description, imageURL, friendlyURL, userBelonging, isMandatory, isUponRequest, isManager);
}

@ -8,3 +8,9 @@ div.gwt-HTML.vre-description {
font-size: 14px;
line-height: 22px;
}
.loading-text {
width: 100%;
text-align: center;
}

@ -14,6 +14,16 @@
<servlet-name>LoggedinServiceImpl</servlet-name>
<url-pattern>/gcubeloggedin/LoggedinServiceImpl</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>scopeService</servlet-name>
<servlet-class>org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>scopeService</servlet-name>
<url-pattern>/gcubeloggedin/scopeService</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>

Loading…
Cancel
Save