OSDN Git Service

- Corrected various null pointer errors. - Corrected problem indexing large PDF docum...
authorRandy Baumgarte <randy@fbn.cx>
Mon, 29 Nov 2010 18:49:39 +0000 (13:49 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Wed, 15 Dec 2010 15:16:44 +0000 (10:16 -0500)
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/dialog/DatabaseStatus.java
src/cx/fbn/nevernote/sql/NoteResourceTable.java
src/cx/fbn/nevernote/sql/WordsTable.java
src/cx/fbn/nevernote/threads/IndexRunner.java
src/cx/fbn/nevernote/xml/NoteFormatter.java

index e4d8397..bdc083f 100644 (file)
@@ -2360,6 +2360,7 @@ public class NeverNote extends QMainWindow{
                status.setUnindexed(unindexed);
                status.setNoteCount(conn.getNoteTable().getNoteCount());
                status.setNotebookCount(listManager.getNotebookIndex().size());
+               status.setUnindexedResourceCount(conn.getNoteTable().noteResourceTable.getUnindexedCount());
                status.setSavedSearchCount(listManager.getSavedSearchIndex().size());
                status.setTagCount(listManager.getTagIndex().size());
                status.setResourceCount(conn.getNoteTable().noteResourceTable.getResourceCount());
@@ -2489,7 +2490,13 @@ public class NeverNote extends QMainWindow{
                searchField.setEditText("");
                saveNoteColumnPositions();
                saveNoteIndexWidth();
-               loadNoteBrowserInformation(browserWindow);
+               noteIndexUpdated(true);
+               if (currentNote == null && listManager.getNoteIndex().size() > 0) {
+                       currentNote = listManager.getNoteIndex().get(0);
+                       currentNoteGuid = currentNote.getGuid();
+               }
+               if (currentNote != null)
+                       loadNoteBrowserInformation(browserWindow);
        }
        // text in the search bar changed.  We only use this to tell if it was cleared, 
        // otherwise we trigger off searchFieldChanged.
index 402de0c..51c529c 100644 (file)
@@ -36,6 +36,7 @@ public class DatabaseStatus extends QDialog {
        QLabel savedSearchCount;\r
        QLabel resourceCount;\r
        QLabel indexCount;\r
+       QLabel resourceIndexNeeded;\r
        private final QPushButton ok;\r
     private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
@@ -52,6 +53,7 @@ public class DatabaseStatus extends QDialog {
                tagCount = new QLabel();\r
                savedSearchCount = new QLabel();                \r
                resourceCount = new QLabel();\r
+               resourceIndexNeeded = new QLabel();\r
                indexCount = new QLabel();\r
                \r
                grid.addWidget(new QLabel(tr("Notebooks:")), 0,0);\r
@@ -68,21 +70,24 @@ public class DatabaseStatus extends QDialog {
                \r
                grid.addWidget(new QLabel(tr("Unindexed Notes:")), 4,0);\r
                grid.addWidget(indexNeeded, 4, 1);\r
-               \r
+                               \r
                grid.addWidget(new QLabel(tr("Attachments/Images:")), 5,0);\r
                grid.addWidget(resourceCount, 5,1);\r
+\r
+               grid.addWidget(new QLabel(tr("Unindexed Attachments/Images:")), 6,0);\r
+               grid.addWidget(resourceIndexNeeded, 6, 1);\r
+\r
+               grid.addWidget(new QLabel(tr("Saved Searches:")),7,0);\r
+               grid.addWidget(savedSearchCount, 7,1);\r
                \r
-               grid.addWidget(new QLabel(tr("Saved Searches:")),6,0);\r
-               grid.addWidget(savedSearchCount, 6,1);\r
-               \r
-               grid.addWidget(new QLabel(tr("Words In Index")), 7,0);\r
-               grid.addWidget(indexCount, 7,1);\r
+               grid.addWidget(new QLabel(tr("Words In Index")), 8,0);\r
+               grid.addWidget(indexCount, 8,1);\r
                        \r
                QGridLayout buttonLayout = new QGridLayout();\r
                ok = new QPushButton(tr("OK"));\r
                ok.clicked.connect(this, "okPushed()");\r
                buttonLayout.addWidget(ok, 1, 1);\r
-               grid.addLayout(buttonLayout,8,1);\r
+               grid.addLayout(buttonLayout,9,1);\r
        }\r
        \r
        @SuppressWarnings("unused")\r
@@ -110,6 +115,9 @@ public class DatabaseStatus extends QDialog {
        public void setResourceCount(int d) {\r
                resourceCount.setText(NumberFormat.getInstance().format(d));\r
        }\r
+       public void setUnindexedResourceCount(int r)  {\r
+               resourceIndexNeeded.setText(NumberFormat.getInstance().format(r));\r
+       }\r
        public void setWordCount(int d) {\r
                indexCount.setText(NumberFormat.getInstance().format(d));\r
        }\r
index c418243..6acc357 100644 (file)
@@ -523,7 +523,7 @@ public class NoteResourceTable  {
                NSqlQuery query = new NSqlQuery(db.getConnection());\r
                query.exec("Update NoteResources set indexneeded=true");\r
        }\r
-       // Count unindexed notes\r
+       // Count attachments\r
        public int getResourceCount() {\r
         NSqlQuery query = new NSqlQuery(db.getConnection());\r
                query.exec("select count(*) from noteresources");\r
@@ -531,7 +531,16 @@ public class NoteResourceTable  {
                int returnValue = new Integer(query.valueString(0));\r
                return returnValue;\r
        }\r
-\r
+       //\r
+       // Count unindexed notes\r
+       public int getUnindexedCount() {\r
+        NSqlQuery query = new NSqlQuery(db.getConnection());\r
+               query.exec("select count(*) from noteresources where indexneeded=true");\r
+               query.next(); \r
+               int returnValue = new Integer(query.valueString(0));\r
+               return returnValue;\r
+       }\r
+       \r
        //********************************************\r
        //** Utility Functions\r
        //********************************************\r
index 786d267..bdf029f 100644 (file)
@@ -132,6 +132,7 @@ public class WordsTable {
                insertWords.bindValue(":type", type);\r
                if (!insertWords.exec()) {\r
                        String err = insertWords.lastError();\r
+                       logger.log(logger.MEDIUM, "Error inserting words into index: " +err);\r
                }\r
        }\r
 \r
index c82e7ae..c352c12 100644 (file)
@@ -277,7 +277,7 @@ public class IndexRunner extends QObject implements Runnable {
                InputStream input;\r
                try {\r
                        input = new FileInputStream(new File(f.fileName()));\r
-                       ContentHandler textHandler = new BodyContentHandler();\r
+                       ContentHandler textHandler = new BodyContentHandler(-1);\r
                        Metadata metadata = new Metadata();\r
                        RTFParser parser = new RTFParser();     \r
                        ParseContext context = new ParseContext();\r
@@ -316,7 +316,7 @@ public class IndexRunner extends QObject implements Runnable {
                InputStream input;\r
                try {\r
                        input = new FileInputStream(new File(f.fileName()));\r
-                       ContentHandler textHandler = new BodyContentHandler();\r
+                       ContentHandler textHandler = new BodyContentHandler(-1);\r
                        Metadata metadata = new Metadata();\r
                        OpenDocumentParser parser = new OpenDocumentParser();   \r
                        ParseContext context = new ParseContext();\r
@@ -355,7 +355,7 @@ public class IndexRunner extends QObject implements Runnable {
                InputStream input;\r
                try {\r
                        input = new FileInputStream(new File(f.fileName()));\r
-                       ContentHandler textHandler = new BodyContentHandler();\r
+                       ContentHandler textHandler = new BodyContentHandler(-1);\r
                        Metadata metadata = new Metadata();\r
                        OfficeParser parser = new OfficeParser();       \r
                        ParseContext context = new ParseContext();\r
@@ -395,7 +395,7 @@ public class IndexRunner extends QObject implements Runnable {
                InputStream input;\r
                try {\r
                        input = new FileInputStream(new File(f.fileName()));\r
-                       ContentHandler textHandler = new BodyContentHandler();\r
+                       ContentHandler textHandler = new BodyContentHandler(-1);\r
                        Metadata metadata = new Metadata();\r
                        PDFParser parser = new PDFParser();     \r
                        ParseContext context = new ParseContext();\r
@@ -410,17 +410,15 @@ public class IndexRunner extends QObject implements Runnable {
                } catch (java.lang.ClassCastException e) {\r
                        logger.log(logger.LOW, "Cast exception: " +e.getMessage());\r
                } catch (FileNotFoundException e) {\r
-                       // TODO Auto-generated catch block\r
                        e.printStackTrace();\r
                } catch (IOException e) {\r
-                       // TODO Auto-generated catch block\r
                        e.printStackTrace();\r
                } catch (SAXException e) {\r
-                       // TODO Auto-generated catch block\r
                        e.printStackTrace();\r
                } catch (TikaException e) {\r
-                       // TODO Auto-generated catch block\r
                        e.printStackTrace();\r
+//             } catch (Exception e) {\r
+//                     e.printStackTrace();\r
                }\r
        }\r
        \r
@@ -434,7 +432,7 @@ public class IndexRunner extends QObject implements Runnable {
                InputStream input;\r
                try {\r
                        input = new FileInputStream(new File(f.fileName()));\r
-                       ContentHandler textHandler = new BodyContentHandler();\r
+                       ContentHandler textHandler = new BodyContentHandler(-1);\r
                        Metadata metadata = new Metadata();\r
                        OOXMLParser parser = new OOXMLParser(); \r
                        ParseContext context = new ParseContext();\r
index d8baebb..191a827 100644 (file)
@@ -53,7 +53,10 @@ public class NoteFormatter {
        public void setNote(Note note, boolean pdfPreview) {\r
                currentNote = note;\r
                this.pdfPreview = pdfPreview;\r
-               currentNoteGuid = note.getGuid();\r
+               if (note != null)\r
+                       currentNoteGuid = note.getGuid();\r
+               else\r
+                       currentNoteGuid = null;\r
                readOnly = false;\r
                resourceError = false;\r
        }\r
@@ -75,6 +78,8 @@ public class NoteFormatter {
        \r
        // Rebuild the note HTML to something usable\r
        public String rebuildNoteHTML() {\r
+               if (currentNote == null)\r
+                       return null;\r
                logger.log(logger.HIGH, "Entering NeverNote.rebuildNoteHTML");\r
                logger.log(logger.EXTREME, "Note guid: " +currentNoteGuid);\r
                logger.log(logger.EXTREME, "Note Text:" +currentNote);\r