From 4f4cb4f7b11e4ad70976634607b8d20ee30df674 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Wed, 8 May 2013 15:17:55 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/social-profile@74720 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 7 - .settings/org.eclipse.core.resources.prefs | 4 +- pom.xml | 2 +- .../socialprofile/client/SocialProfile.java | 135 +----------------- ...reetingService.java => SocialService.java} | 4 +- ...viceAsync.java => SocialServiceAsync.java} | 6 +- .../client/ui/DisplayProfile.java | 29 ++++ .../client/ui/DisplayProfile.ui.xml | 22 +++ .../server/GreetingServiceImpl.java | 48 ------- .../server/SocialServiceImpl.java | 14 ++ .../user/socialprofile/SocialProfile.gwt.xml | 11 -- .../socialprofile/client/Messages.properties | 2 - .../client/Messages_fr.properties | 2 - src/main/webapp/SocialProfile.css | 34 ----- src/main/webapp/SocialProfile.html | 46 +----- .../webapp/WEB-INF/jsp/SocialProfile_view.jsp | 3 +- src/main/webapp/WEB-INF/web.xml | 2 +- 17 files changed, 80 insertions(+), 291 deletions(-) rename src/main/java/org/gcube/portlets/user/socialprofile/client/{GreetingService.java => SocialService.java} (68%) rename src/main/java/org/gcube/portlets/user/socialprofile/client/{GreetingServiceAsync.java => SocialServiceAsync.java} (51%) create mode 100644 src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.java create mode 100644 src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.ui.xml delete mode 100644 src/main/java/org/gcube/portlets/user/socialprofile/server/GreetingServiceImpl.java create mode 100644 src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java delete mode 100644 src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages.properties delete mode 100644 src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages_fr.properties diff --git a/.classpath b/.classpath index e730441..e27ba63 100644 --- a/.classpath +++ b/.classpath @@ -8,13 +8,6 @@ - - - - - - - diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 5d8b3cc..12740e0 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,7 +1,5 @@ -#Mon Jan 21 12:20:12 CET 2013 +#Wed May 08 17:09:53 CEST 2013 eclipse.preferences.version=1 encoding//src/main/java=UTF-8 encoding//src/main/resources=UTF-8 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 encoding/=UTF-8 diff --git a/pom.xml b/pom.xml index d1250e8..e1e50ab 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ org.gcube.applicationsupportlayer aslcore - 3.2.0-2.12.0 + [3.2.0-SNAPSHOT, 4.0.0-SNAPSHOT) provided diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialProfile.java b/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialProfile.java index a854890..565944b 100644 --- a/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialProfile.java +++ b/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialProfile.java @@ -1,148 +1,19 @@ package org.gcube.portlets.user.socialprofile.client; -import org.gcube.portlets.user.socialprofile.shared.FieldVerifier; +import org.gcube.portlets.user.socialprofile.client.ui.DisplayProfile; + import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.event.dom.client.KeyUpHandler; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Button; -import com.google.gwt.user.client.ui.DialogBox; -import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.VerticalPanel; /** * Entry point classes define onModuleLoad(). */ public class SocialProfile implements EntryPoint { - /** - * The message displayed to the user when the server cannot be reached or - * returns an error. - */ - private static final String SERVER_ERROR = "An error occurred while " - + "attempting to contact the server. Please check your network " - + "connection and try again."; - - /** - * Create a remote service proxy to talk to the server-side Greeting service. - */ - private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class); - /** * This is the entry point method. */ public void onModuleLoad() { - final Button sendButton = new Button( "" ); - final TextBox nameField = new TextBox(); - nameField.setText( "" ); - final Label errorLabel = new Label(); - - // We can add style names to widgets - sendButton.addStyleName("sendButton"); - - // Add the nameField and sendButton to the RootPanel - // Use RootPanel.get() to get the entire body element - RootPanel.get("nameFieldContainer").add(nameField); - RootPanel.get("sendButtonContainer").add(sendButton); - RootPanel.get("errorLabelContainer").add(errorLabel); - - // Focus the cursor on the name field when the app loads - nameField.setFocus(true); - nameField.selectAll(); - - // Create the popup dialog box - final DialogBox dialogBox = new DialogBox(); - dialogBox.setText("Remote Procedure Call"); - dialogBox.setAnimationEnabled(true); - final Button closeButton = new Button("Close"); - // We can set the id of a widget by accessing its Element - closeButton.getElement().setId("closeButton"); - final Label textToServerLabel = new Label(); - final HTML serverResponseLabel = new HTML(); - VerticalPanel dialogVPanel = new VerticalPanel(); - dialogVPanel.addStyleName("dialogVPanel"); - dialogVPanel.add(new HTML("Sending name to the server:")); - dialogVPanel.add(textToServerLabel); - dialogVPanel.add(new HTML("
Server replies:")); - dialogVPanel.add(serverResponseLabel); - dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); - dialogVPanel.add(closeButton); - dialogBox.setWidget(dialogVPanel); - - // Add a handler to close the DialogBox - closeButton.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent event) { - dialogBox.hide(); - sendButton.setEnabled(true); - sendButton.setFocus(true); - } - }); - - // Create a handler for the sendButton and nameField - class MyHandler implements ClickHandler, KeyUpHandler { - /** - * Fired when the user clicks on the sendButton. - */ - public void onClick(ClickEvent event) { - sendNameToServer(); - } - - /** - * Fired when the user types in the nameField. - */ - public void onKeyUp(KeyUpEvent event) { - if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { - sendNameToServer(); - } - } - - /** - * Send the name from the nameField to the server and wait for a response. - */ - private void sendNameToServer() { - // First, we validate the input. - errorLabel.setText(""); - String textToServer = nameField.getText(); - if (!FieldVerifier.isValidName(textToServer)) { - errorLabel.setText("Please enter at least four characters"); - return; - } - - // Then, we send the input to the server. - sendButton.setEnabled(false); - textToServerLabel.setText(textToServer); - serverResponseLabel.setText(""); - greetingService.greetServer(textToServer, new AsyncCallback() { - public void onFailure(Throwable caught) { - // Show the RPC error message to the user - dialogBox.setText("Remote Procedure Call - Failure"); - serverResponseLabel.addStyleName("serverResponseLabelError"); - serverResponseLabel.setHTML(SERVER_ERROR); - dialogBox.center(); - closeButton.setFocus(true); - } - - public void onSuccess(String result) { - dialogBox.setText("Remote Procedure Call"); - serverResponseLabel.removeStyleName("serverResponseLabelError"); - serverResponseLabel.setHTML(result); - dialogBox.center(); - closeButton.setFocus(true); - } - }); - } - } - - // Add a handler to send the name to the server - MyHandler handler = new MyHandler(); - sendButton.addClickHandler(handler); - nameField.addKeyUpHandler(handler); + RootPanel.get("SocialProfileDiv").add(new DisplayProfile()); } } diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingService.java b/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialService.java similarity index 68% rename from src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingService.java rename to src/main/java/org/gcube/portlets/user/socialprofile/client/SocialService.java index a77537b..874eb85 100644 --- a/src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingService.java +++ b/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialService.java @@ -7,6 +7,6 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; * The client side stub for the RPC service. */ @RemoteServiceRelativePath("greet") -public interface GreetingService extends RemoteService { - String greetServer(String name) throws IllegalArgumentException; +public interface SocialService extends RemoteService { + } diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingServiceAsync.java b/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialServiceAsync.java similarity index 51% rename from src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingServiceAsync.java rename to src/main/java/org/gcube/portlets/user/socialprofile/client/SocialServiceAsync.java index 3af119f..5fd7918 100644 --- a/src/main/java/org/gcube/portlets/user/socialprofile/client/GreetingServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/socialprofile/client/SocialServiceAsync.java @@ -2,8 +2,6 @@ package org.gcube.portlets.user.socialprofile.client; import com.google.gwt.user.client.rpc.AsyncCallback; -public interface GreetingServiceAsync { - - void greetServer(String name, AsyncCallback callback); - +public interface SocialServiceAsync { + } diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.java b/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.java new file mode 100644 index 0000000..882329d --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.java @@ -0,0 +1,29 @@ +package org.gcube.portlets.user.socialprofile.client.ui; + +import org.gcube.portlets.user.socialprofile.client.SocialService; +import org.gcube.portlets.user.socialprofile.client.SocialServiceAsync; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.Widget; + +public class DisplayProfile extends Composite { + + private static DisplayProfileUiBinder uiBinder = GWT + .create(DisplayProfileUiBinder.class); + + interface DisplayProfileUiBinder extends UiBinder { + } + + private final SocialServiceAsync socialService = GWT.create(SocialService.class); + + @UiField Image avatarImage; + + public DisplayProfile() { + initWidget(uiBinder.createAndBindUi(this)); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.ui.xml b/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.ui.xml new file mode 100644 index 0000000..596e5b8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.ui.xml @@ -0,0 +1,22 @@ + + + + + + + + + +
+ + + + +
+ SSSSSS +
+
+
+
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/server/GreetingServiceImpl.java b/src/main/java/org/gcube/portlets/user/socialprofile/server/GreetingServiceImpl.java deleted file mode 100644 index ecf57a1..0000000 --- a/src/main/java/org/gcube/portlets/user/socialprofile/server/GreetingServiceImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.gcube.portlets.user.socialprofile.server; - -import org.gcube.portlets.user.socialprofile.client.GreetingService; -import org.gcube.portlets.user.socialprofile.shared.FieldVerifier; -import com.google.gwt.user.server.rpc.RemoteServiceServlet; - -/** - * The server side implementation of the RPC service. - */ -@SuppressWarnings("serial") -public class GreetingServiceImpl extends RemoteServiceServlet implements - GreetingService { - - public String greetServer(String input) throws IllegalArgumentException { - // Verify that the input is valid. - if (!FieldVerifier.isValidName(input)) { - // If the input is not valid, throw an IllegalArgumentException back to - // the client. - throw new IllegalArgumentException( - "Name must be at least 4 characters long"); - } - - String serverInfo = getServletContext().getServerInfo(); - String userAgent = getThreadLocalRequest().getHeader("User-Agent"); - - // Escape data from the client to avoid cross-site script vulnerabilities. - input = escapeHtml(input); - userAgent = escapeHtml(userAgent); - - return "Hello, " + input + "!

I am running " + serverInfo - + ".

It looks like you are using:
" + userAgent; - } - - /** - * Escape an html string. Escaping data received from the client helps to - * prevent cross-site script vulnerabilities. - * - * @param html the html string to escape - * @return the escaped string - */ - private String escapeHtml(String html) { - if (html == null) { - return null; - } - return html.replaceAll("&", "&").replaceAll("<", "<").replaceAll( - ">", ">"); - } -} diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java b/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java new file mode 100644 index 0000000..046d66b --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java @@ -0,0 +1,14 @@ +package org.gcube.portlets.user.socialprofile.server; + +import org.gcube.portlets.user.socialprofile.client.SocialService; +import org.gcube.portlets.user.socialprofile.shared.FieldVerifier; +import com.google.gwt.user.server.rpc.RemoteServiceServlet; + +/** + * The server side implementation of the RPC service. + */ +@SuppressWarnings("serial") +public class SocialServiceImpl extends RemoteServiceServlet implements SocialService { + + +} diff --git a/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml b/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml index b4da3d5..ec47f27 100644 --- a/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml @@ -3,17 +3,6 @@ - - - - - - - - - - - diff --git a/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages.properties b/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages.properties deleted file mode 100644 index c222555..0000000 --- a/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages.properties +++ /dev/null @@ -1,2 +0,0 @@ -sendButton = Send -nameField = Enter your name \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages_fr.properties b/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages_fr.properties deleted file mode 100644 index b4a7627..0000000 --- a/src/main/resources/org/gcube/portlets/user/socialprofile/client/Messages_fr.properties +++ /dev/null @@ -1,2 +0,0 @@ -sendButton = Envoyer -nameField = Entrez votre nom \ No newline at end of file diff --git a/src/main/webapp/SocialProfile.css b/src/main/webapp/SocialProfile.css index 7aca7ac..e69de29 100644 --- a/src/main/webapp/SocialProfile.css +++ b/src/main/webapp/SocialProfile.css @@ -1,34 +0,0 @@ -/** Add css rules here for your application. */ - - -/** Example rules used by the template application (remove for your app) */ -h1 { - font-size: 2em; - font-weight: bold; - color: #777777; - margin: 40px 0px 70px; - text-align: center; -} - -.sendButton { - display: block; - font-size: 16pt; -} - -/** Most GWT widgets already have a style name defined */ -.gwt-DialogBox { - width: 400px; -} - -.dialogVPanel { - margin: 5px; -} - -.serverResponseLabelError { - color: red; -} - -/** Set ids using widget.getElement().setId("idOfElement") */ -#closeButton { - margin: 15px 6px 6px; -} diff --git a/src/main/webapp/SocialProfile.html b/src/main/webapp/SocialProfile.html index 78eefdb..5e1aabd 100644 --- a/src/main/webapp/SocialProfile.html +++ b/src/main/webapp/SocialProfile.html @@ -13,51 +13,13 @@ + SOCIAL PROFILE Project - - - - Web Application Starter Project - - - - - - - + - - - - - - - - - - - - -

Web Application Starter Project

- - - - - - - - - - - - -
Please enter your name:
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/SocialProfile_view.jsp b/src/main/webapp/WEB-INF/jsp/SocialProfile_view.jsp index 420df1e..3a22494 100644 --- a/src/main/webapp/WEB-INF/jsp/SocialProfile_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/SocialProfile_view.jsp @@ -9,6 +9,5 @@ --%> -
- +
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 61e288c..2584052 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -8,7 +8,7 @@ greetServlet - org.gcube.portlets.user.socialprofile.server.GreetingServiceImpl + org.gcube.portlets.user.socialprofile.server.SocialServiceImpl