[Tynstep-svn] r146 - in trunk: step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets step-web-app/src/main/java/com/tyndalehouse/step/web/client/view step-web-app/src/main/java/com/tyndalehouse/step/web/public/css step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/scripture
ChrisBurrell at crosswire.org
ChrisBurrell at crosswire.org
Sat Jul 10 09:21:53 MST 2010
Author: ChrisBurrell
Date: 2010-07-10 09:21:53 -0700 (Sat, 10 Jul 2010)
New Revision: 146
Added:
trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/BibleVersionsDropDownWidget.java
Modified:
trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/PassageElementWidget.java
trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/ScriptureView.java
trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/public/css/step.css
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandler.java
trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/scripture/PassageElement.java
Log:
UI updates for scripture display
Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/BibleVersionsDropDownWidget.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/BibleVersionsDropDownWidget.java (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/BibleVersionsDropDownWidget.java 2010-07-10 16:21:53 UTC (rev 146)
@@ -0,0 +1,296 @@
+package com.tyndalehouse.step.web.client.toolkit.widgets;
+
+import java.util.Iterator;
+
+import com.google.gwt.event.dom.client.FocusEvent;
+import com.google.gwt.event.dom.client.FocusHandler;
+import com.google.gwt.event.dom.client.HasKeyPressHandlers;
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.logical.shared.SelectionEvent;
+import com.google.gwt.event.logical.shared.SelectionHandler;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Tree;
+import com.google.gwt.user.client.ui.TreeItem;
+import com.tyndalehouse.step.web.client.view.internal.Area;
+import com.tyndalehouse.step.web.client.view.internal.Version;
+
+/**
+ * displays a dropdown with a filter box
+ *
+ * @author CJBurrell
+ *
+ */
+// TODO: go through application removing anonymous inner classes from GWT code
+// since memory footprint
+// TODO: use optGroup instead to handle events better !
+public class BibleVersionsDropDownWidget extends Composite {
+ protected FlowPanel bibleVersionPanel = new FlowPanel();
+ private final TextBox filterBox = new TextBox();
+ private final Tree bibleVersions = new Tree();
+
+ public BibleVersionsDropDownWidget() {
+ bibleVersionPanel.add(filterBox);
+ bibleVersionPanel.add(bibleVersions);
+
+ addHandlersForFilterBox();
+ addHandlersForTree();
+ addStyles();
+ setSuggestionsVisible(false);
+
+ // bibleVersions.setWidth("98%");
+ // filterBox.setWidth("98%");
+ // bibleVersionPanel.setWidth("100%");
+ filterBox.setText("Please enter a bible version name");
+ initWidget(bibleVersionPanel);
+ }
+
+ /**
+ * adds styles to the components
+ */
+ private void addStyles() {
+ filterBox.addStyleName("prompt");
+ bibleVersionPanel.addStyleName("bibleVersionsDropDown");
+ }
+
+ private final KeyUpHandler typingFilterHandler = new KeyUpHandler() {
+ public void onKeyUp(final KeyUpEvent keyUp) {
+ if (keyUp.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
+ setSuggestionsVisible(false);
+ } else if (keyUp.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
+ // check for single item showing:
+ selectVersionIfAvailable();
+ } else if (!keyUp.isAnyModifierKeyDown()) {
+ setSuggestionsVisible(true);
+ refilterTree();
+ }
+ }
+ };
+
+ private void selectVersionIfAvailable() {
+ final String selectedVersion = this.filterBox.getText();
+ final Iterator<TreeItem> treeIterator = bibleVersions.treeItemIterator();
+ while (treeIterator.hasNext()) {
+ final TreeItem nextItem = treeIterator.next();
+ final Object userObject = nextItem.getUserObject();
+ if (userObject instanceof Version) {
+ final Version v = (Version) userObject;
+ if (v.getInitials().equalsIgnoreCase(selectedVersion) || v.getName().equalsIgnoreCase(selectedVersion)) {
+ bibleVersions.setSelectedItem(nextItem);
+ return;
+ }
+ }
+ }
+ }
+
+ /**
+ * adds the default handlers for the filter box
+ */
+ private void addHandlersForFilterBox() {
+ filterBox.addKeyUpHandler(typingFilterHandler);
+
+ filterBox.addFocusHandler(new FocusHandler() {
+ public void onFocus(final FocusEvent focusEvent) {
+ if (filterBox.getStyleName().contains("prompt")) {
+ filterBox.setText("");
+ filterBox.removeStyleName("prompt");
+ }
+
+ // show the tree
+ setSuggestionsVisible(true);
+ }
+ });
+ }
+
+ /**
+ * sets whether the suggestions should be visible
+ *
+ * @param visible
+ * true to show the suggestions from the tree
+ */
+ private void setSuggestionsVisible(final boolean visible) {
+ bibleVersions.addStyleName(visible ? "visible" : "invisible");
+ bibleVersions.removeStyleName(!visible ? "visible" : "invisible");
+ }
+
+ /**
+ * adds handlers for tree
+ */
+ private void addHandlersForTree() {
+ bibleVersions.addKeyUpHandler(typingFilterHandler);
+ bibleVersions.addSelectionHandler(new SelectionHandler<TreeItem>() {
+ public void onSelection(final SelectionEvent<TreeItem> selectionEvent) {
+ if (selectionEvent.getSelectedItem().getChildCount() == 0) {
+ // on selection we close the tree and set the selected
+ // version
+ filterBox.setText(bibleVersions.getSelectedItem().getText());
+ setSuggestionsVisible(false);
+ }
+ }
+ });
+
+ bibleVersions.addFocusHandler(new FocusHandler() {
+ public void onFocus(final FocusEvent arg0) {
+ setSuggestionsVisible(true);
+ }
+ });
+ }
+
+ /**
+ * filters through the tree
+ */
+ protected void refilterTree() {
+ for (int ii = 0; ii < bibleVersions.getItemCount(); ii++) {
+ filterTreeItem(bibleVersions.getItem(ii), filterBox.getText().toLowerCase());
+ }
+
+ hideEmptyParents();
+ }
+
+ /**
+ * Hide parents where there are no children
+ */
+ private void hideEmptyParents() {
+ for (int ii = 0; ii < bibleVersions.getItemCount(); ii++) {
+ final TreeItem parentLevelItem = bibleVersions.getItem(ii);
+ // we ignore first level elements, only hide ones below for now
+
+ for (int jj = 0; jj < parentLevelItem.getChildCount(); jj++) {
+ final TreeItem child = parentLevelItem.getChild(jj);
+ if (!hasVisibleChildren(child)) {
+ child.setVisible(false);
+ } else {
+ child.setVisible(true);
+ }
+ }
+ }
+ }
+
+ /**
+ * returns the number of visible children
+ *
+ * @param node
+ * to be evaluated for number of visible children
+ * @return
+ */
+ private boolean hasVisibleChildren(final TreeItem node) {
+ if (node.getChildCount() == 0) {
+ return false;
+ }
+ for (int ii = 0; ii < node.getChildCount(); ii++) {
+ // first work out whether
+
+ if (node.getChild(ii).isVisible()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * filters tree items and their children
+ *
+ * @param item
+ * item to be filtered
+ * @param text
+ * the text currently in the box
+ */
+ private void filterTreeItem(final TreeItem item, final String text) {
+ // check for leaf node
+ if (item.getChildCount() == 0) {
+ // then filter
+ // Area node = (Area) item.getUserObject();
+ final Object o = item.getUserObject();
+ if (item.getText().toLowerCase().startsWith(text)
+ || (o instanceof Version && ((Version) o).getInitials().toLowerCase().startsWith(text))) {
+ item.setVisible(true);
+ item.setState(true);
+ item.getParentItem().setState(true);
+ item.getParentItem().getParentItem().setState(true);
+ } else {
+ item.setVisible(false);
+ }
+ } else {
+ for (int ii = 0; ii < item.getChildCount(); ii++) {
+ filterTreeItem(item.getChild(ii), text);
+ }
+ }
+ }
+
+ /**
+ * TODO: do work off the DOM for performance? adds a version to the tree...
+ */
+ public void addVersion(final String area, final String language, final String versionInitials,
+ final String versionName) {
+ // look for area first
+ for (int ii = 0; ii < bibleVersions.getItemCount(); ii++) {
+ final TreeItem item = bibleVersions.getItem(ii);
+ if (item.getText().equals(area)) {
+ // now get the language
+ createLanguageVersionTreeSection(language, versionInitials, versionName, item);
+ return;
+ }
+ }
+
+ // create the whole area field
+ final Area areaParent = new Area(area);
+ final TreeItem areaItem = new TreeItem(area);
+ areaItem.setUserObject(areaParent);
+ bibleVersions.addItem(areaItem);
+
+ createLanguageVersionTreeSection(language, versionInitials, versionName, areaItem);
+ }
+
+ /**
+ * creates the language and version node in the tree
+ *
+ * @param language
+ * language to be added to the tree
+ * @param versionInitials
+ * initials of the bible versions
+ * @param versionName
+ * version name as in jsword
+ * @param item
+ * parent item
+ */
+ private void createLanguageVersionTreeSection(final String language, final String versionInitials,
+ final String versionName, final TreeItem item) {
+ final TreeItem languageParent = findItem(item, language);
+ final TreeItem version = new TreeItem(versionName);
+ version.setUserObject(new Version(versionInitials, language));
+ languageParent.addItem(version);
+ }
+
+ private TreeItem findItem(final TreeItem parent, final String language) {
+ for (int ii = 0; ii < parent.getChildCount(); ii++) {
+ final TreeItem child = parent.getChild(ii);
+ final Area area = (Area) child.getUserObject();
+ if (area.getName().equals(language)) {
+ return child;
+ }
+ }
+
+ final TreeItem newChild = new TreeItem(language);
+ newChild.setUserObject(new Area(language));
+ parent.addItem(newChild);
+ return newChild;
+ }
+
+ public HasKeyPressHandlers getVersionSelectionEntered() {
+ return filterBox;
+ }
+
+ public String getCurrentlySelectedVersion() {
+ final TreeItem selectedItem = bibleVersions.getSelectedItem();
+ if (!(selectedItem == null)) {
+ final Area area = (Area) selectedItem.getUserObject();
+ if (area != null && area instanceof Version) {
+ return ((Version) area).getInitials();
+ }
+ }
+ return null;
+ }
+}
Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/PassageElementWidget.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/PassageElementWidget.java 2010-07-01 21:53:55 UTC (rev 145)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/PassageElementWidget.java 2010-07-10 16:21:53 UTC (rev 146)
@@ -22,11 +22,13 @@
final List<PassageElement> children = passageElement.getChildren();
final FlowPanel versePanel = new FlowPanel();
+ // TODO; verses can be empty!? ACTS 1:5
for (final PassageElement child : children) {
versePanel.add(new PassageElementWidget(child));
}
setElement(versePanel.getElement());
break;
+ case WORD:
case TEXT:
setElementAsLabel(passageElement, "passageWord", new InlineLabel());
// super.setElement(createLabel(passageElement,
@@ -69,9 +71,11 @@
private void styleLabel(final PassageElement passageElement, final String style, final Label label) {
final PassageElement textNode = OsisElementType.TEXT.equals(passageElement.getTypeOfElement()) ? passageElement
: passageElement.getFirstChild();
- final String text = textNode.getAttribute(OsisElementType.TEXT);
- label.setText(text);
+ if (textNode != null) {
+ final String text = textNode.getAttribute(OsisElementType.TEXT);
+ label.setText(text);
+ }
label.addStyleName(style);
}
}
Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/ScriptureView.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/ScriptureView.java 2010-07-01 21:53:55 UTC (rev 145)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/ScriptureView.java 2010-07-10 16:21:53 UTC (rev 146)
@@ -1,37 +1,20 @@
package com.tyndalehouse.step.web.client.view;
import static com.tyndalehouse.step.web.client.toolkit.DecoratorUtils.removePadding;
-import static java.lang.Double.valueOf;
-import java.util.Iterator;
import java.util.List;
import java.util.SortedMap;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.Style.Unit;
-import com.google.gwt.event.dom.client.FocusEvent;
-import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.dom.client.HasChangeHandlers;
import com.google.gwt.event.dom.client.HasKeyPressHandlers;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.event.dom.client.KeyUpEvent;
-import com.google.gwt.event.dom.client.KeyUpHandler;
-import com.google.gwt.event.logical.shared.SelectionEvent;
-import com.google.gwt.event.logical.shared.SelectionHandler;
-import com.google.gwt.uibinder.client.UiBinder;
-import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.LayoutPanel;
-import com.google.gwt.user.client.ui.Panel;
-import com.google.gwt.user.client.ui.TextBox;
-import com.google.gwt.user.client.ui.Tree;
-import com.google.gwt.user.client.ui.TreeItem;
+import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.Widget;
import com.tyndalehouse.step.web.client.presenter.ScripturePresenter;
import com.tyndalehouse.step.web.client.toolkit.HasSource;
+import com.tyndalehouse.step.web.client.toolkit.widgets.BibleVersionsDropDownWidget;
import com.tyndalehouse.step.web.client.toolkit.widgets.PassageWidget;
-import com.tyndalehouse.step.web.client.view.internal.Area;
-import com.tyndalehouse.step.web.client.view.internal.Version;
import com.tyndalehouse.step.web.shared.scripture.Passage;
/**
@@ -47,118 +30,53 @@
/** where the top of the scripture holder should be placed */
private static final int SCRIPTURE_HOLDER_TOP = 20;
- interface Binder extends UiBinder<Widget, ScriptureView> {
- }
-
- private static Binder binder = GWT.create(Binder.class);
-
private String currentPassage;
/**
- * text box in which to filter by bible versions
- */
- @UiField
- protected TextBox bibleVersionSuggestion;
-
- /**
- * a list of bible versions organised in a tree
- */
- @UiField
- protected Tree bibleVersions;
-
- /**
- * layout panel
- */
- @UiField
- protected LayoutPanel scriptureLayoutPanel;
- @UiField
- protected Panel selectorPanel;
- @UiField
- protected Panel treePanel;
- @UiField
- protected Panel scriptureHolderDecorator;
-
- /**
* a logical display of scripture, in that events can be attached to each of
* the elements on this panel
*/
- protected @UiField
- PassageWidget scriptureHolder;
+ private final PassageWidget scriptureHolder = new PassageWidget();
+ private final BibleVersionsDropDownWidget bibleVersionsDropDown = new BibleVersionsDropDownWidget();
+ private final AbsolutePanel scripturePanel = new AbsolutePanel();
- private final KeyUpHandler typingFilterHandler = new KeyUpHandler() {
- public void onKeyUp(final KeyUpEvent keyUp) {
- if (keyUp.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
- hideSuggestions();
- } else if (keyUp.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
- // check for single item showing:
- selectVersionIfAvailable();
- } else if (!keyUp.isAnyModifierKeyDown()) {
- showSuggestions();
- refilterTree();
- }
- }
- };
-
/**
* The default constructor
*
*/
public ScriptureView() {
- super.initWidget(binder.createAndBindUi(this));
-
- // set initial properties
- bibleVersionSuggestion.setStyleName("prompt");
- scriptureLayoutPanel.getWidgetContainerElement(scriptureHolderDecorator).getStyle().setZIndex(1000);
- scriptureLayoutPanel.getWidgetContainerElement(selectorPanel).getStyle().setZIndex(1000);
- scriptureLayoutPanel.getWidgetContainerElement(treePanel).getStyle().setZIndex(2000);
- hideSuggestions();
- addHandlersForFilterBox();
- addHandlersForTree();
-
+ final DecoratorPanel decorator = new DecoratorPanel();
+ decorator.add(scriptureHolder);
+ scripturePanel.add(bibleVersionsDropDown, 0, 0);
+ scripturePanel.add(decorator, 0, SCRIPTURE_HOLDER_TOP);
+ // layoutPanel.add(decorator);
+ initWidget(scripturePanel);
}
- private void selectVersionIfAvailable() {
- final String selectedVersion = this.bibleVersionSuggestion.getText();
- final Iterator<TreeItem> treeIterator = bibleVersions.treeItemIterator();
- while (treeIterator.hasNext()) {
- final TreeItem nextItem = treeIterator.next();
- final Object userObject = nextItem.getUserObject();
- if (userObject instanceof Version) {
- final Version v = (Version) userObject;
- if (v.getInitials().equalsIgnoreCase(selectedVersion) || v.getName().equalsIgnoreCase(selectedVersion)) {
- bibleVersions.setSelectedItem(nextItem);
- // final SelectionEvent<TreeItem> selectionEventItem = new
- // SelectionEvent<TreeItem>(nextItem) {
- // };
- // bibleVersions.fireEvent(selectionEventItem);
-
- return;
- }
- }
- }
- }
-
@Override
public void setWidth(final String width) {
- // super.setWidth(width);
- if (scriptureHolder != null) {
- scriptureHolder.setWidth(removePadding(width));
- }
+ scripturePanel.setWidth(width);
+ scriptureHolder.setWidth(removePadding(width));
}
@Override
public void setHeight(final String height) {
- final Double heightInPixels = valueOf(height.substring(0, height.length() - 2));
+ scripturePanel.setHeight(height);
+
+ final Double heightInPixels = Double.valueOf(height.substring(0, height.length() - 2));
final double adjustedHeight = removePadding(heightInPixels - SCRIPTURE_HOLDER_TOP);
+ scriptureHolder.setHeight(adjustedHeight + "px");
- // finally reset the layer height
- scriptureLayoutPanel.setWidgetTopHeight(scriptureHolderDecorator, SCRIPTURE_HOLDER_TOP, Unit.PX,
- heightInPixels, Unit.PX);
-
- // super.setHeight(height);
- if (scriptureHolder != null) {
- scriptureHolder.setHeight(adjustedHeight + "px");
- }
+ // // bibleVersionsDropDown.setHeight(height);
+ // // finally reset the layer height
+ // layoutPanel
+ // .setWidgetTopHeight(scriptureHolderDecorator, SCRIPTURE_HOLDER_TOP,
+ // Unit.PX, heightInPixels, Unit.PX);
+ //
+ // // super.setHeight(height);
+ // if (scriptureHolder != null) {
+ // scriptureHolder.setHeight(adjustedHeight + "px");
+ // }
}
public void startProcessing() {
@@ -182,212 +100,6 @@
this.currentPassage = currentPassage;
}
- /**
- * adds the default handlers for the filter box
- */
- private void addHandlersForFilterBox() {
- bibleVersionSuggestion.addKeyUpHandler(typingFilterHandler);
-
- bibleVersionSuggestion.addFocusHandler(new FocusHandler() {
- public void onFocus(final FocusEvent focusEvent) {
- if (bibleVersionSuggestion.getStyleName().contains("prompt")) {
- bibleVersionSuggestion.setText("");
- bibleVersionSuggestion.removeStyleName("prompt");
- }
-
- // show the tree
- showSuggestions();
- }
- });
-
- }
-
- private void showSuggestions() {
- bibleVersions.setVisible(true);
- }
-
- private void hideSuggestions() {
- bibleVersions.setVisible(false);
- }
-
- /**
- * adds handlers for tree
- */
- private void addHandlersForTree() {
- bibleVersions.addKeyUpHandler(typingFilterHandler);
- bibleVersions.addSelectionHandler(new SelectionHandler<TreeItem>() {
- public void onSelection(final SelectionEvent<TreeItem> selectionEvent) {
- if (selectionEvent.getSelectedItem().getChildCount() == 0) {
- // on selection we close the tree and set the selected
- // version
- bibleVersionSuggestion.setText(bibleVersions.getSelectedItem().getText());
- hideSuggestions();
- }
- }
- });
-
- bibleVersions.addFocusHandler(new FocusHandler() {
- public void onFocus(final FocusEvent arg0) {
- showSuggestions();
- }
- });
- }
-
- /**
- * filters through the tree
- */
- protected void refilterTree() {
- for (int ii = 0; ii < bibleVersions.getItemCount(); ii++) {
- filterTreeItem(bibleVersions.getItem(ii), bibleVersionSuggestion.getText().toLowerCase());
- }
-
- hideEmptyParents();
- }
-
- /**
- * Hide parents where there are no children
- */
- private void hideEmptyParents() {
- for (int ii = 0; ii < bibleVersions.getItemCount(); ii++) {
- final TreeItem parentLevelItem = bibleVersions.getItem(ii);
- // we ignore first level elements, only hide ones below for now
-
- for (int jj = 0; jj < parentLevelItem.getChildCount(); jj++) {
- final TreeItem child = parentLevelItem.getChild(jj);
- if (!hasVisibleChildren(child)) {
- child.setVisible(false);
- } else {
- child.setVisible(true);
- }
- }
- }
- }
-
- /**
- * returns the number of visible children
- *
- * @param node
- * to be evaluated for number of visible children
- * @return
- */
- private boolean hasVisibleChildren(final TreeItem node) {
- if (node.getChildCount() == 0) {
- return false;
- }
- for (int ii = 0; ii < node.getChildCount(); ii++) {
- // first work out whether
-
- if (node.getChild(ii).isVisible()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * filters tree items and their children
- *
- * @param item
- * item to be filtered
- * @param text
- * the text currently in the box
- */
- private void filterTreeItem(final TreeItem item, final String text) {
- // check for leaf node
- if (item.getChildCount() == 0) {
- // then filter
- // Area node = (Area) item.getUserObject();
- final Object o = item.getUserObject();
- if (item.getText().toLowerCase().startsWith(text)
- || (o instanceof Version && ((Version) o).getInitials().toLowerCase().startsWith(text))) {
- item.setVisible(true);
- item.setState(true);
- item.getParentItem().setState(true);
- item.getParentItem().getParentItem().setState(true);
- } else {
- item.setVisible(false);
- }
- } else {
- for (int ii = 0; ii < item.getChildCount(); ii++) {
- filterTreeItem(item.getChild(ii), text);
- }
- }
- }
-
- /**
- * TODO: do work off the DOM for performance? adds a version to the tree...
- */
- public void addVersion(final String area, final String language, final String versionInitials,
- final String versionName) {
- // look for area first
- for (int ii = 0; ii < bibleVersions.getItemCount(); ii++) {
- final TreeItem item = bibleVersions.getItem(ii);
- if (item.getText().equals(area)) {
- // now get the language
- createLanguageVersionTreeSection(language, versionInitials, versionName, item);
- return;
- }
- }
-
- // create the whole area field
- final Area areaParent = new Area(area);
- final TreeItem areaItem = new TreeItem(area);
- areaItem.setUserObject(areaParent);
- bibleVersions.addItem(areaItem);
-
- createLanguageVersionTreeSection(language, versionInitials, versionName, areaItem);
- }
-
- /**
- * creates the language and version node in the tree
- *
- * @param language
- * language to be added to the tree
- * @param versionInitials
- * initials of the bible versions
- * @param versionName
- * version name as in jsword
- * @param item
- * parent item
- */
- private void createLanguageVersionTreeSection(final String language, final String versionInitials,
- final String versionName, final TreeItem item) {
- final TreeItem languageParent = findItem(item, language);
- final TreeItem version = new TreeItem(versionName);
- version.setUserObject(new Version(versionInitials, language));
- languageParent.addItem(version);
- }
-
- private TreeItem findItem(final TreeItem parent, final String language) {
- for (int ii = 0; ii < parent.getChildCount(); ii++) {
- final TreeItem child = parent.getChild(ii);
- final Area area = (Area) child.getUserObject();
- if (area.getName().equals(language)) {
- return child;
- }
- }
-
- final TreeItem newChild = new TreeItem(language);
- newChild.setUserObject(new Area(language));
- parent.addItem(newChild);
- return newChild;
- }
-
- public HasKeyPressHandlers getVersionSelectionEntered() {
- return bibleVersionSuggestion;
- }
-
- public String getCurrentlySelectedVersion() {
- final TreeItem selectedItem = bibleVersions.getSelectedItem();
- if (!(selectedItem == null)) {
- final Area area = (Area) selectedItem.getUserObject();
- if (area != null && area instanceof Version) {
- return ((Version) area).getInitials();
- }
- }
- return null;
- }
-
public HasChangeHandlers getChangeHandlers() {
// TODO Auto-generated method stub
return null;
@@ -414,4 +126,17 @@
public void setPassage(final Passage passage) {
scriptureHolder.setPassage(passage);
}
+
+ public void addVersion(final String area, final String language, final String versionInitials,
+ final String versionName) {
+ bibleVersionsDropDown.addVersion(area, language, versionInitials, versionName);
+ }
+
+ public String getCurrentlySelectedVersion() {
+ return bibleVersionsDropDown.getCurrentlySelectedVersion();
+ }
+
+ public HasKeyPressHandlers getVersionSelectionEntered() {
+ return bibleVersionsDropDown.getVersionSelectionEntered();
+ }
}
Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/public/css/step.css
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/public/css/step.css 2010-07-01 21:53:55 UTC (rev 145)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/public/css/step.css 2010-07-10 16:21:53 UTC (rev 146)
@@ -10,10 +10,34 @@
color: grey;
}
-.bibleVersionsDropDown {
- width: 250px;
+div.bibleVersionsDropDown {
+ text-align: center;
+ width: 100%;
}
+.bibleVersionsDropDown * {
+ text-align: left;
+
+}
+
+.bibleVersionsDropDown input {
+ text-align: left;
+ width: 99%;
+ padding: 0px;
+ margin: 0px;
+}
+
+.gwt-Tree {
+ background-color: #BCD56D;
+ border: black solid 1px;
+ border: black solid 1px;
+ padding: 0px 0px 0px 1px;
+ margin:-1px 0px 0px 1px;
+ z-index: 1000;
+}
+
+
+
.stepPanelBackground {
background-color: #BCD56D;
border: black solid 1px;
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandler.java 2010-07-01 21:53:55 UTC (rev 145)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandler.java 2010-07-10 16:21:53 UTC (rev 146)
@@ -87,6 +87,9 @@
return result;
}
+ /**
+ * sets up initial filters to ensure some OSIS information gets filtered out
+ */
void initFilters() {
if (elementFilter == null) {
elementFilter = OsisParserFilter.DEFAULT_ELEMENT_FILTER;
Modified: trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/scripture/PassageElement.java
===================================================================
--- trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/scripture/PassageElement.java 2010-07-01 21:53:55 UTC (rev 145)
+++ trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/scripture/PassageElement.java 2010-07-10 16:21:53 UTC (rev 146)
@@ -84,7 +84,10 @@
* @return the first child
*/
public PassageElement getFirstChild() {
- return this.getChild(0);
+ if (this.children != null && this.children.size() > 0) {
+ return this.getChild(0);
+ }
+ return null;
}
/**
More information about the Tynstep-svn
mailing list