[Tynstep-svn] r154 - in trunk: 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-app/src/main/resources/com/tyndalehouse/step/web/client/view step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler step-web-server/src/main/java/com/tyndalehouse/step/web/server/service step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl step-web-server/src/test/java/com/tyndalehouse/step/web/server/service/impl step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/result

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Sat Jul 17 02:16:19 MST 2010


Author: ChrisBurrell
Date: 2010-07-17 02:16:19 -0700 (Sat, 17 Jul 2010)
New Revision: 154

Added:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/ScripturePresenterPosition.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/handlers/BookmarkHandlers.java
Removed:
   trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/view/BookmarkView.ui.xml
Modified:
   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/StepEventBus.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/BookmarkPresenter.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/presenter/ScriptureSelectorPresenter.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/StepPresenter.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/view/BookmarkView.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-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
   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/service/JSwordService.java
   trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImpl.java
   trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImplTest.java
   trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/result/GetCurrentBibleTextResult.java
Log:
adding bookmarks

Modified: 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	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/Layout.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -6,4 +6,6 @@
     String inlinePanel();
 
     String floatRight();
+
+    String floatLeft();
 }

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/ScripturePresenterPosition.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/ScripturePresenterPosition.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/ScripturePresenterPosition.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -0,0 +1,16 @@
+package com.tyndalehouse.step.web.client.framework;
+
+/**
+ * Indicates the position of the presenter
+ * 
+ * @author CJBurrell
+ * 
+ */
+public enum ScripturePresenterPosition {
+    /** the targeted presenter is the left presenter */
+    LEFT,
+    /** the targeted presenter is the right presenter */
+    RIGHT,
+    /** both presenters, left and right are targeted */
+    BOTH,
+}

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/StepEventBus.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/StepEventBus.java	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/StepEventBus.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -70,10 +70,24 @@
      * @param newReference
      *            a new reference
      */
-    @Event(handlers = ScripturePresenter.class)
-    void scriptureChanged(String newReference);
+    @Event(handlers = { ScripturePresenter.class })
+    void scriptureChanged(String newReference, ScripturePresenterPosition position);
 
     /**
+     * alerts the UI that a scripture has been retrieved successfully from the
+     * server
+     * 
+     * @param reference
+     *            of the passage
+     * 
+     */
+    // IMPROVEMENT we can have this show the user-entered reference if we want
+    // IMPROVEMENT we can also store the options that were requested and have
+    // those stored as well
+    @Event(handlers = { BookmarkPresenter.class })
+    void scriptureChangedSuccessfully(String referenceShortName);
+
+    /**
      * a change of version has occured
      * 
      * @param newVersion

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/BookmarkPresenter.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/BookmarkPresenter.java	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/BookmarkPresenter.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -1,27 +1,119 @@
 package com.tyndalehouse.step.web.client.presenter;
 
-import net.customware.gwt.dispatch.client.DispatchAsync;
+import static com.tyndalehouse.step.web.client.framework.ScripturePresenterPosition.BOTH;
+import static com.tyndalehouse.step.web.client.framework.ScripturePresenterPosition.LEFT;
+import static com.tyndalehouse.step.web.client.framework.ScripturePresenterPosition.RIGHT;
 
-import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.HasClickHandlers;
 import com.mvp4g.client.annotation.Presenter;
 import com.mvp4g.client.presenter.BasePresenter;
+import com.tyndalehouse.step.web.client.framework.ScripturePresenterPosition;
 import com.tyndalehouse.step.web.client.framework.StepEventBus;
 import com.tyndalehouse.step.web.client.framework.StepViewInterface;
+import com.tyndalehouse.step.web.client.toolkit.handlers.BookmarkHandlers;
 import com.tyndalehouse.step.web.client.view.BookmarkView;
 
 @Presenter(view = BookmarkView.class)
 public class BookmarkPresenter extends BasePresenter<BookmarkPresenter.Display, StepEventBus> {
-    private final DispatchAsync dispatcher;
+    /** IMPROVEMENT make bookmark capacity a user setting */
+    private static final int BOOKMARK_CAPACITY = 20;
+    /**
+     * a list of bookmarks that are current displayed on the screen IMPROVEMENT
+     * store in server side session or as a cookie
+     * */
+    private final List<String> currentBookmarks = new ArrayList<String>();
 
     /** contact with the sidebar view */
     public interface Display extends StepViewInterface {
+
+        /**
+         * adds a bookmark to the view display
+         * 
+         * @param shortNameReference
+         *            short name reference for e.g. Matt 1:1
+         * @param referenceShortName
+         *            the
+         * @param displayOptions
+         */
+        BookmarkHandlers addBookmark(String shortNameReference);
+
+        /**
+         * removes the bookmark stored at index
+         * 
+         * @param index
+         *            index of the bookmark to be removed
+         */
+        void removeBookmark(int index);
     }
 
-    @Inject
-    BookmarkPresenter(final DispatchAsync dispatcher) {
-        this.dispatcher = dispatcher;
+    /**
+     * scripture changed successfully, so add it to the bookmarks
+     * 
+     * @param shortNameReference
+     *            the short name reference ot be displayed on the reference
+     * 
+     *            TODO: write presenter test for this! FIXME: issue since view
+     *            inserts at index 0 all the time, so inverted
+     */
+    public void onScriptureChangedSuccessfully(final String shortNameReference) {
+        // if bookmark already in there, then we move it
+        for (int ii = 0; ii < currentBookmarks.size(); ii++) {
+            if (currentBookmarks.get(ii).equals(shortNameReference)) {
+                // we relocate the bookmark
+                safelyRemoveBookmark(ii);
+                safelyAddBookmark(shortNameReference);
+                return;
+            }
+        }
+
+        if (this.currentBookmarks.size() >= BOOKMARK_CAPACITY) {
+            safelyRemoveBookmark(this.currentBookmarks.size() - 1);
+        }
+
+        safelyAddBookmark(shortNameReference);
     }
 
+    private void safelyAddBookmark(final String shortNameReference) {
+        final BookmarkHandlers bookmarkHandlers = view.addBookmark(shortNameReference);
+        currentBookmarks.add(0, shortNameReference);
+        addHandler(bookmarkHandlers.getLeftHandler(), shortNameReference, LEFT);
+        addHandler(bookmarkHandlers.getBothHandler(), shortNameReference, BOTH);
+        addHandler(bookmarkHandlers.getRightHandler(), shortNameReference, RIGHT);
+
+    }
+
+    /**
+     * adds a handler to change the scripture on a click of the bookmark
+     * 
+     * @param handler
+     *            the handler
+     * @param shortNameReference
+     *            the reference to be loaded up
+     * @param position
+     *            the presenter position that is targeted
+     */
+    // IMPROVEMENT: the event could contain the passage, and therefore, we
+    // could make these non-anonymous inner classes
+    private void addHandler(final HasClickHandlers handler, final String shortNameReference,
+            final ScripturePresenterPosition position) {
+        handler.addClickHandler(new ClickHandler() {
+
+            public void onClick(final ClickEvent arg0) {
+                eventBus.scriptureChanged(shortNameReference, position);
+            }
+        });
+    }
+
+    private void safelyRemoveBookmark(final int ii) {
+        view.removeBookmark(ii);
+        currentBookmarks.remove(ii);
+    }
+
     public void onStart() {
         eventBus.setCenterPanel(view);
     }

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-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/ScripturePresenter.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -1,6 +1,7 @@
 package com.tyndalehouse.step.web.client.presenter;
 
 import static com.tyndalehouse.step.web.client.common.StringUtils.isNotEmpty;
+import static com.tyndalehouse.step.web.client.framework.ScripturePresenterPosition.BOTH;
 import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.OSIS_ID;
 import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.VERSE;
 
@@ -22,6 +23,7 @@
 import com.google.inject.Inject;
 import com.mvp4g.client.annotation.Presenter;
 import com.mvp4g.client.presenter.BasePresenter;
+import com.tyndalehouse.step.web.client.framework.ScripturePresenterPosition;
 import com.tyndalehouse.step.web.client.framework.StepEventBus;
 import com.tyndalehouse.step.web.client.framework.StepViewInterface;
 import com.tyndalehouse.step.web.client.toolkit.HasSource;
@@ -108,6 +110,7 @@
      * default asynchronous dispatcher
      */
     private final DispatchAsync dispatcher;
+    private ScripturePresenterPosition position;
 
     /**
      * 
@@ -215,12 +218,32 @@
     /**
      * updates the state of the view with the new scripture change, and
      * refreshes the view
+     * 
+     * @param newReference
+     *            the reference to be displayed
      */
     public void onScriptureChanged(final String newReference) {
         view.setCurrentPassage(newReference);
         refreshViewFromServer();
     }
 
+    /**
+     * updates the state of the view only if the position matches the position
+     * of the presenter
+     * 
+     * @param newReference
+     *            the reference of the passage to be displayed
+     * @param position
+     *            the position of the targeted presenter
+     */
+    public void onScriptureChanged(final String newReference, final ScripturePresenterPosition position) {
+        // TODO at the moment, this leaves the box top-right out of sync with
+        // everything else...
+        if (position == this.position || position == BOTH) {
+            onScriptureChanged(newReference);
+        }
+    }
+
     public void onVersionChanged(final String newVersionInitials) {
         refreshViewFromServer();
     }
@@ -243,6 +266,7 @@
 
                 public void onSuccess(final GetCurrentBibleTextResult result) {
                     view.setPassage(result.getPassage());
+                    eventBus.scriptureChangedSuccessfully(result.getReadableKey());
                 }
             });
         }
@@ -251,4 +275,8 @@
     public void onLemmaClicked(final List<String> lemmas) {
         view.highlight(lemmas);
     }
+
+    public void setScripturePresenterPosition(final ScripturePresenterPosition position) {
+        this.position = position;
+    }
 }

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/ScriptureSelectorPresenter.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/ScriptureSelectorPresenter.java	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/ScriptureSelectorPresenter.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -1,5 +1,6 @@
 package com.tyndalehouse.step.web.client.presenter;
 
+import static com.tyndalehouse.step.web.client.framework.ScripturePresenterPosition.BOTH;
 import net.customware.gwt.dispatch.client.DispatchAsync;
 
 import com.google.gwt.event.dom.client.ClickEvent;
@@ -42,7 +43,7 @@
 
         view.getSelectReferenceButton().addClickHandler(new ClickHandler() {
             public void onClick(final ClickEvent event) {
-                eventBus.scriptureChanged(view.getScriptureReference().getText());
+                eventBus.scriptureChanged(view.getScriptureReference().getText(), BOTH);
             }
         });
     }

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/StepPresenter.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/StepPresenter.java	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/StepPresenter.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -1,5 +1,8 @@
 package com.tyndalehouse.step.web.client.presenter;
 
+import static com.tyndalehouse.step.web.client.framework.ScripturePresenterPosition.LEFT;
+import static com.tyndalehouse.step.web.client.framework.ScripturePresenterPosition.RIGHT;
+
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.DeferredCommand;
 import com.mvp4g.client.annotation.Presenter;
@@ -47,9 +50,14 @@
     }
 
     public void onStart() {
-        view.setLeftColumn(eventBus.addHandler(ScripturePresenter.class).getView());
-        view.setRightColumn(eventBus.addHandler(ScripturePresenter.class).getView());
+        final ScripturePresenter leftHandler = eventBus.addHandler(ScripturePresenter.class);
+        leftHandler.setScripturePresenterPosition(LEFT);
 
+        final ScripturePresenter rightHandler = eventBus.addHandler(ScripturePresenter.class);
+        rightHandler.setScripturePresenterPosition(RIGHT);
+        view.setLeftColumn(leftHandler.getView());
+        view.setRightColumn(rightHandler.getView());
+
         view.setTopLeftPanel(eventBus.addHandler(ScriptureSelectorPresenter.class).getView());
         final ScriptureSelectorPresenter.Display rightScriptureSelector = eventBus.addHandler(
                 ScriptureSelectorPresenter.class).getView();
@@ -100,44 +108,7 @@
         super.view.setFilterPanelVisible(!SideBarModule.NONE.equals(newModule));
     }
 
-    /**
-     * the default dispatcher for async server requests
-     */
-    // private final DispatchAsync dispatcher;
-
-    //	
     // /**
-    // * Constructor to set up the timeline module
-    // *
-    // * @param display the view, passed in by Gin
-    // * @param eventBus the event bus, passed in by Gin
-    // * @param dispatcher the dispatcher, passed in by Gin
-    // */
-    // @Inject
-    // public StepPresenter(final Display display, final EventBus eventBus,
-    // final DispatchAsync dispatcher) {
-    // super(display, eventBus);
-    // this.dispatcher = dispatcher;
-    //
-    // Log.debug("StepPresenter initialised");
-    // bind();
-    // }
-    //
-    // @Override
-    // public Place getPlace() {
-    // // TODO Auto-generated method stub
-    // return null;
-    // }
-    //
-    // public void refreshDisplay() {
-    // // TODO Auto-generated method stub
-    // }
-    //
-    // public void revealDisplay() {
-    // // TODO Auto-generated method stub
-    // }
-
-    // /**
     // * adds event handlers when they need to be parsed only once, but multiple
     // * presenters may be interested this is a proxy. Typically an event should
     // * then be fired if necessary to the presenters

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/handlers/BookmarkHandlers.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/handlers/BookmarkHandlers.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/handlers/BookmarkHandlers.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -0,0 +1,44 @@
+package com.tyndalehouse.step.web.client.toolkit.handlers;
+
+import com.google.gwt.event.dom.client.HasClickHandlers;
+
+/**
+ * A simple holder object that holds the three handlers created by a view when a
+ * bookmark is created.
+ * 
+ * @author CJBurrell
+ * 
+ */
+public class BookmarkHandlers {
+    private final HasClickHandlers leftHandler;
+    private final HasClickHandlers bothHandler;
+    private final HasClickHandlers rightHandler;
+
+    public BookmarkHandlers(final HasClickHandlers leftHandler, final HasClickHandlers bothHandler,
+            final HasClickHandlers rightHandler) {
+        this.leftHandler = leftHandler;
+        this.bothHandler = bothHandler;
+        this.rightHandler = rightHandler;
+    }
+
+    /**
+     * @return the leftHandler which should send the passage to the left
+     */
+    public HasClickHandlers getLeftHandler() {
+        return leftHandler;
+    }
+
+    /**
+     * @return the bothHandler which should update both passages
+     */
+    public HasClickHandlers getBothHandler() {
+        return bothHandler;
+    }
+
+    /**
+     * @return the rightHandler which should update the passage on the right
+     */
+    public HasClickHandlers getRightHandler() {
+        return rightHandler;
+    }
+}

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-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/widgets/PassageElementWidget.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -32,6 +32,10 @@
  * @author CJBurrell
  * 
  */
+// IMPROVEMENT in true likeness of MVP, the model should not be passed to the
+// view, and therefore we should remove
+// the models from here. The presenter instead should be doing the logic, and
+// asking different types of elements to be created
 public class PassageElementWidget extends Widget {
     static {
         RESOURCES.passage().ensureInjected();

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/BookmarkView.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/BookmarkView.java	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/BookmarkView.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -1,23 +1,74 @@
 package com.tyndalehouse.step.web.client.view;
 
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.uibinder.client.UiBinder;
+import static com.tyndalehouse.step.web.client.framework.StepResources.RESOURCES;
+
+import com.google.gwt.event.dom.client.HasClickHandlers;
+import com.google.gwt.user.client.ui.Anchor;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.tyndalehouse.step.web.client.presenter.BookmarkPresenter;
 import com.tyndalehouse.step.web.client.toolkit.DecoratedComposite;
+import com.tyndalehouse.step.web.client.toolkit.handlers.BookmarkHandlers;
 
 public class BookmarkView extends DecoratedComposite implements BookmarkPresenter.Display {
-
-    interface MyUiBinder extends UiBinder<Widget, BookmarkView> {
+    static {
+        RESOURCES.passage().ensureInjected();
     }
 
-    private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
+    private final FlowPanel containerPanel = new FlowPanel();
+    private final VerticalPanel bookmarkPanel = new VerticalPanel();
 
     public BookmarkView() {
-        initWidget(BookmarkView.uiBinder.createAndBindUi(this));
+        // we add an empty label, to ensure that table is rendered properly
+        // IMPROVEMENT raise bug with GWT to showcase this!
+        final Label placeholder = new Label(" ");
+        containerPanel.add(placeholder);
+        containerPanel.add(bookmarkPanel);
+        bookmarkPanel.setWidth("100%");
+        initWidget(containerPanel);
     }
 
     public Widget getContainerWidget() {
         return this;
     }
+
+    public BookmarkHandlers addBookmark(final String shortNameReference) {
+        final FlowPanel bookmark = new FlowPanel();
+        bookmark.addStyleName("bookmark");
+
+        final HasClickHandlers leftHandler = addHyperlink(shortNameReference, bookmark, RESOURCES.layout().floatLeft(),
+                "&larr;");
+        final HasClickHandlers bothHandler = addHyperlink(shortNameReference, bookmark, null, shortNameReference);
+        final HasClickHandlers rightHandler = addHyperlink(shortNameReference, bookmark, RESOURCES.layout()
+                .floatRight(), "&rarr;");
+
+        bookmarkPanel.insert(bookmark, 0);
+        final BookmarkHandlers handlers = new BookmarkHandlers(leftHandler, bothHandler, rightHandler);
+        return handlers;
+
+    }
+
+    // IMPROVEMENT do we have a click handler leak? by still having them
+    // referenced in the preenter
+    public void removeBookmark(final int index) {
+        this.bookmarkPanel.remove(index);
+    }
+
+    /**
+     * is the current bookmarks has reached capacity, then we remove the element
+     * that is first in line to be removed.
+     */
+    private HasClickHandlers addHyperlink(final String shortNameReference, final FlowPanel fp,
+            final String layoutStyle, final String suffix) {
+        final Anchor link = new Anchor(suffix, true);
+        if (layoutStyle != null) {
+            link.addStyleName(layoutStyle);
+        }
+        link.addStyleName("bookmarkLink");
+        fp.add(link);
+        return link;
+    }
+
 }

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-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StepView.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -47,7 +47,7 @@
     final private static int COLUMN_BOTTOM = 10;
     final private static int CENTER_PANEL_TOP = COLUMN_TOP + 50;
     final private static int CENTER_PANEL_BOTTOM = COLUMN_BOTTOM + 50;
-    final private static int CENTER_PANEL_WIDTH = 80;
+    final private static int CENTER_PANEL_WIDTH = 120;
 
     /**
      * Main STEP entry view, sets up the layout in a pluggable and replaceable

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-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/public/css/step.css	2010-07-17 09:16:19 UTC (rev 154)
@@ -1,3 +1,16 @@
+div.bookmark {
+	text-align: center;
+}
+
+a.bookmarkLink {
+	text-decoration: none;
+	font-weight: bold;
+}
+
+a:hover.bookmarkLink {
+	color: blue;	
+}
+
 .visible {
 	display: block;
 }

Modified: 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	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/layout.css	2010-07-17 09:16:19 UTC (rev 154)
@@ -5,3 +5,7 @@
 .floatRight {
 	float: right;
 }
+
+.floatLeft {
+	float: left;
+}
\ No newline at end of file

Modified: 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	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/css/passage.css	2010-07-17 09:16:19 UTC (rev 154)
@@ -19,7 +19,7 @@
 .word {
 }
 
-.quotePanel {
+.quotePanel * {
 	color: red;
 }
 	

Deleted: trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/view/BookmarkView.ui.xml
===================================================================
--- trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/view/BookmarkView.ui.xml	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/client/view/BookmarkView.ui.xml	2010-07-17 09:16:19 UTC (rev 154)
@@ -1,17 +0,0 @@
-<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui'>
-
-		<g:SimplePanel>
-			<g:HTML>
-				Mark 1:1
-				<br />
-				Matthew 1:1
-				<br />
-				Genesis 1:1
-				<br />
-				Exodus 1:1
-				<br />
-				Deutoronomy 2:1
-				<br />
-			</g:HTML>
-		</g:SimplePanel>
-</ui:UiBinder>

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-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandler.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -96,9 +96,15 @@
 
         result.getPassage().setElementFilter(elementFilter);
         result.getPassage().setAttributeFilter(attributeFilter);
+        result.setReadableKey(jsword.getReadableKey(version, reference));
         return result;
     }
 
+    private String getKey() {
+
+        return null;
+    }
+
     /**
      * sets up initial filters to ensure some OSIS information gets filtered out
      */

Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/JSwordService.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/JSwordService.java	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/JSwordService.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -22,4 +22,15 @@
      * @return the language code
      */
     String getLanguage(String version);
+
+    /**
+     * retrieves the short form of the key that is a human readable form
+     * 
+     * @param version
+     *            the version to be retrieved from
+     * @param reference
+     *            the reference to be converted
+     * @return a human readable version of the key
+     */
+    String getReadableKey(String version, String reference);
 }

Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImpl.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImpl.java	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImpl.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -1,12 +1,12 @@
 package com.tyndalehouse.step.web.server.service.impl;
 
-import org.apache.log4j.Logger;
 import org.crosswire.common.util.Language;
 import org.crosswire.jsword.book.Book;
 import org.crosswire.jsword.book.BookData;
 import org.crosswire.jsword.book.BookException;
 import org.crosswire.jsword.book.Books;
 import org.crosswire.jsword.passage.NoSuchKeyException;
+import org.crosswire.jsword.versification.BibleInfo;
 import org.jdom.Element;
 
 import com.tyndalehouse.step.web.server.service.JSwordService;
@@ -21,8 +21,6 @@
 // TODO go through implementing correct exception handling with runtime
 // exceptions being caught
 public class JSwordServiceImpl implements JSwordService {
-    private final Logger logger = Logger.getLogger(getClass());
-
     /*
      * (non-Javadoc)
      * 
@@ -44,12 +42,6 @@
         }
     }
 
-    /**
-     * returns the language for a particular version
-     * 
-     * @param version
-     * @return
-     */
     public String getLanguage(final String version) {
         final Book currentBook = Books.installed().getBook(version);
         if (currentBook == null) {
@@ -62,4 +54,17 @@
         }
         return null;
     }
+
+    /**
+     * IMPROVEMENT NOTE that this is not thread safe, since JSword relies on
+     * statics in the background
+     */
+    public String getReadableKey(final String version, final String reference) {
+        try {
+            BibleInfo.setFullBookName(false);
+            return Books.installed().getBook(version).getKey(reference).getName();
+        } catch (final NoSuchKeyException e) {
+            throw new InternalException("Unable to get readable key from OSIS reference", e);
+        }
+    }
 }

Modified: trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImplTest.java
===================================================================
--- trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImplTest.java	2010-07-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImplTest.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -4,6 +4,7 @@
 import static com.tyndalehouse.step.web.shared.scripture.PassageLanguage.HEBREW;
 import static com.tyndalehouse.step.web.shared.scripture.PassageLanguage.OTHER;
 import static com.tyndalehouse.step.web.shared.scripture.PassageLanguage.resolveFromCode;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import org.jdom.Element;
@@ -37,4 +38,14 @@
             assertTrue(language[ii].equals(resolveFromCode(code)));
         }
     }
+
+    /**
+     * tests that short keys are being returned
+     */
+    @Test
+    public void testGetReadableKey() {
+        final JSwordService service = new JSwordServiceImpl();
+        final String key = service.getReadableKey("ESV", "Mat.1.1");
+        assertEquals("Mat 1:1", 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-15 15:08:26 UTC (rev 153)
+++ trunk/step-web-shared/src/main/java/com/tyndalehouse/step/web/shared/result/GetCurrentBibleTextResult.java	2010-07-17 09:16:19 UTC (rev 154)
@@ -13,6 +13,7 @@
 public class GetCurrentBibleTextResult implements Result {
     private static final long serialVersionUID = -5781394877510591218L;
     private Passage passage;
+    private String readableKey;
 
     /**
      * returns the logical form passage
@@ -32,4 +33,23 @@
     public void setPassage(final Passage p) {
         this.passage = p;
     }
+
+    /**
+     * the readable key that the UI might want to display
+     * 
+     * @param readableKey
+     *            a key in readable form
+     */
+    public void setReadableKey(final String readableKey) {
+        this.readableKey = readableKey;
+
+    }
+
+    /**
+     * @return the readableKey
+     */
+    public String getReadableKey() {
+        return readableKey;
+    }
+
 }




More information about the Tynstep-svn mailing list