Archive for the ‘GWT’ Category

Google maps using GWT – getting directions

Monday, October 25th, 2010


Getting directions, calculating and displaying the route between start point and destination can be easily done using com.google.gwt.maps.client.geocode
All we need is a map object ,a directions pannel then the direction query options
DirectionQueryOptions opts = new DirectionQueryOptions(map,directionsPanel);

The query for direction is a string which looks like “from: departure address to: destination address”.This query will be loaded by the Directions object.

Here’s a simple example (two separate text boxes for entering the from and to addresses ,the root panel contains a grid which includes the map having the route marked and the direction panel) :

package com.gwtmaps.project.client;
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.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.control.LargeMapControl;
import com.google.gwt.maps.client.geocode.DirectionQueryOptions;
import com.google.gwt.maps.client.geocode.DirectionResults;
import com.google.gwt.maps.client.geocode.Directions;
import com.google.gwt.maps.client.geocode.DirectionsCallback;
import com.google.gwt.maps.client.geocode.DirectionsPanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;

/**
* Entry point classes define onModuleLoad().
*/
public class GWTDirections 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 Grid grid = new Grid(1, 2);
grid.setWidth(“100%”);
grid.getCellFormatter().setWidth(0, 0, “74%”);
grid.getCellFormatter().setVerticalAlignment(0,0, HasVerticalAlignment.ALIGN_TOP);
grid.getCellFormatter().setWidth(0, 1, “24%”);
grid.getCellFormatter().setVerticalAlignment(0,1, HasVerticalAlignment.ALIGN_TOP);

final Button sendButton = new Button(“Send”);
final TextBox fromField = new TextBox();
fromField.setText(“Enter Departure”);
fromField.setTitle(“From:”);

final TextBox toField = new TextBox();
toField.setText(“Enter Destination”);
toField.setTitle(“To:”);
// We can add style names to widgets
sendButton.addStyleName(“getMap”);

// Add the nameField and sendButton to the RootPanel
// Use RootPanel.get() to get the entire body element
RootPanel.get().add(fromField);
RootPanel.get().add(toField);
RootPanel.get().add(sendButton);

// Focus the cursor on the name field when the app loads
fromField.setFocus(true);
fromField.selectAll();

// 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) {
//remove preexisting maps
removeExistingMaps();

MapWidget map = new MapWidget();
map.setSize(“500px”, “500px”);

// Add some controls for the zoom level
map.addControl(new LargeMapControl());

//calculate direction

grid.setWidget(0, 0, map);
DirectionsPanel directionsPanel = new DirectionsPanel();
grid.setWidget(0, 1, directionsPanel);
directionsPanel.setSize(“100%”, “100%”);
// Add the map to the HTML host page
RootPanel.get().add(grid);

DirectionQueryOptions opts = new DirectionQueryOptions(map,directionsPanel);
String query = “from: ” +fromField.getText() + ” to: ” + toField.getText();

Directions.load(query , opts, new DirectionsCallback() {
public void onFailure(int statusCode) {

GWT.log(“Failed to load directions: Status ” + statusCode, null);
}

public void onSuccess(DirectionResults result) {
GWT.log(“Succesfully load directions “, null);
}
});

}
private void removeExistingMaps() {
for( int i=1;i
if(RootPanel.get().getWidget(i).getClass().equals(MapWidget.class))
{
MapWidget mapWidget = (MapWidget) RootPanel.get().getWidget(i);
RootPanel.get().remove(mapWidget);
}
}
}
public void onKeyUp(KeyUpEvent event) {

}

}
MyHandler handler = new MyHandler();
sendButton.addClickHandler(handler);

}

}

The entire project can be downloaded from here ( the file GWTDirectionsDemo.zip)
Enjoy :)

Installing GWT Designer

Saturday, October 23rd, 2010

Google Web Toolkit Downloads In early August, Google acquired Instantiations, a company known for its focus on Eclipse Java developer tools, including GWT Designer. We’re happy to announce today that we’re relaunching the following former Instantiations products under the Google name and making them available to all developers at no charge:

SDK

The Google Web Toolkit SDK contains the core libraries and compiler that you need to write web applications. See the Release Notes for this latest version.

Speed Tracer

Speed Tracer is a Chrome Extension that allows you to pinpoint performance problems in your web applications.

Plugin for Eclipse

The Google Plugin for Eclipse provides IDE support for Google Web Toolkit and App Engine web projects.

GWT Designer

Create rich web applications with GWT Designer, a powerful set of Eclipse-based development tools that enables Java developers to quickly create Ajax web applications using the Google Web Toolkit (GWT).

Other Java Tools

WindowBuilder Pro

Develop Java graphical user interfaces in minutes for Swing, SWT, RCP, XWT and GWT with WindowBuilder Pro’s WYSIWYG, drag-and-drop interface. Use wizards, editors and intelligent layout assist to automatically generate clean Java code, with the visual design and source always in sync.

WindowTester Pro

Streamline testing of Java rich client applications with WindowTester Pro, including tools for automated recording, test generation, code coverage and playback of GUI interactions that can occur within an application. WindowTester Pro includes support for SWT and Swing.

CodePro AnalytiX

Employ the comprehensive automated software code quality and security analysis toolkit CodePro AnalytiX to automatically improve software quality, reliability, and maintainability in developer applications.

Google Web Toolkit (GWT) Resource Center

Friday, October 15th, 2010
Google Web Toolkit Widgets, Plugins, and Tools
Autocompleter GWT Widget
http://jroller.com/page/glongman?entry=gwt_autocompleter

Check out the code for this Autocompleter GWT widget.
Canvas Widget
http://gwt.components.googlepages.com/canvas

Download the Canvas widget and learn how to use it in your GWT classes.
GWT-Components
http://sourceforge.net/projects/gwt-components

Download and contribute to the GWT-Components—a collection of GWT extensions.
GWT Addons
http://sourceforge.net/projects/gwtaddons

Download the GWT Addons including a rich text editor and more.
SpringGWT
http://sourceforge.net/projects/spring-gwt

Download the SpringGWT for use in client-side application development using the GWT.
Project Dune Quality Support System
http://sourceforge.net/projects/pdune

Download the Project Dune Quality Support System, built with the Google Web Toolkit and other technologies.
Java Applet Web Server (AppletServer)
http://sourceforge.net/projects/appletserver

Download the Java Applet Web Server (AppletServer). Use the GWT and allows you to run Java applets on the server-side and automatically generate AJAX for the browser.
Google Web Toolkit Hacks
http://sourceforge.net/projects/gwt-hacks

Download the Google Web Toolkit Hacks. Includes widgets, plugins, AJAX applets and games based on the GWT.
Openfount
http://www.openfount.com/

Download the Openfount Google Web Toolkit. Features include XML classes, SOAP classes, crypto classes, Base64 classes, Amazon S3 classes, Amazon Simple Queue Service classes, and SOAP classes for the Openfount Queued Server.
IntelliJ IDEA Studio Plugin
http://www.jetbrains.net/confluence/display/IDEADEV/GWT+Studio+plugin

Download the GWT Studio plugin for IntelliJ IDEA. Site includes a demo, a description of the GWT Studio and a walkthrough of its features.
Eclipse GWT Plugin
http://sourceforge.net/projects/eclipse-gwt

Download the Eclipse GWT plugin.
Googlipse
http://www.googlipse.com/

Googlipse is an Eclipse plugin for the Google Web Toolkit. Find downloads, documentation, a FAQ and more.
GWT Widget Library
http://gwt-widget.sourceforge.net/

Check out the GWT Widget Library. Includes widgets, utilities and wrappers. Also find demos, a source reference and more.
Open Source Widgets
http://gwt.components.googlepages.com/

Collection of open source Google Web Toolkit widgets.
Google Web Toolkit Widget Gallery
http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.UserInterface.WidgetGallery.html

Google Web Toolkit’s Widget Gallery. Here you will find widgets for a normal button, a radio button, a check box, text box, password text box, text area, hyperlink, list box, menu bar , tree, table, tab bar, dialog box, popup panel, stack panel, horizontal panel, vertical panel, flow panel, dock panel, and tab panel.

Google Web Toolkit Tutorials and Demos

Friday, October 15th, 2010
Google Web Toolkit Tutorials and Demos
“Step by Step: A Mortgage Calculator using GWT”
http://www.mooreds.com/weblog/archives/000348.html

Tutorial: “Step by Step: A Mortgage Calculator using GWT,” by Dan Moore of Moore Consulting.
GWT Integration Tutorial
http://angel.hurtado.googlepages.com/tutorialgwt2

Tutorial discusses how to integrate GWT with an Apache, MySQL and PHP back end.
IntelliJ Idea Animated Demo
http://download.jetbrains.com/idea/GWT.htm?version=1

Animated demo walks through the configuration of IntelliJ Idea for the Google Web Toolkit and shows how to write a GWT image viewer application.
“Kickstarting Google Web Toolkit on the Client Sid
http://today.java.net/pub/a/today/2006/06/27/client-side-google-web-toolkit.html

Tutorial: “Kickstarting Google Web Toolkit on the Client Side” by Simon Morris, provides an introduction to client side development with the GWT. Includes walkthroughs of three projects with sample code.
“Working with the Google Web Toolkit”
http://www.onjava.com/pub/a/onjava/2006/05/31/working-with-google-web-toolkit.html

Tutorial: “Working with the Google Web Toolkit” by Robert Cooper. Topics include getting started with the GWT, project basics, building the table, the history class, the maven module and license concerns. Includes source code for the examples.
“Google Web Toolkit”
http://www.devx.com/webdev/Article/31868

Tutorial: “Google Web Toolkit: AJAX Buzz Meets Real World Development: With its Swing-like development framework and its awe-inspiring compiler/debugger, the GWT eases AJAX development,” by Gautam Shah. Provides introductions to the Google Web Toolkit, AJAX development, GWT components and GWT RPC. Includes source code.
“Jump Start Your AJAX Development with…”
http://google.wikia.com/wiki/Jump_Start_Your_AJAX_Development_with_the_Google_Web_Toolkit

Tutorial: “Jump Start Your AJAX Development with the Google Web Toolkit,” by Tyrell Perera. Topics include an introduction to the GWT, Creating an Eclipse project, importing the project into the Eclipse IDE, running “hello World,” and translating the “Hello World” into JavaScript.
“Google Web Toolkit: the Breakdown”
http://www.juixe.com/techknow/index.php/2006/05/21/google-web-toolkit-tutorial-the-break-down/

Tutorial: “Google Web Toolkit: the Breakdown” walks through the development of an AJAX web application using the Google Web Toolkit.
“Ajax for Java Developers: Exploring the Google…
http://www-128.ibm.com/developerworks/library/j-ajax4/index.html?ca=dgr-lnxw01GWT4Ajax

Tutorial: “Ajax for Java Developers: Exploring the Google Web Toolkit: Develop Ajax applications from a single Java codebase,” by Philip McCarthy.
“Google Web Toolkit”
http://www.xml.com/pub/a/2006/07/12/google-web-toolkit-ajax-java-ant-xml.html

Tutorial: “Google Web Toolkit” by Bruce Perry. Discusses how to develop an AJAX application for Mac OS X using the GWT, Apache Ant, the Tomcat 5.0, and IntelliJ IDEA integrated development environment.
“Working with the Google Web Toolkit”
http://www.onjava.com/pub/a/onjava/2006/05/31/working-with-google-web-toolkit.html

Tutorial: “Working with the Google Web Toolkit” by Robert Cooper. Discusses what the GWT is and how to get started using it.
“Getting started with the Google Web Toolkit”
http://blogs.zdnet.com/Burnette/?p=122

Blog entry: “Getting started with the Google Web Toolkit,” by Ed Burnette, shows you how to get the GWT set up so that you can begin AJAX development.
“Google Web Toolkit Getting Started Guide”
http://code.google.com/webtoolkit/gettingstarted.html

Tutorial: “Google Web Toolkit Getting Started Guide.” Discusses installing the GWT, building a sample application, running in hosted mode, running in Web mode, and creating an application from scratch with and without Eclipse.

GWT Sample Applications and Source Code

Friday, October 15th, 2010
Google Web Toolkit Sample Applications and Source Code
RSS Reader Application
http://ajax.lodgon.com/demo1.html

RSS Reader application built with the GWT. Includes a demo and source code.
RPC Hello Source Code and Walkthrough
http://ajax.lodgon.com/hello.html

Source code and walkthrough of an RPC Hello example.
GWT Application Source Code
http://roberthanson.blogspot.com/2006/06/trivial-gwt-example.html

Source code for a simple GWT application.
GWT Application Sample Code
http://www.bigbold.com/snippets/tag/gwt

Sample code for a simple GWT application using the Mouse Wheel feature.
Photo Sharing Site
http://www.mynetimages.com/

Free photo sharing site developed using the Google Web toolkit.
Kitchen Sink Example Project
http://code.google.com/webtoolkit/documentation/examples/kitchensink/

Kitchen Sink example project built with the Google Web Toolkit using the UI widgets and history management features. This example demonstrates features including buttons, menus, images, layouts, lists, popups, tables, text, trees, frames and tabs. Includes a demo of the application and source code.
JSON RPC Example Project
http://code.google.com/webtoolkit/documentation/examples/jsonrpc/

JSON RPC example project built with the Google Web Toolkit using the UI widgets, JSNI (JavaScript Native Interface) and RPC features. Includes a demo of the application and source code.
Desktop App Clone Example Project
http://code.google.com/webtoolkit/documentation/examples/desktopclone/

Desktop App Clone example project built with the Google Web Toolkit using the UI widgets and history management features. Includes a demo of the application and source code.
Dynamic Table Example Project
http://code.google.com/webtoolkit/documentation/examples/dynamictable/

Dynamic Table example project built with the Google Web Toolkit using the UI widgets and polymorphic RPC features. Includes a demo of the application and source code.
“Hello World” Example
http://code.google.com/webtoolkit/documentation/examples/helloworld/

“Hello World” example project built with the Google Web Toolkit using the UI widgets feature. Includes a demo of the application and source code.
Google Web Toolkit Example Applications
http://code.google.com/webtoolkit/documentation/examples/

Google Web Toolkit Example Applications page includes several sample applications built with the GWT. View a demo of the application, download the source code and check out the list of GWT features used to build the application.
Animated Poker
http://www.gpokr.com/

Animated poker game built using the Google Web Toolkit.
Hangman
http://octagonsoftware.com/home/mark/gwthangman/

Check out this game of hangman, by Mark Roth, built using the Google Web toolkit.