mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-10 22:30:56 +00:00
created a new bundle project from scratch, adding GWT OSGi bundle as dependency
This commit is contained in:
1 parent
37f57fb6e3
commit
4db5d2c140
41 files changed
+375
-3
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="war/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1 @@
|
||||
/bin
|
||||
@@ -10,6 +10,16 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
|
||||
<arguments>
|
||||
@@ -22,6 +32,7 @@
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
|
||||
</natures>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#Mon Jul 04 13:09:48 CEST 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
@@ -0,0 +1,4 @@
|
||||
#Mon Jul 04 13:09:48 CEST 2011
|
||||
eclipse.preferences.version=1
|
||||
pluginProject.extensions=false
|
||||
resolve.requirebundle=false
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Sailing App GWT UI
|
||||
Bundle-SymbolicName: com.sap.sailing.gwt.ui
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: com.google.gwt.osgi;bundle-version="2.3.0"
|
||||
File renamed without changes.
Executable
+4
@@ -0,0 +1,4 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="war/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.sap.sailing.gwt.ui</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
File renamed without changes.
File renamed without changes.
Executable
+23
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to='com_sap_sailing_gwt_ui'>
|
||||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name='com.google.gwt.user.User'/>
|
||||
|
||||
<!-- Inherit the default GWT style sheet. You can change -->
|
||||
<!-- the theme of your GWT application by uncommenting -->
|
||||
<!-- any one of the following lines. -->
|
||||
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
|
||||
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
<!-- Other module inherits -->
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point class='com.sap.sailing.gwt.ui.client.Com_sap_sailing_gwt_ui'/>
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client'/>
|
||||
<source path='shared'/>
|
||||
|
||||
</module>
|
||||
Executable
+146
@@ -0,0 +1,146 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import com.sap.sailing.gwt.ui.shared.FieldVerifier;
|
||||
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 <code>onModuleLoad()</code>.
|
||||
*/
|
||||
public class Com_sap_sailing_gwt_ui 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("Send");
|
||||
final TextBox nameField = new TextBox();
|
||||
nameField.setText("GWT User");
|
||||
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("<b>Sending name to the server:</b>"));
|
||||
dialogVPanel.add(textToServerLabel);
|
||||
dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
|
||||
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<String>() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
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;
|
||||
}
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/**
|
||||
* The async counterpart of <code>GreetingService</code>.
|
||||
*/
|
||||
public interface GreetingServiceAsync {
|
||||
void greetServer(String input, AsyncCallback<String> callback) throws IllegalArgumentException;
|
||||
}
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
package com.sap.sailing.gwt.ui.server;
|
||||
|
||||
import com.sap.sailing.gwt.ui.client.GreetingService;
|
||||
import com.sap.sailing.gwt.ui.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 + "!<br><br>I am running " + serverInfo + ".<br><br>It looks like you are using:<br>"
|
||||
+ 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(">", ">");
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.sap.sailing.gwt.ui.shared;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* FieldVerifier validates that the name the user enters is valid.
|
||||
* </p>
|
||||
* <p>
|
||||
* This class is in the <code>shared</code> package because we use it in both
|
||||
* the client code and on the server. On the client, we verify that the name is
|
||||
* valid before sending an RPC request so the user doesn't have to wait for a
|
||||
* network round trip to get feedback. On the server, we verify that the name is
|
||||
* correct to ensure that the input is correct regardless of where the RPC
|
||||
* originates.
|
||||
* </p>
|
||||
* <p>
|
||||
* When creating a class that is used on both the client and the server, be sure
|
||||
* that all code is translatable and does not use native JavaScript. Code that
|
||||
* is not translatable (such as code that interacts with a database or the file
|
||||
* system) cannot be compiled into client side JavaScript. Code that uses native
|
||||
* JavaScript (such as Widgets) cannot be run on the server.
|
||||
* </p>
|
||||
*/
|
||||
public class FieldVerifier {
|
||||
|
||||
/**
|
||||
* Verifies that the specified name is valid for our service.
|
||||
*
|
||||
* In this example, we only require that the name is at least four
|
||||
* characters. In your application, you can use more complex checks to ensure
|
||||
* that usernames, passwords, email addresses, URLs, and other fields have the
|
||||
* proper syntax.
|
||||
*
|
||||
* @param name the name to validate
|
||||
* @return true if valid, false if invalid
|
||||
*/
|
||||
public static boolean isValidName(String name) {
|
||||
if (name == null) {
|
||||
return false;
|
||||
}
|
||||
return name.length() > 3;
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+23
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to='com_sap_sailing_gwt_ui'>
|
||||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name='com.google.gwt.user.User'/>
|
||||
|
||||
<!-- Inherit the default GWT style sheet. You can change -->
|
||||
<!-- the theme of your GWT application by uncommenting -->
|
||||
<!-- any one of the following lines. -->
|
||||
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
|
||||
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
<!-- Other module inherits -->
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point class='com.sap.sailing.gwt.ui.client.Com_sap_sailing_gwt_ui'/>
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client'/>
|
||||
<source path='shared'/>
|
||||
|
||||
</module>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user