Created
December 3, 2010 16:03
-
-
Save jawher/727141 to your computer and use it in GitHub Desktop.
GWT JSNI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gwt.core.client.JavaScriptObject; | |
public final class FsItem extends JavaScriptObject { | |
protected FsItem() { | |
} | |
public native FsItem init(boolean folder, String absoluteName, String name, int size) /*-{ | |
this.folder = folder; | |
this.absoluteName = absoluteName; | |
this.name = name; | |
this.size = size; | |
return this; | |
}-*/; | |
public native boolean isFolder() /*-{ return this.folder }-*/; | |
public native String getAbsoluteName()/*-{ return this.absoluteName }-*/; | |
public native String getName() /*-{ return this.name }-*/; | |
public native int getSize()/*-{ return this.size }-*/; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gwt.core.client.JavaScriptObject; | |
public class JsArray<E extends JavaScriptObject> extends JavaScriptObject { | |
protected JsArray() { } | |
public final native int length() /*-{ return this.length; }-*/; | |
public final native E get(int i) /*-{ return this[i]; }-*/; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final native JsArray<FsItem> fsItems(String json) /*-{ | |
return eval('('+json+')'); //important: wrap the json in () | |
}-*/; | |
public static final native FsItem newItem(boolean folder, String absoluteName, String name, int size) /*-{ | |
return eval('({folder: '+folder+', absoluteName: "'+absoluteName+'", name: "'+name+'", size: '+size+' })'); | |
}-*/; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment