[sword-svn] r176 - in trunk/paralleltag: . src/org/crosswire/modedit

scribe at crosswire.org scribe at crosswire.org
Sun Mar 15 16:12:38 MST 2009


Author: scribe
Date: 2009-03-15 16:12:37 -0700 (Sun, 15 Mar 2009)
New Revision: 176

Added:
   trunk/paralleltag/src/org/crosswire/modedit/ScrollingTextDialog.java
Removed:
   trunk/paralleltag/src/org/crosswire/modedit/Application1.java
   trunk/paralleltag/src/org/crosswire/modedit/Frame1.java
Modified:
   trunk/paralleltag/ModEdit.properties
   trunk/paralleltag/README
   trunk/paralleltag/modedit.cpp
   trunk/paralleltag/src/org/crosswire/modedit/MainFrame.java
Log:
added other context list for word clicks


Modified: trunk/paralleltag/ModEdit.properties
===================================================================
--- trunk/paralleltag/ModEdit.properties	2009-03-15 02:23:28 UTC (rev 175)
+++ trunk/paralleltag/ModEdit.properties	2009-03-15 23:12:37 UTC (rev 176)
@@ -1,5 +1,6 @@
 #ModEdit Properties
-#Sat Jul 28 19:25:06 MST 2007
+#Sun Mar 15 22:41:27 GMT 2009
+contextMod=KJV
 localTarget=true
 localImages=true
 localTR=true

Modified: trunk/paralleltag/README
===================================================================
--- trunk/paralleltag/README	2009-03-15 02:23:28 UTC (rev 175)
+++ trunk/paralleltag/README	2009-03-15 23:12:37 UTC (rev 176)
@@ -2,11 +2,12 @@
 
 It have been 'genericized'.
 
-Included is the exact TR (with NU updates) module used so the word numbering can be used to
-patch update the KJV2003 project to other greek texts.  It is also might
-be useful to use the same word number for other tagging projects for
+Included is the exact TR (with NU updates) module used so the word numbering
+can be used to patch update the KJV2003 project to other greek texts.  It is
+also might be useful to use the same word number for other tagging projects for
 consistency.
 
+
 PREREQUISITES
 
 sword built and installed
@@ -20,6 +21,22 @@
 make
 ant
 
+SETTING UP
+
+Have a look at ModEdit.properties
+
+contextMod - if this entry has a value then word clicks will attempt to show
+other verses which contain the selected word.  You must install the module you
+choose for context.  It must contain lemma (Strong's) information.  And you
+must build an index on the module. e.g.,
+
+contextMod=KJV
+
+wget http://crosswire.org/ftpmirror/pub/sword/packages/rawzip/KJV.zip
+unzip KJV.zip
+mkfastmod KJV
+
+
 RUNNING
 
 java -jar ParallelTag.jar

Modified: trunk/paralleltag/modedit.cpp
===================================================================
--- trunk/paralleltag/modedit.cpp	2009-03-15 02:23:28 UTC (rev 175)
+++ trunk/paralleltag/modedit.cpp	2009-03-15 23:12:37 UTC (rev 176)
@@ -12,6 +12,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <regex.h> // GNU
 
 
 
@@ -113,6 +114,26 @@
 }
 
 
+void getContext(const char *modName, const char *strong) {
+	SWModule *mod = mgr->getModule(modName);
+	if (mod) {
+		int MAX_ENTRIES = 7;
+//	 	int SEARCH_TYPE = -3; //  - entryAttrib (eg. Word//Lemma/G1234/)	- slower
+	 	int SEARCH_TYPE = -4; //  - lucene (be sure to run mkfastmod on your module)
+		SWBuf searchTerm;
+//		searchTerm.setFormatted("Word//Lemma/%s/", strong);	// entryAttribute format
+		searchTerm.setFormatted("lemma:%s", strong);		// lucene format
+		ListKey listKey = mod->search(searchTerm.c_str(), SEARCH_TYPE, REG_ICASE);
+		for (listKey = TOP; !listKey.Error() && MAX_ENTRIES; listKey++) {
+			std::cout << listKey.getShortText() << "|";
+			mod->setKey(listKey);
+			std::cout << mod->StripText() << "\n";
+			MAX_ENTRIES--;
+		}
+	}
+}
+
+
 void getModHTML(const char *modName, const char *key) {
 	SWModule *mod = mgr->getModule(modName);
 	if (mod) {
@@ -132,7 +153,7 @@
 
 int main(int argc, char **argv) {
 	if (argc < 2) {
-		fprintf(stderr, "usage: %s <read|html|write|fileWrite|attributes|export> <modname> <key> [text]\n\n", *argv);
+		fprintf(stderr, "usage: %s <read|html|write|fileWrite|attributes|export|context> <modname> <key> [text]\n\n", *argv);
 		exit(1);
 	}
 
@@ -155,6 +176,8 @@
 			break;
 	case 'f': writeModEntryFromFile(argv[2], argv[3], argv[4]);
 			break;
+	case 'c': getContext(argv[2], argv[3]);
+			break;
 	}
 	char buf[20];
 //	cin >> buf;

Deleted: trunk/paralleltag/src/org/crosswire/modedit/Application1.java
===================================================================
--- trunk/paralleltag/src/org/crosswire/modedit/Application1.java	2009-03-15 02:23:28 UTC (rev 175)
+++ trunk/paralleltag/src/org/crosswire/modedit/Application1.java	2009-03-15 23:12:37 UTC (rev 176)
@@ -1,42 +0,0 @@
-package org.crosswire.modedit;
-
-import javax.swing.UIManager;
-import java.awt.*;
-
-public class Application1 {
-     boolean packFrame = false;
-
-     //Construct the application
-     public Application1() {
-          Frame1 frame = new Frame1();
-          //Validate frames that have preset sizes
-          //Pack frames that have useful preferred size info, e.g. from their layout
-          if (packFrame) {
-               frame.pack();
-          }
-          else {
-               frame.validate();
-          }
-          //Center the window
-          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-          Dimension frameSize = frame.getSize();
-          if (frameSize.height > screenSize.height) {
-               frameSize.height = screenSize.height;
-          }
-          if (frameSize.width > screenSize.width) {
-               frameSize.width = screenSize.width;
-          }
-          frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
-          frame.setVisible(true);
-     }
-     //Main method
-     public static void main(String[] args) {
-          try {
-               UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
-          }
-          catch(Exception e) {
-               e.printStackTrace();
-          }
-          new Application1();
-     }
-}
\ No newline at end of file

Deleted: trunk/paralleltag/src/org/crosswire/modedit/Frame1.java
===================================================================
--- trunk/paralleltag/src/org/crosswire/modedit/Frame1.java	2009-03-15 02:23:28 UTC (rev 175)
+++ trunk/paralleltag/src/org/crosswire/modedit/Frame1.java	2009-03-15 23:12:37 UTC (rev 176)
@@ -1,36 +0,0 @@
-package org.crosswire.modedit;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-public class Frame1 extends JFrame {
-     JPanel contentPane;
-     BorderLayout borderLayout1 = new BorderLayout();
-
-     //Construct the frame
-     public Frame1() {
-          enableEvents(AWTEvent.WINDOW_EVENT_MASK);
-          try {
-               jbInit();
-          }
-          catch(Exception e) {
-               e.printStackTrace();
-          }
-     }
-     //Component initialization
-     private void jbInit() throws Exception  {
-          //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
-          contentPane = (JPanel) this.getContentPane();
-          contentPane.setLayout(borderLayout1);
-          this.setSize(new Dimension(400, 300));
-          this.setTitle("Frame Title");
-     }
-     //Overridden so we can exit when window is closed
-     protected void processWindowEvent(WindowEvent e) {
-          super.processWindowEvent(e);
-          if (e.getID() == WindowEvent.WINDOW_CLOSING) {
-               System.exit(0);
-          }
-     }
-}
\ No newline at end of file

Modified: trunk/paralleltag/src/org/crosswire/modedit/MainFrame.java
===================================================================
--- trunk/paralleltag/src/org/crosswire/modedit/MainFrame.java	2009-03-15 02:23:28 UTC (rev 175)
+++ trunk/paralleltag/src/org/crosswire/modedit/MainFrame.java	2009-03-15 23:12:37 UTC (rev 176)
@@ -59,6 +59,7 @@
 	BorderLayout rightPanelLayout = new BorderLayout();
 	int currentCaret = -1;
 	Object greekHighlight;
+	ScrollingTextDialog infoWindow = new ScrollingTextDialog();
 
 	/**Construct the frame*/
 	public MainFrame() {
@@ -116,6 +117,7 @@
 
     private String proxyHost = null;
     private String proxyPort = null;
+    private String contextMod = "";
     private boolean useProxy = false;
 
 	public String currentKey = null;
@@ -424,6 +426,7 @@
 		useProxy = (props.getProperty("useProxy", "false").equals("true"));
 		proxyHost = props.getProperty("proxyHost", "[none]");
 		proxyPort = props.getProperty("proxyPort", "8080");
+		contextMod = props.getProperty("contextMod", "");
 
 		loadVerse(props.getProperty("lastVerse", "jn 1:1"));
 		if (!localTarget)
@@ -442,6 +445,7 @@
 		props.setProperty("lastVerse", currentKey);
 		props.setProperty("proxyHost", proxyHost);
 		props.setProperty("proxyPort", proxyPort);
+		props.setProperty("contextMod", contextMod);
 		props.setProperty("useProxy", (useProxy) ? "true" : "false");
 		try {
 			props.store(new FileOutputStream("ModEdit.properties"), "ModEdit Properties");
@@ -602,6 +606,13 @@
 			}
 			agentResult = new StringBuffer(tagInfo.thayerCache);
 			loadHTML(strongTextEditor, agentResult);
+
+			if (contextMod.length() > 0) {
+				agentResult = new StringBuffer();
+				callLocalAgent(new String[] {util, "c", contextMod, "G"+tagInfo.strong}, agentResult, true);
+				infoWindow.setHTML(agentResult);
+				infoWindow.setVisible(true);
+			}
 		} catch (Throwable t) {
 			t.printStackTrace();
 		}

Copied: trunk/paralleltag/src/org/crosswire/modedit/ScrollingTextDialog.java (from rev 175, trunk/paralleltag/src/org/crosswire/modedit/Frame1.java)
===================================================================
--- trunk/paralleltag/src/org/crosswire/modedit/ScrollingTextDialog.java	                        (rev 0)
+++ trunk/paralleltag/src/org/crosswire/modedit/ScrollingTextDialog.java	2009-03-15 23:12:37 UTC (rev 176)
@@ -0,0 +1,61 @@
+package org.crosswire.modedit;
+
+import java.awt.*;
+import java.io.StringReader;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.text.html.*;
+
+public class ScrollingTextDialog extends JFrame {
+     JPanel contentPane;
+     BorderLayout borderLayout1 = new BorderLayout();
+	private JScrollPane textScrollPane = new JScrollPane();
+	JEditorPane textPane = new JEditorPane() {
+		public boolean isManagingFocus() { return true; }
+	};
+
+     //Construct the frame
+     public ScrollingTextDialog() {
+          enableEvents(AWTEvent.WINDOW_EVENT_MASK);
+          try {
+               jbInit();
+          }
+          catch(Exception e) {
+               e.printStackTrace();
+          }
+     }
+     //Component initialization
+     private void jbInit() throws Exception  {
+          //setIconImage(Toolkit.getDefaultToolkit().createImage(ScrollingTextDialog.class.getResource("[Your Icon]")));
+          contentPane = (JPanel) this.getContentPane();
+          contentPane.setLayout(borderLayout1);
+
+		contentPane.add(textScrollPane, null);
+		textScrollPane.getViewport().add(textPane, null);
+		textScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+          this.setSize(new Dimension(400, 300));
+          this.setTitle("Information");
+
+		HTMLEditorKit htmlKit = new HTMLEditorKit();
+		textPane.setEditable(false);
+		textPane.setEditorKit(htmlKit);
+     }
+     //Overridden so we can exit when window is closed
+     protected void processWindowEvent(WindowEvent e) {
+          super.processWindowEvent(e);
+          if (e.getID() == WindowEvent.WINDOW_CLOSING) {
+//               System.exit(0);
+          }
+     }
+
+	public void setHTML(StringBuffer html) {
+		HTMLDocument doc = (HTMLDocument)textPane.getDocument();
+		try {
+			textPane.setText("");
+			textPane.getEditorKit().read(new StringReader(html.toString()), doc, 0);
+		}
+		catch(Exception ex) {
+			ex.printStackTrace();
+		}
+	}
+}


Property changes on: trunk/paralleltag/src/org/crosswire/modedit/ScrollingTextDialog.java
___________________________________________________________________
Added: svn:mergeinfo
   + 




More information about the sword-cvs mailing list