Added PGF.parse method to GWT client.

This commit is contained in:
bjorn
2008-10-22 19:59:43 +00:00
parent 7c914d39cb
commit 8872b0b010
2 changed files with 28 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ pgf.fcgi:
gwt:
gwt/Translate-compile
gf-gwt.jar: gwt
gf-gwt.jar:
jar -cf $@ -C gwt/src se
cp $@ ../../lib/java

View File

@@ -154,6 +154,33 @@ public class PGF {
public final native String getText() /*-{ return this.text; }-*/;
}
/* Parsing */
public PGFRequest parse (String input, List<String> fromLangs, String cat, final ParseCallback callback) {
List<Arg> args = new ArrayList<Arg>();
args.add(new Arg("input", input));
if (fromLangs != null) {
for (String from : fromLangs) {
args.add(new Arg("from", from));
}
}
args.add(new Arg("cat", cat));
return sendRequest("parse", args, callback);
}
public interface ParseCallback extends GFCallback<ParseResults> { }
public static class ParseResults extends IterableJsArray<ParseResult> {
protected ParseResults() { }
}
public static class ParseResult extends JavaScriptObject {
protected ParseResult() { }
public final native String getFrom() /*-{ return this.from; }-*/;
public final native String getTree() /*-{ return this.tree; }-*/;
}
/* Utilities */
private <T extends JavaScriptObject> PGFRequest sendRequest (String resource, List<Arg> vars, final GFCallback<T> callback) {