mirror of
https://github.com/vaadin/framework.git
synced 2024-09-13 15:46:01 +02:00
Updated Reservr to use "GALGWT" googlemaps gwt api (compatible w/ gwt 1.5). Removed reservr.html (not needed).
svn changeset:5337/svn branch:trunk
This commit is contained in:
parent
1512e2f330
commit
c4a795fdc8
@ -159,7 +159,7 @@
|
||||
<ul id="demo-buttons">
|
||||
<li id="feature-browser"><a href="FeatureBrowser/">Feature browser</a></li>
|
||||
<li id="notifications"><a href="NotificationDemo/">Notifications</a></li>
|
||||
<li id="reservr"><a href="reservr.html">Reservation application</a></li>
|
||||
<li id="reservr"><a href="Reservr/">Reservation application</a></li>
|
||||
<li id="windowed-demos"><a href="WindowedDemos">Windowed demos</a></li>
|
||||
<li class="clearer"></li> <!-- // simplifies things in JavaScipt -->
|
||||
</ul>
|
||||
|
@ -1,51 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
|
||||
<head>
|
||||
<title>IT Mill Toolkit 5 Demo: Reservr</title>
|
||||
<!--
|
||||
Google Maps needs an API key if you're not running this demo on "localhost".
|
||||
|
||||
You can get a Google Maps API key here:
|
||||
http://www.google.com/apis/maps/signup.html
|
||||
|
||||
Append your Google Maps API key to the src -attribute below, like so:
|
||||
src="http://maps.google.com/maps?file=api&v=2&key=XXXXXXXX"
|
||||
where the X:s represent your key.
|
||||
Example for http://toolkit.itmill.com:
|
||||
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA4q5gw_y_N1Anvvn1KqbLwRTHuC2ERVOT66iQW8-FqpCQQUlHqBTZ0rGKdlKh9fxQOKN87TCwVNlIXQ" type="text/javascript"></script>
|
||||
-->
|
||||
<script src="http://maps.google.com/maps?file=api&v=2" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<span id="logo"> Reservr Inc</span>
|
||||
<span id="arrow"> </span>
|
||||
<span id="slogan">Representational cars on-the-road</span>
|
||||
</div>
|
||||
|
||||
<iframe id="__gwt_historyFrame" style="width:0;height:0;border:0;overflow:hidden" src="javascript:false"></iframe>
|
||||
<script language='javascript' src='ITMILL/widgetsets/com.itmill.toolkit.demo.reservation.gwt.ReservationWidgetSet/com.itmill.toolkit.demo.reservation.gwt.ReservationWidgetSet.nocache.js'></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
if(!itmill || !itmill.toolkitConfigurations) {
|
||||
if(!itmill) { var itmill = {}}
|
||||
itmill.toolkitConfigurations = {};
|
||||
itmill.themesLoaded = {}};
|
||||
itmill.toolkitConfigurations["Reservr"] = {appUri:'../../../Reservr', pathInfo: '/', themeUri:'../../../ITMILL/themes/reservr'};
|
||||
//]]>
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
if(!itmill.themesLoaded['reservr']) {
|
||||
var stylesheet = document.createElement('link');
|
||||
stylesheet.setAttribute('rel', 'stylesheet');
|
||||
stylesheet.setAttribute('type', 'text/css');
|
||||
stylesheet.setAttribute('href', 'ITMILL/themes/reservr/styles.css');
|
||||
document.getElementsByTagName('head')[0].appendChild(stylesheet);
|
||||
itmill.themesLoaded['reservr'] = true;
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<div id="Reservr" class="i-app" ></div>
|
||||
</body>
|
||||
</html>
|
@ -660,11 +660,11 @@
|
||||
</target>
|
||||
|
||||
<target name="compile-widgetset-reserver">
|
||||
<condition property="googlemaps-jar" value="${output-dir}/WebContent/demo/lib/reservr/googlemaps_gwt.jar">
|
||||
<available file="${output-dir}/WebContent/demo/lib/reservr/googlemaps_gwt.jar" />
|
||||
<condition property="googlemaps-jar" value="${output-dir}/WebContent/demo/lib/reservr/gwt-maps.jar">
|
||||
<available file="${output-dir}/WebContent/demo/lib/reservr/gwt-maps.jar" />
|
||||
</condition>
|
||||
<condition property="googlemaps-jar" value="lib/reservr/googlemaps_gwt.jar">
|
||||
<available file="lib/reservr/googlemaps_gwt.jar" />
|
||||
<condition property="googlemaps-jar" value="lib/reservr/gwt-maps.jar">
|
||||
<available file="lib/reservr/gwt-maps.jar" />
|
||||
</condition>
|
||||
<echo>com.itmill.toolkit.demo.reservation.gwt.ReservationWidgetSet</echo>
|
||||
<java classname="com.google.gwt.dev.GWTCompiler" failonerror="yes" fork="yes" maxmemory="512m">
|
||||
|
@ -21,8 +21,6 @@ public class GoogleMap extends AbstractComponent implements Sizeable,
|
||||
Container.Viewer {
|
||||
private final String TAG_MARKERS = "markers";
|
||||
private final String TAG_MARKER = "marker";
|
||||
private int width = 400;
|
||||
private int height = 300;
|
||||
private int zoomLevel = 15;
|
||||
private Point2D.Double mapCenter;
|
||||
|
||||
@ -37,13 +35,20 @@ public class GoogleMap extends AbstractComponent implements Sizeable,
|
||||
|
||||
public void paintContent(PaintTarget target) throws PaintException {
|
||||
super.paintContent(target);
|
||||
// Add size info as variables
|
||||
if (getHeight() > -1) {
|
||||
target.addVariable(this, "height", getHeight()
|
||||
+ UNIT_SYMBOLS[getHeightUnits()]);
|
||||
}
|
||||
if (getWidth() > -1) {
|
||||
target.addVariable(this, "width", getWidth()
|
||||
+ UNIT_SYMBOLS[getWidthUnits()]);
|
||||
}
|
||||
if (null != mapCenter) {
|
||||
target.addAttribute("centerX", mapCenter.getX());
|
||||
target.addAttribute("centerY", mapCenter.getY());
|
||||
}
|
||||
target.addAttribute("zoom", zoomLevel);
|
||||
target.addAttribute("width", width);
|
||||
target.addAttribute("height", height);
|
||||
|
||||
if (dataSource != null) {
|
||||
target.startTag(TAG_MARKERS);
|
||||
@ -81,40 +86,14 @@ public class GoogleMap extends AbstractComponent implements Sizeable,
|
||||
|
||||
// Sizeable methods:
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public int getHeightUnits() {
|
||||
return Sizeable.UNITS_PIXELS;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getWidthUnits() {
|
||||
return Sizeable.UNITS_PIXELS;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = height;
|
||||
requestRepaint();
|
||||
}
|
||||
|
||||
public void setHeightUnits(int units) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
requestRepaint();
|
||||
}
|
||||
|
||||
public void setWidthUnits(int units) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setMapCenter(Point2D.Double center) {
|
||||
mapCenter = center;
|
||||
}
|
||||
@ -221,13 +200,4 @@ public class GoogleMap extends AbstractComponent implements Sizeable,
|
||||
setContainerDataSource(null);
|
||||
}
|
||||
|
||||
public void setSizeFull() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void setSizeUndefined() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
@ -90,7 +90,7 @@ public class ReservationApplication extends Application {
|
||||
resourceName.setCaption("Choose resource");
|
||||
infoLayout.addComponent(resourceName);
|
||||
description = new TextField();
|
||||
description.setColumns(20);
|
||||
description.setWidth("250px");
|
||||
description.setRows(5);
|
||||
infoLayout.addComponent(description);
|
||||
reservationButton = new Button("Make reservation", this,
|
||||
@ -98,10 +98,8 @@ public class ReservationApplication extends Application {
|
||||
infoLayout.addComponent(reservationButton);
|
||||
|
||||
map = new GoogleMap();
|
||||
// TODO support EM
|
||||
// map.setWidthUnits(Size.UNITS_EM);
|
||||
map.setWidth(266);
|
||||
map.setHeight(210);
|
||||
map.setWidth("250px");
|
||||
map.setHeight("250px");
|
||||
map.setItemMarkerHtmlPropertyId(SampleDB.Resource.PROPERTY_ID_NAME);
|
||||
map.setItemMarkerXPropertyId(SampleDB.Resource.PROPERTY_ID_LOCATIONX);
|
||||
map.setItemMarkerYPropertyId(SampleDB.Resource.PROPERTY_ID_LOCATIONY);
|
||||
|
@ -3,11 +3,24 @@
|
||||
<inherits name="com.itmill.toolkit.terminal.gwt.DefaultWidgetSetNoEntry" />
|
||||
|
||||
<!-- The googlemaps_gwt module -->
|
||||
<inherits name="com.mapitz.gwt.googleMaps.GoogleMaps" />
|
||||
<inherits name="com.google.gwt.maps.GoogleMaps" />
|
||||
|
||||
<!-- WidgetSet default theme -->
|
||||
<stylesheet src="reservr/styles.css"/>
|
||||
|
||||
<!--
|
||||
Google Maps needs an API key if you're not running this demo on "localhost".
|
||||
You can get a Google Maps API key here:
|
||||
http://www.google.com/apis/maps/signup.html
|
||||
|
||||
Append your Google Maps API key to the src -attribute below, like so:
|
||||
src="http://maps.google.com/maps?gwt=1&file=api&v=2.x&key=XXXXXXXX"
|
||||
where the X:s represent your key.
|
||||
Example for http://toolkit.itmill.com:
|
||||
<script src="http://maps.google.com/maps?gwt=1&file=api&v=2.x&key=ABQIAAAA4q5gw_y_N1Anvvn1KqbLwRTHuC2ERVOT66iQW8-FqpCQQUlHqBTZ0rGKdlKh9fxQOKN87TCwVNlIXQ" type="text/javascript"></script>
|
||||
-->
|
||||
<script src="http://maps.google.com/maps?gwt=1&file=api&v=2.x" />
|
||||
|
||||
<!-- Entry point -->
|
||||
<entry-point class="com.itmill.toolkit.demo.reservation.gwt.client.ReservationWidgetSet"/>
|
||||
|
||||
|
@ -6,36 +6,35 @@ package com.itmill.toolkit.demo.reservation.gwt.client.ui;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.google.gwt.maps.client.InfoWindowContent;
|
||||
import com.google.gwt.maps.client.MapWidget;
|
||||
import com.google.gwt.maps.client.control.SmallMapControl;
|
||||
import com.google.gwt.maps.client.event.MarkerClickHandler;
|
||||
import com.google.gwt.maps.client.geom.LatLng;
|
||||
import com.google.gwt.maps.client.overlay.Marker;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
|
||||
import com.itmill.toolkit.terminal.gwt.client.Paintable;
|
||||
import com.itmill.toolkit.terminal.gwt.client.UIDL;
|
||||
import com.mapitz.gwt.googleMaps.client.GControl;
|
||||
import com.mapitz.gwt.googleMaps.client.GLatLng;
|
||||
import com.mapitz.gwt.googleMaps.client.GMap2;
|
||||
import com.mapitz.gwt.googleMaps.client.GMap2EventManager;
|
||||
import com.mapitz.gwt.googleMaps.client.GMap2Widget;
|
||||
import com.mapitz.gwt.googleMaps.client.GMarker;
|
||||
import com.mapitz.gwt.googleMaps.client.GMarkerEventClickListener;
|
||||
import com.mapitz.gwt.googleMaps.client.GMarkerEventManager;
|
||||
|
||||
public class IGoogleMap extends GMap2Widget implements Paintable {
|
||||
public class IGoogleMap extends Composite implements Paintable {
|
||||
|
||||
public static final String CLASSNAME = "i-googlemap";
|
||||
|
||||
GMap2EventManager mapEventManager;
|
||||
GMarkerEventManager markerEventManager;
|
||||
GMap2 map;
|
||||
private final MapWidget widget = new MapWidget();
|
||||
|
||||
public IGoogleMap() {
|
||||
initWidget(widget);
|
||||
setWidth("200px");
|
||||
setHeight("200px");
|
||||
setStyleName(CLASSNAME);
|
||||
mapEventManager = GMap2EventManager.getInstance();
|
||||
map = getGmap();
|
||||
map.addControl(GControl.GSmallZoomControl());
|
||||
widget.addControl(new SmallMapControl());
|
||||
|
||||
}
|
||||
|
||||
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
|
||||
map.clearOverlays();
|
||||
GLatLng pos = null;
|
||||
widget.clearOverlays();
|
||||
LatLng pos = null;
|
||||
for (final Iterator it = uidl.getChildIterator(); it.hasNext();) {
|
||||
final UIDL u = (UIDL) it.next();
|
||||
if (u.getTag().equals("markers")) {
|
||||
@ -46,9 +45,9 @@ public class IGoogleMap extends GMap2Widget implements Paintable {
|
||||
+ umarker.getStringAttribute("html") + "</span>";
|
||||
final double x = umarker.getDoubleAttribute("x");
|
||||
final double y = umarker.getDoubleAttribute("y");
|
||||
pos = new GLatLng(x, y);
|
||||
final GMarker marker = new GMarker(pos);
|
||||
map.addOverlay(marker);
|
||||
pos = new LatLng(x, y);
|
||||
final Marker marker = new Marker(pos);
|
||||
widget.addOverlay(marker);
|
||||
if (html != null) {
|
||||
addMarkerPopup(marker, html);
|
||||
}
|
||||
@ -56,48 +55,37 @@ public class IGoogleMap extends GMap2Widget implements Paintable {
|
||||
}
|
||||
}
|
||||
if (uidl.hasAttribute("width")) {
|
||||
setWidth("" + uidl.getIntAttribute("width"));
|
||||
widget.setWidth(uidl.getStringAttribute("width"));
|
||||
}
|
||||
if (uidl.hasAttribute("height")) {
|
||||
setHeight("" + uidl.getIntAttribute("height"));
|
||||
widget.setHeight(uidl.getStringAttribute("height"));
|
||||
}
|
||||
if (uidl.hasAttribute("zoom")) {
|
||||
map.setZoom(uidl.getIntAttribute("zoom"));
|
||||
widget.setZoomLevel(uidl.getIntAttribute("zoom"));
|
||||
}
|
||||
if (uidl.hasAttribute("centerX") && uidl.hasAttribute("centerY")) {
|
||||
final GLatLng center = new GLatLng(uidl
|
||||
.getDoubleAttribute("centerX"), uidl
|
||||
final LatLng center = new LatLng(
|
||||
uidl.getDoubleAttribute("centerX"), uidl
|
||||
.getDoubleAttribute("centerY"));
|
||||
map.setCenter(center);
|
||||
widget.setCenter(center);
|
||||
} else if (pos != null) {
|
||||
// use last marker position
|
||||
map.setCenter(pos);
|
||||
widget.setCenter(pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addMarkerPopup(GMarker marker, String html) {
|
||||
if (markerEventManager == null) {
|
||||
markerEventManager = GMarkerEventManager.getInstance();
|
||||
}
|
||||
private void addMarkerPopup(Marker marker, final String html) {
|
||||
marker.addMarkerClickHandler(new MarkerClickHandler() {
|
||||
|
||||
markerEventManager.addOnClickListener(marker, new MarkerEventListener(
|
||||
html));
|
||||
public void onClick(MarkerClickEvent event) {
|
||||
widget.getInfoWindow().open(event.getSender().getPoint(),
|
||||
new InfoWindowContent(html));
|
||||
|
||||
}
|
||||
|
||||
private class MarkerEventListener implements GMarkerEventClickListener {
|
||||
String html;
|
||||
});
|
||||
|
||||
public MarkerEventListener(String html) {
|
||||
this.html = html;
|
||||
}
|
||||
|
||||
public void onClick(GMarker marker) {
|
||||
marker.openInfoWindowHtml(html);
|
||||
}
|
||||
|
||||
public void onDblClick(GMarker marker) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user