[brailleblaster] push by RandomCh...@xxxxxxxxx - Fix for BB forcing the same document to open in new tabs. on 2014-08-22 18:00 GMT

  • From: brailleblaster@xxxxxxxxxxxxxx
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Fri, 22 Aug 2014 18:00:59 +0000

Revision: 6ba9048cd80a
Branch:   default
Author:   cmyers@xxxxxxxxxxxxxxxxx
Date:     Fri Aug 22 19:03:35 2014 UTC
Log:      Fix for BB forcing the same document to open in new tabs.
https://code.google.com/p/brailleblaster/source/detail?r=6ba9048cd80a

Modified:
 /src/main/org/brailleblaster/archiver/Archiver.java
 /src/main/org/brailleblaster/archiver/ArchiverFactory.java
 /src/main/org/brailleblaster/archiver/BrfArchiver.java
 /src/main/org/brailleblaster/archiver/EPub3Archiver.java
 /src/main/org/brailleblaster/archiver/NimasArchiver.java
 /src/main/org/brailleblaster/archiver/TextArchiver.java
 /src/main/org/brailleblaster/archiver/UTDArchiver.java
 /src/main/org/brailleblaster/archiver/WebArchiver.java
 /src/main/org/brailleblaster/perspectives/braille/Manager.java
 /src/main/org/brailleblaster/perspectives/falcon/FalconController.java
/src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java
 /src/main/org/brailleblaster/perspectives/webView/WebViewController.java

=======================================
--- /src/main/org/brailleblaster/archiver/Archiver.java Thu Aug 21 20:56:11 2014 UTC +++ /src/main/org/brailleblaster/archiver/Archiver.java Fri Aug 22 19:03:35 2014 UTC
@@ -122,8 +122,13 @@
        ArchRunner archrun = null;

//////////////////////////////////////////////////////////////////////////////////
-       // Constructor. Stores path to document to prepare.
-       Archiver(String docToPrepare)
+       // Constructor.
+       Archiver() {}
+
+ ////////////////////////////////////////////////////////////////////////////////// + // Constructor. Stores path to document to prepare. Restores previous session's
+       // variables if desired.
+       Archiver(String docToPrepare, boolean restore)
        {
                // Store paths.
                originalDocPath = docToPrepare;
@@ -135,6 +140,16 @@
                tempList = new ArrayList<String>();
                numImages = new ArrayList<Integer>();

+               // Restore paths to a previous session.
+               if(restore)
+                       restorePrevSession();
+
+       } //Archiver(String docToPrepare)
+
+ //////////////////////////////////////////////////////////////////////////////////
+       // Checks the settings file and restores our paths to a previous 
session.
+       public void restorePrevSession()
+       {
                ///////////////////////
                // Auto-save RELOAD!!!!

@@ -169,8 +184,8 @@

                // Auto-save RELOAD!!!!
                ///////////////////////
-
-       } //Archiver(String docToPrepare)
+
+       } // restorePrevSession()

////////////////////////////////////////////////////////////////////////////////// // Clears the previous session from our settings. Used when we're exiting the
=======================================
--- /src/main/org/brailleblaster/archiver/ArchiverFactory.java Wed May 7 14:32:30 2014 UTC +++ /src/main/org/brailleblaster/archiver/ArchiverFactory.java Fri Aug 22 19:03:35 2014 UTC
@@ -42,7 +42,7 @@
////////////////////////////////////////////////////////////////////////////////// // Pass a filepath to a document, and getArchive() will determine the file type,
        // and return the appropriate Archive.
-       public static Archiver getArchive(String filePath)
+       public static Archiver getArchive(String filePath, boolean restore)
        {
                // If the archive is contained within a zip file, go ahead and 
unzip it.
 //             if( filePath.toLowerCase().endsWith(".zip") )
@@ -56,21 +56,21 @@

                // Is this EPub3?
                if( isEPUB3(filePath) )
-                       return new EPub3Archiver(filePath);
+                       return new EPub3Archiver(filePath, restore);
                // Is this EPub?
                if( isEPUB(filePath) )
-                       return new EPub3Archiver(filePath);
+                       return new EPub3Archiver(filePath, restore);
                // Is this Nimas?
                if(isTextFile(filePath))
-                       return new TextArchiver(filePath);
+                       return new TextArchiver(filePath, restore);
                if( isNIMAS(filePath) )
-                       return new NimasArchiver(filePath);
+                       return new NimasArchiver(filePath, restore);
                if(isUTD(filePath))
-                       return new UTDArchiver(filePath);
+                       return new UTDArchiver(filePath, restore);
                if(isHTML(filePath))
-                       return new WebArchiver(filePath);
+                       return new WebArchiver(filePath, restore);
                if(isBRF(filePath))
-                       return new BrfArchiver(filePath);
+                       return new BrfArchiver(filePath, restore);

                // Could not determine file type.
                return null;
=======================================
--- /src/main/org/brailleblaster/archiver/BrfArchiver.java Thu Aug 21 18:39:14 2014 UTC +++ /src/main/org/brailleblaster/archiver/BrfArchiver.java Fri Aug 22 19:03:35 2014 UTC
@@ -34,8 +34,8 @@
 //not yet fully implemented
 public class BrfArchiver extends Archiver{

-       BrfArchiver(String docToPrepare) {
-               super(docToPrepare);
+       BrfArchiver(String docToPrepare, boolean restore) {
+               super(docToPrepare, restore);
                currentConfig = "preferences.cfg";
                //if implemented, set currentConfig
        }
=======================================
--- /src/main/org/brailleblaster/archiver/EPub3Archiver.java Thu Aug 21 20:56:11 2014 UTC +++ /src/main/org/brailleblaster/archiver/EPub3Archiver.java Fri Aug 22 19:03:35 2014 UTC
@@ -80,8 +80,10 @@
        String bkMarkStr = null;
        private String zipPath;

-       public EPub3Archiver(String docToPrepare) {
-               super(docToPrepare);
+       public EPub3Archiver() { super(); }
+
+       public EPub3Archiver(String docToPrepare, boolean restore) {
+               super(docToPrepare, restore);
                open();
                currentConfig = getAutoCfg("epub");
                filterNames = new String[] {"EPUB", "BRF", "UTDML"};
@@ -568,7 +570,7 @@
                // Stop the autosave feature until we're done.
                pauseAutoSave();

-               UTDArchiver arch = new UTDArchiver(workingDocPath, path, 
currentConfig);
+ UTDArchiver arch = new UTDArchiver(workingDocPath, path, currentConfig, false);
                arch.save(doc, path);

                // Restart autosave feature.
=======================================
--- /src/main/org/brailleblaster/archiver/NimasArchiver.java Thu Aug 21 18:39:14 2014 UTC +++ /src/main/org/brailleblaster/archiver/NimasArchiver.java Fri Aug 22 19:03:35 2014 UTC
@@ -65,9 +65,9 @@
        // The number of documents we COULD have if wrote them all to disk.
        int numPotentialFiles = 0;

-       NimasArchiver(String docToPrepare) {
+       NimasArchiver(String docToPrepare, boolean restore) {

-               super(docToPrepare);
+               super(docToPrepare, restore);

                currentConfig = getAutoCfg("nimas"); // Nimas document.
                filterNames = new String[] {"XML", "XML Zip", "BRF", "UTDML"};
@@ -258,7 +258,7 @@
                // Stop the autosave feature until we're done.
                pauseAutoSave();

-               UTDArchiver arch = new UTDArchiver(workingDocPath, path, 
currentConfig);
+ UTDArchiver arch = new UTDArchiver(workingDocPath, path, currentConfig, false);
                arch.save(doc, path);

                // Resume autosave feature.
=======================================
--- /src/main/org/brailleblaster/archiver/TextArchiver.java Thu Aug 21 18:39:14 2014 UTC +++ /src/main/org/brailleblaster/archiver/TextArchiver.java Fri Aug 22 19:03:35 2014 UTC
@@ -55,8 +55,8 @@
private final String TEMPLATEPATH = BBIni.getProgramDataPath() + BBIni.getFileSep() + "xmlTemplates" + BBIni.getFileSep() + "textFileTemplate.html";
        private final int BODYELEMENTINDEX = 1;

-       TextArchiver(String docToPrepare) {
-               super(docToPrepare);
+       TextArchiver(String docToPrepare, boolean restore) {
+               super(docToPrepare, restore);
                fu = new FileUtils();
                currentConfig = getAutoCfg("epub");
filterNames = new String[] { "HTML","TEXT", "BRF", "UTDML working document"};
@@ -206,7 +206,7 @@
                // Stop the autosave feature until we're done.
                pauseAutoSave();

-               UTDArchiver arch = new UTDArchiver(workingDocPath, path, 
currentConfig);
+ UTDArchiver arch = new UTDArchiver(workingDocPath, path, currentConfig, false);
                arch.save(doc, path);

                // Resume autosave feature.
@@ -220,7 +220,7 @@
                // Stop the autosave feature until we're done.
                pauseAutoSave();

-               WebArchiver arch = new WebArchiver(workingDocPath,  path);
+               WebArchiver arch = new WebArchiver(workingDocPath,  path, 
false);
                arch.save(doc, path);

                // Resume autosave feature.
=======================================
--- /src/main/org/brailleblaster/archiver/UTDArchiver.java Thu Aug 21 18:39:14 2014 UTC +++ /src/main/org/brailleblaster/archiver/UTDArchiver.java Fri Aug 22 19:03:35 2014 UTC
@@ -46,8 +46,8 @@

 public class UTDArchiver extends Archiver{

-       UTDArchiver(String docToPrepare) {
-               super(docToPrepare);
+       UTDArchiver(String docToPrepare, boolean restore) {
+               super(docToPrepare, restore);
                filterNames = new String[] { "BRF", "UTDML working document"};
                filterExtensions = new String[] { "*.brf", "*.utd"};
                currentConfig = findConfig();
@@ -60,8 +60,8 @@
         * @param docToPrepare: name of document with new name
         * @param config: configuration file to use
         */
-       UTDArchiver(String oldPath, String docToPrepare, String config){
-               super(docToPrepare);
+ UTDArchiver(String oldPath, String docToPrepare, String config, boolean restore){
+               super(docToPrepare, restore);
                currentConfig = config;
                filterNames = new String[] { "BRF", "UTDML working document"};
                filterExtensions = new String[] { "*.brf", "*.utd"};
=======================================
--- /src/main/org/brailleblaster/archiver/WebArchiver.java Thu Aug 21 18:39:14 2014 UTC +++ /src/main/org/brailleblaster/archiver/WebArchiver.java Fri Aug 22 19:03:35 2014 UTC
@@ -10,8 +10,8 @@

        String ext;

-       WebArchiver(String docToPrepare) {
-               super(docToPrepare);
+       WebArchiver(String docToPrepare, boolean restore) {
+               super(docToPrepare, restore);
                currentConfig = getAutoCfg("epub");

                ext = docToPrepare.substring(docToPrepare.lastIndexOf(".") + 1);
@@ -28,8 +28,8 @@
* @param oldFile: Path to previous file name used to create a new semantic file
         * @param newFile: name of document with new name
         */
-       WebArchiver(String oldFile, String newFile) {
-               super(newFile);
+       WebArchiver(String oldFile, String newFile, boolean restore) {
+               super(newFile, restore);
                currentConfig = getAutoCfg("epub");

                ext = newFile.substring(newFile.lastIndexOf(".") + 1);
@@ -114,7 +114,7 @@
                // Stop the autosave feature until we're done.
                pauseAutoSave();

-               UTDArchiver arch = new UTDArchiver(workingDocPath, path, 
currentConfig);
+ UTDArchiver arch = new UTDArchiver(workingDocPath, path, currentConfig, false);
                arch.save(doc, path);

                // Resume autosave feature.
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/Manager.java Thu Aug 21 18:44:20 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/Manager.java Fri Aug 22 19:03:35 2014 UTC
@@ -51,6 +51,7 @@
 import org.brailleblaster.BBIni;
 import org.brailleblaster.archiver.Archiver;
 import org.brailleblaster.archiver.ArchiverFactory;
+import org.brailleblaster.archiver.EPub3Archiver;
 import org.brailleblaster.embossers.EmbossersManager;
 import org.brailleblaster.localization.LocaleHandler;
 import org.brailleblaster.perspectives.Controller;
@@ -143,7 +144,7 @@
                        openDocument(docName);
                else {
                        docCount++;
-                       arch = ArchiverFactory.getArchive( templateFile);
+                       arch = ArchiverFactory.getArchive( templateFile, false);
                        vi = ViewFactory.createUpdater(arch, document, text, 
braille, treeView);
                        //list = vi.getList(this);
                        resetConfiguations();
@@ -268,25 +269,32 @@

        public void openDocument(String fileName){

-               // 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;
-                               else
-                                       arch.clearPrevSession();
-                       }
+               // 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 )

                // Create archiver and massage document if necessary.
                String config = "";
                if(arch != null)
                        config = arch.getCurrentConfig();

-               arch = ArchiverFactory.getArchive(fileName);
+               arch = ArchiverFactory.getArchive(fileName, restoreArchive);

                if(!config.equals(arch.getCurrentConfig()))
                        resetConfiguations();
=======================================
--- /src/main/org/brailleblaster/perspectives/falcon/FalconController.java Fri Jun 13 19:19:19 2014 UTC +++ /src/main/org/brailleblaster/perspectives/falcon/FalconController.java Fri Aug 22 19:03:35 2014 UTC
@@ -85,7 +85,7 @@
                if (fileName == null)
                        return false;
                // fileName = templateFile;
-               arch = ArchiverFactory.getArchive(fileName);
+               arch = ArchiverFactory.getArchive(fileName, false);

                // Recent Files.
                addRecentFileEntry(fileName);
=======================================
--- /src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java Thu Aug 21 18:44:20 2014 UTC +++ /src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java Fri Aug 22 19:03:35 2014 UTC
@@ -37,6 +37,7 @@
 import org.brailleblaster.BBIni;
 import org.brailleblaster.archiver.Archiver;
 import org.brailleblaster.archiver.ArchiverFactory;
+import org.brailleblaster.archiver.EPub3Archiver;
 import org.brailleblaster.archiver.NimasArchiver;
 import org.brailleblaster.localization.LocaleHandler;
 import org.brailleblaster.perspectives.Controller;
@@ -123,23 +124,30 @@

        public boolean openDocument(String fileName){

-               // 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;
-                               else
-                                       arch.clearPrevSession();
-                       }
+               // 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);
+                       arch = ArchiverFactory.getArchive(fileName, 
restoreArchive);
                else {
-                       arch = ArchiverFactory.getArchive(templateFile);
+                       arch = ArchiverFactory.getArchive(templateFile, false);
                }

                ////////////////
=======================================
--- /src/main/org/brailleblaster/perspectives/webView/WebViewController.java Thu Aug 21 18:39:14 2014 UTC +++ /src/main/org/brailleblaster/perspectives/webView/WebViewController.java Fri Aug 22 19:03:35 2014 UTC
@@ -48,7 +48,7 @@
                vb=new webViewBrowser(this,wp.getFolder(),null);
                // if no file opened then create an empty template
                if(currentPath == null)
-                       arch = ArchiverFactory.getArchive(templateFile);
+                       arch = ArchiverFactory.getArchive(templateFile, false);
                else
                        reuseTab(currentPath);
                webDoc = new webViewDocument(this);
@@ -94,7 +94,7 @@
         */
        private void openBook(String fileName){
                String archFileName=null;
-               arch = ArchiverFactory.getArchive(fileName);
+               arch = ArchiverFactory.getArchive(fileName, false);

                if(arch != null){
                        archFileName = arch.getWorkingFilePath();

Other related posts:

  • » [brailleblaster] push by RandomCh...@xxxxxxxxx - Fix for BB forcing the same document to open in new tabs. on 2014-08-22 18:00 GMT - brailleblaster