ICU-5605 fix design issues and clean up source

X-SVN-Rev: 21150
This commit is contained in:
Ram Viswanadha 2007-03-02 19:38:08 +00:00
parent f65edbb549
commit 04a3e5c0c7
10 changed files with 160 additions and 61 deletions

View File

@ -6,10 +6,18 @@
*/
package com.ibm.icu.dev.tool.tzu;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
import com.ibm.icu.dev.tool.UOption;
import java.util.*;
import java.io.*;
import java.net.*;
public class CLILoader {
public static void main(String[] args) {
@ -35,13 +43,16 @@ public class CLILoader {
showHelp();
return;
}
try{
// init the logger
logger = Logger.initLogger(Logger.DEFAULT_FILENAME,
logger = Logger.getInstance(Logger.DEFAULT_FILENAME,
options[QUIET].doesOccur ? Logger.QUIET
: options[VERBOSE].doesOccur ? Logger.VERBOSE
: Logger.NORMAL);
}catch(FileNotFoundException ex){
ex.printStackTrace();
System.exit(-1);
}
// create the resultModel, the pathModel, and the sourceModel
resultModel = new ResultModel(logger);
pathModel = new PathModel(resultModel, logger);

View File

@ -6,10 +6,15 @@
*/
package com.ibm.icu.dev.tool.tzu;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;
import javax.swing.JFrame;
public class GUILoader {
public static void main(String[] args) {
@ -18,8 +23,11 @@ public class GUILoader {
public GUILoader() {
String title = "ICU Time Zone Updater";
logger = Logger.initLogger(Logger.DEFAULT_FILENAME, Logger.NORMAL);
try{
logger = Logger.getInstance(Logger.DEFAULT_FILENAME, Logger.NORMAL);
}catch(FileNotFoundException ex){
// TODO: handle the exception gracefully
}
resultModel = new ResultModel(logger);
pathModel = new PathModel(resultModel, logger);
sourceModel = new SourceModel(logger);

View File

@ -6,11 +6,28 @@
*/
package com.ibm.icu.dev.tool.tzu;
import java.util.*;
import java.util.jar.*;
import java.io.*;
import java.net.*;
import com.ibm.icu.util.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.MissingResourceException;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import com.ibm.icu.util.UResourceBundle;
public class ICUFile {
public ICUFile(File file, Logger logger) throws IOException {

View File

@ -6,8 +6,13 @@
*/
package com.ibm.icu.dev.tool.tzu;
import java.util.*;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ICUJarFinder {
private ICUJarFinder() {

View File

@ -13,24 +13,19 @@ import java.io.FileNotFoundException;
public class Logger {
private Logger() {
private Logger(String filename, int verbosity)throws FileNotFoundException {
System.out.println("Log file: " + filename);
if (logger.log != null)
logger.log.close();
logger.log = new PrintStream(new FileOutputStream(filename));
logger.verbosity = verbosity;
}
public static Logger initLogger(String filename, int verbosity) {
try {
System.out.println("Log file: " + filename);
if (logger.log != null)
logger.log.close();
logger.log = new PrintStream(new FileOutputStream(filename));
logger.verbosity = verbosity;
} catch (FileNotFoundException ex) {
System.err.println("Could not create " + filename + ".");
}
return logger;
}
public static Logger getInstance() {
return logger;
public static synchronized Logger getInstance(String filename, int verbosity) throws FileNotFoundException{
if(logger == null){
logger = new Logger(filename, verbosity);
}
return logger;
}
public void setVerbosity(int verbosity) {
@ -79,7 +74,7 @@ public class Logger {
private PrintStream log;
private static Logger logger = new Logger();
private static Logger logger = null;
public static final String DEFAULT_FILENAME = "icutzu.log";
}

View File

@ -6,10 +6,30 @@
*/
package com.ibm.icu.dev.tool.tzu;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JList;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextField;
public class PathComponent extends JComponent {
public PathComponent(final GUILoader owner, final PathModel pathModel) {

View File

@ -6,9 +6,16 @@
*/
package com.ibm.icu.dev.tool.tzu;
import java.util.*;
import javax.swing.*;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.swing.AbstractListModel;
class PathModel extends AbstractListModel {
public PathModel(ResultModel resultModel, Logger logger) {

View File

@ -6,11 +6,32 @@
*/
package com.ibm.icu.dev.tool.tzu;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.net.URL;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTable;
import javax.swing.JTextField;
public class ResultComponent extends JComponent {
public ResultComponent(final GUILoader owner,

View File

@ -6,10 +6,17 @@
*/
package com.ibm.icu.dev.tool.tzu;
import java.util.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.swing.table.AbstractTableModel;
class ResultModel extends AbstractTableModel {
public ResultModel(Logger logger) {

View File

@ -6,19 +6,27 @@
*/
package com.ibm.icu.dev.tool.tzu;
import java.util.*;
import javax.swing.*;
import java.io.*;
import java.net.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import javax.swing.text.html.parser.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.TreeMap;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.parser.ParserDelegator;
class SourceModel extends AbstractListModel implements ComboBoxModel {
public SourceModel(Logger logger) {
this.logger = logger;
}
/*
public static void initialize(Logger logger) {
// cannot make TZ_BASE_URL and TZ_LOCAL_URL final since url creations
// need to be try-catched
@ -41,7 +49,7 @@ class SourceModel extends AbstractListModel implements ComboBoxModel {
ex.printStackTrace();
}
}
*/
public void findSources() {
BufferedReader reader = null;
try {