mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-20 00:22:51 -06:00
FridgeApp and TranslateApp now show the type errors
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
APPDIR=`dirname $0`;
|
||||
|
||||
GWT_DIR="/home/angelov/gwt-linux-1.5.3"
|
||||
GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev-linux.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:'
|
||||
|
||||
@@ -5,18 +5,8 @@ import java.util.List;
|
||||
import com.allen_sauer.gwt.dnd.client.PickupDragController;
|
||||
import com.allen_sauer.gwt.dnd.client.drop.DropController;
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.user.client.History;
|
||||
import com.google.gwt.user.client.HistoryListener;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.WindowResizeListener;
|
||||
import com.google.gwt.user.client.ui.ChangeListener;
|
||||
import com.google.gwt.user.client.ui.ClickListener;
|
||||
import com.google.gwt.user.client.ui.DockPanel;
|
||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwt.user.client.*;
|
||||
import com.google.gwt.user.client.ui.*;
|
||||
|
||||
|
||||
public class FridgeApp implements EntryPoint {
|
||||
@@ -57,10 +47,21 @@ public class FridgeApp implements EntryPoint {
|
||||
new PGF.TranslateCallback() {
|
||||
public void onResult (PGF.Translations translations) {
|
||||
outputPanel.removeStyleDependentName("working");
|
||||
for (PGF.Translation t : translations.iterable()) {
|
||||
for (PGF.Linearization l : t.getLinearizations().iterable()) {
|
||||
outputPanel.add(createTranslation(l.getTo(), l.getText()));
|
||||
}
|
||||
for (PGF.TranslationResult tr : translations.iterable()) {
|
||||
if (tr.getTranslations() != null)
|
||||
for (PGF.Translation t : tr.getTranslations().iterable()) {
|
||||
for (PGF.Linearization l : t.getLinearizations().iterable()) {
|
||||
outputPanel.add(createTranslation(l.getTo(), l.getText()));
|
||||
}
|
||||
}
|
||||
|
||||
if (tr.getTypeErrors() != null)
|
||||
for (String error : tr.getTypeErrors()) {
|
||||
SimplePanel panel = new SimplePanel();
|
||||
panel.addStyleName("my-typeError");
|
||||
panel.add(new HTML("<pre>"+error+"</pre>"));
|
||||
outputPanel.add(panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onError (Throwable e) {
|
||||
|
||||
@@ -55,14 +55,22 @@ public class PGF {
|
||||
|
||||
public interface TranslateCallback extends JSONCallback<Translations> { }
|
||||
|
||||
public static class Translations extends IterableJsArray<Translation> {
|
||||
public static class Translations extends IterableJsArray<TranslationResult> {
|
||||
protected Translations() { }
|
||||
}
|
||||
|
||||
public static class TranslationResult extends JavaScriptObject {
|
||||
protected TranslationResult() { }
|
||||
|
||||
public final native String getFrom() /*-{ return this.from; }-*/;
|
||||
public final native String getBracketedString() /*-{ return this.brackets; }-*/;
|
||||
public final native IterableJsArray<Translation> getTranslations() /*-{ return this.translations; }-*/;
|
||||
public final native String[] getTypeErrors() /*-{ return this.typeErrors; }-*/;
|
||||
}
|
||||
|
||||
public static class Translation extends JavaScriptObject {
|
||||
protected Translation() { }
|
||||
|
||||
public final native String getFrom() /*-{ return this.from; }-*/;
|
||||
public final native String getTree() /*-{ return this.tree; }-*/;
|
||||
public final native Linearizations getLinearizations() /*-{ return this.linearizations; }-*/;
|
||||
}
|
||||
@@ -129,7 +137,9 @@ public class PGF {
|
||||
protected ParseResult() { }
|
||||
|
||||
public final native String getFrom() /*-{ return this.from; }-*/;
|
||||
public final native String getTree() /*-{ return this.tree; }-*/;
|
||||
public final native String getBracketedString() /*-{ return this.brackets; }-*/;
|
||||
public final native String[] getTrees() /*-{ return this.trees; }-*/;
|
||||
public final native String[] getTypeErrors() /*-{ return this.typeErrors; }-*/;
|
||||
}
|
||||
|
||||
public String graphvizAbstractTree(String pgfURL, String abstractTree) {
|
||||
|
||||
@@ -45,25 +45,36 @@ public class TranslateApp implements EntryPoint {
|
||||
public void onResult (PGF.Translations translations) {
|
||||
outputPanel.clear();
|
||||
outputPanel.removeStyleDependentName("working");
|
||||
for (PGF.Translation t : translations.iterable()) {
|
||||
HorizontalPanel hPanel = new HorizontalPanel();
|
||||
hPanel.addStyleName("my-translation-frame");
|
||||
VerticalPanel linsPanel = new VerticalPanel();
|
||||
linsPanel.addStyleName("my-translation-bar");
|
||||
hPanel.add(linsPanel);
|
||||
HorizontalPanel btnPanel = new HorizontalPanel();
|
||||
btnPanel.addStyleName("my-translation-btns");
|
||||
btnPanel.setSpacing(4);
|
||||
btnPanel.add(createAbsTreeButton(t.getTree()));
|
||||
btnPanel.add(createAlignButton(t.getTree()));
|
||||
hPanel.add(btnPanel);
|
||||
hPanel.setCellHorizontalAlignment(btnPanel,
|
||||
HasHorizontalAlignment.ALIGN_RIGHT);
|
||||
outputPanel.add(hPanel);
|
||||
for (PGF.TranslationResult tr : translations.iterable()) {
|
||||
if (tr.getTranslations() != null)
|
||||
for (PGF.Translation t : tr.getTranslations().iterable()) {
|
||||
HorizontalPanel hPanel = new HorizontalPanel();
|
||||
hPanel.addStyleName("my-translation-frame");
|
||||
VerticalPanel linsPanel = new VerticalPanel();
|
||||
linsPanel.addStyleName("my-translation-bar");
|
||||
hPanel.add(linsPanel);
|
||||
HorizontalPanel btnPanel = new HorizontalPanel();
|
||||
btnPanel.addStyleName("my-translation-btns");
|
||||
btnPanel.setSpacing(4);
|
||||
btnPanel.add(createAbsTreeButton(t.getTree()));
|
||||
btnPanel.add(createAlignButton(t.getTree()));
|
||||
hPanel.add(btnPanel);
|
||||
hPanel.setCellHorizontalAlignment(btnPanel,
|
||||
HasHorizontalAlignment.ALIGN_RIGHT);
|
||||
outputPanel.add(hPanel);
|
||||
|
||||
for (PGF.Linearization l : t.getLinearizations().iterable()) {
|
||||
linsPanel.add(createTranslation(l.getTo(), t.getTree(), l.getText()));
|
||||
}
|
||||
for (PGF.Linearization l : t.getLinearizations().iterable()) {
|
||||
linsPanel.add(createTranslation(l.getTo(), t.getTree(), l.getText()));
|
||||
}
|
||||
}
|
||||
|
||||
if (tr.getTypeErrors() != null)
|
||||
for (String error : tr.getTypeErrors()) {
|
||||
SimplePanel panel = new SimplePanel();
|
||||
panel.addStyleName("my-typeError");
|
||||
panel.add(new HTML("<pre>"+error+"</pre>"));
|
||||
outputPanel.add(panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onError (Throwable e) {
|
||||
|
||||
@@ -71,6 +71,13 @@ body {
|
||||
margin: 0.2em;
|
||||
}
|
||||
|
||||
.my-typeError {
|
||||
padding: 6px;
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
background: #B9BEC0;
|
||||
}
|
||||
|
||||
.my-SettingsPanel {
|
||||
width: 100%;
|
||||
padding: 0.5em 0;
|
||||
|
||||
@@ -72,6 +72,13 @@
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.my-typeError {
|
||||
padding: 12px;
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
background: #CDFFDA;
|
||||
}
|
||||
|
||||
.my-translation-btns {
|
||||
background: #DDDDDD;
|
||||
cursor:pointer;
|
||||
|
||||
Reference in New Issue
Block a user