Skip to content

Commit

Permalink
changed events objects to JSNI to correct ClassCastException
Browse files Browse the repository at this point in the history
  • Loading branch information
zak905 committed Jul 27, 2016
1 parent 669ff6c commit 898da51
Show file tree
Hide file tree
Showing 16 changed files with 565 additions and 393 deletions.
19 changes: 13 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<packaging>gwt-lib</packaging>

<properties>
<gwtVersion>2.8.0-beta1</gwtVersion>
<gwtVersion>2.8.0-SNAPSHOT</gwtVersion>
</properties>

<developers>
Expand All @@ -33,11 +33,18 @@
</scm>

<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.jsinterop</groupId>
<artifactId>jsinterop-annotations</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
public class DOMMouseEvent {

@JsProperty
public long screenX;
public int screenX;

@JsProperty
public long screenY;
public int screenY;

@JsProperty
public long clientX;
public int clientX;

@JsProperty
public long clientY;
public int clientY;

@JsProperty
public Boolean ctrlKey;
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/gwidgets/api/leaflet/elemental/Document.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.gwidgets.api.leaflet.elemental;

import static jsinterop.annotations.JsPackage.GLOBAL;

import jsinterop.annotations.JsType;

@JsType(isNative=true, name = "document", namespace = GLOBAL)
public class Document extends Node {

private Document(){}

public static native HTMLElement getElementById(String id);

}
12 changes: 4 additions & 8 deletions src/main/java/com/gwidgets/api/leaflet/elemental/Element.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.gwidgets.api.leaflet.elemental;

import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;

@JsType(isNative=true)
public class Element {

@JsMethod
public native String getInnerHTML();
@JsMethod
public native void setInnerHTML(String s);



@JsProperty
public String innerHTML;

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.gwidgets.api.leaflet.elemental;

import com.google.gwt.core.client.JavaScriptObject;
import com.gwidgets.api.leaflet.events.Event;

import com.google.gwt.core.client.JavaScriptObject;
import jsinterop.annotations.JsFunction;


@JsFunction
public interface Function {
public interface Function{

public JavaScriptObject call(Event event, JavaScriptObject...args);
public JavaScriptObject call(JavaScriptObject event);

}
105 changes: 60 additions & 45 deletions src/main/java/com/gwidgets/api/leaflet/events/ErrorEvent.java
Original file line number Diff line number Diff line change
@@ -1,55 +1,70 @@
package com.gwidgets.api.leaflet.events;

import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;

import com.google.gwt.core.client.JavaScriptObject;
import com.gwidgets.api.leaflet.LatLng;
import com.gwidgets.api.leaflet.LatLngBounds;
import com.gwidgets.api.leaflet.Point;
import com.gwidgets.api.leaflet.elemental.DOMMouseEvent;

@JsType(isNative = true)
public class ErrorEvent extends Event {


@JsProperty
public Point layerPoint;

@JsProperty
public Point containerPoint;

@JsProperty
public DOMMouseEvent originalEvent;

@JsProperty
public LatLng latlng;

@JsProperty
public LatLngBounds bounds;

@JsProperty
public Number accuracy;

@JsProperty
public Number altitude;

@JsProperty
public Number altitudeAccuracy;

@JsProperty
public Number heading;

@JsProperty
public Number speed;

@JsProperty
public Number timestamp;

@JsProperty
public String message;
import jsinterop.annotations.JsType;

@JsProperty
public Number code;
@JsType
public class ErrorEvent extends Event {

protected ErrorEvent(){


}

public final native Point getLayerPoint() /*-{
return this.layerPoint;
}-*/;

public final native Point getContainerPoint() /*-{
return this.containerPoint;
}-*/;

public final native DOMMouseEvent getOriginalEvent() /*-{
return this.originalEvent;
}-*/;

public final native LatLng getLatlng() /*-{
return this.latlng;
}-*/;

public final native LatLngBounds getBounds() /*-{
return this.bounds;
}-*/;

public final native Number getAccuracy() /*-{
return this.accuracy;
}-*/;

public final native Number getAltitude() /*-{
return this.altitude;
}-*/;

public final native Number getAltitudeAccuracy() /*-{
return this.altitudeAccuracy;
}-*/;

public final native Number getHeading() /*-{
return this.heading;
}-*/;

public final native Number getSpeed() /*-{
return this.speed;
}-*/;

public final native Number getTimestamp() /*-{
return this.timestamp;
}-*/;

public final native String getMessage() /*-{
return this.message;
}-*/;

public final native Number getCode() /*-{
return this.code;
}-*/;

}
24 changes: 17 additions & 7 deletions src/main/java/com/gwidgets/api/leaflet/events/Event.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
package com.gwidgets.api.leaflet.events;

import com.google.gwt.core.client.JavaScriptObject;
import com.gwidgets.api.leaflet.elemental.HTMLElement;

import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;

@JsType(isNative = true)
public class Event {
@JsType
public class Event extends JavaScriptObject {

protected Event(){


}

public final native String getType() /*-{
return this.target;
}-*/;

@JsProperty
public String type;
public final native HTMLElement getTarget() /*-{
return this.target;
}-*/;

@JsProperty
public JavaScriptObject target;



}
Loading

0 comments on commit 898da51

Please sign in to comment.