[Tynstep-svn] r168 - 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/presenter/display step-web-app/src/main/java/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/handler/util/passage

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Sat Jul 31 12:42:47 MST 2010


Author: ChrisBurrell
Date: 2010-07-31 12:42:47 -0700 (Sat, 31 Jul 2010)
New Revision: 168

Added:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/StrongDefinitionPresenter.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/display/StrongDefinitionDisplay.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StrongDefinitionView.java
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/presenter/PassagePresenter.java
   trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandler.java
   trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/OsisParserFilter.java
Log:
popup for strong numbers

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-31 10:15:08 UTC (rev 167)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/framework/StepEventBus.java	2010-07-31 19:42:47 UTC (rev 168)
@@ -13,6 +13,7 @@
 import com.tyndalehouse.step.web.client.presenter.PassagePresenter;
 import com.tyndalehouse.step.web.client.presenter.ScripturePresenter;
 import com.tyndalehouse.step.web.client.presenter.StepPresenter;
+import com.tyndalehouse.step.web.client.presenter.StrongDefinitionPresenter;
 import com.tyndalehouse.step.web.client.toolkit.data.SideBarModule;
 import com.tyndalehouse.step.web.client.toolkit.timeline.helpers.CurrentBandStats;
 import com.tyndalehouse.step.web.client.view.StepView;
@@ -80,8 +81,8 @@
      * @param lemmas
      *            the list of lemmas
      */
-    @Event(handlers = PassagePresenter.class)
-    void highlightWords(String[] lemmas);
+    @Event(handlers = { PassagePresenter.class, StrongDefinitionPresenter.class })
+    void selectedLemmas(String[] lemmas);
 
     /**
      * alerts the UI that a scripture has been retrieved successfully from the

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/PassagePresenter.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/PassagePresenter.java	2010-07-31 10:15:08 UTC (rev 167)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/PassagePresenter.java	2010-07-31 19:42:47 UTC (rev 168)
@@ -186,23 +186,23 @@
             case TEXT:
                 final HasClickAndHighlightHandlers wordHandler = view.createText(getText(passageElement));
 
-                if (selectedOptions.containsKey(ScriptureDisplayOptions.SHOW_LEMMAS.name())) {
-                    final String lemmaAttribute = passageElement.getAttribute(OsisElementType.LEMMA);
-                    if (lemmaAttribute != null) {
-                        // IMPROVEMENT: this could happen server side, and save
-                        // ops in the browser
-                        final String[] lemmas = lemmaAttribute.split(" ");
-                        for (int ii = 0; ii < lemmas.length; ii++) {
+                final String lemmaAttribute = passageElement.getAttribute(OsisElementType.LEMMA);
+                if (lemmaAttribute != null) {
+                    // IMPROVEMENT: this could happen server side, and save
+                    // ops in the browser
+                    final String[] lemmas = lemmaAttribute.split(" ");
+                    for (int ii = 0; ii < lemmas.length; ii++) {
+                        if (selectedOptions.containsKey(ScriptureDisplayOptions.SHOW_LEMMAS.name())) {
                             view.createLemmaTag(lemmas[ii].replaceAll("strong:", ""));
-                            addHighlitableWord(lemmas[ii], wordHandler);
                         }
+                        addHighlitableWord(lemmas[ii], wordHandler);
+                    }
 
-                        wordHandler.addClickHandler(new ClickHandler() {
-                            public void onClick(final ClickEvent clickEvent) {
-                                getEventBus().highlightWords(lemmas);
-                            }
-                        });
-                    }
+                    wordHandler.addClickHandler(new ClickHandler() {
+                        public void onClick(final ClickEvent clickEvent) {
+                            getEventBus().selectedLemmas(lemmas);
+                        }
+                    });
                 }
                 break;
             case LINE_BREAK:
@@ -250,7 +250,7 @@
      * @param lemmas
      *            the list of lemmas associated with the clicked word
      */
-    public void onHighlightWords(final String[] lemmas) {
+    public void onSelectedLemmas(final String[] lemmas) {
         final Set<String> lemmaSet = new HashSet<String>();
         for (final String lemma : lemmas) {
             lemmaSet.add(lemma);

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/StrongDefinitionPresenter.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/StrongDefinitionPresenter.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/StrongDefinitionPresenter.java	2010-07-31 19:42:47 UTC (rev 168)
@@ -0,0 +1,47 @@
+package com.tyndalehouse.step.web.client.presenter;
+
+import java.util.Arrays;
+
+import net.customware.gwt.dispatch.client.DispatchAsync;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.inject.Inject;
+import com.mvp4g.client.annotation.Presenter;
+import com.mvp4g.client.presenter.BasePresenter;
+import com.tyndalehouse.step.web.client.framework.StepEventBus;
+import com.tyndalehouse.step.web.client.presenter.display.StrongDefinitionDisplay;
+import com.tyndalehouse.step.web.client.view.StrongDefinitionView;
+import com.tyndalehouse.step.web.shared.command.GetDictionaryDefinitionCommand;
+import com.tyndalehouse.step.web.shared.result.GetDictionaryDefinitionResult;
+
+ at Presenter(view = StrongDefinitionView.class)
+public class StrongDefinitionPresenter extends BasePresenter<StrongDefinitionDisplay, StepEventBus> {
+    private final DispatchAsync dispatcher;
+
+    @Inject
+    StrongDefinitionPresenter(final DispatchAsync dispatcher) {
+        this.dispatcher = dispatcher;
+
+    }
+
+    public void onSelectedLemmas(final String[] lemmas) {
+        final GetDictionaryDefinitionCommand cmd = new GetDictionaryDefinitionCommand();
+        // TODO change method signature to avoid having to create list
+        cmd.setLookupReference(Arrays.asList(lemmas));
+
+        dispatcher.execute(cmd, new AsyncCallback<GetDictionaryDefinitionResult>() {
+            public void onFailure(final Throwable e) {
+                Log.error(e.getMessage());
+            }
+
+            public void onSuccess(final GetDictionaryDefinitionResult lemmaDefinition) {
+                Log.warn(lemmaDefinition.getXsltedDefinition());
+
+                // TODO: check whether definition came back alright!
+                // TODO: change the XSLT to something nicer
+                view.setDefiniton(lemmaDefinition.getXsltedDefinition());
+            }
+        });
+    }
+}

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/display/StrongDefinitionDisplay.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/display/StrongDefinitionDisplay.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/presenter/display/StrongDefinitionDisplay.java	2010-07-31 19:42:47 UTC (rev 168)
@@ -0,0 +1,12 @@
+package com.tyndalehouse.step.web.client.presenter.display;
+
+public interface StrongDefinitionDisplay {
+
+    /**
+     * sets the definition to be displayed
+     * 
+     * @param definition
+     */
+    void setDefiniton(String definition);
+
+}

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StrongDefinitionView.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StrongDefinitionView.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/StrongDefinitionView.java	2010-07-31 19:42:47 UTC (rev 168)
@@ -0,0 +1,25 @@
+package com.tyndalehouse.step.web.client.view;
+
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.PopupPanel;
+import com.tyndalehouse.step.web.client.presenter.display.StrongDefinitionDisplay;
+
+public class StrongDefinitionView extends PopupPanel implements StrongDefinitionDisplay {
+    private final PopupPanel popup = new PopupPanel(true);
+    private final HTML content = new HTML();
+
+    StrongDefinitionView() {
+        popup.setWidget(content);
+    }
+
+    public void setDefiniton(final String definition) {
+        content.setHTML(definition);
+        popup.setPopupPositionAndShow(new PositionCallback() {
+            public void setPosition(final int width, final int height) {
+                popup.setPopupPosition(Window.getClientWidth() - popup.getOffsetWidth(), Window.getClientHeight()
+                        - popup.getOffsetHeight());
+            }
+        });
+    }
+}

Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandler.java	2010-07-31 10:15:08 UTC (rev 167)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandler.java	2010-07-31 19:42:47 UTC (rev 168)
@@ -136,7 +136,7 @@
     private String getLookupKeyFromReference(final String reference) throws ActionException {
         if (reference.toLowerCase().startsWith(JSwordConstants.STRONG_PATTERN_START)) {
             // remove strong:H or strong:G
-            return reference.substring(JSwordConstants.STRONG_PATTERN_START.length() + 1);
+            return reference.substring(JSwordConstants.STRONG_PATTERN_START.length());
         }
         throw new ActionException(String.format("Lookup key not recognised: %s", reference));
     }

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-31 10:15:08 UTC (rev 167)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/OsisParserFilter.java	2010-07-31 19:42:47 UTC (rev 168)
@@ -47,6 +47,7 @@
         defaultFilter.add(QUOTE);
         defaultFilter.add(LINE_BREAK);
         defaultFilter.add(TRANS_CHANGE);
+
         return defaultFilter;
     }
 
@@ -54,6 +55,7 @@
         final HashSet<OsisElementType> defaultFilter = new HashSet<OsisElementType>();
         defaultFilter.add(OsisElementType.OSIS_ID);
         defaultFilter.add(OsisElementType.MARKER);
+        defaultFilter.add(OsisElementType.LEMMA);
         return defaultFilter;
     }
 }




More information about the Tynstep-svn mailing list