mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
added GrammarsPanel in the GF editor
This commit is contained in:
@@ -12,7 +12,7 @@ import com.google.gwt.event.shared.*;
|
|||||||
public class EditorApp implements EntryPoint {
|
public class EditorApp implements EntryPoint {
|
||||||
|
|
||||||
protected static final String pgfBaseURL = "/grammars";
|
protected static final String pgfBaseURL = "/grammars";
|
||||||
protected static final String contentBaseURL = "/content.fcgi";
|
protected static final String contentBaseURL = "/grammars.content";
|
||||||
|
|
||||||
protected ContentService contentService;
|
protected ContentService contentService;
|
||||||
protected PGFWrapper pgf;
|
protected PGFWrapper pgf;
|
||||||
@@ -22,6 +22,7 @@ public class EditorApp implements EntryPoint {
|
|||||||
protected BrowsePanel browsePanel;
|
protected BrowsePanel browsePanel;
|
||||||
protected QueryPanel queryPanel;
|
protected QueryPanel queryPanel;
|
||||||
protected DocumentsPanel documentsPanel;
|
protected DocumentsPanel documentsPanel;
|
||||||
|
protected GrammarsPanel grammarsPanel;
|
||||||
protected StatusPopup statusPopup;
|
protected StatusPopup statusPopup;
|
||||||
protected TextInputPanel textPanel;
|
protected TextInputPanel textPanel;
|
||||||
protected FridgeBagPanel bagPanel;
|
protected FridgeBagPanel bagPanel;
|
||||||
@@ -205,6 +206,7 @@ public class EditorApp implements EntryPoint {
|
|||||||
browsePanel = createBrowsePanel();
|
browsePanel = createBrowsePanel();
|
||||||
queryPanel = createQueryPanel();
|
queryPanel = createQueryPanel();
|
||||||
documentsPanel = createDocumentsPanel();
|
documentsPanel = createDocumentsPanel();
|
||||||
|
grammarsPanel = createGrammarsPanel();
|
||||||
|
|
||||||
VerticalPanel vPanel = new VerticalPanel();
|
VerticalPanel vPanel = new VerticalPanel();
|
||||||
vPanel.setWidth("100%");
|
vPanel.setWidth("100%");
|
||||||
@@ -315,6 +317,10 @@ public class EditorApp implements EntryPoint {
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected GrammarsPanel createGrammarsPanel() {
|
||||||
|
return new GrammarsPanel(pgf, contentService, statusPopup);
|
||||||
|
}
|
||||||
|
|
||||||
protected TabBar createLinksPanel(final Panel parent) {
|
protected TabBar createLinksPanel(final Panel parent) {
|
||||||
tabBar = new TabBar();
|
tabBar = new TabBar();
|
||||||
tabBar.setStylePrimaryName("my-LinksPanel");
|
tabBar.setStylePrimaryName("my-LinksPanel");
|
||||||
@@ -322,6 +328,7 @@ public class EditorApp implements EntryPoint {
|
|||||||
tabBar.addTab("Editor");
|
tabBar.addTab("Editor");
|
||||||
tabBar.addTab("Query");
|
tabBar.addTab("Query");
|
||||||
tabBar.addTab("Browse");
|
tabBar.addTab("Browse");
|
||||||
|
tabBar.addTab("Grammars");
|
||||||
|
|
||||||
NavigationHandler handler = new NavigationHandler(tabBar, parent);
|
NavigationHandler handler = new NavigationHandler(tabBar, parent);
|
||||||
tabBar.addSelectionHandler(handler);
|
tabBar.addSelectionHandler(handler);
|
||||||
@@ -349,6 +356,7 @@ public class EditorApp implements EntryPoint {
|
|||||||
parent.remove(editorPanel);
|
parent.remove(editorPanel);
|
||||||
parent.remove(queryPanel);
|
parent.remove(queryPanel);
|
||||||
parent.remove(browsePanel);
|
parent.remove(browsePanel);
|
||||||
|
parent.remove(grammarsPanel);
|
||||||
|
|
||||||
switch (event.getSelectedItem().intValue()) {
|
switch (event.getSelectedItem().intValue()) {
|
||||||
case 0: parent.add(documentsPanel);
|
case 0: parent.add(documentsPanel);
|
||||||
@@ -363,6 +371,9 @@ public class EditorApp implements EntryPoint {
|
|||||||
case 3: parent.add(browsePanel);
|
case 3: parent.add(browsePanel);
|
||||||
if (level == 0) History.newItem("browse", false);
|
if (level == 0) History.newItem("browse", false);
|
||||||
break;
|
break;
|
||||||
|
case 4: parent.add(grammarsPanel);
|
||||||
|
if (level == 0) History.newItem("grammars", false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,6 +393,8 @@ public class EditorApp implements EntryPoint {
|
|||||||
} else if (token.startsWith("browse:")) {
|
} else if (token.startsWith("browse:")) {
|
||||||
linksPanel.selectTab(3);
|
linksPanel.selectTab(3);
|
||||||
browsePanel.browse(token.substring(7));
|
browsePanel.browse(token.substring(7));
|
||||||
|
} else if (token.equals("grammars")) {
|
||||||
|
linksPanel.selectTab(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
level--;
|
level--;
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
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 FlexTable table;
|
||||||
|
private ArrayList documentIds = new ArrayList();
|
||||||
|
|
||||||
|
public GrammarsPanel(PGFWrapper pgf, ContentService contentService, StatusPopup statusPopup) {
|
||||||
|
this.pgf = pgf;
|
||||||
|
this.contentService = contentService;
|
||||||
|
this.statusPopup = statusPopup;
|
||||||
|
|
||||||
|
HorizontalPanel grammarsPanel = new HorizontalPanel();
|
||||||
|
|
||||||
|
UploadFormHandler uploadFormHandler = new UploadFormHandler();
|
||||||
|
|
||||||
|
final FormPanel form = new FormPanel();
|
||||||
|
form.setEncoding(FormPanel.ENCODING_MULTIPART);
|
||||||
|
form.setMethod(FormPanel.METHOD_POST);
|
||||||
|
form.setAction(contentService.getBaseURL());
|
||||||
|
form.addSubmitHandler(uploadFormHandler);
|
||||||
|
form.addSubmitCompleteHandler(uploadFormHandler);
|
||||||
|
grammarsPanel.add(form);
|
||||||
|
|
||||||
|
HorizontalPanel hPanel = new HorizontalPanel();
|
||||||
|
hPanel.setSpacing(8);
|
||||||
|
form.add(hPanel);
|
||||||
|
|
||||||
|
VerticalPanel vPanel = new VerticalPanel();
|
||||||
|
hPanel.add(vPanel);
|
||||||
|
|
||||||
|
vPanel.add(new HTML("<input type=\"hidden\" name=\"command\" value=\"update_grammar\"/>"));
|
||||||
|
|
||||||
|
FileUpload fileUpload = new FileUpload();
|
||||||
|
fileUpload.setName("file");
|
||||||
|
vPanel.add(fileUpload);
|
||||||
|
|
||||||
|
vPanel.add(new HTML("<BR/>"));
|
||||||
|
|
||||||
|
vPanel.add(new Label("Name:"));
|
||||||
|
TextBox grammarName = new TextBox();
|
||||||
|
grammarName.setName("name");
|
||||||
|
grammarName.setWidth("100%");
|
||||||
|
vPanel.add(grammarName);
|
||||||
|
|
||||||
|
vPanel.add(new HTML("<BR/>"));
|
||||||
|
|
||||||
|
vPanel.add(new Label("Description:"));
|
||||||
|
TextArea grammarDescr = new TextArea();
|
||||||
|
grammarDescr.setName("description");
|
||||||
|
grammarDescr.setWidth("100%");
|
||||||
|
grammarDescr.setHeight("150px");
|
||||||
|
vPanel.add(grammarDescr);
|
||||||
|
|
||||||
|
VerticalPanel btnPanel = new VerticalPanel();
|
||||||
|
btnPanel.setSpacing(3);
|
||||||
|
hPanel.add(btnPanel);
|
||||||
|
|
||||||
|
btnPanel.add(new Button("Upload", new ClickListener() {
|
||||||
|
public void onClick(Widget sender) {
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
btnPanel.add(new Button("Cancel", new ClickListener() {
|
||||||
|
public void onClick(Widget sender) {
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
initWidget(grammarsPanel);
|
||||||
|
setStylePrimaryName("my-GrammarsPanel");
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UploadFormHandler implements FormPanel.SubmitHandler, FormPanel.SubmitCompleteHandler {
|
||||||
|
public void onSubmit(FormPanel.SubmitEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -40,6 +40,11 @@
|
|||||||
background-color: rgb(147, 194, 241);
|
background-color: rgb(147, 194, 241);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.my-GrammarsPanel {
|
||||||
|
padding: 1em;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.my-EditorPanel {
|
.my-EditorPanel {
|
||||||
padding-top: 1em;
|
padding-top: 1em;
|
||||||
padding-bottom: 1em
|
padding-bottom: 1em
|
||||||
|
|||||||
Reference in New Issue
Block a user