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="/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="/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="context-root" value="social-profile"/>
</wb-module>

View File

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

18
pom.xml
View File

@ -82,6 +82,18 @@
<version>[3.2.0-SNAPSHOT, 4.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</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>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
@ -94,12 +106,6 @@
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<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;
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.portlets.user.socialprofile.client.SocialService;
import org.gcube.portlets.user.socialprofile.client.SocialServiceAsync;
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.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.ClickHandler;
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;
@ -25,6 +32,7 @@ public class DisplayProfile extends Composite {
protected final static String HEADLINE_TEXT = "Professional Headline";
protected final static String HEADLINE_ERROR = "Your Headline please";
protected final static String ISTI_TEXT = "Company";
protected final static String ISTI_ERROR = "Your Company please";
private static DisplayProfileUiBinder uiBinder = GWT
.create(DisplayProfileUiBinder.class);
@ -40,18 +48,26 @@ public class DisplayProfile extends Composite {
@UiField HTMLPanel mainPanel;
@UiField Image avatarImage;
@UiField HTML userFullName;
@UiField TextBox headline;
@UiField TextBox institution;
@UiField TextBox headlineBox;
@UiField TextBox institutionBox;
@UiField HTML editHeadline;
@UiField HTML editIsti;
@UiField HTML headlineLabel;
@UiField HTML institutionLabel;
@UiField Image savingHeadline;
@UiField Button saveHead;
@UiField Button cancelHead;
@UiField Button saveIsti;
@UiField Button cancelIsti;
@UiField Button messageButton;
private String currHeadLine;
private String currInstitution;
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 isti = (result.getInstitution() == null ||result.getInstitution().compareTo("") == 0) ? ISTI_TEXT : result.getInstitution();
headline.setText(head);
institution.setText(isti);
headlineLabel.setText(head);
institutionLabel.setText(isti);
editHeadline.setStyleName("editImage");
editHeadline.setTitle("Edit your Professional Headline");
headline.setMaxLength(35);
editIsti.setStyleName("editImage");
editIsti.setTitle("Edit your Company");
headlineBox.setMaxLength(70);
institutionBox.setMaxLength(70);
messageButton.removeFromParent();
currHeadLine = head;
if (result.getHeadline() == null || result.getHeadline().compareTo("") == 0) {
headline.getElement().getStyle().setOpacity(0.5);
institution.getElement().getStyle().setOpacity(0.5);
headline.getElement().getStyle().setWidth(270, Unit.PX);
institution.getElement().getStyle().setWidth(270, Unit.PX);
headlineLabel.getElement().getStyle().setOpacity(0.5);
institutionLabel.getElement().getStyle().setOpacity(0.5);
}
} else { //its someone else
String head = (result.getHeadline() == null || result.getHeadline().compareTo("") == 0) ? "" : result.getHeadline();
String isti = (result.getInstitution() == null || result.getInstitution().compareTo("") == 0) ? "" : result.getInstitution();
headline.setText(head);
institution.setText(isti);
headlineLabel.setText(head);
institutionLabel.setText(isti);
avatarImage.getElement().getParentElement().setAttribute("href", "");
avatarImage.setTitle(myUserInfo.getFullName());
@ -112,74 +128,153 @@ public class DisplayProfile extends Composite {
avatarImage.setUrl(avatar_default);
}
});
editHeadline.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
headline.addStyleName("edit");
headline.setReadOnly(false);
headline.setFocus(true);
headline.selectAll();
editHeadline.setVisible(false);
saveHead.setVisible(true);
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>() {
}
@UiHandler("editHeadline")
void onEditHeadlineClick(ClickEvent e) {
headlineLabel.setVisible(false);
headlineBox.setText(headlineLabel.getText());
headlineBox.addStyleName("edit");
headlineBox.setVisible(true);
headlineBox.setFocus(true);
headlineBox.selectAll();
@Override
public void onFailure(Throwable caught) {
Window.alert("Sorry, an error occurred");
cancelHeadline();
}
editHeadline.setVisible(false);
saveHead.setVisible(true);
cancelHead.setVisible(true);
}
@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
public void onSuccess(Boolean result) {
headline.removeStyleName("edit");
editHeadline.setVisible(true);
headline.getElement().getStyle().setOpacity(1.0);
}
});
editIsti.setVisible(false);
saveIsti.setVisible(true);
cancelIsti.setVisible(true);
}
@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);
}
}
});
cancelHead.addClickHandler(new ClickHandler() {
@Override
public void onSuccess(Boolean result) {
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
public void onClick(ClickEvent event) {
cancelHeadline();
public void onSuccess() {
new MailForm(listToLogin);
}
public void onFailure(Throwable reason) {
Window.alert("Could not load this component: " + reason.getMessage());
}
});
}
private void cancelHeadline() {
headline.removeStyleName("edit");
headline.setReadOnly(true);
editHeadline.setVisible(true);
saveHead.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
* @return
*/
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">
<table class="">
<tr>
<td width="120px;" align="middle">
<td width="110px;" align="middle">
<a href="">
<g:Image title="Edit Profile Picture" styleName="user-photo"
url="" ui:field="avatarImage" width="100" height="100" />
</a>
</td>
<td width="420px;" valign="top">
<td valign="top">
<div class="user-details">
<g:HTML styleName="full-name" ui:field="userFullName"></g:HTML>
<table>
<tr>
<td>
<g:TextBox styleName="headline" ui:field="headline"
readOnly="true"></g:TextBox>
</td>
<td style="width:200px">
<g:Button ui:field="saveHead" visible="false">Save</g:Button>
<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 colspan="2">
<g:HTML styleName="full-name" ui:field="userFullName"></g:HTML>
</td>
</tr>
<tr>
<td>
<g:TextBox styleName="institution" ui:field="institution"
readOnly="true"></g:TextBox>
<g:HTML height="15px" width="15px" ui:field="editHeadline"></g:HTML>
</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>
</tr>
</table>
</div>

View File

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

View File

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

View File

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