2 new revisions: Revision: 00f71cdb0ef4 Branch: default Author: Brandon Roller <brandon.r.roller@xxxxxxxxx> Date: Tue Jan 15 05:17:47 2013 Log: Added TreeView class, changed Text and Braille View width http://code.google.com/p/brailleblaster/source/detail?r=00f71cdb0ef4&repo=newdesign Revision: 5a41e00195d0 Branch: default Author: Brandon Roller <brandon.r.roller@xxxxxxxxx> Date: Tue Jan 15 05:21:46 2013 Log: Added TreeView class, changed Text and Braille View width http://code.google.com/p/brailleblaster/source/detail?r=5a41e00195d0&repo=newdesign ============================================================================== Revision: 00f71cdb0ef4 Branch: default Author: Brandon Roller <brandon.r.roller@xxxxxxxxx> Date: Tue Jan 15 05:17:47 2013 Log: Added TreeView class, changed Text and Braille View width http://code.google.com/p/brailleblaster/source/detail?r=00f71cdb0ef4&repo=newdesign Added: /src/main/org/brailleblaster/wordprocessor/TreeView.java Modified: /src/main/org/brailleblaster/BBIni.java /src/main/org/brailleblaster/Main.java /src/main/org/brailleblaster/util/FileUtils.java /src/main/org/brailleblaster/wordprocessor/AbstractView.java /src/main/org/brailleblaster/wordprocessor/BBMenu.java /src/main/org/brailleblaster/wordprocessor/BrailleView.java /src/main/org/brailleblaster/wordprocessor/DocumentManager.java /src/main/org/brailleblaster/wordprocessor/TextView.java ======================================= --- /dev/null+++ /src/main/org/brailleblaster/wordprocessor/TreeView.java Tue Jan 15 05:17:47 2013
@@ -0,0 +1,86 @@ +package org.brailleblaster.wordprocessor; + +import java.io.IOException; + +import javax.swing.text.View; + +import nu.xom.Builder; +import nu.xom.Document; +import nu.xom.Element; +import nu.xom.Elements; +import nu.xom.Node; +import nu.xom.Nodes; +import nu.xom.ParsingException; +import nu.xom.ValidityException; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyleRange; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.graphics.GlyphMetrics; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; + +public class TreeView extends AbstractView { + + static Tree tree; + + public TreeView(Shell documentWindow){ + super(documentWindow, 0, 15, 12, 92); + tree = new Tree(view, SWT.NONE); + /* + * Code below was used for testing purposes only. + * It should be deleted once Document class is properly implemented + try { + Builder builder = new Builder();+ Document doc = builder.build("File:/Users/broller/Documents/TestProject/build.xml");
+ populateTree(doc); + } + catch(IOException e){ + System.out.println("IO Error "); + e.printStackTrace(); + } + catch (ParsingException e){ + System.out.println("Parse Error"); + e.printStackTrace(); + } + */ + + view.setLayout(new FillLayout()); + tree.pack(); + } + + public static void populateTree(Document doc){ + TreeItem root = new TreeItem(tree, 0); + root.setText(doc.getRootElement().getLocalName()); + + Elements rootNode = doc.getRootElement().getChildElements(); + + for(int i = 0; i < rootNode.size(); i++){ + Element e = rootNode.get(i); + TreeItem temp = new TreeItem(root, 0); + temp.setText(e.getLocalName()); + populateHelper(e, temp); + } + } + + private static void populateHelper(Element e, TreeItem item){ + Elements n = e.getChildElements(); + + for(int i = 0; i < n.size(); i++){ + Element e2 = n.get(i); + TreeItem temp = new TreeItem(item, 0); + temp.setText(e2.getLocalName()); + populateHelper(e2, temp); + } + } + + public void clearTree(){ + tree.removeAll(); + } +} ======================================= --- /src/main/org/brailleblaster/BBIni.java Wed Jan 2 08:04:40 2013 +++ /src/main/org/brailleblaster/BBIni.java Tue Jan 15 05:17:47 2013 @@ -1,34 +1,33 @@ /* BrailleBlaster Braille Transcription Application - * - * Copyright (C) 2010, 2012 - * ViewPlus Technologies, Inc. www.viewplus.com - * and - * Abilitiessoft, Inc. www.abilitiessoft.com - * and - * American Printing House for the Blind, Inc. www.aph.org - * - * All rights reserved - * - * This file may contain code borrowed from files produced by various - * Java development teams. These are gratefully acknoledged. - * - * This file is free software; you can redistribute it and/or modify it - * under the terms of the Apache 2.0 License, as given at - * http://www.apache.org/licenses/ - * - * This file is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE - * See the Apache 2.0 License for more details. - * - * You should have received a copy of the Apache 2.0 License along with - * this program; see the file LICENSE. - * If not, see - * http://www.apache.org/licenses/ - * - * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx -*/ - + * + * Copyright (C) 2010, 2012 + * ViewPlus Technologies, Inc. www.viewplus.com + * and + * Abilitiessoft, Inc. www.abilitiessoft.com + * and + * American Printing House for the Blind, Inc. www.aph.org + * + * All rights reserved + * + * This file may contain code borrowed from files produced by various + * Java development teams. These are gratefully acknoledged. + * + * This file is free software; you can redistribute it and/or modify it + * under the terms of the Apache 2.0 License, as given at + * http://www.apache.org/licenses/ + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE + * See the Apache 2.0 License for more details. + * + * You should have received a copy of the Apache 2.0 License along with + * this program; see the file LICENSE. + * If not, see + * http://www.apache.org/licenses/ + * + * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx + */ package org.brailleblaster; @@ -48,19 +47,19 @@ import java.net.URISyntaxException; /** - * Determine and set initial conditions. This class takes care of most - * platform dependencies. Its get methods should be used rather than - * coding platform determining code in other classes.+ * Determine and set initial conditions. This class takes care of most platform
+ * dependencies. Its get methods should be used rather than coding platform + * determining code in other classes. */ public final class BBIni { private static BBIni bbini; -/** - * Calls a private constructor, making this class a singleton. - */ -public static BBIni initialize (String[] args) { + /** + * Calls a private constructor, making this class a singleton. + */ + public static BBIni initialize(String[] args) { if (bbini == null) bbini = new BBIni(args); return bbini; @@ -68,12 +67,12 @@ private static boolean debug = false; private static boolean gotGui = true; - private static boolean multipleSubcommands = false; - private static Logger logger; + private static boolean multipleSubcommands = false; + private static Logger logger; private static Display display = null; private static String BBVersion; private static String releaseDate; - private static String brailleblasterPath; // FO + private static String brailleblasterPath; // FO private static String osName; private static String osVersion; private static String fileSep; @@ -90,7 +89,7 @@ private static String platformName; private static String userSettings; private static String stylePath; - public final static String propExtension = ".properties"; + public final static String propExtension = ".properties"; private static boolean hSubcommands = false; private static boolean hLiblouisutdml = false; private static FileHandler logFile; @@ -99,169 +98,165 @@ private BBIni(String[] args) { long seconds = System.currentTimeMillis() / 1000; - instanceId = Long.toString (seconds, 32); + instanceId = Long.toString(seconds, 32); LocaleHandler lh = new LocaleHandler(); Main m = new Main(); - brailleblasterPath = getBrailleblasterPath (m); - osName = System.getProperty ("os.name"); - osVersion = System.getProperty ("os.version"); - fileSep = System.getProperty ("file.separator"); + brailleblasterPath = getBrailleblasterPath(m); + osName = System.getProperty("os.name"); + osVersion = System.getProperty("os.version"); + fileSep = System.getProperty("file.separator"); platformName = SWT.getPlatform(); - String userHome = System.getProperty ("user.home"); + String userHome = System.getProperty("user.home"); String BBHome; -programDataPath = brailleblasterPath + fileSep + "programData"; -helpDocsPath = brailleblasterPath + fileSep + "helpDocs"; -if (platformName.equals("win32")) { -BBHome = System.getenv ("APPDATA") + fileSep + BBID; -nativeLibrarySuffix = ".dll"; -} -else if (platformName.equals ("cocoa")) { -BBHome = userHome + fileSep + "." + BBID; -nativeLibrarySuffix = ".dylib"; -} -else { -BBHome = userHome + fileSep + "." + BBID; -nativeLibrarySuffix = ".so"; -} -nativeLibraryPath = brailleblasterPath + fileSep + "native" + fileSep + -"lib"; -FileUtils fu = new FileUtils(); -userProgramDataPath = BBHome + fileSep + "programData"; -File userData = new File (userProgramDataPath); -if (!userData.exists()) { -userData.mkdirs(); -} -makeUserProgramData(); -userSettings = userProgramDataPath + fileSep + -"user_settings.properties"; -if (!fu.exists (userSettings)) { -fu.copyFile (programDataPath + fileSep + "settings" + fileSep + -"user_settings.properties", userSettings); + programDataPath = brailleblasterPath + fileSep + "programData"; + helpDocsPath = brailleblasterPath + fileSep + "helpDocs"; + if (platformName.equals("win32")) { + BBHome = System.getenv("APPDATA") + fileSep + BBID; + nativeLibrarySuffix = ".dll"; + } else if (platformName.equals("cocoa")) { + BBHome = userHome + fileSep + "." + BBID; + nativeLibrarySuffix = ".dylib"; + } else { + BBHome = userHome + fileSep + "." + BBID; + nativeLibrarySuffix = ".so"; } - recentDocs = userProgramDataPath + fileSep + - "recent_documents.txt"; + nativeLibraryPath = brailleblasterPath + fileSep + "native" + fileSep + + "lib"; + FileUtils fu = new FileUtils(); + userProgramDataPath = BBHome + fileSep + "programData"; + File userData = new File(userProgramDataPath); + if (!userData.exists()) { + userData.mkdirs(); + } + makeUserProgramData(); + userSettings = userProgramDataPath + fileSep + + "user_settings.properties"; + if (!fu.exists(userSettings)) { + fu.copyFile(programDataPath + fileSep + "settings" + fileSep + + "user_settings.properties", userSettings); + } + recentDocs = userProgramDataPath + fileSep + "recent_documents.txt"; fu.create(recentDocs); - //FO Aug 03 + // FO Aug 03 stylePath = userProgramDataPath + fileSep + "styles"; - File styleDir = new File (stylePath); + File styleDir = new File(stylePath); if (!styleDir.exists()) styleDir.mkdirs(); -tempFilesPath = BBHome + fileSep + "temp" + fileSep + instanceId; - File temps = new File (tempFilesPath); + tempFilesPath = BBHome + fileSep + "temp" + fileSep + instanceId; + File temps = new File(tempFilesPath); if (!temps.exists()) temps.mkdirs(); logFilesPath = BBHome + fileSep + "log"; File logPath = new File(logFilesPath); if (!logPath.exists()) { - logPath.mkdirs(); + logPath.mkdirs(); } - logger = Logger.getLogger ("org.brailleblaster"); + logger = Logger.getLogger("org.brailleblaster"); try { - logFile = new FileHandler - (logFilesPath + fileSep + "log.xml"); + logFile = new FileHandler(logFilesPath + fileSep + "log.xml"); } catch (IOException e) { e.printStackTrace(); - logger.log (Level.SEVERE, "cannot open logfile", e); + logger.log(Level.SEVERE, "cannot open logfile", e); e.printStackTrace(); } if (logFile != null) { - logger.addHandler (logFile); + logger.addHandler(logFile); } // disable output to console logger.setUseParentHandlers(false); - + if (args.length > 0) { -int i = 0; -while (i < args.length) { -if (args[i].charAt(0) != '-') { -break; -} -if (args[i].equals ("-debug")) { -debug = true; -} -else if (args[i].equals ("-nogui")) { -gotGui = false; -} -else if (args[i].equals ("-multcom")) { -multipleSubcommands = true; -} -else { -System.out.println ("Bad option '" + args[i] + "'"); -} -i++; -} -if (i < args.length) { -hSubcommands = true; -} -} -if (gotGui) { -try { -display = new Display(); -} catch (SWTError e) { -logger.log (Level.SEVERE, "Can't find GUI", e); -} -} -try { -liblouisutdml.loadLibrary (nativeLibraryPath, nativeLibrarySuffix); -liblouisutdml.initialize (programDataPath, tempFilesPath, -"liblouisutdml.log"); -hLiblouisutdml = true; -} catch (UnsatisfiedLinkError e) { - logger.log (Level.SEVERE, "Problem with liblouisutdml library", e); + int i = 0; + while (i < args.length) { + if (args[i].charAt(0) != '-') { + break; + } + if (args[i].equals("-debug")) { + debug = true; + } else if (args[i].equals("-nogui")) { + gotGui = false; + } else if (args[i].equals("-multcom")) { + multipleSubcommands = true; + } else { + System.out.println("Bad option '" + args[i] + "'"); + } + i++; + } + if (i < args.length) { + hSubcommands = true; + } + } + if (gotGui) { + try { + display = new Display(); + } catch (SWTError e) { + logger.log(Level.SEVERE, "Can't find GUI", e); + } } - catch (Exception e) { - logger.log (Level.WARNING, "This shouldn't happen", e); + try {+ liblouisutdml.loadLibrary("C:\\Users\\broller\\Documents\\Project\\dist\\native\\lib", nativeLibrarySuffix);
+ liblouisutdml.initialize(programDataPath, tempFilesPath, + "liblouisutdml.log"); + hLiblouisutdml = true; + } catch (UnsatisfiedLinkError e) { + logger.log(Level.SEVERE, "Problem with liblouisutdml library", e); + } catch (Exception e) { + logger.log(Level.WARNING, "This shouldn't happen", e); } } - private String getBrailleblasterPath (Object classToUse) -{ - - /* Option to use an environment variable (mostly for testing with - * Eclipse) */ - String url = System.getenv("BBLASTER_WORK"); - if (url != null) { - url = "file:/" + url ; - } - else { - url = classToUse.getClass().getResource("/" -+ classToUse.getClass().getName().replaceAll("\\.", "/") - + ".class").toString(); + private String getBrailleblasterPath(Object classToUse) { + + /* + * Option to use an environment variable (mostly for testing with + * Eclipse) + */ + String url = System.getenv("BBLASTER_WORK"); + if (url != null) { + url = "file:/" + url; + } else { + url = classToUse + .getClass() + .getResource( + "/" + + classToUse.getClass().getName() + .replaceAll("\\.", "/") + ".class") + .toString(); + + url = url.substring(url.indexOf("file")).replaceFirst( + "/[^/]+\\.jar!.*$", "/"); + }- url = url.substring(url.indexOf("file")).replaceFirst("/[^/]+\\.jar!.*$", "/");
- } - - try { - File dir = new File(new URL(url).toURI()); - url = dir.getAbsolutePath(); + try { + File dir = new File(new URL(url).toURI()); + url = dir.getAbsolutePath(); - - } catch (MalformedURLException mue) { - url = null; - } catch (URISyntaxException ue) { - url = null; - } - return url; - } + } catch (MalformedURLException mue) { + url = null; + } catch (URISyntaxException ue) { + url = null; + } + return url; + } -private void makeUserProgramData () { -String basePath = userProgramDataPath + fileSep; -helpMakeUPD (basePath + "liblouis/tables"); -helpMakeUPD (basePath + "liblouiutdml/lbu_files"); -helpMakeUPD (basePath + "lang"); -helpMakeUPD (basePath + "semantics"); -helpMakeUPD (basePath + "styles"); -helpMakeUPD (basePath + "settings"); -helpMakeUPD (basePath + "fonts"); -} + private void makeUserProgramData() { + String basePath = userProgramDataPath + fileSep; + helpMakeUPD(basePath + "liblouis/tables"); + helpMakeUPD(basePath + "liblouiutdml/lbu_files"); + helpMakeUPD(basePath + "lang"); + helpMakeUPD(basePath + "semantics"); + helpMakeUPD(basePath + "styles"); + helpMakeUPD(basePath + "settings"); + helpMakeUPD(basePath + "fonts"); + } -private void helpMakeUPD (String pathName) { -File file = new File (pathName); -if (!file.exists()) { -file.mkdirs(); -} -} + private void helpMakeUPD(String pathName) { + File file = new File(pathName); + if (!file.exists()) { + file.mkdirs(); + } + } public static boolean debugging() { return debug; @@ -271,21 +266,19 @@ return gotGui; } - public static Display getDisplay() - { + public static Display getDisplay() { return display; } - public static boolean haveLiblouisutdml() - { + public static boolean haveLiblouisutdml() { return hLiblouisutdml; } -public static boolean haveSubcommands() { -return hSubcommands; -} + public static boolean haveSubcommands() { + return hSubcommands; + } - public static void setVersion (String version) { + public static void setVersion(String version) { BBVersion = version; } @@ -293,36 +286,31 @@ return BBVersion; } - public static void setReleaseDate (String relDate) { + public static void setReleaseDate(String relDate) { releaseDate = relDate; } - public static String getReleaseDate () { + public static String getReleaseDate() { return releaseDate; } - public static String getBrailleblasterPath() - { + public static String getBrailleblasterPath() { return brailleblasterPath; } - public static String getFileSep() - { + public static String getFileSep() { return fileSep; } - public static String getNativeCommandPath() - { + public static String getNativeCommandPath() { return nativeCommandPath; } - public static String getNativeLibraryPath() - { + public static String getNativeLibraryPath() { return nativeLibraryPath; } - public static String getProgramDataPath() - { + public static String getProgramDataPath() { return programDataPath; } @@ -330,49 +318,47 @@ return helpDocsPath; } - public static String getNativeCommandSuffix() - { + public static String getNativeCommandSuffix() { return nativeCommandSuffix; } - public static String getNativeLibrarySuffix() - { + public static String getNativeLibrarySuffix() { return nativeLibrarySuffix; } - public static String getUserProgramDataPath() - { + public static String getUserProgramDataPath() { return userProgramDataPath; } - public static String getTempFilesPath () { + public static String getTempFilesPath() { return tempFilesPath; } public static String getLogFilesPath() { - return logFilesPath; + return logFilesPath; } public static String getPlatformName() { return platformName; } - - public static String getUserSettings(){ + + public static String getUserSettings() { return userSettings; } - - public static String getRecentDocs(){ - return recentDocs; + + public static String getRecentDocs() { + return recentDocs; } public static Logger getLogger() { return logger; } -public static boolean multCommands () { -return multipleSubcommands; -} - public static String getStylePath(){ + public static boolean multCommands() { + return multipleSubcommands; + } + + public static String getStylePath() { return stylePath; } ======================================= --- /src/main/org/brailleblaster/Main.java Fri Aug 31 04:10:32 2012 +++ /src/main/org/brailleblaster/Main.java Tue Jan 15 05:17:47 2013 @@ -1,34 +1,33 @@ /* BrailleBlaster Braille Transcription Application - * - * Copyright (C) 2010, 2012 - * ViewPlus Technologies, Inc. www.viewplus.com - * and - * Abilitiessoft, Inc. www.abilitiessoft.com - * and - * American Printing House for the Blind, Inc. www.aph.org - * - * All rights reserved - * - * This file may contain code borrowed from files produced by various - * Java development teams. These are gratefully acknoledged. - * - * This file is free software; you can redistribute it and/or modify it - * under the terms of the Apache 2.0 License, as given at - * http://www.apache.org/licenses/ - * - * This file is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE - * See the Apache 2.0 License for more details. - * - * You should have received a copy of the Apache 2.0 License along with - * this program; see the file LICENSE. - * If not, see - * http://www.apache.org/licenses/ - * - * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx -*/ - + * + * Copyright (C) 2010, 2012 + * ViewPlus Technologies, Inc. www.viewplus.com + * and + * Abilitiessoft, Inc. www.abilitiessoft.com + * and + * American Printing House for the Blind, Inc. www.aph.org + * + * All rights reserved + * + * This file may contain code borrowed from files produced by various + * Java development teams. These are gratefully acknoledged. + * + * This file is free software; you can redistribute it and/or modify it + * under the terms of the Apache 2.0 License, as given at + * http://www.apache.org/licenses/ + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE + * See the Apache 2.0 License for more details. + * + * You should have received a copy of the Apache 2.0 License along with + * this program; see the file LICENSE. + * If not, see + * http://www.apache.org/licenses/ + * + * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx + */ package org.brailleblaster; @@ -37,30 +36,29 @@ import org.liblouis.liblouisutdml; /** -* This class contains the main method. If there are no arguments it -* passes control directly to the word processor. If there are arguments -* it passes them first to BBIni and then to Subcommands. -* It will do more processing as the project develops. -*/ + * This class contains the main method. If there are no arguments it passes+ * control directly to the word processor. If there are arguments it passes them + * first to BBIni and then to Subcommands. It will do more processing as the
+ * project develops. + */ public class Main { -public static void main (String[] args) { -BBIni.initialize(args); -BBIni.setVersion ("brailleblaster-1.4.0"); -BBIni.setReleaseDate ("July 17, 2012"); -if (BBIni.haveSubcommands()) { -new Subcommands(args); -} else { -new WPManager (null); -} -Display display = BBIni.getDisplay(); -if (display != null) -display.dispose(); -if (BBIni.haveLiblouisutdml()) -{ -liblouisutdml louisutdml = liblouisutdml.getInstance (); -louisutdml.free(); -} -} + public static void main(String[] args) { + BBIni.initialize(args); + BBIni.setVersion("brailleblaster-1.4.0"); + BBIni.setReleaseDate("July 17, 2012"); + if (BBIni.haveSubcommands()) { + new Subcommands(args); + } else { + new WPManager(null); + } + Display display = BBIni.getDisplay(); + if (display != null) + display.dispose(); + if (BBIni.haveLiblouisutdml()) { + liblouisutdml louisutdml = liblouisutdml.getInstance(); + louisutdml.free(); + } + } } =======================================--- /src/main/org/brailleblaster/util/FileUtils.java Fri Dec 7 21:16:07 2012 +++ /src/main/org/brailleblaster/util/FileUtils.java Tue Jan 15 05:17:47 2013
@@ -113,6 +113,12 @@ new Notify ("output file " + outputFileName + "could not be completed"); } + try { + inFile.close(); + } + catch (IOException e){ + e.printStackTrace(); + } } public boolean deleteDirectory(File directory) { =======================================--- /src/main/org/brailleblaster/wordprocessor/AbstractView.java Sun Jul 29 22:59:08 2012 +++ /src/main/org/brailleblaster/wordprocessor/AbstractView.java Tue Jan 15 05:17:47 2013
@@ -1,30 +1,30 @@ /* BrailleBlaster Braille Transcription Application - * - * Copyright (C) 2010, 2012 - * ViewPlus Technologies, Inc. www.viewplus.com - * and - * Abilitiessoft, Inc. www.abilitiessoft.com - * All rights reserved - * - * This file may contain code borrowed from files produced by various - * Java development teams. These are gratefully acknoledged. - * - * This file is free software; you can redistribute it and/or modify it - * under the terms of the Apache 2.0 License, as given at - * http://www.apache.org/licenses/ - * - * This file is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE - * See the Apache 2.0 License for more details. - * - * You should have received a copy of the Apache 2.0 License along with - * this program; see the file LICENSE. - * If not, see - * http://www.apache.org/licenses/ - * - * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx -*/ + * + * Copyright (C) 2010, 2012 + * ViewPlus Technologies, Inc. www.viewplus.com + * and + * Abilitiessoft, Inc. www.abilitiessoft.com + * All rights reserved + * + * This file may contain code borrowed from files produced by various + * Java development teams. These are gratefully acknoledged. + * + * This file is free software; you can redistribute it and/or modify it + * under the terms of the Apache 2.0 License, as given at + * http://www.apache.org/licenses/ + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE + * See the Apache 2.0 License for more details. + * + * You should have received a copy of the Apache 2.0 License along with + * this program; see the file LICENSE. + * If not, see + * http://www.apache.org/licenses/ + * + * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx + */ package org.brailleblaster.wordprocessor; @@ -38,42 +38,42 @@ import org.eclipse.swt.events.*; abstract class AbstractView { -StyledText view; -boolean hasFocus = false; -boolean hasChanged = false; + StyledText view; + boolean hasFocus = false; + boolean hasChanged = false; -AbstractView() {} + AbstractView() { + } -AbstractView (Shell documentWindow, int left, int right, int top, -int bottom) { -view = new StyledText (documentWindow, SWT.BORDER | SWT.H_SCROLL -| SWT.V_SCROLL | SWT.WRAP);+ AbstractView(Shell documentWindow, int left, int right, int top, int bottom) {
+ view = new StyledText(documentWindow, SWT.BORDER | SWT.H_SCROLL + | SWT.V_SCROLL | SWT.WRAP); -FormData location = new FormData(); -location.left = new FormAttachment(left); -location.right = new FormAttachment(right); -location.top = new FormAttachment (top); -location.bottom = new FormAttachment(bottom); -view.setLayoutData (location); + FormData location = new FormData(); + location.left = new FormAttachment(left); + location.right = new FormAttachment(right); + location.top = new FormAttachment(top); + location.bottom = new FormAttachment(bottom); + view.setLayoutData(location); -//view.addVerifyKeyListener (new VerifyKeyListener() { -//public void verifyKey (VerifyEvent event) { -//handleKeystrokes (event); -//} -//}); + // view.addVerifyKeyListener (new VerifyKeyListener() { + // public void verifyKey (VerifyEvent event) { + // handleKeystrokes (event); + // } + // }); -view.addModifyListener(viewMod); -} + view.addModifyListener(viewMod); + } -// Better use a ModifyListener to set the change flag. -ModifyListener viewMod = new ModifyListener () { - public void modifyText(ModifyEvent e) { - hasChanged = true; - } -}; + // Better use a ModifyListener to set the change flag. + ModifyListener viewMod = new ModifyListener() { + public void modifyText(ModifyEvent e) { + hasChanged = true; + } + }; -void handleKeystrokes (VerifyEvent event) { - hasChanged = true; - event.doit = true; - } + void handleKeystrokes(VerifyEvent event) { + hasChanged = true; + event.doit = true; + } } =======================================--- /src/main/org/brailleblaster/wordprocessor/BBMenu.java Mon Sep 24 03:06:59 2012 +++ /src/main/org/brailleblaster/wordprocessor/BBMenu.java Tue Jan 15 05:17:47 2013
@@ -422,7 +422,8 @@ stylePanelItem.setText(lh.localValue("&StylePanel")); stylePanelItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - dm.getStyleManager().stylePanel(); + //dm.getStyleManager().stylePanel(); + System.out.println("Empty method"); } }); =======================================--- /src/main/org/brailleblaster/wordprocessor/BrailleView.java Fri Jan 11 11:29:21 2013 +++ /src/main/org/brailleblaster/wordprocessor/BrailleView.java Tue Jan 15 05:17:47 2013
@@ -40,7 +40,7 @@ BrailleView (Shell documentWindow) { // super (documentWindow, 56, 100, 12, 92); - super (documentWindow, 50, 100, 12, 92); + super (documentWindow, 58, 100, 12, 92); } =======================================--- /src/main/org/brailleblaster/wordprocessor/DocumentManager.java Wed Jan 9 21:00:00 2013 +++ /src/main/org/brailleblaster/wordprocessor/DocumentManager.java Tue Jan 15 05:17:47 2013
@@ -1,33 +1,33 @@ /* BrailleBlaster Braille Transcription Application - * - * Copyright (C) 2010, 2012 - * ViewPlus Technologies, Inc. www.viewplus.com - * and - * Abilitiessoft, Inc. www.abilitiessoft.com - * and - * American Printing House for the Blind, Inc. www.aph.org - * - * All rights reserved - * - * This file may contain code borrowed from files produced by various - * Java development teams. These are gratefully acknoledged. - * - * This file is free software; you can redistribute it and/or modify it - * under the terms of the Apache 2.0 License, as given at - * http://www.apache.org/licenses/ - * - * This file is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE - * See the Apache 2.0 License for more details. - * - * You should have received a copy of the Apache 2.0 License along with - * this program; see the file LICENSE. - * If not, see - * http://www.apache.org/licenses/ - * - * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx -*/ + * + * Copyright (C) 2010, 2012 + * ViewPlus Technologies, Inc. www.viewplus.com + * and + * Abilitiessoft, Inc. www.abilitiessoft.com + * and + * American Printing House for the Blind, Inc. www.aph.org + * + * All rights reserved + * + * This file may contain code borrowed from files produced by various + * Java development teams. These are gratefully acknoledged. + * + * This file is free software; you can redistribute it and/or modify it + * under the terms of the Apache 2.0 License, as given at + * http://www.apache.org/licenses/ + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE + * See the Apache 2.0 License for more details. + * + * You should have received a copy of the Apache 2.0 License along with + * this program; see the file LICENSE. + * If not, see + * http://www.apache.org/licenses/ + * + * Maintained by John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx + */ package org.brailleblaster.wordprocessor; @@ -135,8 +135,9 @@ RecentDocuments rd; UTD utd; AbstractView activeView; - DaisyView daisy; + TextView daisy; BrailleView braille; + TreeView treeView; BBStatusBar statusBar; Document doc = null; NewDocument newDoc; @@ -181,12 +182,12 @@ StringBuilder daisyLine = new StringBuilder(10000); // character encoding for import static String encoding = null; - + static Logger logger; - + MediaType mediaType; - - final String[] compressed = {"application/zip", "application/epub+zip"}; + + final String[] compressed = { "application/zip", "application/epub+zip" }; public boolean isNimas; public boolean isEpub; @@ -212,15 +213,16 @@ menu = new BBMenu(this); toolBar = new BBToolBar(this); /* text window is on the left */ - daisy = new DaisyView(documentWindow); + daisy = new TextView(documentWindow); braille = new BrailleView(documentWindow); - + treeView = new TreeView(documentWindow); logger = BBIni.getLogger(); // activeView = (ProtoView)daisy; statusBar = new BBStatusBar(documentWindow); documentWindow.setSize(1000, 700); documentWindow.layout(true, true); + documentWindow.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { @@ -282,7 +284,7 @@ new Notify(lh.localValue("fontNotLoadedBraille")); } } - + if (Courier) { daisyFont = new Font(documentWindow.getDisplay(), courierFont, daisyFontHeight, SWT.NORMAL); @@ -312,12 +314,15 @@ String loc = lh.getLocale().toString(); if (!loc.contentEquals(lh.localValue("localeResource"))) {- logger.log(Level.WARNING, "Locale resource for " + loc + " not found. Using default."); -// System.err.println("Locale resource for '" + lh.getLocale().getDisplayName() +
-// "' not found. Using default.");-// new Notify("Locale resource for '" + lh.getLocale().getDisplayName() + "' not found.");
+ logger.log(Level.WARNING, "Locale resource for " + loc + + " not found. Using default."); + // System.err.println("Locale resource for '" + + // lh.getLocale().getDisplayName() + + // "' not found. Using default."); + // new Notify("Locale resource for '" + + // lh.getLocale().getDisplayName() + "' not found."); } - + switch (action) { case WP.OpenDocumentGetFile: fileOpen(); @@ -333,21 +338,21 @@ brailleFileName = getBrailleFileName(); openDocument(documentName); if (ext.contentEquals("utd")) { -// BBIni.setUtd(true); + // BBIni.setUtd(true); utd.displayTranslatedFile(documentName, brailleFileName); braille.hasChanged = false; } daisy.hasChanged = false; - } else if (arcType != null ) { - importZip(arcType); - daisy.hasChanged = true; - + } else if (arcType != null) { + importZip(arcType); + daisy.hasChanged = true; + } else { if (ext.contentEquals("brf")) { openBrf(documentName); setWindowTitle("untitled"); - } else { - parseImport(documentName, getEncodingString()); + } else { + parseImport(documentName, getEncodingString()); setWindowTitle(documentName); } daisy.hasChanged = true; @@ -483,7 +488,7 @@ daisy.hasChanged = false; braille.hasChanged = false; doc = null; -// BBIni.setUtd(false); + // BBIni.setUtd(false); setWindowTitle(" untitled"); daisy.view.setFocus(); } else { @@ -525,10 +530,10 @@ Shell shell = new Shell(display, SWT.DIALOG_TRIM); FileDialog dialog = new FileDialog(shell, SWT.OPEN); String filterPath = "/"; - String[] filterNames = new String[] { "XML", "TEXT", - "BRF", "UTDML working document", }; - String[] filterExtensions = new String[] { "*.xml", - "*.txt", "*.brf", "*.utd", }; + String[] filterNames = new String[] { "XML", "TEXT", "BRF", + "UTDML working document", }; + String[] filterExtensions = new String[] { "*.xml", "*.txt", "*.brf", + "*.utd", }; String platform = SWT.getPlatform(); if (platform.equals("win32") || platform.equals("wpf")) { @@ -574,7 +579,7 @@ daisy.hasChanged = false; braille.hasChanged = false; doc = null; -// BBIni.setUtd(false); + // BBIni.setUtd(false); } if (doc != null) { @@ -600,23 +605,23 @@ brailleFileName = getBrailleFileName(); openDocument(documentName); if (ext.contentEquals("utd")) { -// BBIni.setUtd(true); + // BBIni.setUtd(true); utd.displayTranslatedFile(documentName, brailleFileName); braille.hasChanged = false; } daisy.hasChanged = false; - + } else if (arcType != null) { importZip(arcType); } else { if (ext.contentEquals("brf")) { openBrf(documentName); setWindowTitle("untitled"); - } else { - parseImport(documentName, getEncodingString()); + } else { + parseImport(documentName, getEncodingString()); setWindowTitle(documentName); - } + } } daisy.view.setFocus(); } @@ -624,7 +629,7 @@ void openDocument(String fileName) { stopRequested = false; - + Builder parser = new Builder(); try { doc = parser.build(new File(fileName)); @@ -636,38 +641,39 @@ return; } // add this file to recentDocList- if ( !((fileName.contains("-tempdoc.xml")) || (fileName.contains(tempPath))) ) {
- rd.addDocument(fileName); + if (!((fileName.contains("-tempdoc.xml")) || (fileName + .contains(tempPath)))) { + rd.addDocument(fileName); }- if ((getFileExt(fileName).contentEquals("brf")) || (getFileExt(fileName).contentEquals("brl"))) {
+ if ((getFileExt(fileName).contentEquals("brf")) + || (getFileExt(fileName).contentEquals("brl"))) { setWindowTitle("untitled"); } else { - setWindowTitle(fileName); - haveOpenedFile = true; + setWindowTitle(fileName); + haveOpenedFile = true; } numLines = 0; numChars = 0; statusBar.setText(lh.localValue("loadingDocument") + " " + fileName); daisyLine.delete(0, daisyLine.length()); - + final Element rootElement = doc.getRootElement();// this needs to be // final, because it // will be used by a // different thread new Thread() { - public void run() { - while (!stopRequested) { - walkTree(rootElement); - } - } - } - .start(); + public void run() { + while (!stopRequested) { + walkTree(rootElement); + } + } + }.start(); } private void walkTree(Node node) { Node newNode; - + for (int i = 0; i < node.getChildCount(); i++) { newNode = node.getChild(i); @@ -675,31 +681,32 @@ walkTree(newNode); } else if (newNode instanceof Text) { String nname = ((Element) node).getLocalName();- if (!(nname.matches("span") || nname.matches("brl") || nname.matches("body") || nname.matches("title"))) {
+ if (!(nname.matches("span") || nname.matches("brl") + || nname.matches("body") || nname.matches("title"))) { final String value = newNode.getValue(); numLines++; numChars += value.length(); daisyLine.append(value + '\n'); } - + // the main thread gets to execute the block inside syncExec() if (daisyLine.length() > 8192 || i == node.getChildCount() - 1) { display.syncExec(new Runnable() { public void run() { daisy.view.append(daisyLine.toString()); - statusBar.setText("Read " + numLines + " lines, " + numChars - + " characters."); + statusBar.setText("Read " + numLines + " lines, " + + numChars + " characters."); } }); - daisyLine.delete(0, daisyLine.length()); - daisy.hasChanged = false; + daisyLine.delete(0, daisyLine.length()); + daisy.hasChanged = false; } } } stopRequested = true; } - + void openTikaDocument(String fileName) { stopRequested = false; @@ -708,11 +715,12 @@ doc = parser.build(new File(fileName)); } catch (ParsingException e) {- logger.log(Level.SEVERE, lh.localValue("malformedDocument: " + fileName));
+ logger.log(Level.SEVERE, + lh.localValue("malformedDocument: " + fileName)); logger.log(Level.INFO, e.getMessage()); new Notify(lh.localValue("malformedDocument") + "\n" + fileName); -// e.getStackTrace(); + // e.getStackTrace(); return; } catch (IOException e) { new Notify(lh.localValue("couldNotOpen") + " " + fileName); @@ -720,25 +728,24 @@ } statusBar.setText(lh.localValue("loadingDocument") + " " + fileName);- final Element rootElement = doc.getRootElement();// this needs to be final
+ final Element rootElement = doc.getRootElement();// this needs to be + // final // use thread only for single-file documents - if (!(isNimas || isEpub) ) { + if (!(isNimas || isEpub)) { new Thread() { - public void run() { - while (!stopRequested) { - walkTikaTree(rootElement); - } - } - } - .start(); - } else { - while (!stopRequested) { - walkTikaTree(rootElement); - } - } - } - + public void run() { + while (!stopRequested) { + walkTikaTree(rootElement); + } + } + }.start(); + } else { + while (!stopRequested) { + walkTikaTree(rootElement); + } + } + } private void walkTikaTree(Node node) { Node newNode; @@ -764,8 +771,8 @@ String value = newNode.getValue() + "\n"; // replace Unicode with matching codepoints - Matcher matcher = Pattern.compile("\\\\u((?i)[0-9a-fA-F]{4})") - .matcher(value); + Matcher matcher = Pattern.compile( + "\\\\u((?i)[0-9a-fA-F]{4})").matcher(value); StringBuffer sb = new StringBuffer(); int codepoint; while (matcher.find()) { @@ -780,17 +787,18 @@ numChars += value.length(); daisyLine.append(value); - }; - + } + ; + if (daisyLine.length() > 4096 || i == node.getChildCount() - 1) { display.syncExec(new Runnable() { public void run() { daisy.view.append(daisyLine.toString()); - statusBar.setText("Read " + numChars + statusBar.setText("Read " + numChars + " characters."); } }); - + daisyLine.delete(0, daisyLine.length()); } } @@ -903,12 +911,12 @@ dialog.setFileName(documentName); } else { if (documentName != null) { - if (getFileExt(documentName).contentEquals("brf")) { - saveDaisyWorkFile(); - int i = documentName.lastIndexOf("."); - String fn = documentName.substring(0, i); - newDaisyFile = fn + ".xml"; - } + if (getFileExt(documentName).contentEquals("brf")) { + saveDaisyWorkFile(); + int i = documentName.lastIndexOf("."); + String fn = documentName.substring(0, i); + newDaisyFile = fn + ".xml"; + } } dialog.setFileName(newDaisyFile); } @@ -921,7 +929,7 @@ String fileName = new File(saveTo).getName(); statusBar.setText(lh.localValue("savingFile") + " " + fileName); - + /* text and braille utd */ if (textAndBraille) { if (translatedFileName == null) { @@ -940,7 +948,6 @@ statusBar.setText(lh.localValue("fileSaved") + " " + saveTo); documentWindow.setText("BrailleBlaster " + fileName); - if (!textAndBraille) { translatedFileName = null; braille.view.replaceTextRange(0, braille.view.getCharCount(), ""); @@ -952,7 +959,7 @@ void fileClose() { if (daisy.view == null) { logger.log(Level.SEVERE, "fileCLose() - something wrong!!!"); -// System.err.println("fileCLose() - something wrong!!!"); + // System.err.println("fileCLose() - something wrong!!!"); return; } activateMenus(false); @@ -967,7 +974,7 @@ brailleFileName = null; documentName = null; doc = null; -// BBIni.setUtd(false); + // BBIni.setUtd(false); stopRequested = false; statusBar.setText(""); daisy.view.setText(""); @@ -991,7 +998,7 @@ firstTime = true; boolean eof = false; String line; - + while (!eof) { try { line = translation.readLine(); @@ -1002,7 +1009,7 @@ + translatedFileName); return; } - + if (line == null) { eof = true; } else { @@ -1072,7 +1079,8 @@ outputDoc.write(doc); outputDoc.flush(); } catch (IOException e) {- logger.log(Level.SEVERE, lh.localValue("cannotWriteFile") + ": " + daisyWorkFile);
+ logger.log(Level.SEVERE, lh.localValue("cannotWriteFile") + ": " + + daisyWorkFile); new Notify(lh.localValue("cannotWriteFile")); return; } @@ -1093,10 +1101,10 @@ saveDaisyWorkFile(); - /*if (!BBIni.useUtd()) */ { + /* if (!BBIni.useUtd()) */{ YesNoChoice ync = new YesNoChoice(lh.localValue("askUtdml")); if (ync.result == SWT.YES) { -// BBIni.setUtd(true); + // BBIni.setUtd(true); } } translate(display); @@ -1105,7 +1113,7 @@ void translate(boolean display) { configFileList = "preferences.cfg"; configSettings = null; - /*if (BBIni.useUtd())*/ { + /* if (BBIni.useUtd()) */{ configSettings = "formatFor utd\n" + "mode notUC\n"; } @@ -1120,7 +1128,7 @@ return; } - /*if (!BBIni.useUtd())*/ { + /* if (!BBIni.useUtd()) */{ brailleFileName = getBrailleFileName(); new FileUtils().copyFile(translatedFileName, brailleFileName); } @@ -1129,18 +1137,14 @@ braille.hasChanged = true; if (display) { - /*if (BBIni.useUtd())*/ { + /* if (BBIni.useUtd()) */{ brailleFileName = getBrailleFileName(); utd.displayTranslatedFile(translatedFileName, brailleFileName); - } -/* else { - new Thread() { - public void run() { - showBraille(); - } - }.start(); } - */ + /* + * else { new Thread() { public void run() { showBraille(); } + * }.start(); } + */ } } @@ -1181,17 +1185,18 @@ embosserDevice = new PrinterDevice(data.name, true); embosserDevice.transmit(translatedFile); } catch (PrintException e) {- new Notify(lh.localValue("cannotEmboss") + ": " + data.name + "\n" + e.getMessage());
+ new Notify(lh.localValue("cannotEmboss") + ": " + data.name + "\n" + + e.getMessage()); } } - + void daisyPrint() { - + PrintersManager pn = new PrintersManager(daisy.view.getText()); pn.printText(); - -// placeholder(); -} + + // placeholder(); + } void toggleBrailleFont() { if (displayBrailleFont) { @@ -1287,7 +1292,7 @@ documentName = null; daisy.hasChanged = false; doc = null; -// BBIni.setUtd(false); + // BBIni.setUtd(false); setWindowTitle(" untitled"); daisy.view.setFocus(); } @@ -1304,22 +1309,18 @@ Shell shell = new Shell(display, SWT.DIALOG_TRIM); FileDialog dialog = new FileDialog(shell, SWT.OPEN); String filterPath = System.getProperty("user.home"); - String[] filterNames = new String[] { "ASCII Text", - "NIMAS archive (ZIP)", - "EPUB Book", - "Word Doc", "Word Docx", - "Rich Text Format", "Braille BRF", "OpenOffice ODT", "PDF", "XML", - "All Files (*)" }; - String[] filterExtensions = new String[] { "*.txt", - "*.zip", "*.epub", - "*.doc", "*.docx", - "*.rtf", "*.brf", "*.odt", "*.pdf", "*.xml", + String[] filterNames = new String[] { "ASCII Text", + "NIMAS archive (ZIP)", "EPUB Book", "Word Doc", "Word Docx", + "Rich Text Format", "Braille BRF", "OpenOffice ODT", "PDF", + "XML", "All Files (*)" }; + String[] filterExtensions = new String[] { "*.txt", "*.zip", "*.epub", + "*.doc", "*.docx", "*.rtf", "*.brf", "*.odt", "*.pdf", "*.xml", "*" }; String platform = SWT.getPlatform(); if (platform.equals("win32") || platform.equals("wpf")) { - filterNames[filterNames.length-1] = "All Files (*.*)"; - filterExtensions[filterExtensions.length-1] = "*.*"; + filterNames[filterNames.length - 1] = "All Files (*.*)"; + filterExtensions[filterExtensions.length - 1] = "*.*"; filterPath = System.getProperty("user.home"); if (filterPath == null) filterPath = "c:\\"; @@ -1339,7 +1340,7 @@ // add this file to recentDocList rd.addDocument(documentName); - + numLines = 0; numChars = 0; @@ -1347,12 +1348,12 @@ isEpub = false; String arcType = archiveType(documentName); - if (arcType != null) { - importZip(arcType); - return; - } - - // special case + if (arcType != null) { + importZip(arcType); + return; + } + + // special case if (getFileExt(documentName).contentEquals("brf")) { openBrf(documentName); setWindowTitle("untitled"); @@ -1365,126 +1366,129 @@ daisy.hasChanged = true; daisy.view.setFocus(); } - + void importZip(String arcType) { - String [] arc = null; -- statusBar.setText(lh.localValue("loadingFile") + " " + documentName + ", " + arcType );
- + String[] arc = null; + + statusBar.setText(lh.localValue("loadingFile") + " " + documentName + + ", " + arcType); + try { - ImportersManager im = new ImportersManager(documentName, tempPath, + ImportersManager im = new ImportersManager(documentName, tempPath, docID, arcType); arc = im.extractPubFiles(); isNimas = im.isNimas(); isEpub = im.isEpub(); encoding = im.getEncoding(); - + } catch (IOException e) { - logger.log(Level.SEVERE, "ImportersManager IOException: " - + e.getMessage()); -// System.err.println("ImportersManager IOException: " -// + e.getMessage()); - new Notify(lh.localValue("couldNotOpen") + ":\n" + documentName + - "\n" + e.getMessage()); + logger.log(Level.SEVERE, + "ImportersManager IOException: " + e.getMessage()); + // System.err.println("ImportersManager IOException: " + // + e.getMessage()); + new Notify(lh.localValue("couldNotOpen") + ":\n" + documentName + + "\n" + e.getMessage()); } catch (Exception e) { - logger.log(Level.SEVERE, "ImportersManager IOException: " - + e.getMessage()); -// System.err.println("ImportersManager exception: " + e.getMessage()); - new Notify(lh.localValue("couldNotOpen") + ":\n" + documentName ); - } - + logger.log(Level.SEVERE, + "ImportersManager IOException: " + e.getMessage()); + // System.err.println("ImportersManager exception: " + + // e.getMessage()); + new Notify(lh.localValue("couldNotOpen") + ":\n" + documentName); + } + if (arc == null) { - new Notify(lh.localValue("problemReading") + ":\n" + documentName ); + new Notify(lh.localValue("problemReading") + ":\n" + documentName); return; } statusBar.setText(lh.localValue("importCompleted")); - + String path = null; String xslFile = "";- String xslPath = BBIni.getProgramDataPath() + BBIni.getFileSep() + "xsl" + BBIni.getFileSep();
- if (isNimas) { - xslFile = xslPath + "nimas.xsl"; - } else if (isEpub) { - xslFile = xslPath + "epub.xsl"; - } + String xslPath = BBIni.getProgramDataPath() + BBIni.getFileSep() + + "xsl" + BBIni.getFileSep(); + if (isNimas) { + xslFile = xslPath + "nimas.xsl"; + } else if (isEpub) { + xslFile = xslPath + "epub.xsl"; + } - String outFile; - XSLtransformer xsl = new XSLtransformer(); - int i = 0; - while ( i < arc.length) { - if (arc[i] != null) { - daisyWorkFile = tempPath + arc[i]; -- outFile = tempPath + docID + "-" + (new File(daisyWorkFile).getName());
- - xsl.transformXml(xslFile, daisyWorkFile, outFile); - openTikaDocument(outFile); - - File d = new File (daisyWorkFile); - if (path == null) path = d.getParentFile().getPath(); - d.delete(); - d = new File(outFile); - d.delete(); - } - i++; + String outFile; + XSLtransformer xsl = new XSLtransformer(); + int i = 0; + while (i < arc.length) { + if (arc[i] != null) { + daisyWorkFile = tempPath + arc[i]; + + outFile = tempPath + docID + "-" + + (new File(daisyWorkFile).getName()); + + xsl.transformXml(xslFile, daisyWorkFile, outFile); + openTikaDocument(outFile); + + File d = new File(daisyWorkFile); + if (path == null) + path = d.getParentFile().getPath(); + d.delete(); + d = new File(outFile); + d.delete(); + } + i++; } - - if (!path.contentEquals(tempPath)) removeDirectory(new File (path)); + + if (!path.contentEquals(tempPath)) + removeDirectory(new File(path)); if (isEpub) { - removeDirectory (new File (tempPath + "META-INF")); - removeDirectory (new File (tempPath + "OEBPS")); + removeDirectory(new File(tempPath + "META-INF")); + removeDirectory(new File(tempPath + "OEBPS")); } - - haveOpenedFile=false; - documentName = null; - daisyWorkFile = null; + + haveOpenedFile = false; + documentName = null; + daisyWorkFile = null; } - + public boolean removeDirectory(File directory) { - // System.out.println("removeDirectory " + directory); + // System.out.println("removeDirectory " + directory); - if (directory == null) - return false; - if (!directory.exists()) - return true; - if (!directory.isDirectory()) - return false; + if (directory == null) + return false; + if (!directory.exists()) + return true; + if (!directory.isDirectory()) + return false; - String[] list = directory.list(); + String[] list = directory.list(); - // Some JVMs return null for File.list() when the - // directory is empty. - if (list != null) { - for (int i = 0; i < list.length; i++) { - File entry = new File(directory, list[i]); + // Some JVMs return null for File.list() when the + // directory is empty. + if (list != null) { + for (int i = 0; i < list.length; i++) { + File entry = new File(directory, list[i]); - if (entry.isDirectory()) - { - if (!removeDirectory(entry)) - return false; - } - else - { - if (!entry.delete()) - return false; - } - } - } - return directory.delete(); + if (entry.isDirectory()) { + if (!removeDirectory(entry)) + return false; + } else { + if (!entry.delete()) + return false; + } + } + } + return directory.delete(); } - + void parseImport(String fileName, String encoding) { /** Tika extract **/ try { useTikaParser(fileName, encoding); } catch (ParserConfigurationException e) { logger.log(Level.SEVERE, "Error importing: " + fileName); -// System.err.println("Error importing: " + fileName); + // System.err.println("Error importing: " + fileName); return; } catch (Exception e) { logger.log(Level.SEVERE, "Error importing: " + fileName); -// System.err.println("Error importing: " + fileName); + // System.err.println("Error importing: " + fileName); return; } @@ -1503,10 +1507,12 @@ try { workFile.createNewFile(); } catch (IOException e) {- logger.log(Level.SEVERE, "useTikaHtmlParser: Error creating Tika workfile " +
- tikaWorkFile + " " + e.getMessage());-// System.out.println("useTikaHtmlParser: Error creating Tika workfile " +
-// e.getMessage()); + logger.log(Level.SEVERE, + "useTikaHtmlParser: Error creating Tika workfile " + + tikaWorkFile + " " + e.getMessage()); + // System.out.println("useTikaHtmlParser: Error creating Tika workfile " + // + + // e.getMessage()); return; } @@ -1526,20 +1532,20 @@ encoding); parser.parse(stream, handler, metadata, context); } catch (IOException e) { - logger.log(Level.SEVERE, "useTikaHtmlParser IOException: " - + e.getMessage()); -// System.err.println("useTikaHtmlParser IOException: " -// + e.getMessage()); + logger.log(Level.SEVERE, + "useTikaHtmlParser IOException: " + e.getMessage()); + // System.err.println("useTikaHtmlParser IOException: " + // + e.getMessage()); } catch (SAXException e) { - logger.log(Level.SEVERE, "useTikaHtmlParser IOException: " - + e.getMessage()); -// System.err.println("useTikaHtmlParser SAXException: " -// + e.getMessage()); + logger.log(Level.SEVERE, + "useTikaHtmlParser IOException: " + e.getMessage()); + // System.err.println("useTikaHtmlParser SAXException: " + // + e.getMessage()); } catch (TikaException e) { - logger.log(Level.SEVERE, "useTikaHtmlParser IOException: " - + e.getMessage()); -// System.err.println("useTikaHtmlParser TikaException: " -// + e.getMessage()); + logger.log(Level.SEVERE, + "useTikaHtmlParser IOException: " + e.getMessage()); + // System.err.println("useTikaHtmlParser TikaException: " + // + e.getMessage()); } finally { stream.close(); output.close(); @@ -1593,26 +1599,25 @@ // plain BRF file to back-translate void openBrf(String fileName) { translatedFileName = getBrailleFileName(); - new FileUtils().copyFile (fileName, translatedFileName); + new FileUtils().copyFile(fileName, translatedFileName); showBraille(); - + // backtranslate -// BBIni.setUtd(false) ; + // BBIni.setUtd(false) ; configFileList = "backtranslate.cfg"; - configSettings = "mode notUc\n" ; + configSettings = "mode notUc\n"; daisyWorkFile = tempPath + docID + "-tempdoc.xml"; - - boolean result = louisutdml.backTranslateFile(configFileList, - fileName, daisyWorkFile, logFile, configSettings, - mode); + + boolean result = louisutdml.backTranslateFile(configFileList, fileName, + daisyWorkFile, logFile, configSettings, mode); if (!result) { new Notify(lh.localValue("translationFailed")); return; } - + openDocument(daisyWorkFile); haveOpenedFile = false; } @@ -1671,30 +1676,30 @@ return ext; } - private String archiveType (String doc) { + private String archiveType(String doc) { Tika tika = new Tika(); File inFile = new File(doc); - String type = ""; - try { - type = tika.detect(inFile); - } catch (IOException e) {- logger.log(Level.SEVERE, "Error detecting " + inFile.getName() + ":\n" + e.getMessage());
-// System.err.println(inFile.getName() + ":\n" + e.getMessage()); - new Notify(lh.localValue("couldNotOpen") + ":\n" + inFile.getName() + - "\n" + e.getLocalizedMessage()); - return null; - } + String type = ""; + try { + type = tika.detect(inFile); + } catch (IOException e) { + logger.log(Level.SEVERE, "Error detecting " + inFile.getName() + + ":\n" + e.getMessage()); + // System.err.println(inFile.getName() + ":\n" + e.getMessage()); + new Notify(lh.localValue("couldNotOpen") + ":\n" + inFile.getName() + + "\n" + e.getLocalizedMessage()); + return null; + } - for (int i=0; i<compressed.length; i++) { - if (type.contentEquals(compressed[i])) { -// System.out.println(type); - return type; - } - } - return null; + for (int i = 0; i < compressed.length; i++) { + if (type.contentEquals(compressed[i])) { + // System.out.println(type); + return type; + } + } + return null; } - ***The diff for this file has been truncated for email.*** =======================================--- /src/main/org/brailleblaster/wordprocessor/TextView.java Fri Jan 11 05:59:27 2013 +++ /src/main/org/brailleblaster/wordprocessor/TextView.java Tue Jan 15 05:17:47 2013
@@ -40,7 +40,7 @@ TextView (Shell documentWindow) { // super (documentWindow, 0, 55, 12, 92); -super (documentWindow, 0, 49, 12, 92); +super (documentWindow, 16, 57, 12, 92); } ============================================================================== Revision: 5a41e00195d0 Branch: default Author: Brandon Roller <brandon.r.roller@xxxxxxxxx> Date: Tue Jan 15 05:21:46 2013 Log: Added TreeView class, changed Text and Braille View width http://code.google.com/p/brailleblaster/source/detail?r=5a41e00195d0&repo=newdesign