forked from GitHub/gf-core
dummy UI for documents saving/loading in the editor
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
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.*;
|
||||||
|
|
||||||
|
public class DocumentsPanel extends Composite {
|
||||||
|
|
||||||
|
private PGFWrapper pgf;
|
||||||
|
private FlexTable table;
|
||||||
|
|
||||||
|
public DocumentsPanel(PGFWrapper pgf) {
|
||||||
|
this.pgf = pgf;
|
||||||
|
|
||||||
|
VerticalPanel documentsPanel = new VerticalPanel();
|
||||||
|
documentsPanel.setStylePrimaryName("my-DocumentsFrame");
|
||||||
|
|
||||||
|
Label header = new Label("Documents");
|
||||||
|
header.setStylePrimaryName("my-DocumentsHeader");
|
||||||
|
documentsPanel.add(header);
|
||||||
|
|
||||||
|
table = new FlexTable();
|
||||||
|
table.setStylePrimaryName("my-DocumentsTable");
|
||||||
|
documentsPanel.add(table);
|
||||||
|
|
||||||
|
addRow(0, "Test0");
|
||||||
|
addRow(1, "Test1");
|
||||||
|
addRow(2, "Test2");
|
||||||
|
addRow(3, "Test3");
|
||||||
|
|
||||||
|
table.addClickHandler(new ClickHandler() {
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
HTMLTable.Cell cell = table.getCellForEvent(event);
|
||||||
|
if (cell != null) {
|
||||||
|
int row = cell.getRowIndex();
|
||||||
|
selectRow(row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
initWidget(documentsPanel);
|
||||||
|
setStylePrimaryName("my-DocumentsPanel");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRow(int row, String text) {
|
||||||
|
table.setText(row, 0, text);
|
||||||
|
table.getRowFormatter().addStyleName(row, "row");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectRow(int row) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ public class EditorApp implements EntryPoint {
|
|||||||
protected Widget translatePanel;
|
protected Widget translatePanel;
|
||||||
protected BrowsePanel browsePanel;
|
protected BrowsePanel browsePanel;
|
||||||
protected QueryPanel queryPanel;
|
protected QueryPanel queryPanel;
|
||||||
|
protected DocumentsPanel documentsPanel;
|
||||||
protected StatusPopup statusPopup;
|
protected StatusPopup statusPopup;
|
||||||
protected TextInputPanel textPanel;
|
protected TextInputPanel textPanel;
|
||||||
protected FridgeBagPanel bagPanel;
|
protected FridgeBagPanel bagPanel;
|
||||||
@@ -217,6 +218,7 @@ public class EditorApp implements EntryPoint {
|
|||||||
translatePanel = createTranslatePanel();
|
translatePanel = createTranslatePanel();
|
||||||
browsePanel = createBrowsePanel();
|
browsePanel = createBrowsePanel();
|
||||||
queryPanel = createQueryPanel();
|
queryPanel = createQueryPanel();
|
||||||
|
documentsPanel = createDocumentsPanel();
|
||||||
|
|
||||||
VerticalPanel vPanel = new VerticalPanel();
|
VerticalPanel vPanel = new VerticalPanel();
|
||||||
vPanel.setWidth("100%");
|
vPanel.setWidth("100%");
|
||||||
@@ -318,13 +320,29 @@ public class EditorApp implements EntryPoint {
|
|||||||
return new QueryPanel(pgf);
|
return new QueryPanel(pgf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DocumentsPanel createDocumentsPanel() {
|
||||||
|
return new DocumentsPanel(pgf);
|
||||||
|
}
|
||||||
|
|
||||||
protected Widget createLinksPanel(final Panel parent) {
|
protected Widget createLinksPanel(final Panel parent) {
|
||||||
HorizontalPanel linksPanel = new HorizontalPanel();
|
HorizontalPanel linksPanel = new HorizontalPanel();
|
||||||
linksPanel.setStylePrimaryName("my-LinksPanel");
|
linksPanel.setStylePrimaryName("my-LinksPanel");
|
||||||
|
|
||||||
|
Hyperlink documentsLink = new Hyperlink("Documents", "documents");
|
||||||
|
documentsLink.addClickListener(new ClickListener() {
|
||||||
|
public void onClick(Widget sender) {
|
||||||
|
parent.remove(browsePanel);
|
||||||
|
parent.remove(queryPanel);
|
||||||
|
parent.remove(translatePanel);
|
||||||
|
parent.add(documentsPanel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
linksPanel.add(documentsLink);
|
||||||
|
|
||||||
Hyperlink translateLink = new Hyperlink("Translate", "translate");
|
Hyperlink translateLink = new Hyperlink("Translate", "translate");
|
||||||
translateLink.addClickListener(new ClickListener() {
|
translateLink.addClickListener(new ClickListener() {
|
||||||
public void onClick(Widget sender) {
|
public void onClick(Widget sender) {
|
||||||
|
parent.remove(documentsPanel);
|
||||||
parent.remove(browsePanel);
|
parent.remove(browsePanel);
|
||||||
parent.remove(queryPanel);
|
parent.remove(queryPanel);
|
||||||
parent.add(translatePanel);
|
parent.add(translatePanel);
|
||||||
@@ -335,6 +353,7 @@ public class EditorApp implements EntryPoint {
|
|||||||
Hyperlink queryLink = new Hyperlink("Query", "query");
|
Hyperlink queryLink = new Hyperlink("Query", "query");
|
||||||
queryLink.addClickListener(new ClickListener() {
|
queryLink.addClickListener(new ClickListener() {
|
||||||
public void onClick(Widget sender) {
|
public void onClick(Widget sender) {
|
||||||
|
parent.remove(documentsPanel);
|
||||||
parent.remove(translatePanel);
|
parent.remove(translatePanel);
|
||||||
parent.remove(browsePanel);
|
parent.remove(browsePanel);
|
||||||
parent.add(queryPanel);
|
parent.add(queryPanel);
|
||||||
@@ -345,6 +364,7 @@ public class EditorApp implements EntryPoint {
|
|||||||
Hyperlink browseLink = new Hyperlink("Browse", "browse");
|
Hyperlink browseLink = new Hyperlink("Browse", "browse");
|
||||||
browseLink.addClickListener(new ClickListener() {
|
browseLink.addClickListener(new ClickListener() {
|
||||||
public void onClick(Widget sender) {
|
public void onClick(Widget sender) {
|
||||||
|
parent.remove(documentsPanel);
|
||||||
parent.remove(translatePanel);
|
parent.remove(translatePanel);
|
||||||
parent.remove(queryPanel);
|
parent.remove(queryPanel);
|
||||||
parent.add(browsePanel);
|
parent.add(browsePanel);
|
||||||
@@ -379,15 +399,23 @@ public class EditorApp implements EntryPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onHistoryChanged(String token) {
|
public void onHistoryChanged(String token) {
|
||||||
if (token.equals("translate")) {
|
if (token.equals("documents")) {
|
||||||
|
parent.add(documentsPanel);
|
||||||
|
parent.remove(translatePanel);
|
||||||
parent.remove(queryPanel);
|
parent.remove(queryPanel);
|
||||||
parent.remove(browsePanel);
|
parent.remove(browsePanel);
|
||||||
|
} else if (token.equals("translate")) {
|
||||||
|
parent.remove(documentsPanel);
|
||||||
parent.add(translatePanel);
|
parent.add(translatePanel);
|
||||||
} else if (token.equals("query")) {
|
parent.remove(queryPanel);
|
||||||
parent.remove(translatePanel);
|
|
||||||
parent.remove(browsePanel);
|
parent.remove(browsePanel);
|
||||||
|
} else if (token.equals("query")) {
|
||||||
|
parent.remove(documentsPanel);
|
||||||
|
parent.remove(translatePanel);
|
||||||
parent.add(queryPanel);
|
parent.add(queryPanel);
|
||||||
|
parent.remove(browsePanel);
|
||||||
} else if (token.equals("browse")) {
|
} else if (token.equals("browse")) {
|
||||||
|
parent.remove(documentsPanel);
|
||||||
parent.remove(translatePanel);
|
parent.remove(translatePanel);
|
||||||
parent.remove(queryPanel);
|
parent.remove(queryPanel);
|
||||||
parent.add(browsePanel);
|
parent.add(browsePanel);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class TextInputPanel extends Composite implements Focusable, HasValueChan
|
|||||||
toolbar.setCellVerticalAlignment(buttons,HorizontalPanel.ALIGN_MIDDLE);
|
toolbar.setCellVerticalAlignment(buttons,HorizontalPanel.ALIGN_MIDDLE);
|
||||||
|
|
||||||
Image clearButton = new Image("org.grammaticalframework.ui.gwt.EditorApp/textinput-buttons.png",0,0,20,20);
|
Image clearButton = new Image("org.grammaticalframework.ui.gwt.EditorApp/textinput-buttons.png",0,0,20,20);
|
||||||
clearButton.setTitle("Clears the whole text.");
|
clearButton.setTitle("Clears the whole document.");
|
||||||
clearButton.setStylePrimaryName("button");
|
clearButton.setStylePrimaryName("button");
|
||||||
clearButton.addClickListener(new ClickListener () {
|
clearButton.addClickListener(new ClickListener () {
|
||||||
public void onClick(Widget sender) {
|
public void onClick(Widget sender) {
|
||||||
@@ -80,7 +80,17 @@ public class TextInputPanel extends Composite implements Focusable, HasValueChan
|
|||||||
});
|
});
|
||||||
buttons.add(clearButton);
|
buttons.add(clearButton);
|
||||||
|
|
||||||
Image deleteLastButton = new Image("org.grammaticalframework.ui.gwt.EditorApp/textinput-buttons.png",20,0,20,20);
|
Image saveButton = new Image("org.grammaticalframework.ui.gwt.EditorApp/textinput-buttons.png",20,0,20,20);
|
||||||
|
saveButton.setTitle("Save the document.");
|
||||||
|
saveButton.setStylePrimaryName("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.setTitle("Removes the last word.");
|
||||||
deleteLastButton.setStylePrimaryName("button");
|
deleteLastButton.setStylePrimaryName("button");
|
||||||
deleteLastButton.addClickListener(new ClickListener () {
|
deleteLastButton.addClickListener(new ClickListener () {
|
||||||
@@ -160,6 +170,9 @@ public class TextInputPanel extends Composite implements Focusable, HasValueChan
|
|||||||
tempPanel = null;
|
tempPanel = null;
|
||||||
fireValueChange();
|
fireValueChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
}
|
||||||
|
|
||||||
public void addMagnet(Magnet magnet) {
|
public void addMagnet(Magnet magnet) {
|
||||||
Label wordLabel = new Label(magnet.getText());
|
Label wordLabel = new Label(magnet.getText());
|
||||||
|
|||||||
@@ -1,4 +1,36 @@
|
|||||||
/** Add css rules here for your application. */
|
.my-DocumentsPanel {
|
||||||
|
padding: 1em;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.my-DocumentsFrame {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.my-DocumentsHeader {
|
||||||
|
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-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-TranslatePanel {
|
.my-TranslatePanel {
|
||||||
padding-top: 1em;
|
padding-top: 1em;
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 1.1 KiB |
Reference in New Issue
Block a user