1
0
forked from GitHub/gf-core

the user can now upload their own grammars in the editor

This commit is contained in:
krasimir
2011-03-07 21:05:29 +00:00
parent 62c85f1bb6
commit 42ad2d5e95
13 changed files with 251 additions and 141 deletions

View File

@@ -52,22 +52,30 @@ cgiMain' cache path =
case mb_command of
Just "update_grammar"
-> do mb_pgf <- getFile
id <- getGrammarId
id <- getGrammarId
name <- getFileName
descr <- getDescription
doUpdateGrammar c mb_pgf id name descr
userId <- getUserId
doUpdateGrammar c mb_pgf id name descr userId
Just "delete_grammar"
-> do id <- getGrammarId
doDeleteGrammar c id
userId <- getUserId
doDeleteGrammar c id userId
Just "grammars"
-> doGrammars c
-> do userId <- getUserId
doGrammars c userId
Just "save" -> doSave c =<< getId
Just "load" -> doLoad c =<< getId
Just "search" -> doSearch c =<< getQuery
Just "delete" -> doDelete c =<< getIds
Just cmd -> throwCGIError 400 "Unknown command" ["Unknown command: " ++ show cmd]
Nothing -> throwCGIError 400 "No command given" ["No command given"]
Nothing -> do mb_uri <- getIdentity
mb_email <- getEMail
doLogin c mb_uri mb_email
where
getUserId :: CGI (Maybe String)
getUserId = getInput "userId"
getId :: CGI (Maybe Int)
getId = readInput "id"
@@ -80,7 +88,7 @@ cgiMain' cache path =
getGrammarId :: CGI String
getGrammarId = do
mb_url <- getInput "url"
return (maybe "null" (reverse . drop 4 . reverse) mb_url)
return (maybe "null" (reverse . takeWhile (/='/') . drop 4 . reverse) mb_url)
getFile :: CGI (Maybe BS.ByteString)
getFile = do
@@ -97,27 +105,49 @@ cgiMain' cache path =
getDescription :: CGI String
getDescription = fmap (fromMaybe "") (getInput "description")
doGrammars c = do
getIdentity :: CGI (Maybe String)
getIdentity = getInput "openid.identity"
getEMail :: CGI (Maybe String)
getEMail = getInput "openid.ext1.value.email"
doLogin c mb_uri mb_email = do
path <- scriptName
r <- liftIO $ handleSql (return . Left) $ do
s <- query c "call getGrammars()"
rows <- collectRows getGrammar s
s <- query c ("call getUserId("++toSqlValue mb_uri++","++toSqlValue mb_email++")")
[id] <- collectRows getUserId s
return (Right id)
case r of
Right mb_id -> outputHTML (startupHTML mb_id mb_uri mb_email (Just path))
Left e -> throwCGIError 400 "Login failed" (lines (show e))
where
getUserId s = do
id <- getFieldValueMB s "userId"
return (id :: Maybe Int)
doGrammars c mb_userId = do
path <- scriptName
r <- liftIO $ handleSql (return . Left) $ do
s <- query c ("call getGrammars("++toSqlValue mb_userId++")")
rows <- collectRows (getGrammar path) s
return (Right rows)
case r of
Right rows -> outputJSONP rows
Left e -> throwCGIError 400 "Loading failed" (lines (show e))
where
getGrammar s = do
getGrammar path s = do
id <- getFieldValue s "id"
name <- getFieldValue s "name"
description <- getFieldValue s "description"
return $ toJSObject [ ("url", showJSON (addExtension (show (id :: Int)) "pgf"))
return $ toJSObject [ ("url", showJSON (dropExtension path ++ '/':addExtension (show (id :: Int)) "pgf"))
, ("name", showJSON (name :: String))
, ("description", showJSON (description :: String))
]
doUpdateGrammar c mb_pgf id name descr = do
doUpdateGrammar c mb_pgf id name descr mb_userId = do
r <- liftIO $ handleSql (return . Left) $ do
s <- query c ("call updateGrammar("++id++","++toSqlValue name++","++toSqlValue descr++")")
s <- query c ("call updateGrammar("++id++","++toSqlValue name++","++toSqlValue descr++","++toSqlValue mb_userId++")")
[id] <- collectRows (\s -> getFieldValue s "id") s
return (Right id)
nid <- case r of
@@ -133,9 +163,9 @@ doUpdateGrammar c mb_pgf id name descr = do
Nothing -> return ()
outputHTML ""
doDeleteGrammar c id = do
doDeleteGrammar c id mb_userId = do
r <- liftIO $ handleSql (return . Left) $ do
execute c ("call deleteGrammar("++id++")")
execute c ("call deleteGrammar("++id++","++toSqlValue mb_userId++")")
return (Right "")
case r of
Right x -> outputJSONP ([] :: [(String,String)])
@@ -213,22 +243,56 @@ dbConnect fpath = do
[host,db,user,pwd] <- fmap words $ readFile fpath
connect host db user pwd
startupHTML mb_id mb_uri mb_email mb_path = unlines [
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">",
"<html>",
" <head>",
" <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">",
" <title>Editor</title>",
" <script type=\"text/javascript\" language=\"javascript\" src=\"org.grammaticalframework.ui.gwt.EditorApp/org.grammaticalframework.ui.gwt.EditorApp.nocache.js\"></script>",
" </head>",
" <body onload=\"window.__gfInit = new Object(); "++
maybe "" (\id -> "window.__gfInit.userId = "++show id++"; ") mb_id++
maybe "" (\uri -> "window.__gfInit.userURI = '"++uri++"'; ") mb_uri++
maybe "" (\email -> "window.__gfInit.userEMail = '"++email++"'; ") mb_email++
maybe "" (\path -> "window.__gfInit.contentURL = '"++path++"'; ") mb_path++
"\">",
" <iframe src=\"javascript:''\" id=\"__gwt_historyFrame\" tabIndex='-1' style=\"position:absolute;width:0;height:0;border:0\"></iframe>",
" </body>",
"</html>"]
dbInit c =
handleSql (fail . show) $ do
inTransaction c $ \c -> do
execute c "DROP TABLE IF EXISTS Documents"
execute c ("CREATE TABLE Documents(id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,"++
" title VARCHAR(256) NOT NULL,\n"++
" created TIMESTAMP NOT NULL DEFAULT 0,\n"++
" modified TIMESTAMP NOT NULL DEFAULT 0,\n"++
" content TEXT NOT NULL,\n"++
" FULLTEXT INDEX (content)) TYPE=MyISAM")
execute c "DROP TABLE IF EXISTS GrammarUsers"
execute c "DROP TABLE IF EXISTS Users"
execute c "DROP TABLE IF EXISTS Grammars"
execute c ("CREATE TABLE Grammars(id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,"++
" name VARCHAR(64) NOT NULL,\n"++
" description VARCHAR(512) NOT NULL,\n"++
" created TIMESTAMP NOT NULL DEFAULT 0,\n"++
" modified TIMESTAMP NOT NULL DEFAULT 0)")
execute c "DROP TABLE IF EXISTS Documents"
execute c ("CREATE TABLE Users"++
" (id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,\n"++
" identity VARCHAR(256) NOT NULL,\n"++
" email VARCHAR(128) NOT NULL,\n"++
" UNIQUE INDEX (identity))")
execute c ("CREATE TABLE Grammars"++
" (id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,"++
" name VARCHAR(64) NOT NULL,\n"++
" description VARCHAR(512) NOT NULL,\n"++
" created TIMESTAMP NOT NULL DEFAULT 0,\n"++
" modified TIMESTAMP NOT NULL DEFAULT 0)")
execute c ("CREATE TABLE Documents"++
" (id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,"++
" title VARCHAR(256) NOT NULL,\n"++
" created TIMESTAMP NOT NULL DEFAULT 0,\n"++
" modified TIMESTAMP NOT NULL DEFAULT 0,\n"++
" content TEXT NOT NULL,\n"++
" FULLTEXT INDEX (content)) TYPE=MyISAM")
execute c ("CREATE TABLE GrammarUsers"++
" (userId INTEGER NOT NULL,\n"++
" grammarId INTEGER NOT NULL,\n"++
" flags INTEGER NOT NULL,\n"++
" PRIMARY KEY (userId, grammarId),\n"++
" FOREIGN KEY (userId) REFERENCES Users(id) ON DELETE CASCADE,\n"++
" FOREIGN KEY (grammarId) REFERENCES Grammars(id) ON DELETE RESTRICT)")
execute c "DROP PROCEDURE IF EXISTS saveDocument"
execute c ("CREATE PROCEDURE saveDocument(IN id INTEGER, content TEXT)\n"++
"BEGIN\n"++
@@ -241,23 +305,51 @@ dbInit c =
" END IF;\n"++
"END")
execute c "DROP PROCEDURE IF EXISTS updateGrammar"
execute c ("CREATE PROCEDURE updateGrammar(IN id INTEGER, name VARCHAR(64), description VARCHAR(512))\n"++
execute c ("CREATE PROCEDURE updateGrammar(IN id INTEGER, name VARCHAR(64), description VARCHAR(512), userId INTEGER)\n"++
"BEGIN\n"++
" IF id IS NULL THEN\n"++
" INSERT INTO Grammars(name,description,created,modified) VALUES (name,description,NOW(),NOW());\n"++
" SELECT LAST_INSERT_ID() as id;\n"++
" SET id = LAST_INSERT_ID();\n"++
" INSERT INTO GrammarUsers(grammarId,userId,flags) VALUES (id,userId,0);\n"++
" ELSE\n"++
" UPDATE Grammars gr SET name = name, description=description, modified=NOW() WHERE gr.id = id;\n"++
" select id;\n"++
" END IF;\n"++
" SELECT id;\n"++
"END")
execute c "DROP PROCEDURE IF EXISTS deleteGrammar"
execute c ("CREATE PROCEDURE deleteGrammar(IN grammarId INTEGER)\n"++
execute c ("CREATE PROCEDURE deleteGrammar(IN aGrammarId INTEGER, aUserId INTEGER)\n"++
"BEGIN\n"++
" DELETE FROM Grammars WHERE id = grammarId;\n"++
" DECLARE deleted INTEGER;\n"++
" DELETE FROM GrammarUsers\n"++
" WHERE grammarId = aGrammarId AND userId = aUserId;\n"++
" IF NOT EXISTS(SELECT * FROM GrammarUsers gu WHERE gu.grammarId = aGrammarId) THEN\n"++
" DELETE FROM Grammars WHERE id = aGrammarId;\n"++
" SET deleted = 1;\n"++
" ELSE\n"++
" SET deleted = 0;\n"++
" END IF;\n"++
" SELECT deleted;\n"++
"END")
execute c "DROP PROCEDURE IF EXISTS getGrammars"
execute c ("CREATE PROCEDURE getGrammars()\n"++
execute c ("CREATE PROCEDURE getGrammars(IN userId INTEGER)\n"++
"BEGIN\n"++
" SELECT id,name,description FROM Grammars ORDER BY name;\n"++
" SELECT g.id,g.name,g.description\n"++
" FROM Grammars g JOIN GrammarUsers gu ON g.id = gu.grammarId\n"++
" WHERE gu.userId = userId\n"++
" ORDER BY g.name;\n"++
"END")
execute c "DROP PROCEDURE IF EXISTS getUserId"
execute c ("CREATE PROCEDURE getUserId(identity VARCHAR(256), email VARCHAR(128))\n"++
"BEGIN\n"++
" DECLARE userId INTEGER;\n"++
" IF identity IS NULL OR email IS NULL THEN\n"++
" SET userId = NULL;\n"++
" ELSE\n"++
" SELECT id INTO userId FROM Users u WHERE u.identity = identity;\n"++
" IF userId IS NULL THEN\n"++
" INSERT INTO Users(identity, email) VALUES (identity, email);\n"++
" SET userId = LAST_INSERT_ID();\n"++
" END IF;\n"++
" END IF;\n"++
" SELECT userId;\n"++
"END")

View File

@@ -46,7 +46,7 @@ cgiMain' cache path =
pgfMain pgf command
pgfMain :: PGF -> String -> CGI CGIResult
pgfMain pgf command =
pgfMain pgf command = do
case command of
"parse" -> outputJSONP =<< doParse pgf `fmap` getText `ap` getCat `ap` getFrom
"complete" -> outputJSONP =<< doComplete pgf `fmap` getText `ap` getCat `ap` getFrom `ap` getLimit

View File

@@ -3,7 +3,7 @@ import Control.Concurrent(forkIO)
import Network.FastCGI(runFastCGI,runFastCGIConcurrent')
import PGFService(cgiMain,newPGFCache,stderrToFile,logFile)
import System.IO
main = do stderrToFile logFile
fcgiMain =<< newPGFCache

View File

@@ -6,29 +6,37 @@ import java.util.*;
import com.google.gwt.core.client.*;
public class ContentService {
String contentBaseURL;
// Event listeners
private List<SettingsListener> listeners = new LinkedList<SettingsListener>();
private List<GrammarInfo> grammars = null;
public ContentService(String contentBaseURL) {
this.contentBaseURL = contentBaseURL;
public ContentService() {
}
public String getBaseURL() {
return contentBaseURL;
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(contentBaseURL, args, new GrammarsCallback() {
JSONRequestBuilder.sendRequest(getInit().getContentURL(), args, new GrammarsCallback() {
public void onResult(IterableJsArray<ContentService.GrammarInfo> grammars_) {
grammars = new ArrayList<GrammarInfo>();
for (ContentService.GrammarInfo grammar : grammars_.iterable()) {
@@ -62,8 +70,9 @@ public class ContentService {
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(contentBaseURL, args, callback);
return JSONRequestBuilder.sendRequest(getInit().getContentURL(), args, callback);
}
public JSONRequest save(Object id, String content, SaveCallback callback) {
@@ -71,7 +80,7 @@ public class ContentService {
if (id != null)
args.add(new Arg("id", id.toString()));
args.add(new Arg("command", "save"));
return JSONRequestBuilder.sendDataRequest(contentBaseURL, args, content, callback);
return JSONRequestBuilder.sendDataRequest(getInit().getContentURL(), args, content, callback);
}
public interface SaveCallback extends JSONCallback<DocumentSignature> {}
@@ -80,7 +89,7 @@ public class ContentService {
List<Arg> args = new ArrayList<Arg>();
args.add(new Arg("command", "load"));
args.add(new Arg("id", id.toString()));
return JSONRequestBuilder.sendRequest(contentBaseURL, args, callback);
return JSONRequestBuilder.sendRequest(getInit().getContentURL(), args, callback);
}
public interface LoadCallback extends JSONCallback<Document> {}
@@ -89,7 +98,7 @@ public class ContentService {
List<Arg> args = new ArrayList<Arg>();
args.add(new Arg("command", "search"));
args.add(new Arg("query", fullTextQuery));
return JSONRequestBuilder.sendRequest(contentBaseURL, args, callback);
return JSONRequestBuilder.sendRequest(getInit().getContentURL(), args, callback);
}
public interface SearchCallback extends JSONCallback<IterableJsArray<DocumentSignature>> {}
@@ -115,7 +124,7 @@ public class ContentService {
for (Object id : ids) {
args.add(new Arg("id", id.toString()));
}
return JSONRequestBuilder.sendRequest(contentBaseURL, args, callback);
return JSONRequestBuilder.sendRequest(getInit().getContentURL(), args, callback);
}
public interface DeleteCallback extends JSONCallback<DeleteResult> {}

View File

@@ -11,9 +11,6 @@ import com.google.gwt.event.shared.*;
public class EditorApp implements EntryPoint {
protected static final String pgfBaseURL = "/grammars";
protected static final String contentBaseURL = "/grammars.content";
protected ContentService contentService;
protected PGFWrapper pgf;
@@ -420,10 +417,10 @@ public class EditorApp implements EntryPoint {
protected class MySettingsListener implements SettingsListener {
// Will only happen on load
public void onAvailableGrammarsChanged() {
if (pgf.getPGFName() == null) {
if (pgf.getGrammarURL() == null) {
List<String> grammars = pgf.getGrammars();
if (!grammars.isEmpty()) {
pgf.setPGFName(grammars.get(0));
pgf.setGrammarURL(grammars.get(0));
}
}
}
@@ -452,8 +449,8 @@ public class EditorApp implements EntryPoint {
public void onModuleLoad() {
statusPopup = new StatusPopup();
pgf = new PGFWrapper(pgfBaseURL);
contentService = new ContentService(contentBaseURL);
pgf = new PGFWrapper();
contentService = new ContentService();
RootPanel.get().add(createUI());
pgf.addSettingsListener(new MySettingsListener());
contentService.updateAvailableGrammars();

View File

@@ -272,16 +272,16 @@ public class FridgeApp implements EntryPoint {
protected void updateSettingsFromHistoryToken(String[] tokenParts) {
if (tokenParts.length >= 1 && tokenParts[0].length() > 0) {
setPGFName(tokenParts[0]);
setGrammarURL(tokenParts[0]);
}
if (tokenParts.length >= 2 && tokenParts[1].length() > 0) {
setInputLanguage(tokenParts[1]);
}
}
protected void setPGFName (String pgfName) {
if (pgfName != null && !pgfName.equals(pgf.getPGFName())) {
pgf.setPGFName(pgfName);
protected void setGrammarURL(String url) {
if (url != null && !url.equals(pgf.getGrammarURL())) {
pgf.setGrammarURL(url);
}
}
@@ -298,12 +298,12 @@ public class FridgeApp implements EntryPoint {
protected class MySettingsListener implements SettingsListener {
// Will only happen on load
public void onAvailableGrammarsChanged() {
if (pgf.getPGFName() == null) {
if (pgf.getGrammarURL() == null) {
List<String> grammars = pgf.getGrammars();
if (!grammars.isEmpty()) {
pgf.setPGFName(grammars.get(0));
pgf.setGrammarURL(grammars.get(0));
}
}
}
}
public void onSelectedGrammarChanged() {
if (pgf.getInputLanguage() == null) {
@@ -327,7 +327,7 @@ public class FridgeApp implements EntryPoint {
public void onModuleLoad() {
statusPopup = new StatusPopup();
pgf = new PGFWrapper(pgfBaseURL);
pgf = new PGFWrapper();
RootPanel.get().add(createUI());
pgf.addSettingsListener(new MySettingsListener());
History.addHistoryListener(new MyHistoryListener());

View File

@@ -112,7 +112,7 @@ public class GrammarsPanel extends Composite {
form.setWidth("100%");
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
form.setAction(contentService.getBaseURL());
form.setAction(ContentService.getInit().getContentURL());
form.addSubmitHandler(uploadFormHandler);
form.addSubmitCompleteHandler(uploadFormHandler);
@@ -120,7 +120,8 @@ public class GrammarsPanel extends Composite {
vPanel.setWidth("100%");
form.add(vPanel);
vPanel.add(new HTML("<input type=\"hidden\" name=\"command\" value=\"update_grammar\"/>"));
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);

View File

@@ -11,11 +11,7 @@ import com.google.gwt.core.client.*;
public class PGFWrapper {
private String baseURL;
private String grammarURL;
private String pgfName = null;
private String grammarURL = null;
private PGF pgf;
@@ -44,17 +40,11 @@ public class PGFWrapper {
public PGFWrapper() {
this.baseURL = null;
this.pgf = new PGF();
}
public PGFWrapper(String baseURL) {
this.baseURL = baseURL;
this.pgf = new PGF();
}
public void updateAvailableGrammars() {
String url = baseURL+"/grammars.xml";
String url = "/grammars.xml";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
try
{
@@ -172,26 +162,12 @@ public class PGFWrapper {
//
// Settings
//
public String getPGFName() {
return pgfName;
}
public void setPGFName(String pgfName) {
this.pgfName = pgfName;
this.grammarURL = (pgfName == null) ? null : baseURL + "/" + pgfName;
this.inputLanguage = null;
this.outputLanguage = null;
this.cat = null;
updateSelectedGrammar();
}
public String getGrammarURL() {
return grammarURL;
}
public void setGrammarURL(String grammarURL) {
this.pgfName = null;
this.grammarURL = grammarURL;
this.inputLanguage = null;
this.outputLanguage = null;

View File

@@ -24,7 +24,7 @@ public class SettingsPanel extends Composite {
grammarBox = new MyListBox();
grammarBox.addChangeListener(new ChangeListener() {
public void onChange(Widget sender) {
SettingsPanel.this.pgf.setPGFName(grammarBox.getSelectedValue());
SettingsPanel.this.pgf.setGrammarURL(grammarBox.getSelectedValue());
}
});
settingsPanel.add(new FormWidget("Grammar:", grammarBox));
@@ -45,6 +45,28 @@ public class SettingsPanel extends Composite {
});
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");
@@ -54,7 +76,7 @@ public class SettingsPanel extends Composite {
private static class FormWidget extends HorizontalPanel {
public FormWidget(String label, Widget w) {
setStylePrimaryName(".my-FormWidget");
setStylePrimaryName("form-widget");
setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
add(new Label(label));
add(w);
@@ -65,16 +87,18 @@ public class SettingsPanel extends Composite {
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.setPGFName(grammarBox.getSelectedValue());
pgf.setGrammarURL(grammarBox.getSelectedValue());
}
}
public void onSelectedGrammarChanged() {
if (grammarBox != null) {
grammarBox.setSelectedValue(pgf.getPGFName());
grammarBox.setSelectedValue(pgf.getGrammarURL());
}
if (fromLangBox != null) {
fromLangBox.clear();

View File

@@ -253,16 +253,16 @@ public class TranslateApp implements EntryPoint {
protected void updateSettingsFromHistoryToken(String[] tokenParts) {
if (tokenParts.length >= 1 && tokenParts[0].length() > 0) {
setPGFName(tokenParts[0]);
setGrammarURL(tokenParts[0]);
}
if (tokenParts.length >= 2 && tokenParts[1].length() > 0) {
setInputLanguage(tokenParts[1]);
}
}
protected void setPGFName (String pgfName) {
if (pgfName != null && !pgfName.equals(pgf.getPGFName())) {
pgf.setPGFName(pgfName);
protected void setGrammarURL (String url) {
if (url != null && !url.equals(pgf.getGrammarURL())) {
pgf.setGrammarURL(url);
}
}
@@ -279,10 +279,10 @@ public class TranslateApp implements EntryPoint {
protected class MySettingsListener implements SettingsListener {
// Will only happen on load
public void onAvailableGrammarsChanged() {
if (pgf.getPGFName() == null) {
if (pgf.getGrammarURL() == null) {
List<String> grammars = pgf.getGrammars();
if (!grammars.isEmpty()) {
pgf.setPGFName(grammars.get(0));
pgf.setGrammarURL(grammars.get(0));
}
}
}
@@ -310,7 +310,7 @@ public class TranslateApp implements EntryPoint {
public void onModuleLoad() {
statusPopup = new StatusPopup();
pgf = new PGFWrapper(pgfBaseURL);
pgf = new PGFWrapper();
RootPanel.get().add(createUI());
pgf.addSettingsListener(new MySettingsListener());
History.addHistoryListener(new MyHistoryListener());

View File

@@ -152,10 +152,17 @@
font-size: 150%;
}
.my-SettingsPanel * {
.my-SettingsPanel {
}
.my-SettingsPanel .form-widget {
margin: 0 0.4em;
}
.my-SettingsPanel .form-widget * {
margin: 0 0.1em;
}
.my-LinksPanel * {
margin: 0 0.2em;
}

View File

@@ -0,0 +1,36 @@
<!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>

View File

@@ -1,36 +1,4 @@
<!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>
<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>