Revision: 572aa917f1f8 Author: John Boyer <john.boyer@xxxxxxxxxxxxxxxxx> Date: Sat Jul 14 09:31:47 2012Log: Added CheckLiblouisutdmlLog class; subcommands now show log on console
http://code.google.com/p/brailleblaster/source/detail?r=572aa917f1f8 Added: /src/main/org/brailleblaster/util/CheckLiblouisutdmlLog.java Deleted: /src/main/org/brailleblaster/util/CheckLogFile.java Modified: /src/main/org/brailleblaster/Subcommands.java ======================================= --- /dev/null+++ /src/main/org/brailleblaster/util/CheckLiblouisutdmlLog.java Sat Jul 14 09:31:47 2012
@@ -0,0 +1,121 @@ +/* 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 +*/ + +package org.brailleblaster.util; + +import org.eclipse.swt.*; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.MessageBox; +import org.brailleblaster.BBIni; +import org.brailleblaster.localization.LocaleHandler; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.FileNotFoundException; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.BufferedReader; + +/** + * Check the file liblouisutdml.log in brlblst/temp. If it is not empty + * show its contents. There are separate methods for the GUI and the + * command line. + */ +public class CheckLiblouisutdmlLog { +String logFileName; + +public CheckLiblouisutdmlLog () { +logFileName = BBIni.getTempFilesPath() + BBIni.getFileSep() + +"liblouisutdml.log"; +} + +public void displayLog () { +StringBuilder logMessages = new StringBuilder (4096); +Display display = BBIni.getDisplay(); +Shell shell = new Shell(display, SWT.DIALOG_TRIM); +MessageBox mb = new MessageBox(shell, SWT.OK); +String line; +BufferedReader logStream = null; +try { +logStream = new BufferedReader (new FileReader +(logFileName)); +} catch (FileNotFoundException e) { +new Notify ("Could not find " + logFileName); +} +while(true) { +try { +line = logStream.readLine(); +} catch (IOException e) { +new Notify ("Problem reading " + logFileName); +return; +} +if (line == null) { +break; +} +logMessages.append (line); +} +try { +logStream.close(); +} catch (IOException e) { +} +if (logMessages.length() > 0) { +mb.setMessage (logMessages.toString()); +mb.open(); +} +shell.dispose(); +} + +public void showLog () { +String line; +BufferedReader logStream = null; +try { +logStream = new BufferedReader (new FileReader +(logFileName)); +} catch (FileNotFoundException e) { +new Notify ("Could not find " + logFileName); +} +while(true) { +try { +line = logStream.readLine(); +} catch (IOException e) { +new Notify ("Problem reading " + logFileName); +return; +} +if (line == null) { +break; +} +System.out.println (line); +} +try { +logStream.close(); +} catch (IOException e) { +} +} + +} =======================================--- /src/main/org/brailleblaster/util/CheckLogFile.java Wed Jul 11 21:04:00 2012
+++ /dev/null @@ -1,61 +0,0 @@ -/* 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 -*/ - -package org.brailleblaster.util; - -import org.eclipse.swt.*; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.MessageBox; -import org.brailleblaster.BBIni; -import org.brailleblaster.localization.LocaleHandler; - -/** - * Check the file liblouisutdml.log in brlblst/temp. If it is not empty - * show its contents. There are separate methods for the GUI and the - * command line. - */ -public class CheckLogFile { - -public CheckLogFile () { -} - -public void displayLog () { -String logMessages = null; -Display display = BBIni.getDisplay(); -Shell shell = new Shell(display, SWT.DIALOG_TRIM); -MessageBox mb = new MessageBox(shell, SWT.OK); -mb.setMessage (logMessages); -mb.open(); -shell.dispose(); -} - -public void showLog () { -} - -} ======================================= --- /src/main/org/brailleblaster/Subcommands.java Mon Jul 9 02:19:57 2012 +++ /src/main/org/brailleblaster/Subcommands.java Sat Jul 14 09:31:47 2012 @@ -28,6 +28,7 @@ package org.brailleblaster; +import org.brailleblaster.util.CheckLiblouisutdmlLog; import org.brailleblaster.wordprocessor.WPManager; import org.brailleblaster.localization.LocaleHandler; import org.brailleblaster.util.ProgramCaller; @@ -52,6 +53,7 @@ private Logger logger = BBIni.getLogger(); private LocaleHandler lh = new LocaleHandler (); private liblouisutdml louisutdml; +private CheckLiblouisutdmlLog lbuLog = new CheckLiblouisutdmlLog(); private String subcommand; private String[] subArgs; @@ -103,6 +105,7 @@ */ private void doTranslate() { louisutdml.file2brl (subArgs); +lbuLog.showLog(); } /** @@ -125,6 +128,7 @@ } catch (PrintException e) { logger.log (Level.SEVERE, "Embosser is not working", e); } +lbuLog.showLog(); } private void doChecktable() { @@ -136,12 +140,8 @@ if (subArgs.length > 1) { logFile = subArgs[1]; } -if (louisutdml.checkTable (subArgs[0], logFile, 0)) { -System.out.println ("No errors found"); -} -else { -System.out.println ("This table will not work."); -} +louisutdml.checkTable (subArgs[0], logFile, 0); +lbuLog.showLog(); } private void doHelp() {