diff options
Diffstat (limited to 'src/ui/gwt')
69 files changed, 0 insertions, 5702 deletions
diff --git a/src/ui/gwt/.classpath b/src/ui/gwt/.classpath deleted file mode 100644 index 781d7a2f8..000000000 --- a/src/ui/gwt/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
- <classpathentry kind="output" path="src"/>
-</classpath>
diff --git a/src/ui/gwt/.project b/src/ui/gwt/.project deleted file mode 100644 index dfd6dab3f..000000000 --- a/src/ui/gwt/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>GF-GWT</name>
- <comment>GF-GWT project</comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>com.google.gwt.eclipse.core.gwtNature</nature>
- </natures>
-</projectDescription>
diff --git a/src/ui/gwt/Editor-compile b/src/ui/gwt/Editor-compile deleted file mode 100644 index 4106298ea..000000000 --- a/src/ui/gwt/Editor-compile +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -APPDIR=`dirname $0`; - -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:' - echo 'export GWT_DIR="/Users/bringert/src/gwt-2.0.4"' - echo 'export GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev.jar"' - exit 1 -fi - -if [ `uname` = "Darwin" ]; then - GWT_JAVA_OPTS=-XstartOnFirstThread -fi - -java $GWT_JAVA_OPTS -Xmx256M -cp "$APPDIR/src:$APPDIR/bin:$GWT_CLASSPATH" com.google.gwt.dev.Compiler -war "$APPDIR/www/editor" "$@" org.grammaticalframework.ui.gwt.EditorApp; diff --git a/src/ui/gwt/Editor-compile.bat b/src/ui/gwt/Editor-compile.bat deleted file mode 100644 index 2c9b77f4e..000000000 --- a/src/ui/gwt/Editor-compile.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -set APPDIR=. -set GWT_DIR=C:\Program Files\eclipse\plugins\com.google.gwt.eclipse.sdkbundle.2.0.4_2.0.4.v201006301254\gwt-2.0.4 -set GWT_CLASSPATH=%GWT_DIR%\gwt-user.jar;%GWT_DIR%\gwt-dev.jar - -java %GWT_JAVA_OPTS% -Xmx256M -cp "%APPDIR%\src;%GWT_CLASSPATH%" com.google.gwt.dev.Compiler -war "%APPDIR%\www\editor" org.grammaticalframework.ui.gwt.EditorApp -style PRETTY diff --git a/src/ui/gwt/Fridge-compile b/src/ui/gwt/Fridge-compile deleted file mode 100644 index 887e253bc..000000000 --- a/src/ui/gwt/Fridge-compile +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -APPDIR=`dirname $0`; - -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:' - echo 'export GWT_DIR="/Users/bringert/src/gwt-2.0.4"' - echo 'export GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev.jar"' - exit 1 -fi - -if [ `uname` = "Darwin" ]; then - GWT_JAVA_OPTS=-XstartOnFirstThread -fi - -java $GWT_JAVA_OPTS -Xmx256M -cp "$APPDIR/src:$APPDIR/bin:$GWT_CLASSPATH" com.google.gwt.dev.Compiler -war "$APPDIR/www/fridge" "$@" org.grammaticalframework.ui.gwt.FridgeApp; diff --git a/src/ui/gwt/Fridge-compile-fast b/src/ui/gwt/Fridge-compile-fast deleted file mode 100644 index 1a7a4df03..000000000 --- a/src/ui/gwt/Fridge-compile-fast +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -APPDIR=`dirname $0`; - -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:' - echo 'export GWT_DIR="/Users/bringert/src/gwt-mac-1.5.2"' - echo 'export GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev-mac.jar"' - exit 1 -fi - -if [ `uname` = "Darwin" ]; then - GWT_JAVA_OPTS=-XstartOnFirstThread -fi - -LIBS=$APPDIR/lib/gwt-dnd-2.5.6.jar - -java $GWT_JAVA_OPTS -Xmx256M -cp "$APPDIR/src:$APPDIR/bin:$LIBS:$GWT_CLASSPATH" com.google.gwt.dev.GWTCompiler -out "$APPDIR/www" -style DETAILED "$@" se.chalmers.cs.gf.gwt.FridgeApp_IE6; diff --git a/src/ui/gwt/Fridge-compile.bat b/src/ui/gwt/Fridge-compile.bat deleted file mode 100644 index 8617d8528..000000000 --- a/src/ui/gwt/Fridge-compile.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off - -set APPDIR=. -set GWT_DIR=c:\gwt-windows-1.5.2 -set GWT_CLASSPATH="%GWT_DIR%\gwt-user.jar;%GWT_DIR%\gwt-dev-windows.jar" - -set LIBS=%APPDIR%\lib\gwt-dnd-2.5.6.jar - -java %GWT_JAVA_OPTS% -Xmx256M -cp "%APPDIR%\src;%APPDIR%\bin;%LIBS%;%GWT_CLASSPATH%" com.google.gwt.dev.GWTCompiler -out "%APPDIR%\www\fridge" se.chalmers.cs.gf.gwt.FridgeApp diff --git a/src/ui/gwt/Fridge-shell-external b/src/ui/gwt/Fridge-shell-external deleted file mode 100644 index 1209047ed..000000000 --- a/src/ui/gwt/Fridge-shell-external +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -APPDIR=`dirname $0`; - -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:' - echo 'export GWT_DIR="/Users/bringert/src/gwt-mac-1.5.2"' - echo 'export GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev-mac.jar"' - exit 1 -fi - -if [ `uname` = "Darwin" ]; then - GWT_JAVA_OPTS=-XstartOnFirstThread -fi - -LIBS=$APPDIR/lib/gwt-dnd-2.5.6.jar - -java $GWT_JAVA_OPTS -Xmx256M -cp "$APPDIR/src:$APPDIR/bin:$LIBS:$GWT_CLASSPATH" com.google.gwt.dev.GWTShell -out "$APPDIR/www" -noserver "$@" http://localhost:41296/fridge/; diff --git a/src/ui/gwt/Morpho-compile b/src/ui/gwt/Morpho-compile deleted file mode 100644 index 234e18322..000000000 --- a/src/ui/gwt/Morpho-compile +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -APPDIR=`dirname $0`; - -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:' - echo 'export GWT_DIR="/Users/bringert/src/gwt-2.0.4"' - echo 'export GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev.jar"' - exit 1 -fi - -if [ `uname` = "Darwin" ]; then - GWT_JAVA_OPTS=-XstartOnFirstThread -fi - -java $GWT_JAVA_OPTS -Xmx256M -cp "$APPDIR/src:$APPDIR/bin:$LIBS:$GWT_CLASSPATH" com.google.gwt.dev.Compiler -war "$APPDIR/www/morpho" "$@" org.grammaticalframework.ui.gwt.MorphoApp; diff --git a/src/ui/gwt/Translate-compile b/src/ui/gwt/Translate-compile deleted file mode 100644 index 220cf4a46..000000000 --- a/src/ui/gwt/Translate-compile +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -APPDIR=`dirname $0`; - -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:' - echo 'export GWT_DIR="/Users/bringert/src/gwt-2.0.4"' - echo 'export GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev.jar"' - exit 1 -fi - -if [ `uname` = "Darwin" ]; then - GWT_JAVA_OPTS=-XstartOnFirstThread -fi - -java $GWT_JAVA_OPTS -Xmx256M -cp "$APPDIR/src:$APPDIR/bin:$GWT_CLASSPATH" com.google.gwt.dev.Compiler -war "$APPDIR/www/translate" "$@" org.grammaticalframework.ui.gwt.TranslateApp; diff --git a/src/ui/gwt/Translate-compile.bat b/src/ui/gwt/Translate-compile.bat deleted file mode 100644 index df3ee9389..000000000 --- a/src/ui/gwt/Translate-compile.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off - -set APPDIR=. -set GWT_DIR=c:\gwt-windows-1.5.2 -set GWT_CLASSPATH="%GWT_DIR%\gwt-user.jar;%GWT_DIR%\gwt-dev-windows.jar" - -set LIBS=%APPDIR%\lib\gwt-dnd-2.5.6.jar - -java %GWT_JAVA_OPTS% -Xmx256M -cp "%APPDIR%\src;%APPDIR%\bin;%LIBS%;%GWT_CLASSPATH%" com.google.gwt.dev.GWTCompiler -out "%APPDIR%\www\translate" se.chalmers.cs.gf.gwt.TranslateApp diff --git a/src/ui/gwt/Translate-shell-external b/src/ui/gwt/Translate-shell-external deleted file mode 100644 index b1e58f019..000000000 --- a/src/ui/gwt/Translate-shell-external +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -APPDIR=`dirname $0`; - -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:' - echo 'export GWT_DIR="/Users/bringert/src/gwt-mac-1.5.2"' - echo 'export GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev-mac.jar"' - exit 1 -fi - -if [ `uname` = "Darwin" ]; then - GWT_JAVA_OPTS=-XstartOnFirstThread -fi - -LIBS=$APPDIR/lib/gwt-dnd-2.5.6.jar - -java $GWT_JAVA_OPTS -Xmx256M -cp "$APPDIR/src:$APPDIR/bin:$LIBS:$GWT_CLASSPATH" com.google.gwt.dev.GWTShell -out "$APPDIR/www" -noserver "$@" http://localhost:41296/translate/; diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/EditorApp.gwt.xml b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/EditorApp.gwt.xml deleted file mode 100644 index a7b24c1af..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/EditorApp.gwt.xml +++ /dev/null @@ -1,27 +0,0 @@ -<module> - - <!-- Inherit the core Web Toolkit stuff. --> - <inherits name="com.google.gwt.user.User" /> - <inherits name="com.google.gwt.xml.XML" /> - - <inherits name="org.grammaticalframework.ui.gwt.PGF" /> - - <!-- Inherit the default GWT style sheet. You can change --> - <!-- the theme of your GWT application by uncommenting --> - <!-- any one of the following lines. --> - <inherits name="com.google.gwt.user.theme.standard.Standard"/> - <!-- <inherits name="com.google.gwt.user.theme.chrome.Chrome"/> --> - <!-- <inherits name="com.google.gwt.user.theme.dark.Dark"/> --> - - <replace-with class="org.grammaticalframework.ui.gwt.client.selection.support.InternetExplorerSelectionSupport"> - <when-type-is class="org.grammaticalframework.ui.gwt.client.selection.support.SelectionSupport"/> - <when-property-is name="user.agent" value="ie6"/> - </replace-with> - - <!-- Specify the app entry point class. --> - <entry-point class="org.grammaticalframework.ui.gwt.client.EditorApp" /> - - <!-- Specify the application specific style sheet. --> - <stylesheet src="Editor.css" /> - -</module> diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/FridgeApp.gwt.xml b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/FridgeApp.gwt.xml deleted file mode 100644 index b041f9830..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/FridgeApp.gwt.xml +++ /dev/null @@ -1,25 +0,0 @@ -<module> - - <!-- Inherit the core Web Toolkit stuff. --> - <inherits name="com.google.gwt.user.User" /> - <inherits name="com.google.gwt.xml.XML" /> - - <inherits name="org.grammaticalframework.ui.gwt.PGF" /> - - <!-- Inherit the default GWT style sheet. You can change --> - <!-- the theme of your GWT application by uncommenting --> - <!-- any one of the following lines. --> - <inherits name="com.google.gwt.user.theme.standard.Standard"/> - <!-- <inherits name="com.google.gwt.user.theme.chrome.Chrome"/> --> - <!-- <inherits name="com.google.gwt.user.theme.dark.Dark"/> --> - - <!-- Other module inherits --> - - - <!-- Specify the app entry point class. --> - <entry-point class="org.grammaticalframework.ui.gwt.client.FridgeApp" /> - - <!-- Specify the application specific style sheet. --> - <stylesheet src="Fridge.css" /> - -</module> diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/FridgeApp_IE6.gwt.xml b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/FridgeApp_IE6.gwt.xml deleted file mode 100644 index 70d2b1714..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/FridgeApp_IE6.gwt.xml +++ /dev/null @@ -1,5 +0,0 @@ -<module rename-to="org.grammaticalframework.ui.gwt.FridgeApp"> - <inherits name="org.grammaticalframework.ui.gwt.FridgeApp" /> - <set-property name="user.agent" value="ie6" /> - <set-property name="locale" value="default" /> -</module>
\ No newline at end of file diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/MorphoApp.gwt.xml b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/MorphoApp.gwt.xml deleted file mode 100644 index 9bdd8d5ac..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/MorphoApp.gwt.xml +++ /dev/null @@ -1,20 +0,0 @@ -<module> - - <!-- Inherit the core Web Toolkit stuff. --> - <inherits name="com.google.gwt.user.User" /> - <inherits name="com.google.gwt.xml.XML" /> - - <!-- Inherit the default GWT style sheet. You can change --> - <!-- the theme of your GWT application by uncommenting --> - <!-- any one of the following lines. --> - <inherits name="com.google.gwt.user.theme.standard.Standard"/> - <!-- <inherits name="com.google.gwt.user.theme.chrome.Chrome"/> --> - <!-- <inherits name="com.google.gwt.user.theme.dark.Dark"/> --> - - <!-- Specify the app entry point class. --> - <entry-point class="org.grammaticalframework.ui.gwt.client.MorphoApp" /> - - <!-- Specify the application specific style sheet. --> - <stylesheet src="Morpho.css" /> - -</module> diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/PGF.gwt.xml b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/PGF.gwt.xml deleted file mode 100644 index 549a16f0d..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/PGF.gwt.xml +++ /dev/null @@ -1,9 +0,0 @@ -<module> - - <!-- Inherit the core Web Toolkit stuff. --> - <inherits name="com.google.gwt.user.User" /> - <inherits name="com.google.gwt.http.HTTP" /> - <inherits name="com.google.gwt.json.JSON" /> - <inherits name="com.google.gwt.xml.XML" /> - -</module> diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/TranslateApp.gwt.xml b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/TranslateApp.gwt.xml deleted file mode 100644 index ef51227ec..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/TranslateApp.gwt.xml +++ /dev/null @@ -1,25 +0,0 @@ -<module> - - <!-- Inherit the core Web Toolkit stuff. --> - <inherits name="com.google.gwt.user.User" /> - <inherits name="com.google.gwt.xml.XML" /> - - <inherits name="org.grammaticalframework.ui.gwt.PGF" /> - - <!-- Inherit the default GWT style sheet. You can change --> - <!-- the theme of your GWT application by uncommenting --> - <!-- any one of the following lines. --> - <inherits name="com.google.gwt.user.theme.standard.Standard"/> - <!-- <inherits name="com.google.gwt.user.theme.chrome.Chrome"/> --> - <!-- <inherits name="com.google.gwt.user.theme.dark.Dark"/> --> - - <!-- Other module inherits --> - - - <!-- Specify the app entry point class. --> - <entry-point class="org.grammaticalframework.ui.gwt.client.TranslateApp" /> - - <!-- Specify the application specific style sheet. --> - <stylesheet src="Translate.css" /> - -</module> diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/BrowsePanel.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/BrowsePanel.java deleted file mode 100644 index 3f4c8a9a4..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/BrowsePanel.java +++ /dev/null @@ -1,269 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.HistoryListener; -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DeferredCommand; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.http.client.*; -import com.google.gwt.xml.client.*; -import com.google.gwt.event.logical.shared.*; - -public class BrowsePanel extends Composite { - - private PGFWrapper pgf; - private StatusPopup statusPopup; - private HTML sourceView; - private SuggestBox searchBox; - private CompletionOracle oracle; - private List<String> identifiers = null; - - public BrowsePanel(PGFWrapper pgf, StatusPopup statusPopup) { - this.pgf = pgf; - this.statusPopup = statusPopup; - - oracle = new CompletionOracle(); - - HorizontalPanel browsePanel = new HorizontalPanel(); - VerticalPanel vPanel = new VerticalPanel(); - vPanel.add(createSearchPanel(oracle)); - vPanel.add(createTreeView()); - browsePanel.add(vPanel); - browsePanel.add(createSourcePanel()); - browsePanel.setCellWidth(sourceView,"100%"); - - initWidget(browsePanel); - setStylePrimaryName("my-BrowsePanel"); - - pgf.addSettingsListener(new MySettingsListener(pgf)); - } - - public native void onActivate() /*-{ - $doc.browsePanel = this; - $doc.callBrowse = @org.grammaticalframework.ui.gwt.client.BrowsePanel::callBrowse(Lorg/grammaticalframework/ui/gwt/client/BrowsePanel;Ljava/lang/String;); - }-*/; - - protected Widget createSearchPanel(CompletionOracle oracle) { - searchBox = new SuggestBox(oracle); - searchBox.setLimit(10); - searchBox.addKeyboardListener(new KeyboardListenerAdapter() { - public void onKeyUp (Widget sender, char keyCode, int modifiers) { - if (keyCode == KEY_ENTER) { - callBrowse(BrowsePanel.this,searchBox.getText()); - } - } - }); - - DecoratorPanel decorator = new DecoratorPanel(); - VerticalPanel vPanel = new VerticalPanel(); - vPanel.add(new Label("Search")); - vPanel.add(searchBox); - decorator.add(vPanel); - return decorator; - } - - private static void callBrowse(BrowsePanel panel, String id) { - panel.browse(id); - History.newItem("browse:"+id, false); - } - - public void browse(final String id) { - if (id == null || id.equals("")) { - sourceView.setHTML(""); - return; - } - - pgf.browse(id, "javascript:document.callBrowse(document.browsePanel,'$ID')", - "my-identifierLink", - new RequestCallback() { - public void onResponseReceived(Request request, Response response) { - sourceView.setHTML(response.getText()); - } - - public void onError(Request request, java.lang.Throwable e) { - statusPopup.showError("Cannot load the page", e); - } - }); - } - - protected Widget createTreeView() { - hierarchyTree = new Tree(); - hierarchyTree.addSelectionHandler(new SelectionHandler<TreeItem>() { - public void onSelection(SelectionEvent<TreeItem> event) { - TreeItem item = event.getSelectedItem(); - callBrowse(BrowsePanel.this,item.getText()); - } - }); - return hierarchyTree; - } - - protected Widget createSourcePanel() { - sourceView = new HTML(); - sourceView.setStylePrimaryName("source"); - return sourceView; - } - - protected class CompletionOracle extends SuggestOracle { - - public CompletionOracle() { - } - - public void requestSuggestions(SuggestOracle.Request request, SuggestOracle.Callback callback) { - List<CompletionSuggestion> list = new ArrayList(); - - int index = Collections.binarySearch(identifiers, request.getQuery()); - index = (index >= 0) ? index : -(index+1); - - for (; index < identifiers.size(); index++) { - String id = identifiers.get(index); - - if (id.startsWith(request.getQuery())) { - list.add(new CompletionSuggestion(id)); - } - else - break; - - if (list.size() > request.getLimit()) - break; - } - - callback.onSuggestionsReady(request, new SuggestOracle.Response(list)); - } - } - - protected static class CompletionSuggestion implements SuggestOracle.Suggestion { - private String string; - - public CompletionSuggestion(String string) { - this.string = string; - } - - public String getDisplayString() { - return string; - } - - public String getReplacementString() { - return string; - } - } - - Tree hierarchyTree = null; - - protected void reloadHierarchyTree() { - hierarchyTree.clear(); - - final String url = pgf.getGrammarURL()+".xml"; - RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url)); - try - { - builder.sendRequest(null, new RequestCallback() { - public void onResponseReceived(Request request, Response response) - { - if (200 == response.getStatusCode()) - { - try - { - Document browseDoc = XMLParser.parse(response.getText()); - - TreeLoader loader = new TreeLoader(); - - Element element = browseDoc.getDocumentElement(); - NodeList children = element.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - if (node instanceof Element) { - Element childElement = (Element) node; - TreeItem childItem = hierarchyTree.addItem(childElement.getAttribute("name")); - loader.push(childElement, childItem); - } - } - - loader.execute(); - } - catch (DOMException e) - { - } - } - else - { - } - } - - public void onError(Request request, Throwable e) - { - } - }); - } - catch (RequestException e) - { - } - } - - private class TreeLoader implements Command { - private int count = 0; - private ArrayList<Element> elements = new ArrayList<Element>(); - private ArrayList<TreeItem> items = new ArrayList<TreeItem>(); - - public void execute() { - for (int n = 0; n < 100; n++) { - if (count <= 0) - return; - - int index = --count; - Element element = (Element) elements.remove(index); - TreeItem item = (TreeItem) items.remove(index); - - NodeList children = element.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node node = children.item(i); - if (node instanceof Element) { - Element childElement = (Element) node; - TreeItem childItem = item.addItem(childElement.getAttribute("name")); - push(childElement, childItem); - } - } - } - DeferredCommand.addCommand(this); - } - - public final void push(Element element, TreeItem item) { - elements.add(element); - items.add(item); - count++; - } - } - - protected class MySettingsListener implements SettingsListener { - - private PGFWrapper pgf; - - public MySettingsListener(PGFWrapper pgf) { - this.pgf = pgf; - } - - public void onAvailableGrammarsChanged() { } - public void onSelectedGrammarChanged() - { - List<String> ids = new ArrayList(); - - for (int i = 0; i < pgf.getCategories().length(); i++) { - ids.add(pgf.getCategories().get(i)); - } - for (int i = 0; i < pgf.getFunctions().length(); i++) { - ids.add(pgf.getFunctions().get(i)); - } - - Collections.sort(ids); - - identifiers = ids; - sourceView.setText(""); - searchBox.setText(""); - reloadHierarchyTree(); - } - public void onInputLanguageChanged() { } - public void onOutputLanguageChanged() { } - public void onStartCategoryChanged() { } - public void onSettingsError(String msg, Throwable e) { } - } -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/CompletionOracle.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/CompletionOracle.java deleted file mode 100644 index 7ea5d2be6..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/CompletionOracle.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import com.google.gwt.user.client.ui.SuggestOracle; - -public class CompletionOracle extends SuggestOracle { - - private static final int LIMIT_SCALE_FACTOR = 4; - - private PGFWrapper pgf; - - private ErrorHandler errorHandler; - - private JSONRequest jsonRequest = null; - - private String oldQuery = null; - - private List<CompletionSuggestion> oldSuggestions = Collections.emptyList(); - - - public CompletionOracle (PGFWrapper pgf) { - this(pgf, null); - } - - public CompletionOracle (PGFWrapper pgf, ErrorHandler errorHandler) { - this.pgf = pgf; - this.errorHandler = errorHandler; - pgf.addSettingsListener(new SettingsListener() { - public void onAvailableGrammarsChanged() { clearState(); } - public void onSelectedGrammarChanged() { clearState(); } - public void onInputLanguageChanged() { clearState(); } - public void onOutputLanguageChanged() { clearState(); } - public void onStartCategoryChanged() { clearState(); } - public void onSettingsError(String msg, Throwable e) { clearState(); } - }); - } - - private void clearState () { - this.oldQuery = null; - this.oldSuggestions = Collections.emptyList(); - if (jsonRequest != null) { - jsonRequest.cancel(); - jsonRequest = null; - } - } - - public void setErrorHandler(ErrorHandler errorHandler) { - this.errorHandler = errorHandler; - } - - public static interface ErrorHandler { - public void onError(Throwable e); - } - - public static class CompletionSuggestion implements SuggestOracle.Suggestion { - private String string; - public CompletionSuggestion(String string) { - this.string = string; - } - - public String getDisplayString() { - return string; - } - - public String getReplacementString() { - return string; - } - } - - public void requestSuggestions(SuggestOracle.Request request, SuggestOracle.Callback callback) { - // Only allow a single completion request at a time - if (jsonRequest != null) { - jsonRequest.cancel(); - jsonRequest = null; - } - - List<CompletionSuggestion> suggestions = filterOldSuggestions(request); - if (suggestions != null) { - suggestionsReady(request, callback, suggestions); - } else { - retrieveSuggestions(request, callback); - } - } - - /** Filters old suggestions and checks if we still have enough suggestions. */ - private List<CompletionSuggestion> filterOldSuggestions(SuggestOracle.Request request) { - String query = request.getQuery(); - if (query.length() > 0 && oldQuery != null && query.startsWith(oldQuery)) { - // If the prefix had no completions, there is no way that the current input will. - if (oldSuggestions.isEmpty()) { - return Collections.emptyList(); - } - // If the new input since the previous query ends in whitespace, - // always get completions from the server, - // since the old suggestions won't include the next word. - if (query.indexOf(' ', oldQuery.length()) != -1) { - return null; - } - List<CompletionSuggestion> suggestions = new ArrayList<CompletionSuggestion>(); - for (CompletionSuggestion c : oldSuggestions) { - if (c.getReplacementString().startsWith(query)) { - suggestions.add(c); - } - } - if (suggestions.size() >= request.getLimit() || oldSuggestions.size() < request.getLimit()) { - return suggestions; - } - } - return null; - } - - private void retrieveSuggestions(final SuggestOracle.Request request, final SuggestOracle.Callback callback) { - // hack: first report no completions, to hide suggestions until we get the new completions - callback.onSuggestionsReady(request, new SuggestOracle.Response(Collections.<CompletionSuggestion>emptyList())); - - jsonRequest = pgf.complete(request.getQuery(), LIMIT_SCALE_FACTOR * request.getLimit(), - new PGF.CompleteCallback() { - public void onResult(IterableJsArray<PGF.Completion> completions) { - jsonRequest = null; - List<CompletionSuggestion> suggestions = new ArrayList<CompletionSuggestion>(); - for (PGF.Completion completion : completions.iterable()) { - String text = completion.getBracketedString().render(); - for (String tokn : completion.getCompletions()) { - StringBuilder sbuilder = new StringBuilder(); - sbuilder.append(text); - if (sbuilder.length() > 0) - sbuilder.append(' '); - sbuilder.append(tokn); - suggestions.add(new CompletionSuggestion(sbuilder.toString())); - } - } - suggestionsReady(request, callback, suggestions); - } - - public void onError(Throwable e) { - errorHandler.onError(e); - } - - }); - } - - private void suggestionsReady(SuggestOracle.Request request, SuggestOracle.Callback callback, List<CompletionSuggestion> suggestions) { - this.oldQuery = request.getQuery(); - this.oldSuggestions = suggestions; - suggestions = suggestions.size() <= request.getLimit() ? suggestions : SubList.makeSubList(suggestions, 0, request.getLimit()); - callback.onSuggestionsReady(request, new SuggestOracle.Response(suggestions)); - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/ContentService.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/ContentService.java deleted file mode 100644 index fd336bf34..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/ContentService.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import org.grammaticalframework.ui.gwt.client.JSONRequestBuilder.Arg; - -import java.util.*; -import com.google.gwt.core.client.*; - -public class ContentService { - - // Event listeners - private List<SettingsListener> listeners = new LinkedList<SettingsListener>(); - private List<GrammarInfo> grammars = null; - - - public ContentService() { - } - - public static class Init extends JavaScriptObject { - protected Init() { } - - public final native String getUserId() /*-{ return this.userId; }-*/; - public final native String getUserURL() /*-{ return this.userURL; }-*/; - public final native String getUserEMail() /*-{ return this.userEMail; }-*/; - public final native String getContentURL() /*-{ return this.contentURL; }-*/; - } - - public static final native Init getInit() /*-{ - return $wnd.__gfInit; - }-*/; - - public void addSettingsListener(SettingsListener listener) { - listeners.add(listener); - } - - public void updateAvailableGrammars() { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("userId", getInit().getUserId())); - args.add(new Arg("command", "grammars")); - JSONRequestBuilder.sendRequest(getInit().getContentURL(), args, new GrammarsCallback() { - public void onResult(IterableJsArray<ContentService.GrammarInfo> grammars_) { - grammars = new ArrayList<GrammarInfo>(); - for (ContentService.GrammarInfo grammar : grammars_.iterable()) { - grammars.add(grammar); - } - - for (SettingsListener listener : listeners) { - listener.onAvailableGrammarsChanged(); - } - } - - public void onError(Throwable e) { - } - }); - } - - public List<GrammarInfo> getGrammars() { - return grammars; - } - - public interface GrammarsCallback extends JSONCallback<IterableJsArray<GrammarInfo>> {} - - public static class GrammarInfo extends JavaScriptObject { - protected GrammarInfo() { } - - public final native String getURL() /*-{ return this.url; }-*/; - public final native String getName() /*-{ return this.name; }-*/; - public final native String getDescription() /*-{ return this.description; }-*/; - } - - public JSONRequest deleteGrammar(String grammarURL, DeleteCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("url", grammarURL)); - args.add(new Arg("userId", getInit().getUserId())); - args.add(new Arg("command", "delete_grammar")); - return JSONRequestBuilder.sendRequest(getInit().getContentURL(), args, callback); - } - - public JSONRequest save(Object id, String content, SaveCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - if (id != null) - args.add(new Arg("id", id.toString())); - args.add(new Arg("command", "save")); - return JSONRequestBuilder.sendDataRequest(getInit().getContentURL(), args, content, callback); - } - - public interface SaveCallback extends JSONCallback<DocumentSignature> {} - - public JSONRequest load(Object id, LoadCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("command", "load")); - args.add(new Arg("id", id.toString())); - return JSONRequestBuilder.sendRequest(getInit().getContentURL(), args, callback); - } - - public interface LoadCallback extends JSONCallback<Document> {} - - public JSONRequest search(String fullTextQuery, SearchCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("command", "search")); - args.add(new Arg("query", fullTextQuery)); - return JSONRequestBuilder.sendRequest(getInit().getContentURL(), args, callback); - } - - public interface SearchCallback extends JSONCallback<IterableJsArray<DocumentSignature>> {} - - public static class DocumentSignature extends JavaScriptObject { - protected DocumentSignature() { } - - public final native int getId() /*-{ return this.id; }-*/; - public final native String getTitle() /*-{ return this.title; }-*/; - public final native String getCreated() /*-{ return this.created; }-*/; - public final native String getModified() /*-{ return this.modified; }-*/; - } - - public static class Document extends DocumentSignature { - protected Document() { } - - public final native String getContent() /*-{ return this.content; }-*/; - } - - public JSONRequest delete(List ids, DeleteCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("command", "delete")); - for (Object id : ids) { - args.add(new Arg("id", id.toString())); - } - return JSONRequestBuilder.sendRequest(getInit().getContentURL(), args, callback); - } - - public interface DeleteCallback extends JSONCallback<DeleteResult> {} - - public static class DeleteResult extends JavaScriptObject { - protected DeleteResult() { } - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/DocumentsPanel.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/DocumentsPanel.java deleted file mode 100644 index 09acce5f5..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/DocumentsPanel.java +++ /dev/null @@ -1,142 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; -import com.google.gwt.user.client.*; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.http.client.*; -import com.google.gwt.xml.client.*; -import com.google.gwt.event.logical.shared.*; -import com.google.gwt.event.dom.client.*; -import com.google.gwt.event.shared.*; - -public class DocumentsPanel extends Composite implements HasSelectionHandlers<Object> { - - private PGFWrapper pgf; - private ContentService contentService; - private StatusPopup statusPopup; - private FlexTable table; - private ArrayList documentIds = new ArrayList(); - - public DocumentsPanel(PGFWrapper pgf, ContentService contentService, StatusPopup statusPopup) { - this.pgf = pgf; - this.contentService = contentService; - this.statusPopup = statusPopup; - - VerticalPanel documentsPanel = new VerticalPanel(); - documentsPanel.setStylePrimaryName("my-DocumentsFrame"); - - HorizontalPanel searchPanel = new HorizontalPanel(); - searchPanel.setStylePrimaryName("my-DocumentsSearchFrame"); - final TextBox searchBox = new TextBox(); - searchBox.setWidth("20em"); - final Button searchBtn = new Button("Search"); - searchPanel.add(searchBox); - searchPanel.add(searchBtn); - documentsPanel.add(searchPanel); - - Image deleteButton = new Image("org.grammaticalframework.ui.gwt.EditorApp/trash-button.png"); - deleteButton.setTitle("Deletes the selected documents."); - deleteButton.setStylePrimaryName("toolbar-button"); - deleteButton.addClickListener(new ClickListener () { - public void onClick(Widget sender) { - deleteSelected(); - } - }); - - FlexTable header = new FlexTable(); - header.setStylePrimaryName("my-TableHeader"); - header.setText(0,0,"Documents"); - header.setWidget(0,1,deleteButton); - header.getColumnFormatter().setWidth(1,"20px"); - documentsPanel.add(header); - - table = new FlexTable(); - table.setCellPadding(2); - table.setStylePrimaryName("my-DocumentsTable"); - table.getColumnFormatter().setWidth(1,"80em"); - table.getColumnFormatter().setWidth(2,"80em"); - documentsPanel.add(table); - - searchBtn.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent event) { - searchDocuments(searchBox.getText()); - } - }); - table.addClickHandler(new ClickHandler() { - public void onClick(ClickEvent event) { - HTMLTable.Cell cell = table.getCellForEvent(event); - if (cell != null) { - int row = cell.getRowIndex(); - selectDocument(row); - } - } - }); - - initWidget(documentsPanel); - setStylePrimaryName("my-DocumentsPanel"); - } - - public HandlerRegistration addSelectionHandler(SelectionHandler<Object> handler) { - return addHandler(handler, SelectionEvent.getType()); - } - - protected void selectDocument(int row) { - SelectionEvent.fire(this, documentIds.get(row)); - } - - protected void searchDocuments(String fullTextQuery) { - statusPopup.setStatus("Searching..."); - - documentIds.clear(); - while (table.getRowCount() > 0) - table.removeRow(0); - - contentService.search(fullTextQuery, new ContentService.SearchCallback() { - public void onResult(IterableJsArray<ContentService.DocumentSignature> documents) { - for (ContentService.DocumentSignature sign : documents.iterable()) { - int row = table.getRowCount(); - table.setWidget(row, 0, new CheckBox(sign.getTitle())); - table.setText(row, 1, sign.getCreated()); - table.setText(row, 2, sign.getModified()); - table.getRowFormatter().addStyleName(row, "row"); - documentIds.add(sign.getId()); - } - - statusPopup.clearStatus(); - } - - public void onError(Throwable e) { - statusPopup.showError("Search failed", e); - } - }); - } - - protected void deleteSelected() { - statusPopup.setStatus("Deleting..."); - - final ArrayList ids = new ArrayList(); - final ArrayList<Integer> rows = new ArrayList<Integer>(); - for (int row = 0; row < table.getRowCount(); row++) { - CheckBox checkBox = (CheckBox) table.getWidget(row,0); - if (checkBox.isChecked()) { - ids.add(documentIds.get(row)); - rows.add(new Integer(row)); - } - } - - contentService.delete(ids, new ContentService.DeleteCallback() { - public void onResult(ContentService.DeleteResult result) { - for (Integer row : rows) { - table.removeRow(row.intValue()); - } - - statusPopup.clearStatus(); - } - - public void onError(Throwable e) { - statusPopup.showError("Delete failed", e); - } - }); - - } -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/EditorApp.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/EditorApp.java deleted file mode 100644 index ece9ecac8..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/EditorApp.java +++ /dev/null @@ -1,461 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; - -import com.google.gwt.core.client.*; -import com.google.gwt.user.client.*; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.event.dom.client.*; -import com.google.gwt.event.logical.shared.*; -import com.google.gwt.event.shared.*; - -public class EditorApp implements EntryPoint { - - protected ContentService contentService; - protected PGFWrapper pgf; - - protected SettingsPanel settingsPanel; - protected VerticalPanel outputPanel; - protected Widget editorPanel; - protected BrowsePanel browsePanel; - protected QueryPanel queryPanel; - protected DocumentsPanel documentsPanel; - protected GrammarsPanel grammarsPanel; - protected StatusPopup statusPopup; - protected TextInputPanel textPanel; - protected FridgeBagPanel bagPanel; - protected MagnetFactory magnetFactory; - protected TabBar tabBar; - - private JSONRequest completeRequest = null; - private JSONRequest translateRequest = null; - - private int maxMagnets = 100; - private static final int LIMIT_SCALE_FACTOR = 4; - - private String cachedPrefix = null; - private List<Magnet> cachedMagnets = Collections.emptyList(); - - // - // Update - // - protected void update() { - clearMagnetCache(); - updateBag(""); - updateTranslation(); - } - - protected void clearMagnetCache() { - cachedPrefix = null; - cachedMagnets = Collections.emptyList(); - } - - protected void updateTranslation() { - if (translateRequest != null) { - translateRequest.cancel(); - } - - outputPanel.clear(); - outputPanel.addStyleDependentName("working"); - translateRequest = pgf.translate(textPanel.getText(), - new PGF.TranslateCallback() { - public void onResult (IterableJsArray<PGF.TranslationResult> translations) { - translateRequest = null; - - outputPanel.clear(); - outputPanel.removeStyleDependentName("working"); - for (PGF.TranslationResult tr : translations.iterable()) { - textPanel.renderBracketedString(tr.getBracketedString()); - - if (tr.getTranslations() != null) - for (PGF.Linearizations lins : tr.getTranslations().iterable()) { - LinearizationsPanel lin = new LinearizationsPanel(pgf, lins); - lin.setWidth("100%"); - outputPanel.add(lin); - } - - if (tr.getTypeErrors() != null && tr.getTypeErrors().length > 0) { - for (PGF.TcError error : tr.getTypeErrors()) { - VerticalPanel panel = new VerticalPanel(); - panel.addStyleName("my-typeError"); - Label errLabel = new Label("Type Error"); - errLabel.addStyleName("title"); - panel.add(errLabel); - panel.add(createErrorMsg(error)); - outputPanel.add(panel); - } - textPanel.showError(tr.getTypeErrors()[0].getFId()); - } - } - } - public void onError (Throwable e) { - translateRequest = null; - - statusPopup.showError("Translation failed", e); - } - }); - } - - private class Callback { - private String prefix; - - public Callback(String prefix) { - this.prefix = prefix; - } - - public void onResult(List<Magnet> magnets) { - bagPanel.fill(magnets); - - if (magnets.size() == 0) { - if (prefix.isEmpty()) { - textPanel.hideSearchBox(); - textPanel.setFocus(true); - } - else - textPanel.showSearchError(); - } else { - textPanel.clearSearchError(); - } - } - } - - public void updateBag(String prefix) { - Callback callback = new Callback(prefix); - List<Magnet> magnets = filterCachedMagnets(prefix); - if (magnets != null) - callback.onResult(magnets); - else - retrieveMagnets(prefix, callback); - } - - public List<Magnet> filterCachedMagnets(final String prefix) { - if (prefix.length() > 0 && cachedPrefix != null && prefix.startsWith(cachedPrefix)) { - // If the prefix had no completions, there is no way that the current input will. - if (cachedMagnets.isEmpty()) { - return Collections.emptyList(); - } - - List<Magnet> magnets = new ArrayList<Magnet>(); - for (Magnet magnet : cachedMagnets) { - if (magnet.getWord().startsWith(prefix)) { - magnets.add(magnet); - if (magnets.size() >= maxMagnets) - return magnets; - } - } - } - return null; - } - - public void retrieveMagnets(final String prefix, final Callback callback) { - final String query = textPanel.getText() + " " + prefix; - - if (completeRequest != null) { - completeRequest.cancel(); - } - - bagPanel.clear(); - completeRequest = pgf.complete(query, LIMIT_SCALE_FACTOR * maxMagnets, - new PGF.CompleteCallback() { - public void onResult(IterableJsArray<PGF.Completion> completions) { - completeRequest = null; - - cachedPrefix = query; - cachedMagnets = new ArrayList<Magnet>(); - - for (PGF.Completion completion : completions.iterable()) { - textPanel.renderBracketedString(completion.getBracketedString()); - if (completion.getCompletions() != null) { - if (completion.getText() != prefix) - textPanel.setSearchTerm(completion.getText()); - - for (String word : completion.getCompletions()) { - Magnet magnet = magnetFactory.createMagnet(word, completion.getFrom()); - cachedMagnets.add(magnet); - } - } else { - textPanel.setSearchTerm(completion.getText()); - } - } - - List<Magnet> magnets = new ArrayList<Magnet>(); - for (Magnet magnet : cachedMagnets) { - magnets.add(magnet); - if (magnets.size() >= maxMagnets) - break; - } - callback.onResult(magnets); - } - - public void onError(Throwable e) { - completeRequest = null; - - statusPopup.showError("Getting completions failed", e); - } - }); - } - - // - // GUI - // - - protected Widget createUI() { - editorPanel = createEditorPanel(); - browsePanel = createBrowsePanel(); - queryPanel = createQueryPanel(); - documentsPanel = createDocumentsPanel(); - grammarsPanel = createGrammarsPanel(); - - VerticalPanel vPanel = new VerticalPanel(); - vPanel.setWidth("100%"); - vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); - - HorizontalPanel hPanel = new HorizontalPanel(); - hPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); - hPanel.setStylePrimaryName("my-HeaderPanel"); - - TabBar linksPanel = createLinksPanel(vPanel); - hPanel.add(linksPanel); - hPanel.setCellHorizontalAlignment(linksPanel,HorizontalPanel.ALIGN_LEFT); - linksPanel.selectTab(1); - - settingsPanel = createSettingsPanel(); - hPanel.add(settingsPanel); - hPanel.setCellHorizontalAlignment(settingsPanel,HorizontalPanel.ALIGN_RIGHT); - - vPanel.add(hPanel); - vPanel.add(editorPanel); - - return vPanel; - } - - protected SettingsPanel createSettingsPanel () { - return new SettingsPanel(pgf, contentService, statusPopup); - } - - protected Widget createEditorPanel() { - textPanel = new TextInputPanel(contentService, statusPopup); - textPanel.addValueChangeHandler(new ValueChangeHandler<String>() { - public void onValueChange(ValueChangeEvent<String> event) { - update(); - } - }); - textPanel.addSelectionHandler(new SelectionHandler<String>() { - public void onSelection(SelectionEvent<String> event) { - String prefix = event.getSelectedItem(); - char lastChar = prefix.charAt(prefix.length()-1); - - Iterator<Magnet> iter = bagPanel.iterator(); - if ((Character.isSpace(lastChar) || lastChar == 160) && iter.hasNext()) { - Magnet magnet = iter.next(); - textPanel.setSearchTerm(""); - textPanel.addMagnet(magnet); - } - else - updateBag(prefix); - } - }); - - final ClickListener magnetClickListener = new ClickListener () { - public void onClick(Widget widget) { - Magnet magnet = (Magnet)widget; - textPanel.hideSearchBox(); - textPanel.addMagnet(magnet); - textPanel.setFocus(true); - } - }; - magnetFactory = new MagnetFactory(magnetClickListener); - - bagPanel = new FridgeBagPanel(); - - outputPanel = new VerticalPanel(); - outputPanel.addStyleName("my-translations"); - - final DockPanel editorPanel = new DockPanel(); - editorPanel.setStyleName("my-EditorPanel"); - editorPanel.add(textPanel, DockPanel.NORTH); - editorPanel.add(bagPanel, DockPanel.CENTER); - editorPanel.add(outputPanel, DockPanel.EAST); - - editorPanel.setCellHeight(bagPanel, "100%"); - editorPanel.setCellWidth(bagPanel, "70%"); - editorPanel.setCellHeight(outputPanel, "100%"); - editorPanel.setCellWidth(outputPanel, "30%"); - editorPanel.setCellVerticalAlignment(bagPanel, HasVerticalAlignment.ALIGN_TOP); - editorPanel.setCellHorizontalAlignment(outputPanel, HasHorizontalAlignment.ALIGN_RIGHT); - - Window.addWindowResizeListener(new WindowResizeListener() { - public void onWindowResized(int w, int h) { - editorPanel.setPixelSize(w-20, h-50); - } - }); - int w = Window.getClientWidth(); - int h = Window.getClientHeight(); - editorPanel.setPixelSize(w-20, h-50); - - return editorPanel; - } - - protected BrowsePanel createBrowsePanel() { - return new BrowsePanel(pgf, statusPopup); - } - - protected QueryPanel createQueryPanel() { - return new QueryPanel(pgf, statusPopup); - } - - protected DocumentsPanel createDocumentsPanel() { - DocumentsPanel panel = new DocumentsPanel(pgf, contentService, statusPopup); - panel.addSelectionHandler(new SelectionHandler<Object>() { - public void onSelection(SelectionEvent<Object> event) { - tabBar.selectTab(1); - textPanel.load(event.getSelectedItem()); - } - }); - return panel; - } - - protected GrammarsPanel createGrammarsPanel() { - return new GrammarsPanel(pgf, contentService, statusPopup); - } - - protected TabBar createLinksPanel(final Panel parent) { - tabBar = new TabBar(); - tabBar.setStylePrimaryName("my-LinksPanel"); - tabBar.addTab("Documents"); - tabBar.addTab("Editor"); - tabBar.addTab("Query"); - tabBar.addTab("Browse"); - tabBar.addTab("Grammars"); - - NavigationHandler handler = new NavigationHandler(tabBar, parent); - tabBar.addSelectionHandler(handler); - History.addHistoryListener(handler); - - return tabBar; - } - - // - // History stuff - // - - protected class NavigationHandler implements HistoryListener, SelectionHandler<Integer> { - private final TabBar linksPanel; - private final Panel parent; - private int level = 0; - - public NavigationHandler(TabBar linksPanel, Panel parent) { - this.linksPanel = linksPanel; - this.parent = parent; - } - - public void onSelection(SelectionEvent<Integer> event) { - parent.remove(documentsPanel); - parent.remove(editorPanel); - parent.remove(queryPanel); - parent.remove(browsePanel); - parent.remove(grammarsPanel); - - switch (event.getSelectedItem().intValue()) { - case 0: parent.add(documentsPanel); - if (level == 0) History.newItem("documents", false); - break; - case 1: parent.add(editorPanel); - if (level == 0) History.newItem("editor", false); - break; - case 2: parent.add(queryPanel); - if (level == 0) History.newItem("query", false); - break; - case 3: parent.add(browsePanel); - if (level == 0) History.newItem("browse", false); - browsePanel.onActivate(); - break; - case 4: parent.add(grammarsPanel); - if (level == 0) History.newItem("grammars", false); - break; - } - } - - public void onHistoryChanged(String token) { - level++; - - if (token.equals("documents")) { - linksPanel.selectTab(0); - } else if (token.equals("editor")) { - linksPanel.selectTab(1); - } else if (token.equals("query")) { - linksPanel.selectTab(2); - } else if (token.equals("browse")) { - linksPanel.selectTab(3); - browsePanel.onActivate(); - browsePanel.browse(null); - } else if (token.startsWith("browse:")) { - linksPanel.selectTab(3); - browsePanel.browse(token.substring(7)); - } else if (token.equals("grammars")) { - linksPanel.selectTab(4); - } - - level--; - } - }; - - protected Widget createErrorMsg(final PGF.TcError error) { - HTML msgHTML = new HTML("<pre>"+error.getMsg()+"</pre>"); - msgHTML.addStyleName("content"); - msgHTML.addClickListener(new ClickListener() { - public void onClick(Widget sender) { - textPanel.showError(error.getFId()); - } - }); - return msgHTML; - } - - // - // Initialization - // - - protected class MySettingsListener implements SettingsListener { - // Will only happen on load - public void onAvailableGrammarsChanged() { - if (pgf.getGrammarURL() == null) { - List<String> grammars = pgf.getGrammars(); - if (!grammars.isEmpty()) { - pgf.setGrammarURL(grammars.get(0)); - } - } - } - public void onSelectedGrammarChanged() { - textPanel.clear(); - if (pgf.getInputLanguage() == null) { - GWT.log("Setting input language to user language: " + pgf.getUserLanguage(), null); - pgf.setInputLanguage(pgf.getUserLanguage()); - } - update(); - } - public void onInputLanguageChanged() { - update(); - } - public void onOutputLanguageChanged() { - update(); - } - public void onStartCategoryChanged() { - update(); - } - public void onSettingsError(String msg, Throwable e) { - statusPopup.showError(msg,e); - } - } - - public void onModuleLoad() { - statusPopup = new StatusPopup(); - - pgf = new PGFWrapper(); - contentService = new ContentService(); - RootPanel.get().add(createUI()); - pgf.addSettingsListener(new MySettingsListener()); - contentService.updateAvailableGrammars(); - - textPanel.setFocus(true); - } -} 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 deleted file mode 100644 index 4e9963451..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeApp.java +++ /dev/null @@ -1,338 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.user.client.*; -import com.google.gwt.user.client.ui.*; - - -public class FridgeApp implements EntryPoint { - - protected static final String pgfBaseURL = "/grammars"; - - protected PGFWrapper pgf; - - protected JSONRequest completeRequest = null; - protected JSONRequest translateRequest = null; - - private FridgeBagPanel bagPanel; - private FridgeTextPanel textPanel; - protected VerticalPanel outputPanel; - protected StatusPopup statusPopup; - - private FlowPanel prefixPanel; - private LinkedHashSet<String> prefixes = new LinkedHashSet<String>(); - - private int maxMagnets = 100; - - private MagnetFactory magnetFactory; - - // - // Text - // - - protected void update () { - updateBag(getText()); - translate(); - } - - public void updateBag (String text) { - updateBag(text, ""); - } - - public void updateBag (final String text, String prefix) { - if (completeRequest != null) { - completeRequest.cancel(); - } - final boolean updatePrefixes = prefix.equals(""); - bagPanel.clear(); - bagPanel.addStyleDependentName("empty"); - if (updatePrefixes) { clearPrefixes(); } - int limit = updatePrefixes ? 0 : maxMagnets; - completeRequest = pgf.complete(text + " " + prefix, - limit, new PGF.CompleteCallback() { - public void onResult(IterableJsArray<PGF.Completion> completions) { - List<Magnet> magnets = new ArrayList<Magnet>(); - for (PGF.Completion completion : completions.iterable()) { - for (String word : completion.getCompletions()) { - if (updatePrefixes) { - addPrefix(text, word.substring(0,1)); - } - if (magnets.size() < maxMagnets) { - Magnet magnet = magnetFactory.createMagnet(word, completion.getFrom()); - magnets.add(magnet); - } else { - prefixPanel.setVisible(true); - } - } - } - bagPanel.fill(magnets); - } - public void onError(Throwable e) { - showError("Translation failed", e); - } - }); - } - - protected void clearPrefixes () { - prefixes.clear(); - prefixPanel.clear(); - prefixPanel.setVisible(false); - } - - protected void addPrefix(final String text, final String prefix) { - if (prefixes.add(prefix)) { - Button prefixButton = new Button(prefix, new ClickListener() { - public void onClick(Widget sender) { - updateBag(text, prefix); - } - }); - prefixButton.setTitle("Show only magnets stating with '" + prefix + "'"); - prefixPanel.add(prefixButton); - } - } - - // - // Translation - // - - protected void translate() { - outputPanel.clear(); - outputPanel.addStyleDependentName("working"); - if (translateRequest != null) { - translateRequest.cancel(); - } - translateRequest = pgf.translate(getText(), - new PGF.TranslateCallback() { - public void onResult (IterableJsArray<PGF.TranslationResult> translations) { - outputPanel.removeStyleDependentName("working"); - for (PGF.TranslationResult tr : translations.iterable()) { - if (tr.getTranslations() != null) - for (PGF.Linearizations t : tr.getTranslations().iterable()) { - for (PGF.Linearization l : t.getLinearizations().iterable()) { - outputPanel.add(createTranslation(l.getTo(), l.getText())); - } - } - - if (tr.getTypeErrors() != null) - for (PGF.TcError error : tr.getTypeErrors()) { - SimplePanel panel = new SimplePanel(); - panel.addStyleName("my-typeError"); - panel.add(new HTML("<pre>"+error.getMsg()+"</pre>")); - outputPanel.add(panel); - } - } - } - public void onError (Throwable e) { - showError("Translation failed", e); - } - }); - } - - protected ClickListener translationClickListener = new ClickListener () { - public void onClick(Widget widget) { - Magnet magnet = (Magnet)widget; - setInputLanguage(magnet.getLanguage()); // FIXME: this causes an unnecessary update() - setText(magnet.getText(), magnet.getLanguage()); - } - }; - - protected Widget createTranslation(String language, String text) { - Magnet magnet = magnetFactory.createUsedMagnet(text, language); - magnet.addClickListener(translationClickListener); - String lang = pgf.getLanguageCode(language); - if (lang != null) { - magnet.getElement().setLang(lang); - } - return magnet; - } - - // - // Current text - // - - public String getText () { - return textPanel.getText(); - } - - public void setText(String text, String language) { - textPanel.setText(text, language); - } - - private void clear() { - textPanel.clear(); - } - - - // - // Status stuff - // - - protected void setStatus(String msg) { - statusPopup.setStatus(msg); - } - - protected void showError(String msg, Throwable e) { - statusPopup.showError(msg, e); - } - - protected void clearStatus() { - statusPopup.clearStatus(); - } - - // GUI - - protected Widget createUI() { - ClickListener magnetClickListener = new ClickListener () { - public void onClick(Widget widget) { - Magnet magnet = (Magnet)widget; - textPanel.addMagnet(magnet); - } - }; - magnetFactory = new MagnetFactory(magnetClickListener); - - textPanel = new FridgeTextPanel(magnetFactory); - textPanel.addChangeListener(new ChangeListener() { - public void onChange(Widget widget) { - update(); - } - }); - prefixPanel = new FlowPanel(); - prefixPanel.setStylePrimaryName("my-PrefixPanel"); - bagPanel = new FridgeBagPanel(); - outputPanel = new TranslationsPanel(); - SettingsPanel settingsPanel = new SettingsPanel(pgf, null, statusPopup); - - VerticalPanel vPanel = new VerticalPanel(); - vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); - vPanel.setWidth("100%"); - vPanel.add(prefixPanel); - vPanel.add(bagPanel); - - final DockPanel mainPanel = new DockPanel(); - mainPanel.setStyleName("my-FridgeApp"); - mainPanel.add(textPanel, DockPanel.NORTH); - mainPanel.add(settingsPanel, DockPanel.SOUTH); - mainPanel.add(vPanel, DockPanel.CENTER); - mainPanel.add(outputPanel, DockPanel.EAST); - - mainPanel.setCellHeight(vPanel, "100%"); - mainPanel.setCellWidth(vPanel, "80%"); - mainPanel.setCellHeight(outputPanel, "100%"); - mainPanel.setCellWidth(outputPanel, "20%"); - mainPanel.setCellVerticalAlignment(vPanel, HasVerticalAlignment.ALIGN_TOP); - mainPanel.setCellHorizontalAlignment(outputPanel, HasHorizontalAlignment.ALIGN_RIGHT); - mainPanel.setCellWidth(settingsPanel, "100%"); - - Window.addWindowResizeListener(new WindowResizeListener() { - public void onWindowResized(int w, int h) { - mainPanel.setPixelSize(w, h); - } - }); - int w = Window.getClientWidth(); - int h = Window.getClientHeight(); - mainPanel.setPixelSize(w, h); - - return mainPanel; - } - - private static class TranslationsPanel extends VerticalPanel { - public TranslationsPanel () { - setStylePrimaryName("my-TranslationsPanel"); - addStyleDependentName("empty"); - } - - public void clear () { - super.clear(); - addStyleDependentName("empty"); - } - - public void add(Widget w) { - removeStyleDependentName("empty"); - super.add(w); - } - - } - - - // - // History stuff - // - - protected class MyHistoryListener implements HistoryListener { - public void onHistoryChanged(String historyToken) { - updateSettingsFromHistoryToken(); - } - }; - - protected void updateSettingsFromHistoryToken() { - updateSettingsFromHistoryToken(History.getToken().split("/")); - } - - protected void updateSettingsFromHistoryToken(String[] tokenParts) { - if (tokenParts.length >= 1 && tokenParts[0].length() > 0) { - setGrammarURL(tokenParts[0]); - } - if (tokenParts.length >= 2 && tokenParts[1].length() > 0) { - setInputLanguage(tokenParts[1]); - } - } - - protected void setGrammarURL(String url) { - if (url != null && !url.equals(pgf.getGrammarURL())) { - pgf.setGrammarURL(url); - } - } - - protected void setInputLanguage (String inputLanguage) { - if (inputLanguage != null && !inputLanguage.equals(pgf.getInputLanguage())) { - pgf.setInputLanguage(inputLanguage); - } - } - - // - // Initialization - // - - protected class MySettingsListener implements SettingsListener { - // Will only happen on load - public void onAvailableGrammarsChanged() { - if (pgf.getGrammarURL() == null) { - List<String> grammars = pgf.getGrammars(); - if (!grammars.isEmpty()) { - pgf.setGrammarURL(grammars.get(0)); - } - } - } - public void onSelectedGrammarChanged() { - if (pgf.getInputLanguage() == null) { - pgf.setInputLanguage(pgf.getUserLanguage()); - } - } - public void onInputLanguageChanged() { - clear(); - } - public void onOutputLanguageChanged() { - update(); - } - public void onStartCategoryChanged() { - update(); - } - public void onSettingsError(String msg, Throwable e) { - showError(msg,e); - } - } - - public void onModuleLoad() { - statusPopup = new StatusPopup(); - - pgf = new PGFWrapper(); - RootPanel.get().add(createUI()); - pgf.addSettingsListener(new MySettingsListener()); - History.addHistoryListener(new MyHistoryListener()); - updateSettingsFromHistoryToken(); - pgf.updateAvailableGrammars(); - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeBagPanel.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeBagPanel.java deleted file mode 100644 index bab14808e..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeBagPanel.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.*; - -public class FridgeBagPanel extends Composite implements Iterable<Magnet> { - - private FlowPanel mainPanel; - - public FridgeBagPanel () { - mainPanel = new FlowPanel(); - - initWidget(new ScrollPanel(mainPanel)); - setStylePrimaryName("my-FridgeBagPanel"); - addStyleDependentName("empty"); - } - - public void clear() { - mainPanel.clear(); - } - - public void fill(List<Magnet> magnets) { - for (Magnet magnet : magnets) { - mainPanel.add(magnet); - } - - if (mainPanel.getWidgetCount() == 0) - addStyleDependentName("empty"); - else - removeStyleDependentName("empty"); - } - - public Iterator<Magnet> iterator() { - return (Iterator<Magnet>) (Iterator) mainPanel.iterator(); - } -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeTextPanel.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeTextPanel.java deleted file mode 100644 index a44a72446..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/FridgeTextPanel.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import com.google.gwt.user.client.ui.*; - -public class FridgeTextPanel extends Composite { - - private MagnetFactory magnetFactory; - - private FlowPanel mainPanel; - - private ChangeListenerCollection listeners = null; - - public FridgeTextPanel (MagnetFactory magnetFactory) { - this.magnetFactory = magnetFactory; - mainPanel = new FlowPanel(); - mainPanel.setStylePrimaryName("magnets"); - DockPanel wrapper = new DockPanel(); - wrapper.add(mainPanel, DockPanel.CENTER); - Widget buttons = createButtonPanel(); - wrapper.add(buttons, DockPanel.EAST); - wrapper.setCellWidth(mainPanel, "100%"); - wrapper.setCellWidth(buttons, "6em"); - wrapper.setHorizontalAlignment(DockPanel.ALIGN_RIGHT); - initWidget(wrapper); - setStylePrimaryName("my-FridgeTextPanel"); - } - - - protected Widget createButtonPanel () { - Panel buttons = new VerticalPanel(); - buttons.setStylePrimaryName("buttons"); - PushButton deleteLastButton = new PushButton(new Image("org.grammaticalframework.ui.gwt.FridgeApp/delete-last.png")); - deleteLastButton.setTitle("Removes the last magnet."); - deleteLastButton.addClickListener(new ClickListener () { - public void onClick(Widget sender) { - deleteLast(); - } - }); - buttons.add(deleteLastButton); - PushButton clearButton = new PushButton("Clear"); - clearButton.addClickListener(new ClickListener () { - public void onClick(Widget sender) { - clear(); - } - }); - clearButton.setTitle("Removes all magnets."); - buttons.add(clearButton); - return buttons; - } - - public void setEngaged(boolean engaged) { - if (engaged) { - addStyleDependentName("engage"); - } else { - removeStyleDependentName("engage"); - } - } - - public String getText () { - StringBuilder sb = new StringBuilder(); - for (Widget w : mainPanel) { - if (w instanceof Magnet) { - String word = ((Magnet)w).getText(); - if (sb.length() > 0) { - sb.append(' '); - } - sb.append(word); - } - } - return sb.toString(); - } - - public void setText (String text, String language) { - if (!text.equals(getText())) { - mainPanel.clear(); - for (String word : text.split("\\s+")) { - if (word.length() > 0) { - mainPanel.add(magnetFactory.createUsedMagnet(word, language)); - } - } - fireChange(); - } - } - - public void clear () { - mainPanel.clear(); - fireChange(); - } - - public void addMagnet (Magnet magnet) { - mainPanel.add(magnetFactory.createUsedMagnet(magnet)); - fireChange(); - } - - public void deleteLast() { - int c = mainPanel.getWidgetCount(); - if (c > 0) { - mainPanel.remove(c-1); - fireChange(); - } - } - - protected void fireChange() { - listeners.fireChange(this); - } - - public void addChangeListener(ChangeListener listener) { - if (listeners == null) { - listeners = new ChangeListenerCollection(); - } - listeners.add(listener); - } -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/GrammarsPanel.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/GrammarsPanel.java deleted file mode 100644 index 0857c3c4e..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/GrammarsPanel.java +++ /dev/null @@ -1,201 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; -import com.google.gwt.user.client.*; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.http.client.*; -import com.google.gwt.xml.client.*; -import com.google.gwt.event.logical.shared.*; -import com.google.gwt.event.dom.client.*; -import com.google.gwt.event.shared.*; - -public class GrammarsPanel extends Composite { - - private PGFWrapper pgf; - private ContentService contentService; - private StatusPopup statusPopup; - - private VerticalPanel grammarsPanel; - private FormPanel form = null; - - public GrammarsPanel(PGFWrapper pgf, ContentService contentService, StatusPopup statusPopup) { - this.pgf = pgf; - this.contentService = contentService; - this.statusPopup = statusPopup; - - VerticalPanel vpanel = new VerticalPanel(); - - Button btnNew = new Button("New Grammar"); - btnNew.addClickListener(new ClickListener() { - public void onClick(Widget sender) { - if (form == null) { - grammarsPanel.insert(new GrammarInfoPanel(null),0); - } - } - }); - vpanel.add(btnNew); - - grammarsPanel = new VerticalPanel(); - grammarsPanel.setWidth("100%"); - vpanel.add(grammarsPanel); - - initWidget(vpanel); - setStylePrimaryName("my-GrammarsPanel"); - - contentService.addSettingsListener(new MySettingsListener()); - } - - private class GrammarInfoPanel extends Composite { - public GrammarInfoPanel(final ContentService.GrammarInfo grammar) { - final VerticalPanel vpanel = new VerticalPanel(); - - if (grammar != null) { - FlexTable header = new FlexTable(); - header.setStylePrimaryName("my-TableHeader"); - header.setText(0,0,grammar.getName()); - vpanel.add(header); - - final Image updateButton = new Image("org.grammaticalframework.ui.gwt.EditorApp/grammar-buttons.png",0,0,20,20); - updateButton.setTitle("Edit the grammar definition."); - updateButton.setStylePrimaryName("toolbar-button"); - header.setWidget(0,1,updateButton); - header.getColumnFormatter().setWidth(1,"20px"); - - final Image deleteButton = new Image("org.grammaticalframework.ui.gwt.EditorApp/grammar-buttons.png",20,0,20,20); - deleteButton.setTitle("Delete this grammar."); - deleteButton.setStylePrimaryName("toolbar-button"); - header.setWidget(0,2,deleteButton); - header.getColumnFormatter().setWidth(2,"20px"); - - final Label descr = new Label(grammar.getDescription()); - descr.setStylePrimaryName("descr-label"); - vpanel.add(descr); - - updateButton.addClickListener(new ClickListener () { - public void onClick(Widget sender) { - if (form == null) { - vpanel.remove(descr); - vpanel.add(form = createUploadForm(grammar)); - } - } - }); - - deleteButton.addClickListener(new ClickListener () { - public void onClick(Widget sender) { - contentService.deleteGrammar(grammar.getURL(), new ContentService.DeleteCallback() { - public void onResult(ContentService.DeleteResult result) { - contentService.updateAvailableGrammars(); - } - - public void onError(Throwable e) { - statusPopup.showError("Delete failed", e); - } - }); - } - }); - } else { - FlexTable header = new FlexTable(); - header.setStylePrimaryName("my-TableHeader"); - header.setText(0,0,"Add New Grammar"); - vpanel.add(header); - vpanel.add(form = createUploadForm(grammar)); - } - - initWidget(vpanel); - setStylePrimaryName("my-GrammarInfoPanel"); - } - - public FormPanel createUploadForm(final ContentService.GrammarInfo grammar) { - UploadFormHandler uploadFormHandler = new UploadFormHandler(); - - final FormPanel form = new FormPanel(); - form.setWidth("100%"); - form.setEncoding(FormPanel.ENCODING_MULTIPART); - form.setMethod(FormPanel.METHOD_POST); - form.setAction(ContentService.getInit().getContentURL()); - form.addSubmitHandler(uploadFormHandler); - form.addSubmitCompleteHandler(uploadFormHandler); - - VerticalPanel vPanel = new VerticalPanel(); - vPanel.setWidth("100%"); - form.add(vPanel); - - vPanel.add(new HTML("<input type=\"hidden\" name=\"userId\" value=\""+ContentService.getInit().getUserId()+"\"/>\n"+ - "<input type=\"hidden\" name=\"command\" value=\"update_grammar\"/>")); - - HorizontalPanel hPanel = new HorizontalPanel(); - hPanel.setSpacing(8); - hPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); - vPanel.add(hPanel); - - final FileUpload fileUpload = new FileUpload(); - fileUpload.setName("file"); - hPanel.add(fileUpload); - - hPanel.add(new HTML(" ")); - - hPanel.add(new Label("Name:")); - final TextBox grammarName = new TextBox(); - grammarName.setName("name"); - grammarName.setWidth("300px"); - hPanel.add(grammarName); - - hPanel.add(new HTML(" ")); - - hPanel.add(new Button("Upload", new ClickListener() { - public void onClick(Widget sender) { - if (grammar == null && - fileUpload.getFilename().equals("")) - statusPopup.showError("You must select a file to upload", null); - else - form.submit(); - } - })); - hPanel.add(new Button("Cancel", new ClickListener() { - public void onClick(Widget sender) { - contentService.updateAvailableGrammars(); - } - })); - - vPanel.add(new Label("Description:")); - TextArea grammarDescr = new TextArea(); - grammarDescr.setName("description"); - grammarDescr.setWidth("100%"); - grammarDescr.setHeight("50px"); - vPanel.add(grammarDescr); - - if (grammar != null) { - grammarName.setText(grammar.getName()); - grammarDescr.setText(grammar.getDescription()); - - vPanel.add(new HTML("<input type=\"hidden\" name=\"url\" value=\""+grammar.getURL()+"\"/>")); - } - - return form; - } - - private class UploadFormHandler implements FormPanel.SubmitHandler, FormPanel.SubmitCompleteHandler { - public void onSubmit(FormPanel.SubmitEvent event) { - } - - public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) { - contentService.updateAvailableGrammars(); - } - } - } - - private class MySettingsListener implements SettingsListener { - public void onAvailableGrammarsChanged() { - form = null; - grammarsPanel.clear(); - for (ContentService.GrammarInfo grammar : contentService.getGrammars()) { - grammarsPanel.add(new GrammarInfoPanel(grammar)); - } - } - public void onSelectedGrammarChanged() { } - public void onInputLanguageChanged() { } - public void onOutputLanguageChanged() { } - public void onStartCategoryChanged() { } - public void onSettingsError(String msg, Throwable e) { } - } -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/IterableJsArray.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/IterableJsArray.java deleted file mode 100644 index b1d501ddb..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/IterableJsArray.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.core.client.JsArray; - -public class IterableJsArray<T extends JavaScriptObject> extends JsArray<T> { - - protected IterableJsArray() {} - - public final boolean isEmpty() { - return length() == 0; - } - - public final Iterable<T> iterable() { - return new Iterable<T>() { - public Iterator<T> iterator() { - return new Iterator<T>() { - private int i = 0; - public boolean hasNext() { - return i < length(); - } - public T next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - return get(i++); - } - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - }; - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/JSONCallback.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/JSONCallback.java deleted file mode 100644 index 485173b49..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/JSONCallback.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import com.google.gwt.core.client.JavaScriptObject; - -public interface JSONCallback<T extends JavaScriptObject> { - public void onResult (T result) ; - public void onError (Throwable e) ; -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/JSONRequest.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/JSONRequest.java deleted file mode 100644 index 15da7caf0..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/JSONRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import com.google.gwt.http.client.*; - -public class JSONRequest { - - private Request httpRequest; - - JSONRequest (Request httpRequest) { - this.httpRequest = httpRequest; - } - - public void cancel() { - if (httpRequest != null) { - httpRequest.cancel(); - } - } - -}
\ No newline at end of file diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/JSONRequestBuilder.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/JSONRequestBuilder.java deleted file mode 100644 index e2e83dc6f..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/JSONRequestBuilder.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.http.client.Request; -import com.google.gwt.http.client.RequestBuilder; -import com.google.gwt.http.client.RequestCallback; -import com.google.gwt.http.client.RequestException; -import com.google.gwt.http.client.Response; -import com.google.gwt.http.client.URL; - -import java.util.List; - -public class JSONRequestBuilder { - - public static class Arg { - public final String name; - public final String value; - public Arg (String name, String value) { - this.name = name; - this.value = value; - } - public Arg (String name, int value) { - this(name, Integer.toString(value)); - } - } - - public static <T extends JavaScriptObject> JSONRequest sendRequest (String base, List<Arg> vars, final JSONCallback<T> callback) { - String url = getQueryURL(base,vars); - RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); - builder.setTimeoutMillis(30000); - builder.setHeader("Accept","text/plain, text/html;q=0.5, */*;q=0.1"); - Request request = null; - - try { - request = builder.sendRequest(null, new RequestCallback() { - public void onError(Request request, Throwable e) { - callback.onError(e); - } - - public void onResponseReceived(Request request, Response response) { - if (200 == response.getStatusCode()) { - callback.onResult(JSONRequestBuilder.<T>eval(response.getText())); - } else { - RequestException e = new RequestException("Response not OK: " + response.getStatusCode() + ". " + response.getText()); - callback.onError(e); - } - } - }); - } catch (RequestException e) { - callback.onError(e); - } - - return new JSONRequest(request); - } - - public static <T extends JavaScriptObject> JSONRequest sendDataRequest (String base, List<Arg> vars, String content, final JSONCallback<T> callback) { - String url = getQueryURL(base,vars); - RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url); - builder.setTimeoutMillis(30000); - builder.setHeader("Content-Length", Integer.toString(content.length())); - builder.setHeader("Accept","text/plain, text/html;q=0.5, */*;q=0.1"); - Request request = null; - - try { - request = builder.sendRequest(content, new RequestCallback() { - public void onError(Request request, Throwable e) { - callback.onError(e); - } - - public void onResponseReceived(Request request, Response response) { - if (200 == response.getStatusCode()) { - callback.onResult(JSONRequestBuilder.<T>eval(response.getText())); - } else { - RequestException e = new RequestException("Response not OK: " + response.getStatusCode() + ". " + response.getText()); - callback.onError(e); - } - } - }); - } catch (RequestException e) { - callback.onError(e); - } - - return new JSONRequest(request); - } - - private static native <T extends JavaScriptObject> T eval(String json) /*-{ - return eval('(' + json + ')'); - }-*/; - - public static String getQueryURL(String base, List<Arg> args) { - StringBuffer sb = new StringBuffer(); - sb.append(base); - sb.append("?"); - if (args != null) { - for (Arg arg : args) { - if (arg.value != null) { - if (sb.length() > 0) { - sb.append("&"); - } - sb.append(URL.encodeComponent(arg.name)); - sb.append("="); - sb.append(URL.encodeComponent(arg.value)); - } - } - } - return sb.toString(); - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/LinearizationsPanel.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/LinearizationsPanel.java deleted file mode 100644 index 04aa5d5d7..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/LinearizationsPanel.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; - -import com.google.gwt.core.client.*; -import com.google.gwt.user.client.*; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.event.dom.client.*; -import com.google.gwt.event.logical.shared.*; -import com.google.gwt.event.shared.*; - -public class LinearizationsPanel extends Composite { - - protected PGFWrapper pgf; - - public LinearizationsPanel(PGFWrapper pgf, PGF.Linearizations lins) { - this.pgf = pgf; - - HorizontalPanel hPanel = new HorizontalPanel(); - 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(lins.getTree())); - btnPanel.add(createAlignButton(lins.getTree())); - hPanel.add(btnPanel); - hPanel.setCellHorizontalAlignment(btnPanel,HasHorizontalAlignment.ALIGN_RIGHT); - - for (PGF.Linearization l : lins.getLinearizations().iterable()) { - linsPanel.add(createTranslation(l.getTo(), lins.getTree(), l.getText())); - } - - initWidget(hPanel); - setStylePrimaryName("my-translation-frame"); - } - - protected Widget createAbsTreeButton(final String abstractTree) { - Image treeBtn = new Image("org.grammaticalframework.ui.gwt.EditorApp/tree-btn.png"); - treeBtn.setTitle("Displays the abstract syntax tree."); - treeBtn.addClickListener( - new ClickListener() { - public void onClick(Widget sender) { - // Create a dialog box and set the caption text - final DialogBox dialogBox = new DialogBox(); - dialogBox.setText("Abstract Syntax Tree"); - - // Create a table to layout the content - HorizontalPanel dialogContents = new HorizontalPanel(); - dialogContents.setSpacing(4); - dialogBox.setWidget(dialogContents); - - // Add an image to the dialog - - Frame image = new Frame(pgf.graphvizAbstractTree(abstractTree)); - image.addStyleName("my-treeimage"); - dialogContents.add(image); - - // Add a close button at the bottom of the dialog - Button closeButton = new Button("Close", - new ClickListener() { - public void onClick(Widget sender) { - dialogBox.hide(); - } - }); - dialogContents.add(closeButton); - - dialogBox.center(); - dialogBox.show(); - } - }); - return treeBtn; - } - - protected Widget createAlignButton(final String abstractTree) { - Image alignBtn = new Image("org.grammaticalframework.ui.gwt.EditorApp/align-btn.png"); - alignBtn.setTitle("Displays word-alignment diagram."); - alignBtn.addClickListener( - new ClickListener() { - public void onClick(Widget sender) { - // Create a dialog box and set the caption text - final DialogBox dialogBox = new DialogBox(); - dialogBox.setText("Word Alignment"); - - // Create a table to layout the content - HorizontalPanel dialogContents = new HorizontalPanel(); - dialogContents.setSpacing(4); - dialogBox.setWidget(dialogContents); - - // Add an image to the dialog - Frame image = new Frame(pgf.graphvizAlignment(abstractTree)); - image.addStyleName("my-alignmentimage"); - dialogContents.add(image); - - // Add a close button at the bottom of the dialog - Button closeButton = new Button("Close", - new ClickListener() { - public void onClick(Widget sender) { - dialogBox.hide(); - } - }); - dialogContents.add(closeButton); - - dialogBox.center(); - dialogBox.show(); - } - }); - return alignBtn; - } - - protected Widget createTranslation(final String language, final String abstractTree, String text) { - Label l = new Label(text); - l.addStyleName("my-translation"); - String lang = pgf.getLanguageCode(language); - if (lang != null) { - l.getElement().setLang(lang); - } - l.addClickListener(new ClickListener() { - public void onClick(Widget sender) { - // Create a dialog box and set the caption text - final DialogBox dialogBox = new DialogBox(); - dialogBox.setText("Parse Tree"); - - // Create a table to layout the content - HorizontalPanel dialogContents = new HorizontalPanel(); - dialogContents.setSpacing(4); - dialogBox.setWidget(dialogContents); - - // Add an image to the dialog - Frame image = new Frame(pgf.graphvizParseTree(abstractTree, language)); - image.addStyleName("my-treeimage"); - dialogContents.add(image); - - // Add a close button at the bottom of the dialog - Button closeButton = new Button("Close", - new ClickListener() { - public void onClick(Widget sender) { - dialogBox.hide(); - } - }); - dialogContents.add(closeButton); - - dialogBox.center(); - dialogBox.show(); - } - }); - return l; - } -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/Magnet.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/Magnet.java deleted file mode 100644 index ded8a171a..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/Magnet.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import com.google.gwt.user.client.ui.HTML; - -public class Magnet extends HTML { - - private String language; - - public Magnet (String text, String language) { - this.language = language; - setHTML(text); - setStylePrimaryName("my-Magnet"); - } - - public String getLanguage() { - return language; - } - - public String getWord() { - return getHTML(); - } -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MagnetFactory.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MagnetFactory.java deleted file mode 100644 index 5bb780456..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MagnetFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import com.google.gwt.user.client.ui.*; - -public class MagnetFactory { - - private ClickListener clickListener; - - public MagnetFactory (ClickListener clickListener) { - this.clickListener = clickListener; - } - - public Magnet createUsedMagnet(Magnet magnet) { - return createUsedMagnet(magnet.getText(), magnet.getLanguage()); - } - - public Magnet createUsedMagnet(String text, String language) { - return new Magnet(text, language); - } - - public Magnet createMagnet(Magnet magnet) { - return createMagnet(magnet.getText(), magnet.getLanguage()); - } - - public Magnet createMagnet(String text, String language) { - Magnet magnet = new Magnet(text, language); - magnet.addClickListener(clickListener); - return magnet; - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MagnetSearchBox.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MagnetSearchBox.java deleted file mode 100644 index 5a2a70401..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MagnetSearchBox.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; - -import com.google.gwt.core.client.*; -import com.google.gwt.user.client.*; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.event.dom.client.*; -import com.google.gwt.event.logical.shared.*; -import com.google.gwt.event.shared.*; -import com.google.gwt.dom.client.Node; -import com.google.gwt.dom.client.Text; -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.Document; -import org.grammaticalframework.ui.gwt.client.selection.*; - -public class MagnetSearchBox extends FocusWidget { - public MagnetSearchBox() { - this(Document.get().createDivElement()); - } - - public MagnetSearchBox(Element elem) { - super(elem); - elem.setAttribute("contentEditable", "true"); - setStyleName("searchbox"); - } - - public String getText() { - return getElement().getInnerText(); - } - - public void setText(String s) { - getElement().setInnerText(s); - } - - public int getCursorPos() { - return 0; - } - - public void setCursorPos(int pos) { - Node child = getElement().getFirstChild(); - if (child instanceof Text) { - SelectionEndPoint selPoint = new SelectionEndPoint((Text) child,pos); - Selection sel = Selection.getSelection(); - sel.select(selPoint,selPoint); - } - return; - } -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MorphoApp.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MorphoApp.java deleted file mode 100644 index 44e7bacb6..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MorphoApp.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; - -import com.google.gwt.core.client.*; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.core.client.JavaScriptObject; - -public class MorphoApp implements EntryPoint { - private TextBox lemmaBox = new TextBox(); - private Button submitButton = new Button("Submit"); - private Grid outputGrid = new Grid(2,0); - - public void onModuleLoad() { - HorizontalPanel inputPanel = new HorizontalPanel(); - inputPanel.add(lemmaBox); - inputPanel.add(submitButton); - - submitButton.addClickListener(new ClickListener() { - public void onClick(Widget sender) { - - String url = "http://localhost:41296/morpho/morpho.fcgi/eval"; - List<JSONRequestBuilder.Arg> args = new ArrayList<JSONRequestBuilder.Arg>(); - args.add(new JSONRequestBuilder.Arg("term", lemmaBox.getText())); - - JSONRequestBuilder.sendRequest(url, args, new TableCallback() { - public void onResult (IterableJsArray<InflectionForm> table) - { - outputGrid.resize(table.length(),2); - int row = 0; - for (InflectionForm form : table.iterable()) { - outputGrid.setText(row,0,form.getName()); - outputGrid.setText(row,1,form.getValue()); - row++; - } - } - - public void onError (Throwable e) - { - outputGrid.resize(1,1); - outputGrid.setText(0,0,e.toString()); - } - }); - } - }); - - - VerticalPanel mainPanel = new VerticalPanel(); - mainPanel.add(inputPanel); - mainPanel.add(outputGrid); - RootPanel.get().add(mainPanel); - } - - public interface TableCallback extends JSONCallback<IterableJsArray<InflectionForm>> { } - - public static class InflectionForm extends JavaScriptObject { - protected InflectionForm() { } - - public final native String getName() /*-{ return this.name; }-*/; - - public final native String getValue() /*-{ return this.value; }-*/; - } -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MyListBox.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MyListBox.java deleted file mode 100644 index ce716b91d..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/MyListBox.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.Collection; - -import com.google.gwt.user.client.ui.ListBox; - -public class MyListBox extends ListBox { - - public MyListBox () { } - - public void clearSelection () { - setSelectedIndex(-1); - } - - public String getSelectedValue() { - int i = getSelectedIndex(); - return i == -1 ? null : getValue(i); - } - - public void setSelectedValue(String value) { - if (value == null) { - clearSelection(); - } else { - int c = getItemCount(); - for (int i = 0; i < c; i++) { - if (getValue(i).equals(value)) { - setSelectedIndex(i); - return; - } - } - } - } - - public void addItems(Collection<String> items) { - for (String item : items) { - addItem(item); - } - } - -} 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 deleted file mode 100644 index 17eef12bb..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/PGF.java +++ /dev/null @@ -1,241 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import org.grammaticalframework.ui.gwt.client.JSONRequestBuilder.Arg; - -import java.util.*; -import com.google.gwt.core.client.*; -import com.google.gwt.http.client.*; - -public class PGF { - - public PGF () { - } - - /* Grammar */ - - public JSONRequest grammar (String pgfURL, final GrammarCallback callback) { - return sendGrammarRequest(pgfURL, "grammar", new ArrayList<Arg>(), callback); - } - - public interface GrammarCallback extends JSONCallback<Grammar> { } - - public static class Grammar extends JavaScriptObject { - protected Grammar() { } - - public final native String getName() /*-{ return this.name; }-*/; - - public final native String getUserLanguage() /*-{ return this.userLanguage; }-*/; - - public final native IterableJsArray<Language> getLanguages() /*-{ return this.languages; }-*/; - - public final native JsArrayString getCategories() /*-{ return this.categories; }-*/; - - public final native JsArrayString getFunctions() /*-{ return this.functions; }-*/; - } - - public static class Language extends JavaScriptObject { - protected Language() { } - - public final native String getName() /*-{ return this.name; }-*/; - public final native String getLanguageCode() /*-{ return this.languageCode; }-*/; - } - - /* Translation */ - - public JSONRequest translate (String pgfURL, String input, String fromLang, String cat, String toLang, - final TranslateCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("input", input)); - args.add(new Arg("from", fromLang)); - args.add(new Arg("cat", cat)); - args.add(new Arg("to", toLang)); - return sendGrammarRequest(pgfURL, "translate", args, callback); - } - - public interface TranslateCallback extends JSONCallback<IterableJsArray<TranslationResult>> { } - - public static class TranslationResult extends JavaScriptObject { - protected TranslationResult() { } - - public final native String getFrom() /*-{ return this.from; }-*/; - public final native BracketedString getBracketedString() /*-{ return this.brackets; }-*/; - public final native IterableJsArray<Linearizations> getTranslations() /*-{ return this.translations; }-*/; - public final native TcError[] getTypeErrors() /*-{ return this.typeErrors; }-*/; - } - - public static class Linearizations extends JavaScriptObject { - protected Linearizations() { } - - public final native String getTree() /*-{ return this.tree; }-*/; - public final native IterableJsArray<Linearization> getLinearizations() /*-{ return this.linearizations; }-*/; - } - - /* Completion */ - - /** - * Get suggestions for completing the input. - * @param limit The number of suggestions to get. - * If -1 is passed, all available suggestions are retrieved. - */ - public JSONRequest complete (String pgfURL, String input, String fromLang, String cat, int limit, final CompleteCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("input", input)); - args.add(new Arg("from", fromLang)); - args.add(new Arg("cat", cat)); - if (limit > 0) { - args.add(new Arg("limit", limit)); - } - return sendGrammarRequest(pgfURL, "complete", args, callback); - } - - public interface CompleteCallback extends JSONCallback<IterableJsArray<Completion>> { } - - public static class Completion extends JavaScriptObject { - protected Completion() { } - - public final native String getFrom() /*-{ return this.from; }-*/; - public final native BracketedString getBracketedString() /*-{ return this.brackets; }-*/; - public final native String[] getCompletions() /*-{ return this.completions; }-*/; - public final native String getText() /*-{ return this.text; }-*/; - } - - /* Parsing */ - - public JSONRequest parse (String pgfURL, String input, String fromLang, String cat, final ParseCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("input", input)); - args.add(new Arg("from", fromLang)); - args.add(new Arg("cat", cat)); - return sendGrammarRequest(pgfURL, "parse", args, callback); - } - - public interface ParseCallback extends JSONCallback<IterableJsArray<ParseResult>> { } - - public static class ParseResult extends JavaScriptObject { - protected ParseResult() { } - - public final native String getFrom() /*-{ return this.from; }-*/; - public final native BracketedString getBracketedString() /*-{ return this.brackets; }-*/; - public final native String[] getTrees() /*-{ return this.trees; }-*/; - 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 final String render() { - if (getToken() != null) - return getToken(); - else { - StringBuilder sbuilder = new StringBuilder(); - for (BracketedString bs : getChildren()) { - if (sbuilder.length() > 0) - sbuilder.append(' '); - sbuilder.append(bs.render()); - } - return sbuilder.toString(); - } - } - } - - public static class TcError extends JavaScriptObject { - protected TcError() { } - - public final native int getFId() /*-{ return this.fid; }-*/; - public final native String getMsg() /*-{ return this.msg; }-*/; - } - - - /* Linearization */ - - public JSONRequest linearize (String pgfURL, String tree, String toLang, final LinearizeCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("tree", tree)); - args.add(new Arg("to", toLang)); - return sendGrammarRequest(pgfURL, "linearize", args, callback); - } - - public interface LinearizeCallback extends JSONCallback<IterableJsArray<Linearization>> { } - - public static class Linearization extends JavaScriptObject { - protected Linearization() { } - - public final native String getTo() /*-{ return this.to; }-*/; - public final native String getText() /*-{ return this.text; }-*/; - } - - public String graphvizAbstractTree(String pgfURL, String abstractTree) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("command", "abstrtree")); - args.add(new Arg("tree", abstractTree)); - return JSONRequestBuilder.getQueryURL(pgfURL,args); - } - - public String graphvizParseTree(String pgfURL, String abstractTree, String lang) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("command", "parsetree")); - args.add(new Arg("tree", abstractTree)); - args.add(new Arg("from", lang)); - return JSONRequestBuilder.getQueryURL(pgfURL,args); - } - - public String graphvizAlignment(String pgfURL, String abstractTree) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("command", "alignment")); - args.add(new Arg("tree", abstractTree)); - return JSONRequestBuilder.getQueryURL(pgfURL,args); - } - - public Request browse(String pgfURL, String id, String href, String cssClass, RequestCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("command", "browse")); - args.add(new Arg("id", id)); - args.add(new Arg("href", href)); - args.add(new Arg("css-class", cssClass)); - - Request request = null; - try { - RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, - JSONRequestBuilder.getQueryURL(pgfURL,args)); - builder.setCallback(callback); - request = builder.send(); - } catch (RequestException ex) { - callback.onError(request, ex); - } - - return request; - } - - public JSONRequest generateAll(String pgfURL, String cat, int depth, int limit, String toLang, GenerationCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("cat", cat)); - args.add(new Arg("depth", depth)); - args.add(new Arg("limit", limit)); - args.add(new Arg("to", toLang)); - return sendGrammarRequest(pgfURL, "generate", args, callback); - } - - public JSONRequest generateRandom(String pgfURL, String cat, int depth, int limit, String toLang, GenerationCallback callback) { - List<Arg> args = new ArrayList<Arg>(); - args.add(new Arg("cat", cat)); - args.add(new Arg("depth", depth)); - args.add(new Arg("limit", limit)); - args.add(new Arg("to", toLang)); - return sendGrammarRequest(pgfURL, "random", args, callback); - } - - public interface GenerationCallback extends JSONCallback<IterableJsArray<Linearizations>> {} - - public <T extends JavaScriptObject> JSONRequest sendGrammarRequest(String pgfURL, String resource, List<Arg> args, final JSONCallback<T> callback) { - args.add(new Arg("command", resource)); - return JSONRequestBuilder.sendRequest(pgfURL, args, callback); - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/PGFWrapper.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/PGFWrapper.java deleted file mode 100644 index 1e248fa40..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/PGFWrapper.java +++ /dev/null @@ -1,294 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import com.google.gwt.http.client.*; -import com.google.gwt.xml.client.*; -import com.google.gwt.core.client.*; - -public class PGFWrapper { - - private String grammarURL = null; - - private PGF pgf; - - private String inputLanguage = null; - - private String outputLanguage = null; - - private String cat = null; - - // Cached info about the available grammars - - private List<String> grammars; - - // Cached info about the currently selected grammar - - private String userLanguage; - - private LinkedHashMap<String,PGF.Language> languages; - - private JsArrayString categories; - private JsArrayString functions; - - // Event listeners - - private List<SettingsListener> listeners = new LinkedList<SettingsListener>(); - - - public PGFWrapper() { - this.pgf = new PGF(); - } - - public void updateAvailableGrammars() { - String url = "/grammars.xml"; - RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url)); - try - { - builder.sendRequest(null, new RequestCallback() { - public void onResponseReceived(Request request, Response response) - { - if (200 == response.getStatusCode()) - { - grammars = new ArrayList<String>(); - try - { - Document grammarsDoc = XMLParser.parse(response.getText()); - - NodeList grammarsList = grammarsDoc.getElementsByTagName("grammar"); - for (int i = 0; i < grammarsList.getLength(); i++) - { - Node grammarNode = grammarsList.item(i); - grammars.add(((Element)grammarNode).getAttribute("name")); - } - } - catch (DOMException e) - { - fireSettingsError("Could not parse XML document.", e); - } - fireAvailableGrammarsChanged(); - } - else - { - fireSettingsError("Error getting grammar list", null); - } - } - - public void onError(Request request, Throwable e) - { - fireSettingsError("Error getting grammar list", e); - } - }); - } - catch (RequestException e) - { - fireSettingsError("Couldn't connect to server", e); - } - } - - protected void updateSelectedGrammar () { - if (grammarURL == null) - return; - - clearCachedInfo(); - pgf.grammar(grammarURL, new PGF.GrammarCallback() { - public void onResult(PGF.Grammar grammar) { - userLanguage = grammar.getUserLanguage(); - languages = new LinkedHashMap<String,PGF.Language>(); - for (PGF.Language l : grammar.getLanguages().iterable()) { - String name = l.getName(); - languages.put(name, l); - } - - categories = grammar.getCategories(); - functions = grammar.getFunctions(); - - fireSelectedGrammarChanged(); - } - - public void onError (Throwable e) { - fireSettingsError("Error getting language information", e); - } - }); - } - - // - // PGF functionality - // - - public JSONRequest translate (String input, final PGF.TranslateCallback callback) { - return pgf.translate(grammarURL, input, inputLanguage, cat, outputLanguage, callback); - } - - public JSONRequest complete (String input, int limit, final PGF.CompleteCallback callback) { - return pgf.complete(grammarURL, input, inputLanguage, cat, limit, callback); - } - - public JSONRequest parse (String input, final PGF.ParseCallback callback) { - return pgf.parse(grammarURL, input, inputLanguage, cat, callback); - } - - public JSONRequest linearize (String tree, final PGF.LinearizeCallback callback) { - return pgf.linearize(grammarURL, tree, outputLanguage, callback); - } - - public String graphvizAbstractTree(String abstractTree) { - return pgf.graphvizAbstractTree(grammarURL,abstractTree); - } - - public String graphvizParseTree(String abstractTree, String lang) { - return pgf.graphvizParseTree(grammarURL,abstractTree,lang); - } - - public String graphvizAlignment(String abstractTree) { - return pgf.graphvizAlignment(grammarURL,abstractTree); - } - - public Request browse(String id, String href, String cssClass, RequestCallback callback) { - return pgf.browse(grammarURL, id, href, cssClass, callback); - } - - public JSONRequest generateAll(String cat, int depth, int limit, PGF.GenerationCallback callback) { - return pgf.generateAll(grammarURL, cat, depth, limit, outputLanguage, callback); - } - - public JSONRequest generateRandom(String cat, int depth, int limit, PGF.GenerationCallback callback) { - return pgf.generateRandom(grammarURL, cat, depth, limit, outputLanguage, callback); - } - - // - // Settings - // - - public String getGrammarURL() { - return grammarURL; - } - - public void setGrammarURL(String grammarURL) { - this.grammarURL = grammarURL; - this.inputLanguage = null; - this.outputLanguage = null; - this.cat = null; - updateSelectedGrammar(); - } - - public String getInputLanguage() { - return inputLanguage; - } - - public void setInputLanguage(String inputLanguage) { - this.inputLanguage = inputLanguage; - fireInputLanguageChanged(); - } - - public String getOutputLanguage() { - return outputLanguage; - } - - public void setOutputLanguage(String outputLanguage) { - this.outputLanguage = outputLanguage; - fireOutputLanguageChanged(); - } - - public String getStartCategory() { - return cat; - } - - public void setStartCategory(String cat) { - this.cat = cat; - fireStartCategoryChanged(); - } - - public JsArrayString getCategories() { - return categories; - } - - public JsArrayString getFunctions() { - return functions; - } - - - // - // Information about the available grammars - // - public List<String> getGrammars() { - return grammars; - } - - // - // Information about the selected grammar - // - private void clearCachedInfo () { - languages = null; - } - - public String getUserLanguage () { - return userLanguage; - } - - public String getLanguageCode (String language) { - PGF.Language l = languages.get(language); - return l == null ? null : l.getLanguageCode(); - } - - public Collection<String> getAllLanguages() { - return languages.keySet(); - } - - // - // Listeners - // - - public static class SettingsAdapter implements SettingsListener { - public void onAvailableGrammarsChanged() {} - public void onSelectedGrammarChanged() {} - public void onInputLanguageChanged() {} - public void onOutputLanguageChanged() {} - public void onStartCategoryChanged() {} - public void onSettingsError(String msg, Throwable e) {} - } - - public void addSettingsListener(SettingsListener listener) { - listeners.add(listener); - } - - protected void fireAvailableGrammarsChanged() { - for (SettingsListener listener : listeners) { - listener.onAvailableGrammarsChanged(); - } - } - - protected void fireSelectedGrammarChanged() { - for (SettingsListener listener : listeners) { - listener.onSelectedGrammarChanged(); - } - } - - protected void fireInputLanguageChanged() { - for (SettingsListener listener : listeners) { - listener.onInputLanguageChanged(); - } - } - - protected void fireOutputLanguageChanged() { - for (SettingsListener listener : listeners) { - listener.onOutputLanguageChanged(); - } - } - - protected void fireStartCategoryChanged() { - for (SettingsListener listener : listeners) { - listener.onStartCategoryChanged(); - } - } - - protected void fireSettingsError(String msg, Throwable e) { - for (SettingsListener listener : listeners) { - listener.onSettingsError(msg, e); - } - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/QueryPanel.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/QueryPanel.java deleted file mode 100644 index b364ed0b6..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/QueryPanel.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; - -import com.google.gwt.http.client.*; -import com.google.gwt.user.client.ui.*; - -public class QueryPanel extends Composite { - - private PGFWrapper pgf; - private StatusPopup statusPopup; - private TextArea queryBox; - private VerticalPanel outputPanel; - private JSONRequest executeRequest = null; - - public QueryPanel(PGFWrapper pgf, StatusPopup statusPopup) { - this.pgf = pgf; - this.statusPopup = statusPopup; - - VerticalPanel vPanel = new VerticalPanel(); - vPanel.add(createQueryPanel()); - - initWidget(vPanel); - setStylePrimaryName("my-QueryPanel"); - - pgf.addSettingsListener(new MySettingsListener()); - } - - protected Widget createQueryPanel() { - queryBox = new TextArea(); - queryBox.setStylePrimaryName("my-QueryBox"); - queryBox.setTitle("Goal category"); - - HorizontalPanel boxPanel = new HorizontalPanel(); - boxPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); - boxPanel.setSpacing(5); - - final TextBox limitBox = new TextBox(); - limitBox.setTitle("Upper limit of the number of examples generated"); - limitBox.setWidth("5em"); - limitBox.setText("10"); - boxPanel.add(new Label("limit:")); - boxPanel.add(limitBox); - - boxPanel.add(new HTML("")); - - final TextBox depthBox = new TextBox(); - depthBox.setTitle("Maximal depth for every example"); - depthBox.setWidth("5em"); - depthBox.setText("4"); - boxPanel.add(new Label("depth:")); - boxPanel.add(depthBox); - - boxPanel.add(new HTML("")); - - final CheckBox randomBox = new CheckBox(); - randomBox.setTitle("random/exhaustive generation"); - randomBox.setText("random"); - boxPanel.add(randomBox); - - outputPanel = new VerticalPanel(); - outputPanel.addStyleName("my-translations"); - outputPanel.addStyleDependentName("working"); - - Button execButton = new Button("Execute"); - - DecoratorPanel queryDecorator = new DecoratorPanel(); - VerticalPanel vPanel = new VerticalPanel(); - vPanel.add(new Label("Query")); - HorizontalPanel hPanel = new HorizontalPanel(); - hPanel.add(queryBox); - hPanel.add(execButton); - vPanel.add(hPanel); - vPanel.add(boxPanel); - queryDecorator.add(vPanel); - - VerticalPanel queryPanel = new VerticalPanel(); - queryPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); - queryPanel.add(queryDecorator); - queryPanel.add(outputPanel); - - execButton.addClickListener(new ClickListener() { - public void onClick(Widget sender) { - if (executeRequest != null) { - executeRequest.cancel(); - } - - PGF.GenerationCallback callback = new PGF.GenerationCallback() { - public void onResult(IterableJsArray<PGF.Linearizations> result) { - executeRequest = null; - - outputPanel.clear(); - outputPanel.removeStyleDependentName("working"); - - for (PGF.Linearizations lins : result.iterable()) { - LinearizationsPanel lin = new LinearizationsPanel(pgf, lins); - lin.setWidth("100%"); - outputPanel.add(lin); - } - } - - public void onError(Throwable e) { - executeRequest = null; - statusPopup.showError("The execution failed", e); - } - }; - - int depth, limit; - try { - depth = Integer.parseInt(depthBox.getText()); - limit = Integer.parseInt(limitBox.getText()); - } catch (NumberFormatException e) { - statusPopup.showError("Invalid depth/limit parameter", e); - return; - } - - if (randomBox.getValue()) - executeRequest = pgf.generateRandom(queryBox.getText(), depth, limit, callback); - else - executeRequest = pgf.generateAll(queryBox.getText(), depth, limit, callback); - } - }); - - return queryPanel; - } - - protected class MySettingsListener implements SettingsListener { - - public MySettingsListener() { - } - - public void onAvailableGrammarsChanged() { } - - public void onSelectedGrammarChanged() { - queryBox.setText(""); - outputPanel.clear(); - } - - public void onInputLanguageChanged() { } - public void onOutputLanguageChanged() { } - public void onStartCategoryChanged() { } - public void onSettingsError(String msg, Throwable e) { } - } -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SettingsListener.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SettingsListener.java deleted file mode 100644 index 494c990f6..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SettingsListener.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -public interface SettingsListener { - public void onAvailableGrammarsChanged(); - public void onSelectedGrammarChanged(); - public void onInputLanguageChanged(); - public void onOutputLanguageChanged(); - public void onStartCategoryChanged(); - public void onSettingsError(String msg, Throwable e); -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SettingsPanel.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SettingsPanel.java deleted file mode 100644 index b3c22572c..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SettingsPanel.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import com.google.gwt.user.client.ui.*; - -public class SettingsPanel extends Composite { - - private PGFWrapper pgf; - private ContentService contentService; - private StatusPopup statusPopup; - - private MyListBox grammarBox; - private MyListBox fromLangBox; - private MyListBox toLangBox; - - public SettingsPanel (PGFWrapper pgf, ContentService contentService, StatusPopup statusPopup) { - this.pgf = pgf; - this.contentService = contentService; - this.statusPopup = statusPopup; - - HorizontalPanel settingsPanel = new HorizontalPanel(); - settingsPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); - settingsPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); - - grammarBox = new MyListBox(); - grammarBox.addChangeListener(new ChangeListener() { - public void onChange(Widget sender) { - SettingsPanel.this.pgf.setGrammarURL(grammarBox.getSelectedValue()); - } - }); - settingsPanel.add(new FormWidget("Grammar:", grammarBox)); - - fromLangBox = new MyListBox(); - fromLangBox.addChangeListener(new ChangeListener() { - public void onChange(Widget sender) { - SettingsPanel.this.pgf.setInputLanguage(fromLangBox.getSelectedValue()); - } - }); - settingsPanel.add(new FormWidget("From:", fromLangBox)); - - toLangBox = new MyListBox(); - toLangBox.addChangeListener(new ChangeListener() { - public void onChange(Widget sender) { - SettingsPanel.this.pgf.setOutputLanguage(toLangBox.getSelectedValue()); - } - }); - settingsPanel.add(new FormWidget("To:", toLangBox)); - - if (contentService.getInit().getUserEMail() != null) { - String url = contentService.getInit().getContentURL(); - settingsPanel.add(new FormWidget(contentService.getInit().getUserEMail(), - new HTML("<A href='"+url+"'>Sign Out</A>"))); - } else { - String url = contentService.getInit().getContentURL(); - url = "https://www.google.com/accounts/o8/ud" - + "?openid.ns=http://specs.openid.net/auth/2.0" - + "&openid.ns.max_auth_age=300" - + "&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select" - + "&openid.identity=http://specs.openid.net/auth/2.0/identifier_select" - + "&openid.return_to=http://localhost:8080"+url - + "&openid.realm=http://localhost:8080/" - + "&openid.mode=checkid_setup" - + "&openid.ns.ax=http://openid.net/srv/ax/1.0" - + "&openid.ax.mode=fetch_request" - + "&openid.ax.type.email=http://axschema.org/contact/email" - + "&openid.ax.required=email"; - settingsPanel.add(new FormWidget("", - new HTML("<A href='"+url+"'>Sign In</A>"))); - } - - initWidget(settingsPanel); - setStylePrimaryName("my-SettingsPanel"); - - pgf.addSettingsListener(new MySettingsListener()); - contentService.addSettingsListener(new MySettingsListener()); - } - - private static class FormWidget extends HorizontalPanel { - public FormWidget(String label, Widget w) { - setStylePrimaryName("form-widget"); - setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); - add(new Label(label)); - add(w); - } - } - - private class MySettingsListener implements SettingsListener { - public void onAvailableGrammarsChanged() { - if (grammarBox != null) { - grammarBox.clear(); - fromLangBox.clear(); - toLangBox.clear(); - - for (ContentService.GrammarInfo grammar : contentService.getGrammars()) { - grammarBox.addItem(grammar.getName(), grammar.getURL()); - } - pgf.setGrammarURL(grammarBox.getSelectedValue()); - } - } - public void onSelectedGrammarChanged() { - if (grammarBox != null) { - grammarBox.setSelectedValue(pgf.getGrammarURL()); - } - if (fromLangBox != null) { - fromLangBox.clear(); - fromLangBox.addItem("Any language", ""); - fromLangBox.addItems(pgf.getAllLanguages()); - String inputLanguage = pgf.getInputLanguage(); - if (inputLanguage != null) { - fromLangBox.setSelectedValue(inputLanguage); - } - } - if (toLangBox != null) { - toLangBox.clear(); - toLangBox.addItem("All languages", ""); - toLangBox.addItems(pgf.getAllLanguages()); - String outputLanguage = pgf.getOutputLanguage(); - if (outputLanguage != null) { - fromLangBox.setSelectedValue(outputLanguage); - } - } - } - public void onInputLanguageChanged() { - if (fromLangBox != null) { - fromLangBox.setSelectedValue(pgf.getInputLanguage()); - } - } - public void onOutputLanguageChanged() { - if (toLangBox != null) { - toLangBox.setSelectedValue(pgf.getOutputLanguage()); - } - } - public void onStartCategoryChanged() { } - public void onSettingsError(String msg, Throwable e) { } - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/StatusPopup.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/StatusPopup.java deleted file mode 100644 index 73ff82e0d..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/StatusPopup.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.PopupPanel; - -public class StatusPopup extends PopupPanel { - - private Label label = new Label(); - - public StatusPopup () { - super(true, true); - label = new Label(); - add(label); - } - - public void setStatus(String msg) { - removeStyleDependentName("error"); - label.setText(msg); - center(); - } - - public void showError(String msg, Throwable e) { - GWT.log(msg, e); - addStyleDependentName("error"); - label.setText(msg); - center(); - } - - public void clearStatus() { - removeStyleDependentName("error"); - label.setText(""); - hide(); - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SubList.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SubList.java deleted file mode 100644 index 9d3221f39..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SubList.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.AbstractList; -import java.util.List; - -/** Work-around for missing List.subList() method in GWT JRE API emulation. */ -public class SubList<T> extends AbstractList<T> { - - private List<T> list; - - private int fromIndex; - - private int toIndex; - - public SubList(List<T> list, int fromIndex, int toIndex) { - this.list = list; - this.fromIndex = fromIndex; - this.toIndex = toIndex; - if (fromIndex < 0 || toIndex > list.size()) - throw new IndexOutOfBoundsException("Endpoint index value out of range"); - if (fromIndex > toIndex) - throw new IllegalArgumentException("Endpoint indices out of order"); - } - - public T get(int index) { - return list.get(fromIndex + index); - } - - public int size() { - return toIndex - fromIndex; - } - - public static <T> SubList<T> makeSubList(List<T> list, int fromIndex, int toIndex) { - return new SubList<T>(list, fromIndex, toIndex); - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SuggestPanel.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SuggestPanel.java deleted file mode 100644 index 8e2edf582..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/SuggestPanel.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.LinkedList; -import java.util.List; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.*; - -public class SuggestPanel extends Composite implements HasText { - - private SuggestBox suggest; - private Button submitButton; - - private List<SubmitListener> listeners = new LinkedList<SubmitListener>(); - - public SuggestPanel (PGFWrapper pgf) { - - CompletionOracle oracle = new CompletionOracle(pgf, new CompletionOracle.ErrorHandler() { - public void onError(Throwable e) { - GWT.log("Completion failed", e); - } - }); - - suggest = new SuggestBox(oracle); - suggest.setLimit(10); - suggest.addKeyboardListener(new KeyboardListenerAdapter() { - public void onKeyUp (Widget sender, char keyCode, int modifiers) { - if (keyCode == KEY_ENTER) { - submit(); - } - } - }); - - submitButton = new Button("Submit"); - submitButton.addClickListener(new ClickListener() { - public void onClick(Widget sender) { - submit(); - } - }); - - DockPanel mainPanel = new DockPanel(); - mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); - mainPanel.add(suggest, DockPanel.CENTER); - mainPanel.add(submitButton, DockPanel.EAST); - - initWidget(mainPanel); - setStylePrimaryName("my-SuggestPanel"); - - } - - public int getLimit() { - return suggest.getLimit(); - } - - public String getText() { - return suggest.getText(); - } - - public String getTitle() { - return suggest.getTitle(); - } - - public void onLoad() { - suggest.setFocus(true); - } - - public void setButtonText (String text) { - submitButton.setText(text); - } - - public void setEnabled(boolean enabled) { - submitButton.setEnabled(enabled); - } - - public void setLimit(int limit) { - suggest.setLimit(limit); - } - - public void setText (String text) { - suggest.setText(text); - } - - public void setTitle(String title) { - suggest.setTitle(title); - } - - public void addSubmitListener(SubmitListener listener) { - listeners.add(listener); - } - - public void submit() { - String text = getText(); - for (SubmitListener listener : listeners) { - listener.onSubmit(text); - } - } - - public interface SubmitListener { - public void onSubmit(String text); - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/TextInputPanel.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/TextInputPanel.java deleted file mode 100644 index bf2c04a03..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/TextInputPanel.java +++ /dev/null @@ -1,600 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.*; - -import com.google.gwt.core.client.*; -import com.google.gwt.user.client.*; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.event.dom.client.*; -import com.google.gwt.event.logical.shared.*; -import com.google.gwt.event.shared.*; - -public class TextInputPanel extends Composite implements Focusable, HasValueChangeHandlers<String>, HasSelectionHandlers<String> { - - protected ContentService contentService; - protected StatusPopup statusPopup; - protected FlowPanel textPanel = null; - protected FlowPanel mainPanel = null; - protected FocusPanel focusPanel = null; - protected Panel focusedPanel = null; - protected List<Panel> selectedPanels = null; - protected List<Panel> errorPanels = null; - protected Panel tempPanel = null; - protected Label status = null; - protected NavigationController navigationController; - protected MagnetSearchBox searchBox = null; - - private List<Label> words = new ArrayList<Label>(); - - private Map<Panel, Phrase> mapPanel2Phrase = new HashMap<Panel, Phrase>(); - private Map<Integer, Phrase> mapFId2Phrase = new HashMap<Integer, Phrase>(); - - private ChangeListenerCollection changeListeners = null; - - private Integer docId = null; - - public TextInputPanel(ContentService contentService, StatusPopup statusPopup) { - this.contentService = contentService; - this.statusPopup = statusPopup; - - mainPanel = new FlowPanel(); - mainPanel.setStylePrimaryName("wordspanel"); - - textPanel = new FlowPanel(); - textPanel.add(mainPanel); - textPanel.setStylePrimaryName("wordspanel"); - - Label space = new Label(" "); - space.setStylePrimaryName("wordspace"); - textPanel.add(space); - - Panel contentPanel = new FlowPanel(); - contentPanel.add(textPanel); - contentPanel.setStylePrimaryName("text"); - - focusPanel = new FocusPanel(); - focusPanel.setWidget(contentPanel); - focusPanel.setStylePrimaryName("frame"); - - Widget buttons = createToolbarPanel(); - - VerticalPanel wrapper = new VerticalPanel(); - wrapper.add(buttons); - wrapper.add(focusPanel); - initWidget(wrapper); - setStylePrimaryName("my-TextInputPanel"); - - navigationController = new NavigationController(); - focusPanel.addKeyDownHandler(navigationController); - } - - protected Widget createToolbarPanel() { - HorizontalPanel toolbar = new HorizontalPanel(); - toolbar.setStylePrimaryName("toolbar"); - - Panel buttons = new HorizontalPanel(); - toolbar.add(buttons); - toolbar.setCellHorizontalAlignment(buttons,HorizontalPanel.ALIGN_LEFT); - toolbar.setCellVerticalAlignment(buttons,HorizontalPanel.ALIGN_MIDDLE); - - Image clearButton = new Image("org.grammaticalframework.ui.gwt.EditorApp/textinput-buttons.png",0,0,20,20); - clearButton.setTitle("Clears the whole document."); - clearButton.setStylePrimaryName("toolbar-button"); - clearButton.addClickListener(new ClickListener () { - public void onClick(Widget sender) { - clear(); - } - }); - buttons.add(clearButton); - - Image saveButton = new Image("org.grammaticalframework.ui.gwt.EditorApp/textinput-buttons.png",20,0,20,20); - saveButton.setTitle("Save the document."); - saveButton.setStylePrimaryName("toolbar-button"); - saveButton.addClickListener(new ClickListener () { - public void onClick(Widget sender) { - save(); - } - }); - buttons.add(saveButton); - - Image deleteLastButton = new Image("org.grammaticalframework.ui.gwt.EditorApp/textinput-buttons.png",40,0,20,20); - deleteLastButton.setTitle("Removes the last word."); - deleteLastButton.setStylePrimaryName("toolbar-button"); - deleteLastButton.addClickListener(new ClickListener () { - public void onClick(Widget sender) { - deleteLast(); - } - }); - buttons.add(deleteLastButton); - - status = new Label(); - status.setTitle("The currently selected category."); - status.setStylePrimaryName("status"); - toolbar.add(status); - toolbar.setCellHorizontalAlignment(status,HorizontalPanel.ALIGN_RIGHT); - toolbar.setCellVerticalAlignment(status,HorizontalPanel.ALIGN_MIDDLE); - - return toolbar; - } - - public void renderBracketedString(final PGF.BracketedString bs) { - words.clear(); - mapPanel2Phrase.clear(); - mapFId2Phrase.clear(); - mainPanel.clear(); - selectedPanels = null; - focusedPanel = null; - errorPanels = null; - tempPanel = null; - - Widget widget = createWordPanels(bs); - mainPanel.add(widget); - } - - private Widget createWordPanels(final PGF.BracketedString bs) { - if (bs.getToken() != null) { - Label wordLabel = new Label(bs.getToken()); - wordLabel.setStylePrimaryName("wordlabel"); - wordLabel.addClickListener(navigationController); - words.add(wordLabel); - return wordLabel; - } else { - FlowPanel panel = new FlowPanel(); - panel.setStylePrimaryName("wordspanel"); - - Integer fid = new Integer(bs.getFId()); - Phrase phrase = mapFId2Phrase.get(fid); - if (phrase == null) { - phrase = new Phrase(); - phrase.cat = bs.getCat(); - phrase.panels = new ArrayList<Panel>(); - mapFId2Phrase.put(fid,phrase); - } - phrase.panels.add(panel); - mapPanel2Phrase.put(panel, phrase); - - for (PGF.BracketedString child : bs.getChildren()) { - if (panel.getWidgetCount() > 0) { - Label space = new Label(" "); - space.setStylePrimaryName("wordspace"); - panel.add(space); - } - panel.add(createWordPanels(child)); - } - return panel; - } - } - - public void clear() { - setSearchTerm(""); - words.clear(); - mapPanel2Phrase.clear(); - mapFId2Phrase.clear(); - mainPanel.clear(); - selectedPanels = null; - focusedPanel = null; - errorPanels = null; - tempPanel = null; - docId = null; - fireValueChange(); - } - - public void save() { - statusPopup.setStatus("Saving..."); - - contentService.save(docId, getText(), new ContentService.SaveCallback() { - public void onResult(ContentService.DocumentSignature sign) { - docId = new Integer(sign.getId()); - statusPopup.clearStatus(); - } - - public void onError(Throwable e) { - statusPopup.showError("Saving failed", e); - } - }); - } - - public void load(Object id) { - statusPopup.setStatus("Loading..."); - - contentService.load(id, new ContentService.LoadCallback() { - public void onResult(ContentService.Document document) { - clear(); - - docId = new Integer(document.getId()); - showSearchBox(); - searchBox.setText(document.getContent()); - - statusPopup.clearStatus(); - } - - public void onError(Throwable e) { - statusPopup.showError("Saving failed", e); - } - }); - } - - public void addMagnet(Magnet magnet) { - Label wordLabel = new Label(magnet.getText()); - wordLabel.setStylePrimaryName("wordlabel"); - getTempPanel().add(wordLabel); - words.add(wordLabel); - - fireValueChange(); - } - - public String deleteLast() { - int wordsCount = words.size(); - if (wordsCount <= 0) - return null; - Label lastWord = words.remove(wordsCount-1); - - setSearchTerm(""); - mapPanel2Phrase.clear(); - mapFId2Phrase.clear(); - mainPanel.clear(); - selectedPanels = null; - focusedPanel = null; - errorPanels = null; - tempPanel = null; - for (Label word : words) { - if (((FlowPanel) getTempPanel()).getWidgetCount() > 0) { - Label space = new Label(" "); - space.setStylePrimaryName("wordspace"); - getTempPanel().add(space); - } - getTempPanel().add(word); - } - fireValueChange(); - - return lastWord.getText(); - } - - public void showSearchBox() { - if (searchBox == null) { - searchBox = new MagnetSearchBox(); - SearchBoxKeyboardHandler handler = new SearchBoxKeyboardHandler(); - searchBox.addKeyUpHandler(handler); - searchBox.addKeyDownHandler(handler); - - textPanel.add(searchBox); - searchBox.setFocus(true); - } - } - - public void hideSearchBox() { - if (searchBox != null) { - searchBox.removeFromParent(); - searchBox = null; - } - } - - public void setSearchTerm(String term) { - if (searchBox != null) { - searchBox.setText(term); - if ("".equals(term)) - searchBox.setCursorPos(0); - } - } - - public String getSearchTerm() { - if (searchBox != null) - return searchBox.getText(); - else - return null; - } - - public void showSearchError() { - if (searchBox != null) { - searchBox.addStyleDependentName("error"); - } - } - - public void clearSearchError() { - if (searchBox != null) { - searchBox.removeStyleDependentName("error"); - } - } - - public void showError(int fid) { - if (errorPanels != null) { - for (Panel panel : errorPanels) { - panel.removeStyleDependentName("error"); - } - errorPanels = null; - } - - Phrase phrase = mapFId2Phrase.get(fid); - if (phrase != null) { - errorPanels = phrase.panels; - if (errorPanels != null) { - for (Panel selPanel : errorPanels) { - selPanel.addStyleDependentName("error"); - } - } - } - } - - private Panel getTempPanel() { - if (tempPanel == null) { - if (mainPanel.getWidgetCount() > 0) { - Label space = new Label(" "); - space.setStylePrimaryName("wordspace"); - mainPanel.add(space); - } - - tempPanel = new FlowPanel(); - tempPanel.setStylePrimaryName("wordspanel"); - mainPanel.add(tempPanel); - } - return tempPanel; - } - - protected void fireValueChange() { - DeferredCommand.addCommand(new Command() { - public void execute() { - ValueChangeEvent.fire(TextInputPanel.this, getText()); - } - }); - } - - protected void fireSelection() { - SelectionEvent.fire(this, (searchBox == null) ? "" : searchBox.getText()); - } - - public HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler) { - return addHandler(handler, ValueChangeEvent.getType()); - } - - public HandlerRegistration addSelectionHandler(SelectionHandler<String> handler) { - return addHandler(handler, SelectionEvent.getType()); - } - - public String getText () { - StringBuilder sb = new StringBuilder(); - for (Label word : words) { - if (sb.length() > 0) { - sb.append(' '); - } - sb.append(word.getText()); - } - return sb.toString(); - } - - public int getTabIndex() { - return focusPanel.getTabIndex(); - } - - public void setTabIndex(int index) { - focusPanel.setTabIndex(index); - } - - public void setAccessKey(char key) { - focusPanel.setAccessKey(key); - } - - public void setFocus(boolean focused) { - focusPanel.setFocus(focused); - } - - private class Phrase { - public String cat; - public ArrayList<Panel> panels; - } - - private final class NavigationController implements KeyDownHandler, ClickListener { - - public void onKeyDown(KeyDownEvent event) { - switch (event.getNativeKeyCode()) { - case KeyCodes.KEY_UP: - if (focusedPanel != null) { - Panel firstUp = null; - FlowPanel parent = (FlowPanel) focusedPanel.getParent(); - while (parent != mainPanel) { - if (parent.getWidgetCount() > 1) { - firstUp = parent; - break; - } - - parent = (FlowPanel) parent.getParent(); - } - - if (firstUp != null) - setFocusedPanel(firstUp); - event.stopPropagation(); - } - break; - case KeyCodes.KEY_DOWN: - if (focusedPanel != null) { - Panel firstDown = null; - for (Widget child : focusedPanel) { - if (child instanceof Panel) { - firstDown = (Panel) child; - break; - } - } - if (firstDown != null) - setFocusedPanel(firstDown); - event.stopPropagation(); - } - break; - case KeyCodes.KEY_LEFT: - if (focusedPanel != null) { - Panel firstLeft = null; - Panel parent = (Panel) focusedPanel.getParent(); - for (Widget child : parent) { - if (child instanceof Panel) { - if (child == focusedPanel) - break; - firstLeft = (Panel) child; - } - } - - if (firstLeft == null) { - if (parent != mainPanel) - firstLeft = parent; - } else { - for (;;) { - Panel lastChild = null; - for (Widget child : firstLeft) { - if (child instanceof Panel) { - lastChild = (Panel) child; - } - } - if (lastChild == null) - break; - firstLeft = lastChild; - } - } - if (firstLeft != null) - setFocusedPanel(firstLeft); - event.stopPropagation(); - } - break; - case KeyCodes.KEY_RIGHT: - if (focusedPanel != null) { - Panel firstRight = null; - Panel parent = (Panel) focusedPanel.getParent(); - Widget prev = null; - for (Widget child : parent) { - if (child instanceof Panel) { - if (prev == focusedPanel) { - firstRight = (Panel) child; - break; - } - prev = child; - } - } - - if (firstRight == null) { - if (parent != mainPanel) - firstRight = parent; - } else { - for (;;) { - Panel firstChild = null; - for (Widget child : firstRight) { - if (child instanceof Panel) { - firstChild = (Panel) child; - break; - } - } - if (firstChild == null) - break; - firstRight = firstChild; - } - } - if (firstRight != null) - setFocusedPanel(firstRight); - event.stopPropagation(); - } - break; - case KeyCodes.KEY_ENTER: - case KeyCodes.KEY_ESCAPE: - break; - default: - if (searchBox == null) { - showSearchBox(); - searchBox.fireEvent(event); - } - } - } - - public void onClick(Widget sender) { - FlowPanel panel = (FlowPanel) sender.getParent(); - FlowPanel tmpPanel = panel; - while (tmpPanel != mainPanel) { - FlowPanel parent = (FlowPanel) tmpPanel.getParent(); - - if (tmpPanel == focusedPanel && parent != mainPanel) { - panel = parent; - break; - } - - tmpPanel = parent; - } - - tmpPanel = (FlowPanel) panel.getParent(); - while (tmpPanel != mainPanel) { - if (tmpPanel.getWidgetCount() > 1) - break; - - panel = tmpPanel; - tmpPanel = (FlowPanel) panel.getParent(); - } - - setFocusedPanel(panel); - } - - private void setFocusedPanel(Panel panel) { - if (selectedPanels != null) { - for (Panel tmpPanel : selectedPanels) { - tmpPanel.removeStyleDependentName("selected"); - } - selectedPanels = null; - } - - if (focusedPanel != null) { - focusedPanel.removeStyleDependentName("focused"); - focusedPanel = null; - } - - Phrase phrase = mapPanel2Phrase.get(panel); - if (phrase != null) { - status.setText(phrase.cat); - selectedPanels = phrase.panels; - if (selectedPanels != null) { - for (Panel selPanel : selectedPanels) { - selPanel.addStyleDependentName("selected"); - } - } - - focusedPanel = panel; - focusedPanel.addStyleDependentName("focused"); - } - } - } - - private final class SearchBoxKeyboardHandler implements KeyUpHandler, KeyDownHandler { - - public void onKeyDown(KeyDownEvent event) { - switch (event.getNativeKeyCode()) { - case KeyCodes.KEY_ESCAPE: - hideSearchBox(); - fireSelection(); - setFocus(true); - event.stopPropagation(); - break; - case KeyCodes.KEY_ENTER: - searchBox.setText(searchBox.getText()+" "); - fireSelection(); - hideSearchBox(); - setFocus(true); - event.stopPropagation(); - break; - case KeyCodes.KEY_BACKSPACE: - if ("".equals(searchBox.getText())) { - String word = deleteLast(); - searchBox.setText(word); - searchBox.setCursorPos(word.length()); - event.stopPropagation(); - event.preventDefault(); - } - break; - } - } - - public void onKeyUp(KeyUpEvent event) { - switch (event.getNativeKeyCode()) { - case KeyCodes.KEY_ESCAPE: - case KeyCodes.KEY_ENTER: - case KeyCodes.KEY_UP: - case KeyCodes.KEY_DOWN: - case KeyCodes.KEY_LEFT: - case KeyCodes.KEY_RIGHT: - break; - default: - fireSelection(); - } - } - } -} 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 deleted file mode 100644 index e6c58c1d8..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/TranslateApp.java +++ /dev/null @@ -1,321 +0,0 @@ -package org.grammaticalframework.ui.gwt.client; - -import java.util.List; - -import com.google.gwt.core.client.*; -import com.google.gwt.user.client.*; -import com.google.gwt.user.client.ui.*; - - -public class TranslateApp implements EntryPoint { - - protected static final String pgfBaseURL = "/grammars"; - - protected PGFWrapper pgf; - - protected SuggestPanel suggestPanel; - protected VerticalPanel outputPanel; - protected StatusPopup statusPopup; - - // - // Text - // - - public String getText () { - return suggestPanel.getText(); - } - - protected void update () { - translate(); - } - - // - // Translation - // - - protected void translate() { - outputPanel.clear(); - outputPanel.addStyleDependentName("working"); - pgf.translate(getText(), - new PGF.TranslateCallback() { - public void onResult (IterableJsArray<PGF.TranslationResult> translations) { - outputPanel.clear(); - outputPanel.removeStyleDependentName("working"); - for (PGF.TranslationResult tr : translations.iterable()) { - if (tr.getTranslations() != null) { - for (PGF.Linearizations t : tr.getTranslations().iterable()) { - outputPanel.add(new LinearizationsPanel(pgf, t)); - } - } - - if (tr.getTypeErrors() != null && tr.getTypeErrors().length > 0) { - for (PGF.TcError error : tr.getTypeErrors()) { - VerticalPanel panel = new VerticalPanel(); - panel.addStyleName("my-typeError"); - Label errLabel = new Label("Type Error"); - errLabel.addStyleName("my-error-title"); - HTML msgHTML = new HTML("<pre>"+error.getMsg()+"</pre>"); - panel.add(errLabel); - panel.add(msgHTML); - outputPanel.add(panel); - } - } - } - } - public void onError (Throwable e) { - showError("Translation failed", e); - } - }); - } - - protected Widget createAbsTreeButton(final String abstractTree) { - Image treeBtn = new Image("org.grammaticalframework.ui.gwt.TranslateApp/tree-btn.png"); - treeBtn.addClickListener( - new ClickListener() { - public void onClick(Widget sender) { - // Create a dialog box and set the caption text - final DialogBox dialogBox = new DialogBox(); - dialogBox.setText("Abstract Syntax Tree"); - - // Create a table to layout the content - HorizontalPanel dialogContents = new HorizontalPanel(); - dialogContents.setSpacing(4); - dialogBox.setWidget(dialogContents); - - // Add an image to the dialog - - Frame image = new Frame(pgf.graphvizAbstractTree(abstractTree)); - image.addStyleName("my-treeimage"); - dialogContents.add(image); - - // Add a close button at the bottom of the dialog - Button closeButton = new Button("Close", - new ClickListener() { - public void onClick(Widget sender) { - dialogBox.hide(); - } - }); - dialogContents.add(closeButton); - - dialogBox.center(); - dialogBox.show(); - } - }); - return treeBtn; - } - - protected Widget createAlignButton(final String abstractTree) { - Image alignBtn = new Image("org.grammaticalframework.ui.gwt.TranslateApp/align-btn.png"); - alignBtn.addClickListener( - new ClickListener() { - public void onClick(Widget sender) { - // Create a dialog box and set the caption text - final DialogBox dialogBox = new DialogBox(); - dialogBox.setText("Word Alignment"); - - // Create a table to layout the content - HorizontalPanel dialogContents = new HorizontalPanel(); - dialogContents.setSpacing(4); - dialogBox.setWidget(dialogContents); - - // Add an image to the dialog - Frame image = new Frame(pgf.graphvizAlignment(abstractTree)); - image.addStyleName("my-alignmentimage"); - dialogContents.add(image); - - // Add a close button at the bottom of the dialog - Button closeButton = new Button("Close", - new ClickListener() { - public void onClick(Widget sender) { - dialogBox.hide(); - } - }); - dialogContents.add(closeButton); - - dialogBox.center(); - dialogBox.show(); - } - }); - return alignBtn; - } - - protected Widget createTranslation(final String language, final String abstractTree, String text) { - Label l = new Label(text); - l.addStyleName("my-translation"); - String lang = pgf.getLanguageCode(language); - if (lang != null) { - l.getElement().setLang(lang); - } - l.addClickListener(new ClickListener() { - public void onClick(Widget sender) { - // Create a dialog box and set the caption text - final DialogBox dialogBox = new DialogBox(); - dialogBox.setText("Parse Tree"); - - // Create a table to layout the content - HorizontalPanel dialogContents = new HorizontalPanel(); - dialogContents.setSpacing(4); - dialogBox.setWidget(dialogContents); - - // Add an image to the dialog - Frame image = new Frame(pgf.graphvizParseTree(abstractTree, language)); - image.addStyleName("my-treeimage"); - dialogContents.add(image); - - // Add a close button at the bottom of the dialog - Button closeButton = new Button("Close", - new ClickListener() { - public void onClick(Widget sender) { - dialogBox.hide(); - } - }); - dialogContents.add(closeButton); - - dialogBox.center(); - dialogBox.show(); - } - }); - return l; - } - - // - // Status stuff - // - - protected void setStatus(String msg) { - statusPopup.setStatus(msg); - } - - protected void showError(String msg, Throwable e) { - statusPopup.showError(msg, e); - } - - protected void clearStatus() { - statusPopup.clearStatus(); - } - - // - // GUI - // - - protected Widget createUI() { - VerticalPanel vPanel = new VerticalPanel(); - vPanel.setWidth("100%"); - vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); - vPanel.add(createSuggestPanel()); - vPanel.add(createSettingsPanel()); - vPanel.add(createTranslationsPanel()); - - return vPanel; - } - - protected Widget createSuggestPanel () { - suggestPanel = new SuggestPanel(pgf); - suggestPanel.setButtonText("Translate"); - suggestPanel.addSubmitListener(new SuggestPanel.SubmitListener() { - public void onSubmit(String text) { - translate(); - } - }); - return suggestPanel; - } - - protected Widget createSettingsPanel () { - return new SettingsPanel(pgf, null, statusPopup); - } - - protected Widget createTranslationsPanel () { - outputPanel = new VerticalPanel(); - outputPanel.addStyleName("my-translations"); - return outputPanel; - } - - protected Widget createLoadingWidget () { - VerticalPanel loadingPanel = new VerticalPanel(); - loadingPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); - loadingPanel.add(new Label("Loading...")); - return loadingPanel; - } - - // - // History stuff - // - - protected class MyHistoryListener implements HistoryListener { - public void onHistoryChanged(String historyToken) { - updateSettingsFromHistoryToken(); - } - }; - - protected void updateSettingsFromHistoryToken() { - updateSettingsFromHistoryToken(History.getToken().split("/")); - } - - protected void updateSettingsFromHistoryToken(String[] tokenParts) { - if (tokenParts.length >= 1 && tokenParts[0].length() > 0) { - setGrammarURL(tokenParts[0]); - } - if (tokenParts.length >= 2 && tokenParts[1].length() > 0) { - setInputLanguage(tokenParts[1]); - } - } - - protected void setGrammarURL (String url) { - if (url != null && !url.equals(pgf.getGrammarURL())) { - pgf.setGrammarURL(url); - } - } - - protected void setInputLanguage (String inputLanguage) { - if (inputLanguage != null && !inputLanguage.equals(pgf.getInputLanguage())) { - pgf.setInputLanguage(inputLanguage); - } - } - - // - // Initialization - // - - protected class MySettingsListener implements SettingsListener { - // Will only happen on load - public void onAvailableGrammarsChanged() { - if (pgf.getGrammarURL() == null) { - List<String> grammars = pgf.getGrammars(); - if (!grammars.isEmpty()) { - pgf.setGrammarURL(grammars.get(0)); - } - } - } - public void onSelectedGrammarChanged() { - if (pgf.getInputLanguage() == null) { - GWT.log("Setting input language to user language: " + pgf.getUserLanguage(), null); - pgf.setInputLanguage(pgf.getUserLanguage()); - } - update(); - } - public void onInputLanguageChanged() { - update(); - } - public void onOutputLanguageChanged() { - update(); - } - public void onStartCategoryChanged() { - update(); - } - public void onSettingsError(String msg, Throwable e) { - showError(msg,e); - } - } - - public void onModuleLoad() { - statusPopup = new StatusPopup(); - - pgf = new PGFWrapper(); - RootPanel.get().add(createUI()); - pgf.addSettingsListener(new MySettingsListener()); - History.addHistoryListener(new MyHistoryListener()); - updateSettingsFromHistoryToken(); - pgf.updateAvailableGrammars(); - } - -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/Selection.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/Selection.java deleted file mode 100644 index ceee8c1a7..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/Selection.java +++ /dev/null @@ -1,66 +0,0 @@ -/*
- * Copyright Miroslav Pokorny
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.grammaticalframework.ui.gwt.client.selection;
-
-import org.grammaticalframework.ui.gwt.client.selection.support.SelectionSupport;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.ui.RootPanel;
-
-/**
- * The Selection class is a singleton that represents any selection made by the
- * user typically done with the mouse.
- *
- * @author Miroslav Pokorny (mP)
- */
-public class Selection extends JavaScriptObject {
-
- /**
- * The browser aware support that takes care of browser difference nasties.
- */
- static private SelectionSupport support = (SelectionSupport) GWT.create(SelectionSupport.class);
-
- static SelectionSupport getSupport() {
- return Selection.support;
- }
-
- /**
- * Returns the document Selection singleton
- *
- * @return The singleton instance
- */
- static public Selection getSelection() {
- return Selection.support.getSelection();
- }
-
- protected Selection() {
- super();
- }
-
- final public SelectionEndPoint getStart() {
- return Selection.getSupport().getStart(this);
- }
-
- final public SelectionEndPoint getEnd() {
- return Selection.getSupport().getEnd(this);
- }
-
- final public void select(final SelectionEndPoint start, final SelectionEndPoint end) {
- Selection.getSupport().select(this, start, end);
- }
-}
diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/SelectionEndPoint.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/SelectionEndPoint.java deleted file mode 100644 index d429b4b19..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/SelectionEndPoint.java +++ /dev/null @@ -1,69 +0,0 @@ -/*
- * Copyright Miroslav Pokorny
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.grammaticalframework.ui.gwt.client.selection;
-
-import com.google.gwt.dom.client.Text;
-
-/**
- * An end point uses a combination of a textNode and offset to mark the
- * start/end of a selection
- *
- * @author Miroslav Pokorny (mP)
- */
-public class SelectionEndPoint {
-
- public SelectionEndPoint() {
- super();
- }
-
- public SelectionEndPoint(Text text, final int offset) {
- super();
-
- this.setTextNode(text);
- this.setOffset(offset);
- }
-
- /**
- * The textNode containing the start/end of the selection.
- */
- private Text textNode;
-
- public Text getTextNode() {
- return textNode;
- }
-
- public void setTextNode(final Text textNode) {
- this.textNode = textNode;
- }
-
- /**
- * The number of characters starting from the beginning of the textNode
- * where the selection begins/ends.
- */
- public int offset;
-
- public int getOffset() {
- return offset;
- }
-
- public void setOffset(final int offset) {
- this.offset = offset;
- }
-
- public String toString() {
- return super.toString() + ", offset: " + offset + ", textNode\"" + this.textNode + "\"";
- }
-}
diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/support/InternetExplorerSelectionSupport.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/support/InternetExplorerSelectionSupport.java deleted file mode 100644 index f986365c7..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/support/InternetExplorerSelectionSupport.java +++ /dev/null @@ -1,248 +0,0 @@ -/*
- * Copyright Miroslav Pokorny
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.grammaticalframework.ui.gwt.client.selection.support;
-
-import org.grammaticalframework.ui.gwt.client.selection.Selection;
-import org.grammaticalframework.ui.gwt.client.selection.SelectionEndPoint;
-
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.dom.client.Text;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
-
-/**
- * A specialised SelectionSupport class that is adapted to handle
- * InternetExplorer differences from the standard implementation.
- *
- * @author Miroslav Pokorny (mP)
- */
-public class InternetExplorerSelectionSupport extends SelectionSupport {
-
- final static String PARENT_NODE = "parentNode";
-
- @Override
- native public Selection getSelection()/*-{
- return $wnd.document.selection;
- }-*/;
-
- @Override
- public SelectionEndPoint getStart(final Selection selection) {
- return this.getStart0(selection);
- }
-
- native protected SelectionEndPoint getStart0(final Selection selection) /*-{
- var selectionRange = selection.createRange();
- var element = selectionRange.parentElement();
-
- return this.@org.grammaticalframework.ui.gwt.client.selection.support.InternetExplorerSelectionSupport::getStart1(Lorg/grammaticalframework/ui/gwt/client/selection/Selection;Lcom/google/gwt/user/client/Element;)(selection,element);
- }-*/;
-
- native protected SelectionEndPoint getStart1(final Selection selection, final Element element)/*-{
- var endPoint = null;
-
- if(! selection.createRange ){
- alert( "selection.createRange" + selection.createRange );
- }
-
- var selectionRange = selection.createRange();
-
- var range = selectionRange.duplicate();
- range.moveToElementText( element );
- range.collapse();
-
- // loop thru all the childNodes belonging to element.
- var childNodes = element.childNodes;
- for( var i = 0; i < childNodes.length; i++ ){
- var node = childNodes[ i ];
- var nodeType = node.nodeType;
-
- // found an element check its child nodes...
- if( 1 == nodeType ){
- endPoint = this.@org.grammaticalframework.ui.gwt.client.selection.support.InternetExplorerSelectionSupport::getStart1(Lorg/grammaticalframework/ui/gwt/client/selection/Selection;Lcom/google/gwt/user/client/Element;)(selection,node);
-
- if( null == endPoint ){
- range.move( "character", node.innerText.toString().length );
- continue;
- }
- // endPoint found stop searching....
- break;
- }
-
- // found a textNode...
- if( 3 == nodeType ){
- var text = node.data;
- for( var j = 0; j < text.length; j++ ){
- // found selection start stop searching!
- if( selectionRange.compareEndPoints( "StartToStart", range ) == 0 ){
- endPoint = @org.grammaticalframework.ui.gwt.client.selection.SelectionEndPoint::new(Lcom/google/gwt/dom/client/Text;I)(node,j);
- break;
- }
- range.move("character", 1 );
- }
- // did the above for loop find the start ? if so stop escape!
- if( null != endPoint ){
- break;
- }
- }
- }
-
- return endPoint;
- }-*/;
-
- @Override
- public void select(final Selection selection, final SelectionEndPoint start, final SelectionEndPoint end) {
- this.setStart0(selection, start.getTextNode(), start.getOffset());
- this.setEnd0(selection, end.getTextNode(), end.getOffset());
- }
-
- native private void setStart0(final Selection selection, final Text textNode, final int offset)/*-{
- var rangeOffset = offset;
- var moveToElement = null;
-
- // try an element before $textNode counting the number of characters one has moved backwards...
- var node = textNode.previousSibling;
-
- while( node ){
- // if a textNode is try its previous sibling...
- if( node.nodeType == 3 ){
- rangeOffset = rangeOffset + node.data.length;
- continue;
- }
-
- // found an element stop searching...
- if( node.nodeType == 1 ){
- moveToElement = node;
- rangeOffset = rangeOffset + node.innerText.toString().length;
- break;
- }
-
- // ignore other types...
- node = node.previousSibling;
- }
-
- // if moveToElement is null use textNode's parent.
- if( ! moveToElement ){
- moveToElement = textNode.parentNode;
- }
-
- // update the start of selection range...
- var range = selection.createRange();
- range.moveToElementText( moveToElement );
- range.moveStart( "character", rangeOffset );
- range.select();
- }-*/;
-
- native private void setEnd0(final Selection selection, final Text textNode, final int offset)/*-{
- var rangeOffset = offset;
- var moveToElement = null;
-
- // try an element before $textNode counting the number of characters one has moved backwards...
- var node = textNode.previousSibling;
-
- while( node ){
- // if textNode is try its previous sibling...
- if( node.nodeType == 3 ){
- rangeOffset = rangeOffset + node.data.length;
- continue;
- }
-
- // found an element stop searching...
- if( node.nodeType == 1 ){
- moveToElement = node;
- rangeOffset = rangeOffset + node.innerText.toString().length;
- break;
- }
-
- // ignore other types...
- node = node.previousSibling;
- }
-
- // if moveToElement is null use textNode's parent.
- if( ! moveToElement ){
- moveToElement = textNode.parentNode;
- }
-
- // update the end of selection range...
- var range = selection.createRange();
- range.moveToElementText( moveToElement );
- range.moveStart( "character", rangeOffset );
- range.collapse();
-
- var selectionRange = selection.createRange();
- selectionRange.setEndPoint( "EndToStart", range );
- selectionRange.select();
- }-*/;
-
- @Override
- public SelectionEndPoint getEnd(final Selection selection) {
- return this.getEnd0(selection);
- }
-
- protected native SelectionEndPoint getEnd0(final Selection selection) /*-{
- var selectionRange = selection.createRange();
- var element = selectionRange.parentElement();
-
- return this.@org.grammaticalframework.ui.gwt.client.selection.support.InternetExplorerSelectionSupport::getEnd1(Lorg/grammaticalframework/ui/gwt/client/selection/Selection;Lcom/google/gwt/user/client/Element;)(selection,element);
- }-*/;
-
- protected native SelectionEndPoint getEnd1(final Selection selection, final Element element)/*-{
- var endPoint = null;
-
- var selectionRange = selection.createRange();
-
- var range = selectionRange.duplicate();
- range.moveToElementText( element );
- range.collapse( true );
-
- // loop thru all the childNodes belonging to element.
- var childNodes = element.childNodes;
- for( var i = 0; i < childNodes.length; i++ ){
- var node = childNodes[ i ];
- var nodeType = node.nodeType;
-
- // found an element check its child nodes...
- if( 1 == nodeType ){
- endPoint = this.@org.grammaticalframework.ui.gwt.client.selection.support.InternetExplorerSelectionSupport::getEnd1(Lorg/grammaticalframework/ui/gwt/client/selection/Selection;Lcom/google/gwt/user/client/Element;)(selection,node);
-
- if( null == endPoint ){
- range.move( "character", node.innerText.toString().length );
- continue;
- }
- // endPoint found stop searching....
- break;
- }
-
- // found a textNode...
- if( 3 == nodeType ){
- var text = node.data;
- for( var j = 0; j < text.length; j++ ){
- // found selection end stop searching!
- if( selectionRange.compareEndPoints( "EndToStart", range ) == 0 ){
- endPoint = @org.grammaticalframework.ui.gwt.client.selection.SelectionEndPoint::new(Lcom/google/gwt/dom/client/Text;I)(node,j);
- break;
- }
- range.move( "character", 1 );
- }
- // did the above for loop find the end ? if so stop escape!
- if( null != endPoint ){
- break;
- }
- }
- }
-
- return endPoint;
- }-*/;
-}
diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/support/SelectionSupport.java b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/support/SelectionSupport.java deleted file mode 100644 index 946c2a812..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/client/selection/support/SelectionSupport.java +++ /dev/null @@ -1,69 +0,0 @@ -/*
- * Copyright Miroslav Pokorny
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.grammaticalframework.ui.gwt.client.selection.support;
-
-import org.grammaticalframework.ui.gwt.client.selection.Selection;
-import org.grammaticalframework.ui.gwt.client.selection.SelectionEndPoint;
-
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.dom.client.Text;
-import com.google.gwt.user.client.Element;
-
-/**
- * This class provides the standard implementation of
- *
- * @author Miroslav Pokorny (mP)
- */
-public class SelectionSupport {
-
- public SelectionEndPoint getStart(final Selection selection) {
- return getStart0(selection);
- }
-
- native private SelectionEndPoint getStart0(final Selection selection) /*-{
- var node = selection.anchorNode || null;
- var offset = selection.anchorOffset;
- return @org.grammaticalframework.ui.gwt.client.selection.SelectionEndPoint::new(Lcom/google/gwt/dom/client/Text;I)(value,j);
- }-*/;
-
- public SelectionEndPoint getEnd(final Selection selection) {
- return getEnd0(selection);
- }
-
- native private SelectionEndPoint getEnd0(final Selection selection) /*-{
- var node = selection.focusNode || null;
- var offset = selection.focusOffset;
- return @org.grammaticalframework.ui.gwt.client.selection.SelectionEndPoint::new(Lcom/google/gwt/dom/client/Text;I)(value,j);
- }-*/;
-
- public void select(final Selection selection, final SelectionEndPoint start, final SelectionEndPoint end) {
- select0(selection, start.getTextNode(), start.getOffset(), end.getTextNode(), end.getOffset());
- }
-
- native private void select0(final Selection selection, final Text startNode, final int startOffset, final Text endNode, final int endOffset)/*-{
- var range = startNode.ownerDocument.createRange();
- range.setStart(startNode, startOffset);
- range.setEnd(endNode, endOffset);
-
- // delete all ranges then recreate...
- selection.removeAllRanges();
- selection.addRange(range);
- }-*/;
-
- native public Selection getSelection()/*-{
- return $wnd.getSelection();
- }-*/;
-}
diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Editor.css b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Editor.css deleted file mode 100644 index f568ab96e..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Editor.css +++ /dev/null @@ -1,333 +0,0 @@ -.my-DocumentsPanel { - padding: 1em; - width: 100%; -} - -.my-DocumentsFrame { - width: 100%; -} - -.my-DocumentsSearchFrame { - margin-bottom: 0.5em; -} - -.my-DocumentsSearchFrame * { - margin: 0 0.4em; -} - -.my-DocumentsTable { - width: 100%; - border: 1px solid #E5E5E5; - border-collapse: collapse; -} - -.my-DocumentsTable .row td { - cursor:pointer; - border: 1px solid #E5E5E5; -} - -.my-DocumentsTable .row:hover { - background-color: rgb(147, 194, 241); -} - -.my-GrammarsPanel { - padding: 1em; - width: 100%; -} - -.my-GrammarInfoPanel { - width: 100%; - border: 1px solid #E5E5E5; - margin-top: 5px; - margin-bottom: 5px; -} - -.my-GrammarInfoPanel .descr-label { - width: 100%; - height: 50px; - padding: 3px; -} - -.my-TableHeader { - width: 100%; - background-attachement: scroll; - background-color: #E5E5E5; - background-image: url("background.png"); - background-position: 0px -192px; - background-repeat: repeat-x; - font-size: 150%; -} - -.my-EditorPanel { - padding-top: 1em; - padding-bottom: 1em -} - -.my-TextInputPanel { - width: 100%; -} - -.my-TextInputPanel .frame { - margin: 0; - padding: 1em; - background-color: #F3F3F3; - outline: 0; -} - -.my-TextInputPanel .text { - padding: 1em; - background-color: white; - border-top: 1px solid #CCCCCC; - border-left: 1px solid #CCCCCC; - border-bottom: 2px solid #BBBBBB; - border-right: 2px solid #BBBBBB; - min-width: 100px; - min-height: 100px; -} - -.my-TextInputPanel .toolbar { - width: 100%; - padding: 3px; - background-attachement: scroll; - background-color: #E5E5E5; - background-image: url("background.png"); - background-position: 0px -192px; - background-repeat: repeat-x; -} - -.toolbar-button { - float: left; - margin: 2px; -} - -.toolbar-button:hover { - margin: 1px; - border: 1px solid rgb(147,194,241); -} - -.my-TextInputPanel .toolbar .status { - padding: 1px; - background-color: #E5E5E5; - border: 1px solid #BBBBBB; - float: right; -} - -.my-TextInputPanel .searchbox { - font-size: 150%; - padding: 2px; - display: inline; - border-bottom: 1px dashed green; - outline: 0; -} - -.my-TextInputPanel .searchbox-error { - border-bottom: 1px dashed red; -} - -.my-TextInputPanel .wordspanel { - padding: 0; - display: inline; -} - -.my-TextInputPanel .wordspanel-selected { - background-color: rgb(147,194,241); -} - -.my-TextInputPanel .wordspanel-focused { - background-color: rgb(147,194,241); - border: 1px solid #666; -} - -.my-TextInputPanel .wordspanel-error { - border-bottom: 1px dashed red; -} - -.my-TextInputPanel .wordlabel { - display: inline; - font-size: 150%; -} - -.my-TextInputPanel .wordspace { - display: inline; - font-size: 150%; -} - -.my-SettingsPanel { -} - -.my-SettingsPanel .form-widget { - margin: 0 0.4em; -} - -.my-SettingsPanel .form-widget * { - margin: 0 0.1em; -} - -.my-LinksPanel * { - margin: 0 0.2em; -} - -.my-LinksPanel .gwt-TabBarItem { - font-weight: normal; - color: gray; - outline: 0; -} - -.my-LinksPanel .gwt-TabBarItem-selected { - font-weight: bold; - color: black; -} - -.my-LinksPanel .gwt-TabBarItem:hover { - text-decoration: underline; -} - -.my-LinksPanel .gwt-TabBarItem-selected:hover { - text-decoration: none; -} - -.my-HeaderPanel { - width: 100%; - margin: 0 0.1em; - padding-top: 2px; - padding-bottom: 2px; - border-bottom-style: solid; - border-bottom-width: 1px; - border-bottom-color: rgb(122,165,214); -} - -.my-BrowsePanel { - width: 100%; - margin: 1em; - border-width: 5px; - border-color: rgb(122,165,214); -} - -.my-BrowsePanel .source { - padding: 1em; -} - -.my-BrowseFrame { - width: 100%; - height: 100%; - margin: 1em; - border-style:none; -} - -.my-QueryPanel { - margin: 1em; - border-width: 5px; - border-color: rgb(122,165,214); -} - -.my-QueryBox { - min-width: 630px; - min-height: 94px; -} - -.my-translations { - margin-top: 1em; -} - -.my-translation-frame { - margin: 0.5em; - background: #D0E4F6; -} - -.my-translation-bar { - padding-left: 25px; - padding-right: 25px; - width: 100%; -} - -.my-translation { - margin: 0.2em; - font-size: 150%; - background-repeat: no-repeat; - background-position: 0% 50%; - cursor:pointer; -} - -.my-translation-btns { - background: #DDDDDD; - cursor:pointer; -} - -.my-treeimage { - width: 650px; - height: 520px; -} - -.my-alignmentimage { - width: 450px; - height: 300px; -} - -.my-typeError { - margin: 2px; - padding: 12px; - font-size: 150%; - font-weight: bold; - background: #CDFFDA; -} - -.my-typeError .title { - background: #DDDDDD; -} - -.my-typeError .content { - cursor:pointer; -} - -.my-identifierLink:link { - text-decoration: none; - color: black; -} - -.my-identifierLink:hover { - text-decoration: none; - color: black; - background-color: rgb(147, 194, 241); -} - -.my-FridgeBagPanel { - padding: 0.2em; - margin-top: 1.5em; - border: 3px solid #dddddd; -} - -.my-FridgeBagPanel-empty { - visibility: hidden; -} - -.my-Magnet { - float: left; - margin: 0.3em; - border-width: 1px; - border-style: solid; - border-color: black; - padding: 0.3em; - color: black; - background-color: white; -} - -.my-SyntaxTable { - font-size: 120%; -} - -.my-SyntaxRow { - margin: 1px; -} - -.my-SyntaxLang { - background: rgb(147,194,241); - padding: 2px; -} - -.my-SyntaxLin { - border: 1px solid rgb(147,194,241); - padding-left: 8px; - padding-right: 8px; - padding-top: 2px; - padding-bottom: 2px; -} diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Fridge.css b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Fridge.css deleted file mode 100644 index 5816831ad..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Fridge.css +++ /dev/null @@ -1,89 +0,0 @@ -body { - background: url("brushed-metal.png"); -} - -.my-FridgeApp { - -} - -.my-FridgeTextPanel { - padding: 0.2em; - width: 100%; - border: 3px dashed #dddddd; -} - -.my-FridgeTextPanel .magnets { - width: 100%; -} - -.my-FridgeTextPanel .buttons { - width: 100%; -} - -.my-FridgeTextPanel .buttons button { - width: 100%; -} - -.my-FridgeTextPanel-engage { - border-color: #666666; - background-color: #dddddd; -} - -.my-FridgeBagPanel { - padding: 0.2em; - border: 3px solid #dddddd; -} - -.my-FridgeBagPanel-empty { - visibility: hidden; -} - -.my-PrefixPanel { - margin-bottom: 1em; -} - -.my-FridgeTextPanel .my-Magnet { - font-size: 150%; -} - -.my-Magnet { - float: left; - margin: 0.3em; - border-width: 1px; - border-style: solid; - border-color: black; - padding: 0.3em; - color: black; - background-color: white; -} - -.my-TranslationsPanel { - padding: 0.2em; - border: 3px solid #dddddd; - width: 100%; -} - -.my-TranslationsPanel-empty { - visibility: hidden; -} - -.my-translation { - margin: 0.2em; -} - -.my-typeError { - padding: 6px; - font-size: 150%; - font-weight: bold; - background: #B9BEC0; -} - -.my-SettingsPanel { - width: 100%; - padding: 0.5em 0; - border-top: 1px solid #dddddd; -} - -.my-SettingsPanel .my-FormWidget { - margin: 0.2em; -}
\ No newline at end of file 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 deleted file mode 100644 index 0c08422d6..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/Translate.css +++ /dev/null @@ -1,82 +0,0 @@ -/** Add css rules here for your application. */ - -.my-SuggestPanel { - margin: 1em 0 0.5em 0; -} - -.my-SuggestPanel .gwt-SuggestBox { - width: 400px; - font-size: 150%; - margin: 0; -} - -.my-SuggestPanel .gwt-Button { - font-size: 150%; - margin: 0; - margin-left: 2px; -} - -.my-SettingsPanel * { - margin: 0 0.4em; -} - -.my-translations { - margin-top: 1em; -} - -.my-translation-frame { - width: 100%; - margin: 0.5em; - background: #D0E4F6; -} - -.my-translation-bar { - padding-left: 25px; - padding-right: 25px; - width: 100%; -} - -.my-translation { - margin: 0.2em; - font-size: 150%; - background-repeat: no-repeat; - background-position: 0% 50%; - cursor:pointer; -} - -.my-typeError { - padding: 12px; - font-size: 150%; - font-weight: bold; - background: #CDFFDA; -} - -.my-translation-btns { - background: #DDDDDD; - cursor:pointer; -} - -.my-treeimage { - width: 650px; - height: 520px; -} - -.my-alignmentimage { - width: 450px; - height: 300px; -} - -/* -* [LANG=bg] { background-image: url("flags/bg.png"); } -* [LANG=ca] { background-image: url("flags/catalonia.png"); } -* [LANG=da] { background-image: url("flags/dk.png"); } -* [LANG=de] { background-image: url("flags/de.png"); } -* [LANG=en] { background-image: url("flags/gb.png"); } -* [LANG=fi] { background-image: url("flags/fi.png"); } -* [LANG=fr] { background-image: url("flags/fr.png"); } -* [LANG=it] { background-image: url("flags/it.png"); } -* [LANG=no] { background-image: url("flags/no.png"); } -* [LANG=ru] { background-image: url("flags/ru.png"); } -* [LANG=es] { background-image: url("flags/es.png"); } -* [LANG=sv] { background-image: url("flags/se.png"); } -*/ diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/align-btn.png b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/align-btn.png Binary files differdeleted file mode 100644 index ca6a391c1..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/align-btn.png +++ /dev/null diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/background.png b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/background.png Binary files differdeleted file mode 100644 index 4c1e4989e..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/background.png +++ /dev/null diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/brushed-metal.png b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/brushed-metal.png Binary files differdeleted file mode 100644 index c2f03fe7d..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/brushed-metal.png +++ /dev/null diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/delete-last.png b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/delete-last.png Binary files differdeleted file mode 100644 index f984b976e..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/delete-last.png +++ /dev/null diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/grammar-buttons.png b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/grammar-buttons.png Binary files differdeleted file mode 100644 index 6cb89ca4b..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/grammar-buttons.png +++ /dev/null diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/new.png b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/new.png Binary files differdeleted file mode 100644 index 6f13ca749..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/new.png +++ /dev/null diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/textinput-buttons.png b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/textinput-buttons.png Binary files differdeleted file mode 100644 index 9f6017f70..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/textinput-buttons.png +++ /dev/null diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/trash-button.png b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/trash-button.png Binary files differdeleted file mode 100644 index 11536bc01..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/trash-button.png +++ /dev/null diff --git a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/tree-btn.png b/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/tree-btn.png Binary files differdeleted file mode 100644 index ebd243617..000000000 --- a/src/ui/gwt/src/org/grammaticalframework/ui/gwt/public/tree-btn.png +++ /dev/null diff --git a/src/ui/gwt/www/editor/editor.html b/src/ui/gwt/www/editor/editor.html deleted file mode 100644 index 114a88ccb..000000000 --- a/src/ui/gwt/www/editor/editor.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<!-- The HTML 4.01 Transitional DOCTYPE declaration--> -<!-- above set at the top of the file will set --> -<!-- the browser's rendering engine into --> -<!-- "Quirks Mode". Replacing this declaration --> -<!-- with a "Standards Mode" doctype is supported, --> -<!-- but may lead to some differences in layout. --> - -<html> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"> - <!-- --> - <!-- Any title is fine --> - <!-- --> - <title>Editor</title> - - <!-- --> - <!-- This script loads your compiled module. --> - <!-- If you add any GWT meta tags, they must --> - <!-- be added before this line. --> - <!-- --> - <script type="text/javascript" language="javascript" src="org.grammaticalframework.ui.gwt.EditorApp/org.grammaticalframework.ui.gwt.EditorApp.nocache.js"></script> - </head> - - <!-- --> - <!-- The body can have arbitrary html, or --> - <!-- you can leave the body empty if you want --> - <!-- to create a completely dynamic UI. --> - <!-- --> - <body> - - <!-- OPTIONAL: include this if you want history support --> - <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> - - </body> -</html> diff --git a/src/ui/gwt/www/editor/index.html b/src/ui/gwt/www/editor/index.html deleted file mode 100644 index 1af492b4a..000000000 --- a/src/ui/gwt/www/editor/index.html +++ /dev/null @@ -1,4 +0,0 @@ -<HEAD> -<META HTTP-EQUIV="REFRESH" - content="0; url=https://www.google.com/accounts/o8/ud?openid.ns=http://specs.openid.net/auth/2.0&openid.ns.max_auth_age=300&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.return_to=http://localhost:8080/editor/grammars.content&openid.realm=http://localhost:8080/&openid.mode=checkid_immediate&openid.ns.ax=http://openid.net/srv/ax/1.0&openid.ax.mode=fetch_request&openid.ax.type.email=http://axschema.org/contact/email&openid.ax.required=email"> -</HEAD> diff --git a/src/ui/gwt/www/fridge/index.html b/src/ui/gwt/www/fridge/index.html deleted file mode 100644 index 723e8a252..000000000 --- a/src/ui/gwt/www/fridge/index.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<!-- The HTML 4.01 Transitional DOCTYPE declaration--> -<!-- above set at the top of the file will set --> -<!-- the browser's rendering engine into --> -<!-- "Quirks Mode". Replacing this declaration --> -<!-- with a "Standards Mode" doctype is supported, --> -<!-- but may lead to some differences in layout. --> - -<html> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"> - <!-- --> - <!-- Any title is fine --> - <!-- --> - <title>Fridge</title> - - <!-- --> - <!-- This script loads your compiled module. --> - <!-- If you add any GWT meta tags, they must --> - <!-- be added before this line. --> - <!-- --> - <script type="text/javascript" language="javascript" src="org.grammaticalframework.ui.gwt.FridgeApp/org.grammaticalframework.ui.gwt.FridgeApp.nocache.js"></script> - </head> - - <!-- --> - <!-- The body can have arbitrary html, or --> - <!-- you can leave the body empty if you want --> - <!-- to create a completely dynamic UI. --> - <!-- --> - <body> - - <!-- OPTIONAL: include this if you want history support --> - <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> - - </body> -</html> diff --git a/src/ui/gwt/www/morpho/index.html b/src/ui/gwt/www/morpho/index.html deleted file mode 100644 index d524b3e91..000000000 --- a/src/ui/gwt/www/morpho/index.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<!-- The HTML 4.01 Transitional DOCTYPE declaration--> -<!-- above set at the top of the file will set --> -<!-- the browser's rendering engine into --> -<!-- "Quirks Mode". Replacing this declaration --> -<!-- with a "Standards Mode" doctype is supported, --> -<!-- but may lead to some differences in layout. --> - -<html> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"> - <!-- --> - <!-- Any title is fine --> - <!-- --> - <title>Morpho</title> - - <!-- --> - <!-- This script loads your compiled module. --> - <!-- If you add any GWT meta tags, they must --> - <!-- be added before this line. --> - <!-- --> - <script type="text/javascript" language="javascript" src="org.grammaticalframework.ui.gwt.MorphoApp/org.grammaticalframework.ui.gwt.MorphoApp.nocache.js"></script> - </head> - - <!-- --> - <!-- The body can have arbitrary html, or --> - <!-- you can leave the body empty if you want --> - <!-- to create a completely dynamic UI. --> - <!-- --> - <body> - - <!-- OPTIONAL: include this if you want history support --> - <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> - - </body> -</html> diff --git a/src/ui/gwt/www/morpho/morpho.fcgi b/src/ui/gwt/www/morpho/morpho.fcgi deleted file mode 100644 index 8d1c8b69c..000000000 --- a/src/ui/gwt/www/morpho/morpho.fcgi +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/ui/gwt/www/translate/index.html b/src/ui/gwt/www/translate/index.html deleted file mode 100644 index 4b6abf89a..000000000 --- a/src/ui/gwt/www/translate/index.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<!-- The HTML 4.01 Transitional DOCTYPE declaration--> -<!-- above set at the top of the file will set --> -<!-- the browser's rendering engine into --> -<!-- "Quirks Mode". Replacing this declaration --> -<!-- with a "Standards Mode" doctype is supported, --> -<!-- but may lead to some differences in layout. --> - -<html> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"> - <!-- --> - <!-- Any title is fine --> - <!-- --> - <title>Translate</title> - - <!-- --> - <!-- This script loads your compiled module. --> - <!-- If you add any GWT meta tags, they must --> - <!-- be added before this line. --> - <!-- --> - <script type="text/javascript" language="javascript" src="org.grammaticalframework.ui.gwt.TranslateApp/org.grammaticalframework.ui.gwt.TranslateApp.nocache.js"></script> - </head> - - <!-- --> - <!-- The body can have arbitrary html, or --> - <!-- you can leave the body empty if you want --> - <!-- to create a completely dynamic UI. --> - <!-- --> - <body> - - <!-- OPTIONAL: include this if you want history support --> - <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> - - </body> -</html> |
