[brailleblaster] push by RandomCh...@xxxxxxxxx - Fixed bug with Braille View failing to load previous session. Was load... on 2014-08-22 19:07 GMT

  • From: brailleblaster@xxxxxxxxxxxxxx
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Fri, 22 Aug 2014 19:07:22 +0000

Revision: 75b0214130f9
Branch:   default
Author:   cmyers@xxxxxxxxxxxxxxxxx
Date:     Fri Aug 22 20:10:20 2014 UTC
Log: Fixed bug with Braille View failing to load previous session. Was loading template, instead.
https://code.google.com/p/brailleblaster/source/detail?r=75b0214130f9

Modified:
 /src/main/org/brailleblaster/perspectives/Controller.java
 /src/main/org/brailleblaster/perspectives/braille/Manager.java
/src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java

=======================================
--- /src/main/org/brailleblaster/perspectives/Controller.java Tue Jul 1 19:31:52 2014 UTC +++ /src/main/org/brailleblaster/perspectives/Controller.java Fri Aug 22 20:10:20 2014 UTC
@@ -9,7 +9,9 @@

 import org.brailleblaster.BBIni;
 import org.brailleblaster.archiver.Archiver;
+import org.brailleblaster.archiver.EPub3Archiver;
 import org.brailleblaster.util.FileUtils;
+import org.brailleblaster.util.PropertyFileManager;
 import org.brailleblaster.wordprocessor.WPManager;
 import org.eclipse.swt.widgets.TabItem;

@@ -28,6 +30,33 @@
                this.wp = wp;
                fu = new FileUtils();
        }
+
+       /////////////////////////////////////////////////////////////////////
+       // Checks the settings file for values belonging to auto save.
+       // Determines if we should restore, and returns path to
+       // previous file. Null if we shouldn't restore.
+       public String docRestore()
+       {
+               String returnPath = null;
+               if( wp.getList().size() < 1 ) {
+                       // Restore a previous session?
+                       PropertyFileManager props = 
BBIni.getPropertyFileManager();
+                       String wkPath = props.getProperty("prevWorkingFile");
+                       String origDocPathStr = 
props.getProperty("originalDocPath");
+                       if( origDocPathStr != null ) {
+                               if(origDocPathStr.length() > 0) {
+                                       File f = new File(wkPath);
+                                       if(f.exists())
+                                               returnPath = origDocPathStr;
+                                       else
+                                               new 
EPub3Archiver().clearPrevSession();
+                               } // if(origDocPathStr.length() > 0)
+                       } // if( origDocPathStr != null )
+               } // if( wp.getList().size() < 1 )
+
+               // Return the path we found, if any.
+               return returnPath;
+       }

        protected void addRecentFileEntry(String fileName){

=======================================
--- /src/main/org/brailleblaster/perspectives/braille/Manager.java Fri Aug 22 19:03:35 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/Manager.java Fri Aug 22 20:10:20 2014 UTC
@@ -143,14 +143,22 @@
                if(docName != null)
                        openDocument(docName);
                else {
+
                        docCount++;
-                       arch = ArchiverFactory.getArchive( templateFile, false);
-                       vi = ViewFactory.createUpdater(arch, document, text, 
braille, treeView);
-                       //list = vi.getList(this);
-                       resetConfiguations();
-                       initializeAllViews(docName, templateFile, null);
-                       //formatTemplateDocument();
-                       setTabTitle(docName);
+
+                       // Restore?
+                       String restorePath = docRestore();
+                       if(restorePath != null)
+                               openDocument(restorePath);
+                       else {
+                               arch = ArchiverFactory.getArchive( 
templateFile, false);
+ vi = ViewFactory.createUpdater(arch, document, text, braille, treeView);
+                               //list = vi.getList(this);
+                               resetConfiguations();
+                               initializeAllViews(docName, templateFile, null);
+                               //formatTemplateDocument();
+                               setTabTitle(docName);
+                       }
                }

                if(BBIni.getPlatformName().equals("cocoa"))
@@ -271,23 +279,15 @@

                // If this is the first document, load a previous session.
                boolean restoreArchive = false;
-               if( wp.getList().size() < 1 ) {
-                       // Restore a previous session?
-                       PropertyFileManager props = 
BBIni.getPropertyFileManager();
-                       String wkPath = props.getProperty("prevWorkingFile");
-                       String origDocPathStr = 
props.getProperty("originalDocPath");
-                       if( origDocPathStr != null ) {
-                               if(origDocPathStr.length() > 0) {
-                                       File f = new File(wkPath);
-                                       if(f.exists()) {
-                                               fileName = origDocPathStr;
-                                               restoreArchive = true;
-                                       }
-                                       else
-                                               new 
EPub3Archiver().clearPrevSession();
-                               } // if(origDocPathStr.length() > 0)
-                       } // if( origDocPathStr != null )
-               } // if( wp.getList().size() < 1 )
+               String restorePath = docRestore();
+               if(restorePath != null) {
+                       restoreArchive = true;
+                       fileName = restorePath;
+               }
+               else if( restorePath == null && fileName != null )
+                       restoreArchive = false;
+               else
+                       restoreArchive = false;

                // Create archiver and massage document if necessary.
                String config = "";
=======================================
--- /src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java Fri Aug 22 19:03:35 2014 UTC +++ /src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java Fri Aug 22 20:10:20 2014 UTC
@@ -125,30 +125,13 @@
        public boolean openDocument(String fileName){

                // If this is the first document, load a previous session.
-               boolean restoreArchive = false;
-               if( wp.getList().size() < 1 ) {
-                       // Restore a previous session?
-                       PropertyFileManager props = 
BBIni.getPropertyFileManager();
-                       String wkPath = props.getProperty("prevWorkingFile");
-                       String origDocPathStr = 
props.getProperty("originalDocPath");
-                       if( origDocPathStr != null ) {
-                               if(origDocPathStr.length() > 0) {
-                                       File f = new File(wkPath);
-                                       if(f.exists()) {
-                                               fileName = origDocPathStr;
-                                               restoreArchive = true;
-                                       }
-                                       else
-                                               new 
EPub3Archiver().clearPrevSession();
-                               } // if(origDocPathStr.length() > 0)
-                       } // if( origDocPathStr != null )
-               } // if( wp.getList().size() < 1 )
-
-               if(fileName != null)
-                       arch = ArchiverFactory.getArchive(fileName, 
restoreArchive);
-               else {
-                       arch = ArchiverFactory.getArchive(templateFile, false);
-               }
+               String restorePath = docRestore();
+               if(restorePath != null)
+                       arch = ArchiverFactory.getArchive( restorePath, true);
+               else if( restorePath == null && fileName != null )
+                       arch = ArchiverFactory.getArchive( fileName, false);
+               else
+                       arch = ArchiverFactory.getArchive( templateFile, false);

                ////////////////
                // Recent Files.

Other related posts:

  • » [brailleblaster] push by RandomCh...@xxxxxxxxx - Fixed bug with Braille View failing to load previous session. Was load... on 2014-08-22 19:07 GMT - brailleblaster