[Tynstep-svn] r153 - in trunk: step-web-app/src/main/java/com/tyndalehouse/step/web/client/common step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/handlers 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-app/src/main/resources/com/tyndalehouse/step/web/client/css step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/common step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/result step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/scripture

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Thu Jul 15 08:08:26 MST 2010


Author: ChrisBurrell
Date: 2010-07-15 08:08:26 -0700 (Thu, 15 Jul 2010)
New Revision: 153

Added:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/common/OsisUtils.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/Layout.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/Passage.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/InlinePanel.java
   trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/layout.css
   trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/passage.css
Removed:
   trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/step.css
Modified:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/StepResources.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/ScripturePresenter.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/handlers/OptionEvent.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/OptionsButtonWidget.java
   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/PassageWidget.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/client/view/StepView.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-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/OsisParserFilter.java
   trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/common/ScriptureDisplayOptions.java
   trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/result/GetCurrentBibleTextResult.java
   trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/scripture/Passage.java
Log:
updating with verse numbers

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/common/OsisUtils.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/common/OsisUtils.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/common/OsisUtils.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -0,0 +1,40 @@
+package com.tyndalehouse.step.web.client.common;
+
+import static com.tyndalehouse.step.web.client.common.StringUtils.isEmpty;
+
+/**
+ * Some helper functions for Osis parsing
+ * 
+ * @author CJBurrell
+ * 
+ */
+public class OsisUtils {
+    private static final char OSIS_REFERENCE_SEPARATOR = '.';
+
+    /**
+     * hiding implementation
+     */
+    private OsisUtils() {
+        // no implementation
+    }
+
+    /**
+     * give an osisID, we extract and return the verse number
+     * 
+     * @param osisId
+     *            the osis id
+     * @return the verse number
+     */
+    public static String getVerseNumberFromOsisId(final String osisId) {
+        if (isEmpty(osisId)) {
+            return "";
+        }
+
+        final int lastOsisPart = osisId.lastIndexOf(OSIS_REFERENCE_SEPARATOR) + 1;
+        if (lastOsisPart > osisId.length()) {
+            return "";
+        }
+
+        return osisId.substring(lastOsisPart);
+    }
+}

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/Layout.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/Layout.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/Layout.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -0,0 +1,9 @@
+package com.tyndalehouse.step.web.client.framework;
+
+import com.google.gwt.resources.client.CssResource;
+
+public interface Layout extends CssResource {
+    String inlinePanel();
+
+    String floatRight();
+}

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/Passage.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/Passage.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/Passage.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -0,0 +1,21 @@
+package com.tyndalehouse.step.web.client.framework;
+
+import com.google.gwt.resources.client.CssResource;
+
+public interface Passage extends CssResource {
+
+    String lineBreak();
+
+    String title();
+
+    String quotePanel();
+
+    String versePanel();
+
+    String transChange();
+
+    String word();
+
+    String verseNumber();
+
+}

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/StepResources.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/StepResources.java	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/StepResources.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -31,7 +31,10 @@
     @Source("com/tyndalehouse/step/web/client/toolkit/options-over.png")
     ImageResource optionsOver();
 
-    @Source("com/tyndalehouse/step/web/client/css/step.css")
-    StepCssResources css();
+    @Source("com/tyndalehouse/step/web/client/css/layout.css")
+    Layout layout();
 
+    @Source("com/tyndalehouse/step/web/client/css/passage.css")
+    Passage passage();
+
 }

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/ScripturePresenter.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/ScripturePresenter.java	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/ScripturePresenter.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -1,9 +1,12 @@
 package com.tyndalehouse.step.web.client.presenter;
 
 import static com.tyndalehouse.step.web.client.common.StringUtils.isNotEmpty;
+import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.OSIS_ID;
+import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.VERSE;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.SortedMap;
 
 import net.customware.gwt.dispatch.client.DispatchAsync;
@@ -31,6 +34,7 @@
 import com.tyndalehouse.step.web.shared.result.GetAvailableBibleVersionsResult;
 import com.tyndalehouse.step.web.shared.result.GetCurrentBibleTextResult;
 import com.tyndalehouse.step.web.shared.result.beans.BibleVersion;
+import com.tyndalehouse.step.web.shared.scripture.OsisElementType;
 import com.tyndalehouse.step.web.shared.scripture.Passage;
 
 /**
@@ -81,14 +85,14 @@
          */
         void setPassage(Passage passage);
 
+        Passage getPassage();
+
         String getCurrentPassage();
 
         void setCurrentPassage(String currentPassage);
 
         void addVersion(String continent, String language, String versionInitials, String versionName);
 
-        // HasClickHandlers getVersionSelectionButton();
-
         HasKeyPressHandlers getVersionSelectionEntered();
 
         String getCurrentlySelectedVersion();
@@ -96,6 +100,8 @@
         HandlerRegistration addOptionHandler(OptionHandler handler);
 
         Map<String, ScriptureDisplayOptions> getSelectedOptions();
+
+        void refreshPassage();
     }
 
     /**
@@ -146,13 +152,42 @@
     private void addHandlersForOptionChange() {
         view.addOptionHandler(new OptionHandler() {
             public void onOptionSelected(final OptionEvent oe) {
-                // if oe == verse numbers, then can do something now
-                // if show notes, etc. then need to get that from elsewhere
-                refreshView();
+                if (!refreshIfDataAlreadyObtained(oe)) {
+                    refreshViewFromServer();
+                }
             }
         });
     }
 
+    /**
+     * either does the refresh if it is possible, without asking the server or
+     * return false
+     * 
+     * @param oe
+     *            the event triggering this refresh the selected option
+     * @return true if a refresh was done
+     */
+    private boolean refreshIfDataAlreadyObtained(final OptionEvent oe) {
+        final Passage p = view.getPassage();
+        final Set<OsisElementType> attributeFilter = p.getAttributeFilter();
+        final Set<OsisElementType> elementFilter = p.getElementFilter();
+
+        if (!oe.isAddingData()) {
+            view.refreshPassage();
+        }
+
+        switch (oe.getSelectedOption()) {
+            case VERSE_NUMBERS:
+                if (!(elementFilter.contains(VERSE) && attributeFilter.contains(OSIS_ID))) {
+                    return false;
+                }
+                view.refreshPassage();
+                return true;
+            default:
+                return false;
+        }
+    }
+
     public void onStart() {
         // eventBus.setLeftColumn(view);
     }
@@ -183,14 +218,14 @@
      */
     public void onScriptureChanged(final String newReference) {
         view.setCurrentPassage(newReference);
-        refreshView();
+        refreshViewFromServer();
     }
 
     public void onVersionChanged(final String newVersionInitials) {
-        refreshView();
+        refreshViewFromServer();
     }
 
-    private void refreshView() {
+    private void refreshViewFromServer() {
         // check whether all parameters are there, otherwise don't fire
         final String currentlySelectedVersion = view.getCurrentlySelectedVersion();
         final String currentPassage = view.getCurrentPassage();
@@ -201,9 +236,6 @@
                     currentPassage);
             cmd.setDisplayOptions(view.getSelectedOptions());
 
-            // TODO: decide if this should be made static or UI driven
-            // cmd.(view.getSelectedOptions());
-
             dispatcher.execute(cmd, new AsyncCallback<GetCurrentBibleTextResult>() {
                 public void onFailure(final Throwable e) {
                     Log.error("An error has occurred", e);

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/handlers/OptionEvent.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/handlers/OptionEvent.java	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/handlers/OptionEvent.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -6,9 +6,21 @@
 public class OptionEvent extends GwtEvent<OptionHandler> {
     private static Type<OptionHandler> TYPE = new Type<OptionHandler>();
     private final ScriptureDisplayOptions selectedOption;
+    private final boolean addingData;
 
-    public OptionEvent(final ScriptureDisplayOptions sdo) {
+    /**
+     * creates an OptionEvent which indicates what feature is requested, and
+     * whether we are adding data to the display, or removing it. Clearly, if we
+     * are removing data, we don't need to do a call to the server
+     * 
+     * @param sdo
+     *            the option that is being toggled
+     * @param addingData
+     *            whether the toggling needs more data than required.
+     */
+    public OptionEvent(final ScriptureDisplayOptions sdo, final boolean addingData) {
         this.selectedOption = sdo;
+        this.addingData = addingData;
     }
 
     @Override
@@ -31,4 +43,11 @@
     public ScriptureDisplayOptions getSelectedOption() {
         return selectedOption;
     }
+
+    /**
+     * @return the addingData
+     */
+    public boolean isAddingData() {
+        return addingData;
+    }
 }

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/InlinePanel.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/InlinePanel.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/InlinePanel.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -0,0 +1,19 @@
+package com.tyndalehouse.step.web.client.toolkit.widgets;
+
+import static com.tyndalehouse.step.web.client.framework.StepResources.RESOURCES;
+
+import com.google.gwt.user.client.ui.FlowPanel;
+
+public class InlinePanel extends FlowPanel {
+    static {
+        RESOURCES.layout().ensureInjected();
+    }
+
+    /**
+     * adds the inline style to the panel
+     */
+    InlinePanel() {
+        super();
+        this.addStyleName(RESOURCES.layout().inlinePanel());
+    }
+}

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/OptionsButtonWidget.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/OptionsButtonWidget.java	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/OptionsButtonWidget.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -15,7 +15,6 @@
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
 import com.google.gwt.event.shared.HandlerManager;
 import com.google.gwt.event.shared.HandlerRegistration;
-import com.google.gwt.user.client.ui.AbsolutePanel;
 import com.google.gwt.user.client.ui.CheckBox;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.Image;
@@ -28,14 +27,17 @@
 import com.tyndalehouse.step.web.client.toolkit.handlers.OptionHandler;
 import com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptions;
 
-//TODO: move this to the scripture display part, since it needs to float right and prevent text from being on it.
 public class OptionsButtonWidget extends Composite implements HasOptionsHandler {
-    final private AbsolutePanel holder = new AbsolutePanel();
+    final private InlinePanel holder = new InlinePanel();
     final private PopupPanel menu = new PopupPanel(false);
     private final Image image;
     private final HandlerManager handlerManager = new HandlerManager(this);
     private final Map<String, ScriptureDisplayOptions> selectedOptions = new HashMap<String, ScriptureDisplayOptions>();
 
+    static {
+        RESOURCES.layout().ensureInjected();
+    }
+
     private final ValueChangeHandler<Boolean> valueChangeHandler = new ValueChangeHandler<Boolean>() {
         public void onValueChange(final ValueChangeEvent<Boolean> valueChangeEvent) {
             final CheckBox option = (CheckBox) valueChangeEvent.getSource();
@@ -47,7 +49,10 @@
             } else {
                 selectedOptions.remove(key);
             }
-            handlerManager.fireEvent(new OptionEvent(scriptureDisplayOption));
+
+            // IMPROVEMENT we assume for now that a tick in the box always adds
+            // information to the screen
+            handlerManager.fireEvent(new OptionEvent(scriptureDisplayOption, checked.booleanValue()));
             menu.hide();
         }
     };
@@ -56,9 +61,9 @@
      * creates an options button
      */
     public OptionsButtonWidget() {
+        holder.addStyleName(RESOURCES.layout().floatRight());
         image = new Image(RESOURCES.options());
         holder.add(image);
-        // holder.add(menu);
         holder.addStyleName("optionsButton");
         initImageHandlers();
         initWidget(holder);
@@ -128,13 +133,8 @@
             menuItem.addValueChangeHandler(valueChangeHandler);
         }
 
-        // menu.setPopupPosition(menu.getOffsetWidth(), image.getAbsoluteTop());
-        // menu.showRelativeTo(image);
-        // menu.addAutoHidePartner(image.getElement());
         menu.hide();
         menu.addStyleName("optionsButtonMenu");
-        // menu.addStyleName(RESOURCES.css().invisible());
-        // menu.addStyleName("optionsMenuScripture");
     }
 
     @Override

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-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/PassageElementWidget.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -1,51 +1,75 @@
 package com.tyndalehouse.step.web.client.toolkit.widgets;
 
+import static com.tyndalehouse.step.web.client.common.OsisUtils.getVerseNumberFromOsisId;
 import static com.tyndalehouse.step.web.client.common.StringUtils.isNotEmpty;
+import static com.tyndalehouse.step.web.client.framework.StepResources.RESOURCES;
+import static com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptions.VERSE_NUMBERS;
+import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.OSIS_ID;
+import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.TITLE;
+import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.VERSE;
 
 import java.util.List;
+import java.util.Map;
 
 import com.allen_sauer.gwt.log.client.Log;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.InlineLabel;
+import com.google.gwt.user.client.ui.InsertPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.Widget;
+import com.tyndalehouse.step.web.client.framework.Passage;
+import com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptions;
 import com.tyndalehouse.step.web.shared.scripture.OsisElementType;
 import com.tyndalehouse.step.web.shared.scripture.PassageElement;
 
+/**
+ * this widget represents a part of a scripture passage, whether that be a
+ * verse, a title, etc. It is in charge of the rendering. IMPROVEMENT It is
+ * designed at the moment, to only be creatable once, and therefore, any changes
+ * in options, should cause each PassageElementWidget to be destroyed and
+ * recreated from scratch
+ * 
+ * @author CJBurrell
+ * 
+ */
 public class PassageElementWidget extends Widget {
+    static {
+        RESOURCES.passage().ensureInjected();
+    }
 
-    public PassageElementWidget(final PassageElement passageElement) {
+    public PassageElementWidget(final PassageElement passageElement, final Map<String, ScriptureDisplayOptions> options) {
+        final Passage passageCss = RESOURCES.passage();
         switch (passageElement.getTypeOfElement()) {
             case TITLE:
-                setElementAsLabel(passageElement, "passageTitle", new Label());
+                setElementAsLabel(passageElement, passageCss.title(), new Label());
                 break;
             case VERSE:
-                addChildren(passageElement, null);
+                addChildren(passageElement, passageCss.versePanel(), options);
                 break;
             case WORD:
             case TEXT:
-                setElementAsLabel(passageElement, "passageWord", new InlineLabel());
+                setElementAsLabel(passageElement, passageCss.word(), new InlineLabel());
                 break;
             case LINE_BREAK:
                 final Label lineBreak = new Label();
-                lineBreak.addStyleName("passageLineBreak");
+                lineBreak.addStyleName(passageCss.lineBreak());
                 setElement(lineBreak.getElement());
                 break;
             case QUOTE:
                 // if quote has children, then render those instead
                 if (passageElement.getNumChildren() != 0) {
-                    addChildren(passageElement, "passageQuotePanel");
+                    addChildren(passageElement, passageCss.quotePanel(), options);
                 } else {
                     final String markerAttribute = passageElement.getAttribute(OsisElementType.MARKER);
                     if (markerAttribute != null) {
-                        setElementAsLabel(null, "passageQuote", new InlineLabel(markerAttribute));
+                        setElementAsLabel(null, passageCss.quotePanel(), new InlineLabel(markerAttribute));
                     } else {
-                        setElementAsLabel(passageElement, "passageQuote", new InlineLabel());
+                        setElementAsLabel(passageElement, passageCss.quotePanel(), new InlineLabel());
                     }
                 }
                 break;
             case TRANS_CHANGE:
-                setElementAsLabel(passageElement, "passageTransChange", new InlineLabel());
+                setElementAsLabel(passageElement, passageCss.transChange(), new InlineLabel());
                 break;
             default:
                 Log.warn("Unrendered element of type: " + passageElement.getTypeOfElement());
@@ -55,26 +79,61 @@
     }
 
     /**
+     * adds a verse number to the start of the panel
+     * 
+     * @param versePanel
+     *            the container panel in which to add the verse number
+     * @param passageElement
+     *            the passage element containing information about the verse
+     *            number
+     * @param options
+     *            the options, defining whether or not we have a verse number to
+     *            display
+     */
+    private void addVerseNumber(final InsertPanel versePanel, final PassageElement passageElement,
+            final Map<String, ScriptureDisplayOptions> options) {
+        final String osisIdAttribute = passageElement.getAttribute(OSIS_ID);
+        if (options.containsKey(VERSE_NUMBERS.name())) {
+            // then we show the verse numbers
+            final InlineLabel verseNumber = new InlineLabel(getVerseNumberFromOsisId(osisIdAttribute));
+            verseNumber.addStyleName(RESOURCES.passage().verseNumber());
+            versePanel.add(verseNumber);
+        }
+    }
+
+    /**
      * adds children to a panel
      * 
      * @param passageElement
      *            parent element for which to add all the children
      * @param parentPanelStyleName
      *            style to apply to the flow panel that gets created
+     * @param options
+     *            the list of options to be applied to this scripture display
+     * @return the panel on which elements have been added
      * */
-    private void addChildren(final PassageElement passageElement, final String parentPanelStyleName) {
+    private InsertPanel addChildren(final PassageElement passageElement, final String parentPanelStyleName,
+            final Map<String, ScriptureDisplayOptions> options) {
         // for each child, go and create children for them
         final List<PassageElement> children = passageElement.getChildren();
-        final FlowPanel containerPanel = new FlowPanel();
+        final InlinePanel containerPanel = new InlinePanel();
         setElement(containerPanel.getElement());
 
         if (isNotEmpty(parentPanelStyleName)) {
             containerPanel.addStyleName(parentPanelStyleName);
         }
 
+        boolean verseNumberInserted = false;
         for (final PassageElement child : children) {
-            containerPanel.add(new PassageElementWidget(child));
+            // for verse numbers, we insert after a title
+            if (VERSE.equals(passageElement.getTypeOfElement()) && !verseNumberInserted
+                    && !TITLE.equals(child.getTypeOfElement())) {
+                addVerseNumber(containerPanel, passageElement, options);
+                verseNumberInserted = true;
+            }
+            containerPanel.add(new PassageElementWidget(child, options));
         }
+        return containerPanel;
     }
 
     /**

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/PassageWidget.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/PassageWidget.java	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/PassageWidget.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -2,18 +2,22 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.Panel;
-import com.google.gwt.user.client.ui.Widget;
+import com.tyndalehouse.step.web.client.toolkit.handlers.OptionHandler;
 import com.tyndalehouse.step.web.client.toolkit.scripture.ScriptureDisplayConstants;
 import com.tyndalehouse.step.web.client.toolkit.scripture.VerseLabel;
+import com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptions;
 import com.tyndalehouse.step.web.shared.scripture.Passage;
 import com.tyndalehouse.step.web.shared.scripture.PassageElement;
 
-public class PassageWidget extends Widget {
+public class PassageWidget extends Composite {
     /**
      * a list of VerseLabel (wrappers of bible text) that are currently being
      * displayed and contain lemmas
@@ -30,9 +34,13 @@
     private final Label passageTitle = new Label();
     private final Panel passageHolder = new FlowPanel();
     private final Panel mainPassage = new FlowPanel();
+    private final OptionsButtonWidget optionsButtonWidget = new OptionsButtonWidget();
 
+    private Passage logicalPassage;
+
     public PassageWidget() {
-        super.setElement(passageHolder.getElement());
+        initWidget(passageHolder);
+        passageHolder.add(optionsButtonWidget);
         passageHolder.add(passageTitle);
         passageHolder.add(mainPassage);
 
@@ -50,6 +58,7 @@
      * @param passage
      */
     public void setPassage(final Passage passage) {
+        this.logicalPassage = passage;
         mainPassage.clear();
 
         final List<PassageElementWidget> passageElementWidgets = new ArrayList<PassageElementWidget>();
@@ -57,7 +66,8 @@
         Log.info("" + System.currentTimeMillis());
         final List<PassageElement> passageElements = passage.getRootPassageNode().getChildren();
         for (final PassageElement passageElement : passageElements) {
-            passageElementWidgets.add(new PassageElementWidget(passageElement));
+            passageElementWidgets
+                    .add(new PassageElementWidget(passageElement, optionsButtonWidget.getSelectedOptions()));
         }
 
         Log.info("" + System.currentTimeMillis());
@@ -87,4 +97,39 @@
             }
         }
     }
+
+    /**
+     * adds an option handler to the round button containing various display
+     * options
+     * 
+     * @param handler
+     *            the handler to execute
+     * @return the registration, in case the caller wants to unregister itself
+     */
+    public HandlerRegistration addOptionHandler(final OptionHandler handler) {
+        return optionsButtonWidget.addOptionHandler(handler);
+    }
+
+    /**
+     * returns a map of all selected options
+     * 
+     * @return a map of all selected options
+     */
+    public Map<String, ScriptureDisplayOptions> getSelectedOptions() {
+        return optionsButtonWidget.getSelectedOptions();
+    }
+
+    /**
+     * @return the logicalPassage
+     */
+    public Passage getLogicalPassage() {
+        return logicalPassage;
+    }
+
+    /**
+     * relays the passage where the options may potentially have changed
+     */
+    public void refreshPassage() {
+        setPassage(this.logicalPassage);
+    }
 }

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-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/ScriptureView.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -17,7 +17,6 @@
 import com.tyndalehouse.step.web.client.toolkit.HasSource;
 import com.tyndalehouse.step.web.client.toolkit.handlers.OptionHandler;
 import com.tyndalehouse.step.web.client.toolkit.widgets.BibleVersionsDropDownWidget;
-import com.tyndalehouse.step.web.client.toolkit.widgets.OptionsButtonWidget;
 import com.tyndalehouse.step.web.client.toolkit.widgets.PassageWidget;
 import com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptions;
 import com.tyndalehouse.step.web.shared.scripture.Passage;
@@ -26,7 +25,6 @@
  * This view aims to show Scripture to the user. In order to do this, the user
  * can select a version from a dropdown. The
  * 
- * TODO: remove the eventBus from the view.
  * 
  * @author cjburrell
  * 
@@ -44,7 +42,6 @@
     private final PassageWidget scriptureHolder = new PassageWidget();
     private final BibleVersionsDropDownWidget bibleVersionsDropDown = new BibleVersionsDropDownWidget();
     private final AbsolutePanel scripturePanel = new AbsolutePanel();
-    private final OptionsButtonWidget optionsButtonWidget;
 
     /**
      * The default constructor
@@ -55,8 +52,8 @@
         decorator.add(scriptureHolder);
         scripturePanel.add(bibleVersionsDropDown, 0, 0);
         scripturePanel.add(decorator, 0, SCRIPTURE_HOLDER_TOP);
-        optionsButtonWidget = new OptionsButtonWidget();
-        scripturePanel.add(optionsButtonWidget);
+
+        // scripturePanel.add(optionsButtonWidget);
         // layoutPanel.add(decorator);
         initWidget(scripturePanel);
     }
@@ -149,10 +146,18 @@
     }
 
     public HandlerRegistration addOptionHandler(final OptionHandler handler) {
-        return optionsButtonWidget.addOptionHandler(handler);
+        return scriptureHolder.addOptionHandler(handler);
     }
 
     public Map<String, ScriptureDisplayOptions> getSelectedOptions() {
-        return optionsButtonWidget.getSelectedOptions();
+        return scriptureHolder.getSelectedOptions();
     }
+
+    public Passage getPassage() {
+        return scriptureHolder.getLogicalPassage();
+    }
+
+    public void refreshPassage() {
+        scriptureHolder.refreshPassage();
+    }
 }

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StepView.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StepView.java	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StepView.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -13,7 +13,6 @@
 import com.google.gwt.user.client.ui.Panel;
 import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.Widget;
-import com.tyndalehouse.step.web.client.framework.StepResources;
 import com.tyndalehouse.step.web.client.framework.StepViewInterface;
 import com.tyndalehouse.step.web.client.presenter.StepPresenter;
 
@@ -55,7 +54,6 @@
      * way
      */
     public StepView() {
-        StepResources.RESOURCES.css().ensureInjected();
         addPanelsToLayout();
         setInitialLayout();
         initWidget(stepPanelLayout);

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-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/public/css/step.css	2010-07-15 15:08:26 UTC (rev 153)
@@ -27,20 +27,23 @@
 	margin: 0px; 
 }
 
+/*
 .optionsButton {
 	display: inline;
-	margin-top: 25px;/* 20px + 5: when worked out how to do style properly, have this reference a static value */
+	margin-top: 25px; /* 20px + 5: when worked out how to do style properly, have this reference a static value * /
 	margin-right: 5px;
 	/* padding-top: 25px; 
-	padding-right: 5px; */
+	padding-right: 5px; * /
 	float: right;		
-	/* text-align: right; */
+	/* text-align: right; * /
 }
-
+*/
+/*
 .optionsButton img {
 	display: inline;
 	z-index: 20;	
 }
+*/
 
 
 
@@ -49,18 +52,7 @@
 }
 
 
-.optionsMenuScripture {
-	top: 25px;
-	left: auto;
-	right: 5px;
-	position: absolute; 
-	right: 30px; 
-	top: 45px; 
-	border: solid thin black;
-	z-index: 10;
-}
 
-
 .gwt-Tree {
 	background-color: #BCD56D;
 	border: black solid 1px;
@@ -86,7 +78,7 @@
 	float: left;
 	padding: 0 0.5em 0.5em 0;
 }
-
+/*
 .passageTitle {
 	font-family: Tahoma;
 	font-size: 14px;
@@ -98,6 +90,10 @@
 	font-size: 12px;			
 }
 
+.passageVersePanel {
+	display: inline;	
+}
+
 .passageQuotePanel {
 	display: inline;	
 	color: red;
@@ -117,7 +113,7 @@
 .passageLineBreak {
 	
 }
-
+*/
 /****************************************************************************
 * Scripture display component
 *****************************************************************************/

Added: trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/layout.css
===================================================================
--- trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/layout.css	                        (rev 0)
+++ trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/layout.css	2010-07-15 15:08:26 UTC (rev 153)
@@ -0,0 +1,7 @@
+.inlinePanel {
+	display: inline;
+}
+
+.floatRight {
+	float: right;
+}

Added: trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/passage.css
===================================================================
--- trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/passage.css	                        (rev 0)
+++ trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/passage.css	2010-07-15 15:08:26 UTC (rev 153)
@@ -0,0 +1,33 @@
+.versePanel * {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 12px;			
+}
+
+.verseNumber {
+	vertical-align: super;
+	font-size: 9px;
+	font-weight: bold;
+	padding-left: 4px;	
+	padding-right: 2px;
+}
+
+.title {
+	padding-top: 5px;
+	font-weight: bold;	
+}
+
+.word {
+}
+
+.quotePanel {
+	color: red;
+}
+	
+
+.transChange {
+	font-style: italic;		
+}
+
+.lineBreak {
+	
+}
\ No newline at end of file

Deleted: trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/step.css
===================================================================
--- trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/step.css	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/step.css	2010-07-15 15:08:26 UTC (rev 153)
@@ -1,7 +0,0 @@
-.visible {
-	display: block;
-}
-
-.invisible {
-	display: none;
-}

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-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandler.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -1,5 +1,7 @@
 package com.tyndalehouse.step.web.server.handler;
 
+import static com.tyndalehouse.step.web.server.handler.util.passage.OsisParserFilter.getDefaultAttributeFilter;
+import static com.tyndalehouse.step.web.server.handler.util.passage.OsisParserFilter.getDefaultElementFilter;
 import static com.tyndalehouse.step.web.shared.scripture.PassageLanguage.resolveFromCode;
 import static org.apache.commons.lang.StringUtils.isEmpty;
 import static org.apache.commons.lang.StringUtils.split;
@@ -23,7 +25,6 @@
 import com.google.inject.Inject;
 import com.tyndalehouse.step.web.server.common.AbstractStepHandler;
 import com.tyndalehouse.step.web.server.common.JSwordConstants;
-import com.tyndalehouse.step.web.server.handler.util.passage.OsisParserFilter;
 import com.tyndalehouse.step.web.server.handler.util.passage.StrongMorphMap;
 import com.tyndalehouse.step.web.server.service.JSwordService;
 import com.tyndalehouse.step.web.shared.command.GetCurrentBibleTextCommand;
@@ -50,6 +51,8 @@
     private String version;
     private String reference;
 
+    // FIXME: the above only get set once...
+
     @Inject
     public GetCurrentBibleTextHandler(final JSwordService jsword) {
         this.jsword = jsword;
@@ -91,6 +94,8 @@
                 break;
         }
 
+        result.getPassage().setElementFilter(elementFilter);
+        result.getPassage().setAttributeFilter(attributeFilter);
         return result;
     }
 
@@ -99,11 +104,11 @@
      */
     void initFilters() {
         if (elementFilter == null) {
-            elementFilter = OsisParserFilter.DEFAULT_ELEMENT_FILTER;
+            elementFilter = getDefaultElementFilter();
         }
 
         if (attributeFilter == null) {
-            attributeFilter = OsisParserFilter.DEFAULT_ATTRIBUTE_FILTER;
+            attributeFilter = getDefaultAttributeFilter();
         }
     }
 

Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/OsisParserFilter.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/OsisParserFilter.java	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/OsisParserFilter.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -20,11 +20,27 @@
  * 
  */
 public class OsisParserFilter {
-    public static Set<OsisElementType> DEFAULT_ELEMENT_FILTER = initDefaultElementFilter();
-    public static Set<OsisElementType> DEFAULT_ATTRIBUTE_FILTER = initDefaultAttributeFilter();
+    private static HashSet<OsisElementType> DEFAULT_ELEMENT_FILTER = initDefaultElementFilter();
+    private static HashSet<OsisElementType> DEFAULT_ATTRIBUTE_FILTER = initDefaultAttributeFilter();
 
-    private static Set<OsisElementType> initDefaultElementFilter() {
-        final Set<OsisElementType> defaultFilter = new HashSet<OsisElementType>();
+    /**
+     * @return a copy of the DEFAULT_ELEMENT_FILTER
+     */
+    @SuppressWarnings("unchecked")
+    public static Set<OsisElementType> getDefaultElementFilter() {
+        return (HashSet<OsisElementType>) DEFAULT_ELEMENT_FILTER.clone();
+    }
+
+    /**
+     * @return a copy of the DEFAULT_ATTRIBUTE_FILTER
+     */
+    @SuppressWarnings("unchecked")
+    public static Set<OsisElementType> getDefaultAttributeFilter() {
+        return (HashSet<OsisElementType>) DEFAULT_ATTRIBUTE_FILTER.clone();
+    }
+
+    private static HashSet<OsisElementType> initDefaultElementFilter() {
+        final HashSet<OsisElementType> defaultFilter = new HashSet<OsisElementType>();
         defaultFilter.add(TITLE);
         defaultFilter.add(VERSE);
         defaultFilter.add(WORD);
@@ -34,8 +50,8 @@
         return defaultFilter;
     }
 
-    private static Set<OsisElementType> initDefaultAttributeFilter() {
-        final Set<OsisElementType> defaultFilter = new HashSet<OsisElementType>();
+    private static HashSet<OsisElementType> initDefaultAttributeFilter() {
+        final HashSet<OsisElementType> defaultFilter = new HashSet<OsisElementType>();
         defaultFilter.add(OsisElementType.OSIS_ID);
         defaultFilter.add(OsisElementType.MARKER);
         return defaultFilter;

Modified: trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/common/ScriptureDisplayOptions.java
===================================================================
--- trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/common/ScriptureDisplayOptions.java	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/common/ScriptureDisplayOptions.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -24,7 +24,7 @@
      */
     REVERSE_INTERLINEAR("Interlinear - Reverse", INTERLINEAR),
     /** displays verse numbers */
-    VERSE_NUMBERS("Verse numbers"),
+    VERSE_NUMBERS("Verse numbers", true),
     /** displays notes */
     NOTES("Notes"),
     /** displays cross references */
@@ -53,6 +53,10 @@
         this(displayValue, null);
     }
 
+    ScriptureDisplayOptions(final String displayValue, final boolean defaultOption) {
+        this(displayValue, null, defaultOption);
+    }
+
     private ScriptureDisplayOptions(final String displayValue, final ScriptureDisplayOptionGroups group) {
         this(displayValue, group, false);
     }
@@ -106,7 +110,6 @@
     }
 
     public static ScriptureDisplayOptions getByKeyName(final String key) {
-        // TODO Auto-generated method stub
-        return null;
+        return cachedKeyedOptions.get(key);
     }
 }

Modified: trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/result/GetCurrentBibleTextResult.java
===================================================================
--- trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/result/GetCurrentBibleTextResult.java	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/result/GetCurrentBibleTextResult.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -11,28 +11,10 @@
  * 
  */
 public class GetCurrentBibleTextResult implements Result {
-
-    /**
-	 * 
-	 */
     private static final long serialVersionUID = -5781394877510591218L;
-
-    /**
-     * the passage in logical form
-     */
     private Passage passage;
 
     /**
-     * the passage text
-     */
-    private String passageText;
-
-    /**
-     * The xslted text
-     */
-    private String xsltedText;
-
-    /**
      * returns the logical form passage
      * 
      * @return the logical form of the passage
@@ -42,22 +24,6 @@
     }
 
     /**
-     * returns the passage text
-     * 
-     * @return the passage text
-     */
-    public String getPassageText() {
-        return passageText;
-    }
-
-    /**
-     * @return the xsltedText
-     */
-    public String getXsltedText() {
-        return xsltedText;
-    }
-
-    /**
      * sets the logical form of the passage
      * 
      * @param p
@@ -66,21 +32,4 @@
     public void setPassage(final Passage p) {
         this.passage = p;
     }
-
-    /**
-     * @param passageText
-     *            the passageText to set
-     */
-    public void setPassageText(final String passageText) {
-        this.passageText = passageText;
-    }
-
-    /**
-     * @param xsltedText
-     *            the xsltedText to set
-     */
-    public void setXsltedText(final String xsltedText) {
-        this.xsltedText = xsltedText;
-    }
-
 }

Modified: trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/scripture/Passage.java
===================================================================
--- trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/scripture/Passage.java	2010-07-14 17:13:59 UTC (rev 152)
+++ trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/scripture/Passage.java	2010-07-15 15:08:26 UTC (rev 153)
@@ -1,11 +1,14 @@
 package com.tyndalehouse.step.web.shared.scripture;
 
 import java.io.Serializable;
+import java.util.Set;
 
 public class Passage implements Serializable {
     private static final long serialVersionUID = -8107771273622629610L;
     private PassageElement rootPassageNode = null;
     private PassageLanguage language = null;
+    private Set<OsisElementType> elementFilter;
+    private Set<OsisElementType> attributeFilter;
 
     /**
      * @return the language
@@ -36,4 +39,38 @@
     public void setRootPassageNode(final PassageElement rootPassageNode) {
         this.rootPassageNode = rootPassageNode;
     }
+
+    /**
+     * sets the filter for elements that was used
+     * 
+     * @param elementFilter
+     *            the element filter used in this result
+     */
+    public void setElementFilter(final Set<OsisElementType> elementFilter) {
+        this.elementFilter = elementFilter;
+    }
+
+    /**
+     * the attribute filter that was used
+     * 
+     * @param attributeFilter
+     *            attribute filter
+     */
+    public void setAttributeFilter(final Set<OsisElementType> attributeFilter) {
+        this.attributeFilter = attributeFilter;
+    }
+
+    /**
+     * @return the elementFilter
+     */
+    public Set<OsisElementType> getElementFilter() {
+        return elementFilter;
+    }
+
+    /**
+     * @return the attributeFilter
+     */
+    public Set<OsisElementType> getAttributeFilter() {
+        return attributeFilter;
+    }
 }




More information about the Tynstep-svn mailing list