From 4fdd21f1273e75b84e87c49b95b02e9fc149b5c0 Mon Sep 17 00:00:00 2001 From: krasimir Date: Tue, 13 Jul 2010 15:33:54 +0000 Subject: detailed information for the type errors from PGFService --- src/ui/gwt/Editor-compile | 2 ++ src/ui/gwt/Translate-compile | 3 +++ .../ui/gwt/client/FridgeApp.java | 4 ++-- .../grammaticalframework/ui/gwt/client/PGF.java | 26 ++++++++++++++++++---- .../ui/gwt/client/TranslateApp.java | 13 +++++++---- .../ui/gwt/public/Translate.css | 4 ++++ 6 files changed, 42 insertions(+), 10 deletions(-) (limited to 'src/ui') diff --git a/src/ui/gwt/Editor-compile b/src/ui/gwt/Editor-compile index 4106298ea..d054d16ad 100644 --- a/src/ui/gwt/Editor-compile +++ b/src/ui/gwt/Editor-compile @@ -1,6 +1,8 @@ #!/bin/sh APPDIR=`dirname $0`; +GWT_DIR="/home/angelov/gwt-2.0.4" +GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev.jar" if [ -z "$GWT_CLASSPATH" ]; then echo 'ERROR: $GWT_CLASSPATH is not set' diff --git a/src/ui/gwt/Translate-compile b/src/ui/gwt/Translate-compile index 220cf4a46..c2fbca65c 100644 --- a/src/ui/gwt/Translate-compile +++ b/src/ui/gwt/Translate-compile @@ -2,6 +2,9 @@ APPDIR=`dirname $0`; +GWT_DIR="/home/angelov/gwt-2.0.4" +GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev.jar" + if [ -z "$GWT_CLASSPATH" ]; then echo 'ERROR: $GWT_CLASSPATH is not set' echo 'Set $GWT_CLASSPATH to point to the GWT JAR files. For example:' diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeApp.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeApp.java index c54bb4ddb..886679b04 100644 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeApp.java +++ b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeApp.java @@ -54,10 +54,10 @@ public class FridgeApp implements EntryPoint { } if (tr.getTypeErrors() != null) - for (String error : tr.getTypeErrors()) { + for (PGF.TcError error : tr.getTypeErrors()) { SimplePanel panel = new SimplePanel(); panel.addStyleName("my-typeError"); - panel.add(new HTML("
"+error+"
")); + panel.add(new HTML("
"+error.getMsg()+"
")); outputPanel.add(panel); } } diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/PGF.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/PGF.java index 41e77539c..5a1a9e873 100644 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/PGF.java +++ b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/PGF.java @@ -63,9 +63,9 @@ public class PGF { protected TranslationResult() { } public final native String getFrom() /*-{ return this.from; }-*/; - public final native String getBracketedString() /*-{ return this.brackets; }-*/; + public final native BracketedString getBracketedString() /*-{ return this.brackets; }-*/; public final native IterableJsArray getTranslations() /*-{ return this.translations; }-*/; - public final native String[] getTypeErrors() /*-{ return this.typeErrors; }-*/; + public final native TcError[] getTypeErrors() /*-{ return this.typeErrors; }-*/; } public static class Translation extends JavaScriptObject { @@ -137,9 +137,27 @@ public class PGF { protected ParseResult() { } public final native String getFrom() /*-{ return this.from; }-*/; - public final native String getBracketedString() /*-{ return this.brackets; }-*/; + public final native BracketedString getBracketedString() /*-{ return this.brackets; }-*/; public final native String[] getTrees() /*-{ return this.trees; }-*/; - public final native String[] getTypeErrors() /*-{ return this.typeErrors; }-*/; + public final native TcError[] getTypeErrors() /*-{ return this.typeErrors; }-*/; + } + + public static class BracketedString extends JavaScriptObject { + protected BracketedString() { } + + public final native String getToken() /*-{ return this.token; }-*/; + + public final native String getCat() /*-{ return this.cat; }-*/; + public final native int getFId() /*-{ return this.fid; }-*/; + public final native int getIndex() /*-{ return this.index; }-*/; + public final native BracketedString[] getChildren() /*-{ return this.children; }-*/; + } + + public static class TcError extends JavaScriptObject { + protected TcError() { } + + public final native int getFId() /*-{ return this.fid; }-*/; + public final native String getMsg() /*-{ return this.msg; }-*/; } public String graphvizAbstractTree(String pgfURL, String abstractTree) { diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/TranslateApp.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/TranslateApp.java index d2ae216ec..2b65a2be7 100644 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/TranslateApp.java +++ b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/TranslateApp.java @@ -66,13 +66,18 @@ public class TranslateApp implements EntryPoint { } } - if (tr.getTypeErrors() != null) - for (String error : tr.getTypeErrors()) { - SimplePanel panel = new SimplePanel(); + if (tr.getTypeErrors() != null && tr.getTypeErrors().length > 0) { + for (PGF.TcError error : tr.getTypeErrors()) { + VerticalPanel panel = new VerticalPanel(); panel.addStyleName("my-typeError"); - panel.add(new HTML("
"+error+"
")); + Label errLabel = new Label("Type Error"); + errLabel.addStyleName("my-error-title"); + HTML msgHTML = new HTML("
"+error.getMsg()+"
"); + panel.add(errLabel); + panel.add(msgHTML); outputPanel.add(panel); } + } } } public void onError (Throwable e) { diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Translate.css b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Translate.css index 49efa8c76..dd0ad3091 100644 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Translate.css +++ b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Translate.css @@ -84,6 +84,10 @@ cursor:pointer; } +.my-error-title { + background: #DDDDDD; +} + .my-treeimage { width: 650px; height: 520px; -- cgit v1.2.3