added encoder decoder base 64 util from js

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/social-profile@79383 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-07-18 15:51:11 +00:00
parent 9e33972e5e
commit d87f9df593
16 changed files with 242 additions and 114 deletions

View File

@ -5,8 +5,6 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/> <property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="social-profile"/> <property name="context-root" value="social-profile"/>
</wb-module> </wb-module>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<faceted-project> <faceted-project>
<fixed facet="wst.jsdt.web"/> <fixed facet="wst.jsdt.web"/>
<installed facet="jst.web" version="2.3"/>
<installed facet="wst.jsdt.web" version="1.0"/> <installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.6"/> <installed facet="java" version="1.6"/>
<installed facet="jst.web" version="2.5"/>
</faceted-project> </faceted-project>

18
pom.xml
View File

@ -82,6 +82,18 @@
<version>[3.2.0-SNAPSHOT, 4.0.0-SNAPSHOT)</version> <version>[3.2.0-SNAPSHOT, 4.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>wsmail-widget</artifactId>
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>com.liferay.portal</groupId> <groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId> <artifactId>portal-service</artifactId>
@ -94,12 +106,6 @@
<version>2.0</version> <version>2.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,16 +1,23 @@
package org.gcube.portlets.user.socialprofile.client.ui; package org.gcube.portlets.user.socialprofile.client.ui;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder;
import org.gcube.portal.databook.shared.UserInfo; import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.socialprofile.client.SocialService; import org.gcube.portlets.user.socialprofile.client.SocialService;
import org.gcube.portlets.user.socialprofile.client.SocialServiceAsync; import org.gcube.portlets.user.socialprofile.client.SocialServiceAsync;
import org.gcube.portlets.user.socialprofile.shared.UserContext; import org.gcube.portlets.user.socialprofile.shared.UserContext;
import org.gcube.portlets.user.wsmail.client.forms.MailForm;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; 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.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
@ -25,6 +32,7 @@ public class DisplayProfile extends Composite {
protected final static String HEADLINE_TEXT = "Professional Headline"; protected final static String HEADLINE_TEXT = "Professional Headline";
protected final static String HEADLINE_ERROR = "Your Headline please"; protected final static String HEADLINE_ERROR = "Your Headline please";
protected final static String ISTI_TEXT = "Company"; protected final static String ISTI_TEXT = "Company";
protected final static String ISTI_ERROR = "Your Company please";
private static DisplayProfileUiBinder uiBinder = GWT private static DisplayProfileUiBinder uiBinder = GWT
.create(DisplayProfileUiBinder.class); .create(DisplayProfileUiBinder.class);
@ -40,18 +48,26 @@ public class DisplayProfile extends Composite {
@UiField HTMLPanel mainPanel; @UiField HTMLPanel mainPanel;
@UiField Image avatarImage; @UiField Image avatarImage;
@UiField HTML userFullName; @UiField HTML userFullName;
@UiField TextBox headline; @UiField TextBox headlineBox;
@UiField TextBox institution; @UiField TextBox institutionBox;
@UiField HTML editHeadline; @UiField HTML editHeadline;
@UiField HTML editIsti; @UiField HTML editIsti;
@UiField HTML headlineLabel;
@UiField HTML institutionLabel;
@UiField Image savingHeadline; @UiField Image savingHeadline;
@UiField Button saveHead; @UiField Button saveHead;
@UiField Button cancelHead; @UiField Button cancelHead;
@UiField Button saveIsti;
@UiField Button cancelIsti;
@UiField Button messageButton; @UiField Button messageButton;
private String currHeadLine; private String currHeadLine;
private String currInstitution;
private UserInfo myUserInfo; private UserInfo myUserInfo;
@ -73,29 +89,29 @@ public class DisplayProfile extends Composite {
String head = (result.getHeadline() == null || result.getHeadline().compareTo("") == 0) ? HEADLINE_TEXT : result.getHeadline(); String head = (result.getHeadline() == null || result.getHeadline().compareTo("") == 0) ? HEADLINE_TEXT : result.getHeadline();
String isti = (result.getInstitution() == null ||result.getInstitution().compareTo("") == 0) ? ISTI_TEXT : result.getInstitution(); String isti = (result.getInstitution() == null ||result.getInstitution().compareTo("") == 0) ? ISTI_TEXT : result.getInstitution();
headline.setText(head); headlineLabel.setText(head);
institution.setText(isti); institutionLabel.setText(isti);
editHeadline.setStyleName("editImage"); editHeadline.setStyleName("editImage");
editHeadline.setTitle("Edit your Professional Headline"); editHeadline.setTitle("Edit your Professional Headline");
headline.setMaxLength(35);
editIsti.setStyleName("editImage"); editIsti.setStyleName("editImage");
editIsti.setTitle("Edit your Company"); editIsti.setTitle("Edit your Company");
headlineBox.setMaxLength(70);
institutionBox.setMaxLength(70);
messageButton.removeFromParent(); messageButton.removeFromParent();
currHeadLine = head; currHeadLine = head;
if (result.getHeadline() == null || result.getHeadline().compareTo("") == 0) { if (result.getHeadline() == null || result.getHeadline().compareTo("") == 0) {
headline.getElement().getStyle().setOpacity(0.5); headlineLabel.getElement().getStyle().setOpacity(0.5);
institution.getElement().getStyle().setOpacity(0.5); institutionLabel.getElement().getStyle().setOpacity(0.5);
headline.getElement().getStyle().setWidth(270, Unit.PX);
institution.getElement().getStyle().setWidth(270, Unit.PX);
} }
} else { //its someone else } else { //its someone else
String head = (result.getHeadline() == null || result.getHeadline().compareTo("") == 0) ? "" : result.getHeadline(); String head = (result.getHeadline() == null || result.getHeadline().compareTo("") == 0) ? "" : result.getHeadline();
String isti = (result.getInstitution() == null || result.getInstitution().compareTo("") == 0) ? "" : result.getInstitution(); String isti = (result.getInstitution() == null || result.getInstitution().compareTo("") == 0) ? "" : result.getInstitution();
headline.setText(head); headlineLabel.setText(head);
institution.setText(isti); institutionLabel.setText(isti);
avatarImage.getElement().getParentElement().setAttribute("href", ""); avatarImage.getElement().getParentElement().setAttribute("href", "");
avatarImage.setTitle(myUserInfo.getFullName()); avatarImage.setTitle(myUserInfo.getFullName());
@ -112,74 +128,153 @@ public class DisplayProfile extends Composite {
avatarImage.setUrl(avatar_default); avatarImage.setUrl(avatar_default);
} }
}); });
}
editHeadline.addClickHandler(new ClickHandler() {
@Override @UiHandler("editHeadline")
public void onClick(ClickEvent event) { void onEditHeadlineClick(ClickEvent e) {
headline.addStyleName("edit"); headlineLabel.setVisible(false);
headline.setReadOnly(false); headlineBox.setText(headlineLabel.getText());
headline.setFocus(true); headlineBox.addStyleName("edit");
headline.selectAll(); headlineBox.setVisible(true);
editHeadline.setVisible(false); headlineBox.setFocus(true);
saveHead.setVisible(true); headlineBox.selectAll();
cancelHead.setVisible(true);
}
});
saveHead.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
String toShare = escapeHtml(headline.getText());
if (toShare.equals("") || toShare.equals(HEADLINE_TEXT) || toShare.equals(HEADLINE_ERROR)) {
headline.setText(HEADLINE_ERROR);
} else {
currHeadLine = toShare;
saveHead.setVisible(false);
cancelHead.setVisible(false);
savingHeadline.setVisible(true);
headline.setReadOnly(true);
socialService.saveHeadline(currHeadLine, new AsyncCallback<Boolean>() {
@Override editHeadline.setVisible(false);
public void onFailure(Throwable caught) { saveHead.setVisible(true);
Window.alert("Sorry, an error occurred"); cancelHead.setVisible(true);
cancelHeadline(); }
}
@UiHandler("editIsti")
void onEditInstitutionClick(ClickEvent e) {
institutionLabel.setVisible(false);
institutionBox.setText(institutionLabel.getText());
institutionBox.addStyleName("edit");
institutionBox.setVisible(true);
institutionBox.setFocus(true);
institutionBox.selectAll();
@Override editIsti.setVisible(false);
public void onSuccess(Boolean result) { saveIsti.setVisible(true);
headline.removeStyleName("edit"); cancelIsti.setVisible(true);
editHeadline.setVisible(true); }
headline.getElement().getStyle().setOpacity(1.0);
} @UiHandler("cancelHead")
}); void onCancelHeadlineClick(ClickEvent e) {
cancelHeadline();
}
@UiHandler("cancelIsti")
void onCancelIstiClick(ClickEvent e) {
cancelInsti();
}
@UiHandler("saveHead")
void onSaveHeadlineClick(ClickEvent e) {
String toShare = escapeHtml(headlineBox.getText());
if (toShare.equals("") || toShare.equals(HEADLINE_TEXT) || toShare.equals(HEADLINE_ERROR)) {
headlineBox.setText(HEADLINE_ERROR);
} else {
currHeadLine = toShare;
saveHead.setVisible(false);
cancelHead.setVisible(false);
savingHeadline.setVisible(true);
socialService.saveHeadline(currHeadLine, new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
Window.alert("Sorry, an error occurred");
cancelHeadline();
savingHeadline.setVisible(false);
} }
}
}); @Override
public void onSuccess(Boolean result) {
cancelHead.addClickHandler(new ClickHandler() { headlineLabel.setText(currHeadLine);
editHeadline.setVisible(true);
headlineLabel.getElement().getStyle().setOpacity(1.0);
headlineBox.setVisible(false);
headlineLabel.setVisible(true);
savingHeadline.setVisible(false);
}
});
}
}
@UiHandler("saveIsti")
void onSaveInstitutionClick(ClickEvent e) {
String toShare = escapeHtml(institutionBox.getText());
if (toShare.equals("") || toShare.equals(ISTI_TEXT) || toShare.equals(ISTI_ERROR)) {
institutionBox.setText(ISTI_ERROR);
} else {
currInstitution = toShare;
saveIsti.setVisible(false);
cancelIsti.setVisible(false);
savingHeadline.setVisible(true);
socialService.saveIsti(currInstitution, new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
Window.alert("Sorry, an error occurred");
cancelHeadline();
savingHeadline.setVisible(false);
}
@Override
public void onSuccess(Boolean result) {
institutionLabel.setText(currInstitution);
editIsti.setVisible(true);
institutionLabel.getElement().getStyle().setOpacity(1.0);
institutionBox.setVisible(false);
institutionLabel.setVisible(true);
savingHeadline.setVisible(false);
}
});
}
}
@UiHandler("messageButton")
void onSendPrivateMessageClick(ClickEvent e) {
final List<String> listToLogin = new ArrayList<String>();
listToLogin.add(getUserToShowId() );
GWT.runAsync(new RunAsyncCallback() {
@Override @Override
public void onClick(ClickEvent event) { public void onSuccess() {
cancelHeadline(); new MailForm(listToLogin);
} }
public void onFailure(Throwable reason) {
Window.alert("Could not load this component: " + reason.getMessage());
}
}); });
} }
private void cancelHeadline() { private void cancelHeadline() {
headline.removeStyleName("edit");
headline.setReadOnly(true);
editHeadline.setVisible(true); editHeadline.setVisible(true);
saveHead.setVisible(false); saveHead.setVisible(false);
cancelHead.setVisible(false); cancelHead.setVisible(false);
headline.setText(currHeadLine); headlineBox.setVisible(false);
headlineLabel.setVisible(true);
} }
private void cancelInsti() {
editIsti.setVisible(true);
saveIsti.setVisible(false);
cancelIsti.setVisible(false);
institutionBox.setVisible(false);
institutionLabel.setVisible(true);
}
/** /**
* check if it has to show just one feed * check if it has to show just one feed
* @return * @return
*/ */
private String getUserToShowId() { private String getUserToShowId() {
return Window.Location.getParameter(GET_OID_PARAMETER); String encodedOid = Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID);
String encodedUserId = Window.Location.getParameter(encodedOid);
return Encoder.decode(encodedUserId);
} }
/** /**

View File

@ -4,40 +4,57 @@
<g:HTMLPanel ui:field="mainPanel"> <g:HTMLPanel ui:field="mainPanel">
<table class=""> <table class="">
<tr> <tr>
<td width="120px;" align="middle"> <td width="110px;" align="middle">
<a href=""> <a href="">
<g:Image title="Edit Profile Picture" styleName="user-photo" <g:Image title="Edit Profile Picture" styleName="user-photo"
url="" ui:field="avatarImage" width="100" height="100" /> url="" ui:field="avatarImage" width="100" height="100" />
</a> </a>
</td> </td>
<td width="420px;" valign="top"> <td valign="top">
<div class="user-details"> <div class="user-details">
<g:HTML styleName="full-name" ui:field="userFullName"></g:HTML>
<table> <table>
<tr> <tr>
<td> <td>
<g:TextBox styleName="headline" ui:field="headline"
readOnly="true"></g:TextBox>
</td> </td>
<td style="width:200px"> <td colspan="2">
<g:Button ui:field="saveHead" visible="false">Save</g:Button> <g:HTML styleName="full-name" ui:field="userFullName"></g:HTML>
<g:Button ui:field="cancelHead" visible="false">Cancel</g:Button>
<g:HTML height="15px" width="15px" ui:field="editHeadline"></g:HTML>
<g:Image height="16px" width="16px" visible="false" ui:field="savingHeadline"></g:Image>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<g:TextBox styleName="institution" ui:field="institution" <g:HTML height="15px" width="15px" ui:field="editHeadline"></g:HTML>
readOnly="true"></g:TextBox>
</td> </td>
<td> <td>
<g:HTML height="15px" width="15px" ui:field="editIsti"></g:HTML> <g:HTML styleName="headline" ui:field="headlineLabel"></g:HTML>
<g:TextBox styleName="headline" ui:field="headlineBox"
visible="false"></g:TextBox>
<div>
<g:Button ui:field="saveHead" visible="false">Save</g:Button>
<g:Button ui:field="cancelHead" visible="false">Cancel</g:Button>
</div>
</td>
<td>
<g:Image height="16px" width="16px" visible="false"
ui:field="savingHeadline"></g:Image>
</td>
</tr>
<tr>
<td>
<g:HTML height="15px" width="15px" ui:field="editIsti"></g:HTML>
</td>
<td>
<g:HTML styleName="institution" ui:field="institutionLabel"></g:HTML>
<g:TextBox styleName="institution" ui:field="institutionBox" visible="false"></g:TextBox>
<div>
<g:Button ui:field="saveIsti" visible="false">Save</g:Button>
<g:Button ui:field="cancelIsti" visible="false">Cancel</g:Button>
</div>
</td>
<td>
<g:Image height="16px" width="16px" visible="false"
ui:field="savingIsti"></g:Image>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>

View File

@ -3,10 +3,11 @@
<!-- Inherit the core Web Toolkit stuff. --> <!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
<!-- To Comment out --> <!-- To Comment out -->
<set-property name="user.agent" value="gecko1_8" /> <!-- <set-property name="user.agent" value="gecko1_8" /> -->
<!-- Other module inherits --> <!-- Other module inherits -->
<!-- inherits GCUBE Widgets --> <!-- inherits GCUBE Widgets -->
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' /> <inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<inherits name='org.gcube.portlets.user.wsmail.WsMail_Widget' />
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' /> <inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
<entry-point <entry-point

View File

@ -21,6 +21,7 @@
font-family: Helvetica, Arial, sans-serif; font-family: Helvetica, Arial, sans-serif;
font-size: 22px; font-size: 22px;
font-weight: bold; font-weight: bold;
white-space: nowrap;
} }
.edit { .edit {
@ -33,18 +34,12 @@
font-family: Helvetica, Arial, sans-serif; font-family: Helvetica, Arial, sans-serif;
font-size: 16px; font-size: 16px;
color: #444444; color: #444444;
border: 0;
cursor: default;
width: 250px;
} }
.institution { .institution {
font-family: Helvetica, Arial, sans-serif; font-family: Helvetica, Arial, sans-serif;
font-size: 16px; font-size: 13px;
color: #444444; color: #444444;
border: 0;
cursor: default;
width: 250px;
} }
.editImage { .editImage {

View File

@ -1,24 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
"http://java.sun.com/dtd/web-app_2_3.dtd"> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
<web-app> <!-- Servlets -->
<servlet>
<servlet-name>socialService</servlet-name>
<servlet-class>org.gcube.portlets.user.socialprofile.server.SocialServiceImpl</servlet-class>
</servlet>
<!-- Servlets --> <servlet-mapping>
<servlet> <servlet-name>socialService</servlet-name>
<servlet-name>socialService</servlet-name> <url-pattern>/socialprofile/socialService</url-pattern>
<servlet-class>org.gcube.portlets.user.socialprofile.server.SocialServiceImpl</servlet-class> </servlet-mapping>
</servlet>
<servlet-mapping> <servlet>
<servlet-name>socialService</servlet-name> <servlet-name>mailWisdgetServlet</servlet-name>
<url-pattern>/socialprofile/socialService</url-pattern> <servlet-class>org.gcube.portlets.user.wsmail.server.WsMailServiceImpl</servlet-class>
</servlet-mapping> </servlet>
<!-- Default page to serve --> <servlet-mapping>
<welcome-file-list> <servlet-name>mailWisdgetServlet</servlet-name>
<welcome-file>SocialProfile.html</welcome-file> <url-pattern>/socialprofile/mailWisdgetServlet</url-pattern>
</welcome-file-list> </servlet-mapping>
<servlet>
<servlet-name>workspaceServiceImpl</servlet-name>
<servlet-class>org.gcube.portlets.user.workspace.lighttree.server.WorkspaceServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>workspaceServiceImpl</servlet-name>
<url-pattern>/socialprofile/WorkspaceLightService</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>SocialProfile.html</welcome-file>
</welcome-file-list>
</web-app> </web-app>