From f64bae8ea658cf95b1ebd20443df77d5857a6828 Mon Sep 17 00:00:00 2001 From: amontano Date: Fri, 13 May 2005 04:25:59 +0000 Subject: [PATCH] Fixed loading default dictionary at the beginning of the installed stand-alone version but making it easily changeable if the user selects another dictionary. --- .../tib/scanner/SwingWindowScannerFilter.java | 52 +++++++++++++++---- .../thdl/tib/scanner/WindowScannerFilter.java | 27 ++++------ 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/source/org/thdl/tib/scanner/SwingWindowScannerFilter.java b/source/org/thdl/tib/scanner/SwingWindowScannerFilter.java index ea1649b..819adfa 100644 --- a/source/org/thdl/tib/scanner/SwingWindowScannerFilter.java +++ b/source/org/thdl/tib/scanner/SwingWindowScannerFilter.java @@ -19,11 +19,8 @@ Contributor(s): ______________________________________. package org.thdl.tib.scanner; import java.awt.*; -import java.util.*; import java.io.*; import java.awt.event.*; -import java.applet.Applet; -import java.awt.*; import java.awt.datatransfer.*; import javax.swing.text.*; import javax.swing.*; @@ -45,7 +42,8 @@ import org.thdl.util.*; */ public class SwingWindowScannerFilter extends WindowScannerFilter { - + private static String firstTimeOption = "thdl.scanner.first.time"; + public SwingWindowScannerFilter() { super(); @@ -196,21 +194,53 @@ public class SwingWindowScannerFilter extends WindowScannerFilter } } + public static void printSyntax() + { + System.out.println("Sintaxis: java SwingWindowScannerFilter [-firsttime] [arch-dict]"); + System.out.println(TibetanScanner.copyrightASCII); + } + public static void main(String[] args) { - String os; + String response; + switch(args.length) { case 0: - new SwingWindowScannerFilter(); - break; + new SwingWindowScannerFilter(); + break; case 1: - new SwingWindowScannerFilter(args[0]); - break; + new SwingWindowScannerFilter(args[0]); + break; + case 2: + if (args[0].equals("-firsttime")) + { + response = ThdlOptions.getStringOption(firstTimeOption); + if (response==null || response.equals("") || !response.equals("no")) + { + ThdlOptions.setUserPreference(defOpenOption, args[1]); + ThdlOptions.setUserPreference(dictOpenType, "local"); + ThdlOptions.setUserPreference(firstTimeOption, "no"); + try + { + ThdlOptions.saveUserPreferences(); + } + catch (Exception e) + { + } + new SwingWindowScannerFilter(args[1]); + } + else new SwingWindowScannerFilter(); + } + else + { + System.out.println("Syntax error! Invalid option."); + printSyntax(); + } + break; default: System.out.println("Syntax error!"); - System.out.println("Sintaxis: java SwingWindowScannerFilter [arch-dict]"); - System.out.println(TibetanScanner.copyrightASCII); + printSyntax(); } } diff --git a/source/org/thdl/tib/scanner/WindowScannerFilter.java b/source/org/thdl/tib/scanner/WindowScannerFilter.java index 552b61a..d27dcfa 100644 --- a/source/org/thdl/tib/scanner/WindowScannerFilter.java +++ b/source/org/thdl/tib/scanner/WindowScannerFilter.java @@ -19,12 +19,7 @@ Contributor(s): ______________________________________. package org.thdl.tib.scanner; import java.awt.*; -import java.util.*; -import java.io.*; import java.awt.event.*; -import java.applet.Applet; -import java.awt.*; -import java.awt.datatransfer.*; import org.thdl.util.*; /** Provides a graphical interfase to input Tibetan text (Roman or @@ -59,17 +54,17 @@ public abstract class WindowScannerFilter implements WindowListener, FocusListen { String response, dictType; WhichDictionaryFrame wdf; + mainWindow = null; - mainWindow = null; - response = ThdlOptions.getStringOption(defOpenOption); - - if (response==null || response.equals("")) + if (argument!=null && !argument.equals("")) { - if (argument!=null && !argument.equals("")) - { - response = argument; - } - else + response = argument; + } + else + { + response = ThdlOptions.getStringOption(defOpenOption); + + if (response==null || response.equals("")) { mainWindow = new Frame("Tibetan Translation Tool"); mainWindow.show(); @@ -100,8 +95,8 @@ public abstract class WindowScannerFilter implements WindowListener, FocusListen { } } - } - } + } + } } makeWindow (response); }