ICU-5606 updated icutzu for demoing
X-SVN-Rev: 21070
This commit is contained in:
parent
d95dc40cd3
commit
71f2d49b40
@ -100,7 +100,8 @@
|
||||
<property name="ime.indic.manifest" value="${src.dir}/com/ibm/icu/dev/tool/ime/indic/manifest.stub"/>
|
||||
<property name="zip.file" value="../icu4j${DSTAMP}.zip"/>
|
||||
<property name="zipSrc.file" value="../icu4jSrc${DSTAMP}.zip"/>
|
||||
|
||||
<property name="tzu.bin.dir" value="${basedir}/ICU4JTZU"/>
|
||||
<property name="tzujar.file" value="${tzu.bin.dir}/icutzu.jar"/>
|
||||
<property file="build.properties" />
|
||||
<!-- fix the data folder every time there is a version update-->
|
||||
|
||||
@ -2457,4 +2458,50 @@
|
||||
<target name="jdk13Compat" depends="init, eclipseCoreMangle, core13" description="builds ICU4J core with JDK 1.3"/>
|
||||
<target name="jdk13CompatTests" depends="init, jdk13Compat, eclipseTestMangle, eclipseTests" description="builds ICU4J tests with JDK 1.3"/>
|
||||
<target name="jdk13CompatCheck" depends="init, jdk13CompatTests, jar13, deleteCore, eclipseRunCheck" description="runs the tests with JDK 1.3"/>
|
||||
<target name="icutzu" depends="init" description="build ICU4J TimeZone Update Utility Classes">
|
||||
<javac includes="com/ibm/icu/dev/tool/tzu/**/*.java"
|
||||
excludes="**/.svn/**/*"
|
||||
srcdir="${src.dir}"
|
||||
destdir="${build.dir}"
|
||||
classpathref="build.classpath"
|
||||
source="${icu4j.javac.source}"
|
||||
target="${icu4j.javac.target}"
|
||||
debug="on" deprecation="off"
|
||||
encoding="ascii"/>
|
||||
</target>
|
||||
|
||||
<target name="icutzujar" depends="init,icutzu,jar" description="build ICU4J TimeZone Update Utility Classes">
|
||||
<mkdir dir="${tzu.bin.dir}"/>
|
||||
<copy todir="${tzu.bin.dir}">
|
||||
<fileset dir="${src.dir}/com/ibm/icu/dev/tool/tzu">
|
||||
<include name="*.bat"/>
|
||||
<include name="*.sh"/>
|
||||
<include name="*.res"/>
|
||||
</fileset>
|
||||
<fileset dir="${basedir}">
|
||||
<include name="${jar.file}"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<echo file="${tzu.bin.dir}/DirectorySearch.txt">all</echo>
|
||||
<jar jarfile="${tzujar.file}" compress="true">
|
||||
<fileset dir="${basedir}" includes="license.html" />
|
||||
<fileset dir="${build.dir}" includes="com/ibm/icu/dev/tool/tzu/**/*.class"/>
|
||||
<fileset dir="${build.dir}" includes="com/ibm/icu/dev/tool/UOption*.*"/>
|
||||
<manifest>
|
||||
<attribute name="Built-By" value="${corp}"/>
|
||||
<section name="common">
|
||||
<attribute name="Specification-Title" value="ICU4J TimeZone Update Utility"/>
|
||||
<attribute name="Specification-Version" value="${icu4j.version.string}"/>
|
||||
<attribute name="Specification-Vendor" value="ICU"/>
|
||||
<attribute name="Implementation-Title" value="ICU4JTZU"/>
|
||||
<attribute name="Implementation-Version" value="${icu4j.version.string}"/>
|
||||
<attribute name="Implementation-Vendor" value="${corp}"/>
|
||||
<attribute name="Implementation-Vendor-Id" value="com.ibm"/>
|
||||
<attribute name="Copyright-Info" value="${copyright}"/>
|
||||
<attribute name="Sealed" value="false"/>
|
||||
</section>
|
||||
</manifest>
|
||||
</jar>
|
||||
<echo message="Please see ${tzu.bin.dir} directory for the files."/>
|
||||
</target>
|
||||
</project>
|
||||
|
@ -18,32 +18,37 @@ public class CLILoader {
|
||||
|
||||
public CLILoader(String[] args) {
|
||||
try {
|
||||
// make sure the result model hides unreadable/unwritable files
|
||||
resultModel.setHidden(false);
|
||||
|
||||
boolean nogui = "true".equals(System.getProperty("nogui"));
|
||||
boolean discoveronly = "true".equals(System
|
||||
.getProperty("discoveronly"));
|
||||
boolean silentpatch = "true".equals(System
|
||||
.getProperty("silentpatch"));
|
||||
|
||||
System.out.println("nogui=" + nogui);
|
||||
System.out.println("discoveryonly=" + discoveronly);
|
||||
System.out.println("silentpatch=" + silentpatch);
|
||||
// set some options to be true based on environment variables
|
||||
if ("true".equals(System.getProperty("discoveronly")))
|
||||
options[DISCOVERONLY].doesOccur = true;
|
||||
if ("true".equals(System.getProperty("silentpatch")))
|
||||
options[QUIET].doesOccur = true;
|
||||
|
||||
// parse the arguments using UOption.parseArgs
|
||||
int argsleft = UOption.parseArgs(args, options);
|
||||
|
||||
// if help is specified, show the help specs and do nothing else
|
||||
if (options[HELP].doesOccur) {
|
||||
showHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure only there is only one update mode in the options
|
||||
int choiceType = (options[OFFLINE].doesOccur ? 1 : 0)
|
||||
+ (options[TZVERSION].doesOccur ? 1 : 0)
|
||||
+ (options[BEST].doesOccur ? 1 : 0);
|
||||
+ (options[BEST].doesOccur ? 1 : 0)
|
||||
+ (options[DISCOVERONLY].doesOccur ? 1 : 0);
|
||||
if (choiceType > 1)
|
||||
syntaxError("Options -o (--offline), -t (--tzversion), and -b (--best) are mutually exclusive");// error
|
||||
syntaxError("Options -o (--offline), -t (--tzversion), -b (--best) and -d (--discoveronly) are mutually exclusive");// error
|
||||
|
||||
// make sure that quiet & verbose do not both occur
|
||||
if (options[QUIET].doesOccur && options[VERBOSE].doesOccur)
|
||||
syntaxError("Options -q (--quiet) and -v (--verbose) are mutually exclusive");// error
|
||||
|
||||
// make sure that exactly one of backup & nobackup occurs
|
||||
if (options[BACKUP].doesOccur && options[NOBACKUP].doesOccur)
|
||||
syntaxError("Options -b (--backup) and -B (--nobackup) are mutually exclusive");// error
|
||||
if (!options[BACKUP].doesOccur && !options[NOBACKUP].doesOccur)
|
||||
@ -51,22 +56,29 @@ public class CLILoader {
|
||||
if (argsleft != 0)
|
||||
syntaxError("Too many arguments");// error
|
||||
|
||||
if (options[QUIET].doesOccur) // quiet implies auto
|
||||
// quiet implies auto
|
||||
if (options[QUIET].doesOccur)
|
||||
options[AUTO].doesOccur = true;
|
||||
if (options[AUTO].doesOccur && choiceType == 0) // auto implies best
|
||||
// by default
|
||||
{
|
||||
|
||||
// auto implies best if no preference specified
|
||||
if (options[AUTO].doesOccur && choiceType == 0) {
|
||||
options[BEST].doesOccur = true;
|
||||
choiceType = 1;
|
||||
}
|
||||
|
||||
// get the backup dir from the options
|
||||
if (options[BACKUP].doesOccur)
|
||||
backupDir = new File(options[BACKUP].value);
|
||||
|
||||
// if the user did not specify to stay offline, go online and find
|
||||
// zoneinfo.res files
|
||||
if (!options[OFFLINE].doesOccur)
|
||||
sourceModel.findSources();
|
||||
|
||||
// load paths from the directory search file
|
||||
pathModel.loadPaths();
|
||||
|
||||
// search the paths for updatable icu4j files
|
||||
try {
|
||||
System.out.println("Search started.");
|
||||
pathModel.searchAll(options[RECURSE].doesOccur, backupDir);
|
||||
@ -75,20 +87,31 @@ public class CLILoader {
|
||||
System.out.println("Search interrupted.");
|
||||
}
|
||||
|
||||
String chosenString = (options[BEST].doesOccur) ? getBestString()
|
||||
: (options[OFFLINE].doesOccur) ? getLocalString()
|
||||
: (options[TZVERSION].doesOccur) ? getTZVersionString(options[TZVERSION].value)
|
||||
: null;
|
||||
|
||||
URL chosenURL = (options[BEST].doesOccur) ? getBestURL()
|
||||
: (options[OFFLINE].doesOccur) ? getLocalURL()
|
||||
: (options[TZVERSION].doesOccur) ? getTZVersionURL(options[TZVERSION].value)
|
||||
: null;
|
||||
// get the name and url associated with the update mode (or null if
|
||||
// unspecified)
|
||||
String chosenName = null;
|
||||
String chosenVersion = null;
|
||||
URL chosenURL = null;
|
||||
if (options[BEST].doesOccur) {
|
||||
chosenName = getBestName();
|
||||
chosenVersion = getBestVersion();
|
||||
chosenURL = getBestURL();
|
||||
} else if (options[OFFLINE].doesOccur) {
|
||||
chosenName = getLocalName();
|
||||
chosenVersion = getLocalVersion();
|
||||
chosenURL = getLocalURL();
|
||||
} else if (options[TZVERSION].doesOccur) {
|
||||
chosenName = getTZVersionName(options[TZVERSION].value);
|
||||
chosenVersion = getTZVersionVersion(options[TZVERSION].value);
|
||||
chosenURL = getTZVersionURL(options[TZVERSION].value);
|
||||
}
|
||||
|
||||
// create a reader for user input
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
System.in));
|
||||
Iterator resultIter = resultModel.iterator();
|
||||
|
||||
// iterate through each icu4j file in the search results
|
||||
Iterator resultIter = resultModel.iterator();
|
||||
while (resultIter.hasNext()) {
|
||||
try {
|
||||
ICUFile entry = (ICUFile) resultIter.next();
|
||||
@ -109,13 +132,14 @@ public class CLILoader {
|
||||
|
||||
if (options[AUTO].doesOccur) // automatic mode
|
||||
{
|
||||
update(entry, chosenString, chosenURL);
|
||||
update(entry, chosenName, chosenURL);
|
||||
} else if (choiceType == 1) // confirmation mode
|
||||
{
|
||||
String input = askConfirm(chosenString, reader);
|
||||
String input = askConfirm(chosenName, chosenVersion,
|
||||
entry.getTZVersion(), reader);
|
||||
|
||||
if ("yes".startsWith(input))
|
||||
update(entry, chosenString, chosenURL);
|
||||
update(entry, chosenName, chosenURL);
|
||||
else
|
||||
skipUpdate();
|
||||
} else // interactive mode
|
||||
@ -123,11 +147,11 @@ public class CLILoader {
|
||||
String input = askChoice(reader);
|
||||
|
||||
if ("best".startsWith(input))
|
||||
update(entry, getBestString(), getBestURL());
|
||||
else if (!"local choice".startsWith(input))
|
||||
update(entry, getLocalString(), getLocalURL());
|
||||
update(entry, getBestName(), getBestURL());
|
||||
else if ("local choice".startsWith(input))
|
||||
update(entry, getLocalName(), getLocalURL());
|
||||
else if (!"none".startsWith(input))
|
||||
update(entry, getTZVersionString(input),
|
||||
update(entry, getTZVersionName(input),
|
||||
getTZVersionURL(input));
|
||||
else
|
||||
skipUpdate();
|
||||
@ -146,11 +170,21 @@ public class CLILoader {
|
||||
}
|
||||
}
|
||||
|
||||
private String askConfirm(String chosenString, BufferedReader reader)
|
||||
throws IOException {
|
||||
System.out.println("Update to " + chosenString
|
||||
+ "? [yes (default), no]");
|
||||
System.out.print(": ");
|
||||
private String askConfirm(String chosenString, String chosenVersion,
|
||||
String currentVersion, BufferedReader reader) throws IOException {
|
||||
int betterness = 1; // chosenString.compareToIgnoreCase(currentVersion);
|
||||
if (betterness == 0) {
|
||||
System.out.println("Updating should have no effect on this file.");
|
||||
System.out.print("Update anyway?");
|
||||
} else if (betterness < 0) {
|
||||
System.out
|
||||
.println("Warning: The version specified is older than the one present in the file.");
|
||||
System.out.print("Update anyway?");
|
||||
} else {
|
||||
System.out.print("Update to " + chosenVersion + "?");
|
||||
}
|
||||
|
||||
System.out.print(" [yes (default), no]\n: ");
|
||||
return reader.readLine().trim().toLowerCase();
|
||||
}
|
||||
|
||||
@ -163,6 +197,7 @@ public class CLILoader {
|
||||
while (sourceIter.hasNext())
|
||||
System.out.print(", " + ((Map.Entry) sourceIter.next()).getKey());
|
||||
|
||||
System.out.println();
|
||||
System.out
|
||||
.println("Update Version? [best (default), <specific version>, local copy, none]");
|
||||
System.out.print(": ");
|
||||
@ -175,7 +210,7 @@ public class CLILoader {
|
||||
entry.updateJar(url, backupDir);
|
||||
System.out.println("Update done.");
|
||||
} catch (IOException ex) {
|
||||
System.out.println(ex);
|
||||
System.err.println(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,20 +218,32 @@ public class CLILoader {
|
||||
System.out.println("Update skipped.");
|
||||
}
|
||||
|
||||
private String getBestString() {
|
||||
private String getBestName() {
|
||||
return (String) sourceModel.getSelectedItem();
|
||||
}
|
||||
|
||||
private String getLocalString() {
|
||||
private String getLocalName() {
|
||||
return SourceModel.TZ_LOCAL_CHOICE;
|
||||
}
|
||||
|
||||
private String getTZVersionString(String version) {
|
||||
return version;
|
||||
private String getTZVersionName(String version) {
|
||||
return version.trim().toLowerCase();
|
||||
}
|
||||
|
||||
private String getBestVersion() {
|
||||
return sourceModel.getVersion(sourceModel.getSelectedItem());
|
||||
}
|
||||
|
||||
private String getLocalVersion() {
|
||||
return SourceModel.TZ_LOCAL_VERSION;
|
||||
}
|
||||
|
||||
private String getTZVersionVersion(String version) {
|
||||
return version.trim().toLowerCase();
|
||||
}
|
||||
|
||||
private URL getBestURL() {
|
||||
return sourceModel.getValue(sourceModel.getSelectedItem());
|
||||
return sourceModel.getURL(sourceModel.getSelectedItem());
|
||||
}
|
||||
|
||||
private URL getLocalURL() {
|
||||
@ -229,9 +276,6 @@ public class CLILoader {
|
||||
|
||||
private File backupDir = null;
|
||||
|
||||
// { pathModel.add(new ICUPath(new File("C:\\Documents and Settings\\Daniel
|
||||
// Kesserich\\Desktop\\Spring 2007\\IBM\\updatehere"), true)); }
|
||||
|
||||
private static UOption options[] = new UOption[] {
|
||||
UOption.create("help", '?', UOption.NO_ARG),
|
||||
UOption.create("verbose", 'v', UOption.NO_ARG),
|
||||
|
@ -6,18 +6,10 @@
|
||||
*/
|
||||
package com.ibm.icu.dev.tool.tzu;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
import javax.swing.border.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.text.html.*;
|
||||
import javax.swing.text.html.parser.*;
|
||||
|
||||
public class GUILoader {
|
||||
public static void main(String[] args) {
|
||||
@ -231,7 +223,5 @@ public class GUILoader {
|
||||
|
||||
private JFrame resultFrame;
|
||||
|
||||
private ICUJarFinder jarFinder;
|
||||
|
||||
private File backupDir;
|
||||
}
|
@ -11,7 +11,6 @@ import java.util.jar.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import com.ibm.icu.util.*;
|
||||
import com.ibm.icu.impl.*;
|
||||
|
||||
public class ICUFile {
|
||||
public ICUFile(File file) throws IOException {
|
||||
@ -28,14 +27,6 @@ public class ICUFile {
|
||||
System.out.println("Added: " + file);
|
||||
}
|
||||
|
||||
public boolean isReadable() {
|
||||
return getFile().canRead();
|
||||
}
|
||||
|
||||
public boolean isWritable() {
|
||||
return getFile().canWrite();
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
@ -70,20 +61,18 @@ public class ICUFile {
|
||||
|
||||
public void updateJar(URL insertURL, File backupDir) throws IOException {
|
||||
if (!file.canRead() || !file.canWrite())
|
||||
throw new JarException("Missing permissions for " + file);
|
||||
throw new IOException("Missing permissions for " + file);
|
||||
File backupFile = null;
|
||||
if ((backupFile = createBackupFile(file, backupDir)) == null)
|
||||
throw new JarException("Failed to create a backup file.");
|
||||
throw new IOException("Failed to create a backup file.");
|
||||
if (!copyFile(file, backupFile))
|
||||
throw new JarException("Could not replace the original jar.");
|
||||
throw new IOException("Could not replace the original jar.");
|
||||
if (!createUpdatedJar(backupFile, file, insertEntry, insertURL))
|
||||
throw new IOException("Could not create an updated jar.");
|
||||
|
||||
tzVersion = findEntryTZVersion(file, insertEntry);
|
||||
}
|
||||
|
||||
// //////////////////////////////////////
|
||||
|
||||
private static File createBackupFile(File inputFile, File backupBase) {
|
||||
String filename = inputFile.getName();
|
||||
String suffix = ".jar";
|
||||
@ -122,8 +111,8 @@ public class ICUFile {
|
||||
backupFile = null;
|
||||
} finally {
|
||||
ostream.close();
|
||||
return backupFile;
|
||||
}
|
||||
return backupFile;
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,8 +150,8 @@ public class ICUFile {
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
private static boolean copyEntry(File inputFile, JarEntry inputEntry,
|
||||
@ -208,8 +197,8 @@ public class ICUFile {
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
private static boolean createUpdatedJar(File inputFile, File outputFile,
|
||||
@ -284,8 +273,8 @@ public class ICUFile {
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
private boolean isUpdatable() {
|
||||
@ -301,8 +290,6 @@ public class ICUFile {
|
||||
Attributes attr = (Attributes) iter.next();
|
||||
icuTitle = attr
|
||||
.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
|
||||
icuVendor = attr
|
||||
.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);
|
||||
icuVersion = attr
|
||||
.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
|
||||
if (!("ICU for Java".equals(icuTitle) || "Modularized ICU for Java"
|
||||
@ -329,8 +316,8 @@ public class ICUFile {
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
return success;
|
||||
|
||||
}
|
||||
|
||||
@ -344,7 +331,7 @@ public class ICUFile {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String findEntryTZVersion(File icuFile, JarEntry tzEntry) {
|
||||
public static String findEntryTZVersion(File icuFile, JarEntry tzEntry) {
|
||||
try {
|
||||
File temp = File.createTempFile("zoneinfo", ".res");
|
||||
temp.deleteOnExit();
|
||||
@ -368,6 +355,13 @@ public class ICUFile {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* public static String findURLTZVersion(File tzFile) { try { File temp =
|
||||
* File.createTempFile("zoneinfo", ".res"); temp.deleteOnExit();
|
||||
* copyFile(tzFile, temp); return findTZVersion(temp); } catch (IOException
|
||||
* ex) { ex.printStackTrace(); return null; } }
|
||||
*/
|
||||
|
||||
private static String findTZVersion(File tzFile) {
|
||||
try {
|
||||
String filename = tzFile.getName();
|
||||
@ -376,6 +370,7 @@ public class ICUFile {
|
||||
|
||||
URL url = new URL(tzFile.getParentFile().toURL().toString());
|
||||
ClassLoader loader = new URLClassLoader(new URL[] { url });
|
||||
|
||||
UResourceBundle bundle = UResourceBundle.getBundleInstance("",
|
||||
entryname, loader);
|
||||
|
||||
@ -388,8 +383,6 @@ public class ICUFile {
|
||||
// included
|
||||
} catch (MalformedURLException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return UNKNOWN_VERSION;
|
||||
@ -407,8 +400,6 @@ public class ICUFile {
|
||||
|
||||
private JarEntry insertEntry;
|
||||
|
||||
private String icuVendor;
|
||||
|
||||
private String icuTitle;
|
||||
|
||||
private String icuVersion;
|
||||
|
@ -29,6 +29,15 @@ public class ICUJarFinder {
|
||||
if (backupDir != null)
|
||||
excluded.add(backupDir);
|
||||
|
||||
System.out.println("*************");
|
||||
System.out.println("Included:");
|
||||
for (int i = 0; i < included.size(); i++)
|
||||
System.out.println(included.get(i));
|
||||
System.out.println("Excluded:");
|
||||
for (int i = 0; i < excluded.size(); i++)
|
||||
System.out.println(excluded.get(i));
|
||||
System.out.println("*************");
|
||||
|
||||
for (int i = 0; i < included.size(); i++)
|
||||
search(resultModel, (File) included.get(i), excluded, subdirs, true);
|
||||
|
||||
@ -37,11 +46,9 @@ public class ICUJarFinder {
|
||||
private static void search(ResultModel resultModel, File file,
|
||||
List excluded, boolean subdirs, boolean firstdip)
|
||||
throws InterruptedException {
|
||||
List result = new ArrayList();
|
||||
|
||||
Iterator iter = excluded.iterator();
|
||||
while (iter.hasNext())
|
||||
if (file.getAbsolutePath().equals(
|
||||
if (file.getAbsolutePath().equalsIgnoreCase(
|
||||
((File) iter.next()).getAbsolutePath()))
|
||||
return;
|
||||
|
||||
|
@ -6,22 +6,13 @@
|
||||
*/
|
||||
package com.ibm.icu.dev.tool.tzu;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
import javax.swing.border.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.text.html.*;
|
||||
import javax.swing.text.html.parser.*;
|
||||
|
||||
public class PathComponent extends JComponent {
|
||||
public PathComponent(final GUILoader owner, final PathModel pathModel) {
|
||||
this.owner = owner;
|
||||
this.pathModel = pathModel;
|
||||
|
||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
@ -157,11 +148,9 @@ public class PathComponent extends JComponent {
|
||||
pathSearchButton.setEnabled(value);
|
||||
}
|
||||
|
||||
private GUILoader owner;
|
||||
|
||||
private JPanel pathInputPanel = new JPanel();
|
||||
|
||||
private JPanel pathListPanel = new JPanel();
|
||||
// private JPanel pathListPanel = new JPanel();
|
||||
|
||||
private JPanel pathOptionPanel = new JPanel();
|
||||
|
||||
@ -199,4 +188,6 @@ public class PathComponent extends JComponent {
|
||||
private JMenuItem pathSearchAllItem = new JMenuItem("Search All");
|
||||
|
||||
private PathModel pathModel;
|
||||
|
||||
public static final long serialVersionUID = 1340;
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ class PathModel extends AbstractListModel {
|
||||
|
||||
public void loadPaths() {
|
||||
BufferedReader reader = null;
|
||||
String buffer;
|
||||
int lineNumber = 1;
|
||||
String line;
|
||||
char sign;
|
||||
@ -42,7 +41,7 @@ class PathModel extends AbstractListModel {
|
||||
if (line.length() >= 1) {
|
||||
sign = line.charAt(0);
|
||||
if (sign != '#') {
|
||||
if (sign != '+' && sign != '-')
|
||||
if (sign != '+' && sign != '-' && !"all".equals(line))
|
||||
pathlistError(
|
||||
"Each path entry must start with a + or - to denote inclusion/exclusion",
|
||||
lineNumber);// error
|
||||
@ -168,4 +167,6 @@ class PathModel extends AbstractListModel {
|
||||
private ResultModel resultModel = null;
|
||||
|
||||
public static final String PATHLIST_FILENAME = "DirectorySearch.txt";
|
||||
|
||||
public static final long serialVersionUID = 1337;
|
||||
}
|
@ -6,11 +6,7 @@
|
||||
*/
|
||||
package com.ibm.icu.dev.tool.tzu;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.*;
|
||||
import javax.swing.border.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
@ -19,7 +15,6 @@ import java.net.*;
|
||||
public class ResultComponent extends JComponent {
|
||||
public ResultComponent(final GUILoader owner,
|
||||
final ResultModel resultModel, final SourceModel sourceModel) {
|
||||
this.owner = owner;
|
||||
this.resultModel = resultModel;
|
||||
this.sourceModel = sourceModel;
|
||||
|
||||
@ -167,7 +162,7 @@ public class ResultComponent extends JComponent {
|
||||
}
|
||||
|
||||
private URL getSelectedSource() {
|
||||
return sourceModel.getValue(resultSourceList.getSelectedItem());
|
||||
return sourceModel.getURL(resultSourceList.getSelectedItem());
|
||||
}
|
||||
|
||||
private boolean addFile(File file) {
|
||||
@ -193,11 +188,9 @@ public class ResultComponent extends JComponent {
|
||||
resultCancelUpdateButton.setEnabled(value);
|
||||
}
|
||||
|
||||
private GUILoader owner;
|
||||
|
||||
private JPanel resultInputPanel = new JPanel();
|
||||
|
||||
private JPanel resultTablePanel = new JPanel();
|
||||
// private JPanel resultTablePanel = new JPanel();
|
||||
|
||||
private JPanel resultOptionPanel = new JPanel();
|
||||
|
||||
@ -238,4 +231,5 @@ public class ResultComponent extends JComponent {
|
||||
|
||||
private SourceModel sourceModel;
|
||||
|
||||
public static final long serialVersionUID = 1341;
|
||||
}
|
||||
|
@ -72,7 +72,8 @@ class ResultModel extends AbstractTableModel {
|
||||
}
|
||||
|
||||
public void add(ICUFile entry) {
|
||||
if (entry.isReadable() && entry.isWritable())
|
||||
File file = entry.getFile();
|
||||
if (file.canRead() && file.canWrite())
|
||||
add(permissibleList, hidden, entry);
|
||||
|
||||
add(completeList, !hidden, entry);
|
||||
@ -109,8 +110,6 @@ class ResultModel extends AbstractTableModel {
|
||||
updateAll(completeList, updateURL, backupDir);
|
||||
}
|
||||
|
||||
// ///////////////////////////
|
||||
|
||||
private void add(List list, boolean fire, ICUFile entry) {
|
||||
remove(list, fire, entry.getFile());
|
||||
list.add(entry);
|
||||
@ -218,4 +217,6 @@ class ResultModel extends AbstractTableModel {
|
||||
private List permissibleList = new ArrayList();
|
||||
|
||||
private boolean hidden = true;
|
||||
|
||||
public static final long serialVersionUID = 1338;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
package com.ibm.icu.dev.tool.tzu;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
@ -16,13 +15,8 @@ import javax.swing.text.html.*;
|
||||
import javax.swing.text.html.parser.*;
|
||||
|
||||
class SourceModel extends AbstractListModel implements ComboBoxModel {
|
||||
public SourceModel() {
|
||||
// map.put(TZ_LOCAL_CHOICE, TZ_LOCAL_URL);
|
||||
}
|
||||
|
||||
public void findSources() {
|
||||
BufferedReader reader = null;
|
||||
final Thread t = Thread.currentThread();
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(TZ_BASE_URL
|
||||
.openStream()));
|
||||
@ -47,14 +41,14 @@ class SourceModel extends AbstractListModel implements ComboBoxModel {
|
||||
if (!"..".equals(str))
|
||||
try {
|
||||
// add the new item to the map
|
||||
map.put(str, new URL(TZ_BASE_URLSTRING_START
|
||||
urlMap.put(str, new URL(TZ_BASE_URLSTRING_START
|
||||
+ str + TZ_BASE_URLSTRING_END));
|
||||
|
||||
// update the selected item and fire off an
|
||||
// event
|
||||
selected = (String) map.lastKey();
|
||||
selected = (String) urlMap.lastKey();
|
||||
int index = 0;
|
||||
for (Iterator iter = map.keySet().iterator(); iter
|
||||
for (Iterator iter = urlMap.keySet().iterator(); iter
|
||||
.hasNext();) {
|
||||
if (iter.next().equals(str))
|
||||
index++;
|
||||
@ -84,31 +78,43 @@ class SourceModel extends AbstractListModel implements ComboBoxModel {
|
||||
}
|
||||
|
||||
public Iterator iterator() {
|
||||
return map.entrySet().iterator();
|
||||
return urlMap.entrySet().iterator();
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return map.size() + 1; // the added size is due to the local copy not
|
||||
// being inside the map
|
||||
// the added size (+1) is due to the local copy not being inside the map
|
||||
return urlMap.size() + 1;
|
||||
}
|
||||
|
||||
public Object getElementAt(int index) {
|
||||
if (index == 0)
|
||||
return TZ_LOCAL_CHOICE;
|
||||
else if (index < 0 || index > map.size())
|
||||
else if (index < 0 || index > urlMap.size())
|
||||
return null;
|
||||
else {
|
||||
Iterator iter = map.keySet().iterator();
|
||||
Iterator iter = urlMap.keySet().iterator();
|
||||
for (int i = 1; i < index; i++)
|
||||
iter.next();
|
||||
return iter.next();
|
||||
}
|
||||
}
|
||||
|
||||
public URL getValue(Object choice) {
|
||||
return (choice == null) ? null
|
||||
: (((String) choice).toLowerCase() == TZ_LOCAL_CHOICE
|
||||
.toLowerCase()) ? TZ_LOCAL_URL : (URL) map.get(choice);
|
||||
public URL getURL(Object choice) {
|
||||
if (choice == null || !(choice instanceof String))
|
||||
return null;
|
||||
else if (TZ_LOCAL_CHOICE.equalsIgnoreCase((String) choice))
|
||||
return TZ_LOCAL_URL;
|
||||
else
|
||||
return (URL) urlMap.get(choice);
|
||||
}
|
||||
|
||||
public String getVersion(Object choice) {
|
||||
if (choice == null || !(choice instanceof String))
|
||||
return null;
|
||||
else if (TZ_LOCAL_CHOICE.equalsIgnoreCase((String) choice))
|
||||
return TZ_LOCAL_VERSION;
|
||||
else
|
||||
return (String) choice;
|
||||
}
|
||||
|
||||
public Object getSelectedItem() {
|
||||
@ -121,7 +127,7 @@ class SourceModel extends AbstractListModel implements ComboBoxModel {
|
||||
|
||||
private Object selected = TZ_LOCAL_CHOICE;
|
||||
|
||||
private TreeMap map = new TreeMap();
|
||||
private TreeMap urlMap = new TreeMap();
|
||||
|
||||
public static final String TZ_LOCAL_CHOICE = "Local Copy";
|
||||
|
||||
@ -129,16 +135,25 @@ class SourceModel extends AbstractListModel implements ComboBoxModel {
|
||||
|
||||
public static final String TZ_BASE_URLSTRING_END = "/be/zoneinfo.res";
|
||||
|
||||
public static final File TZ_LOCAL_FILE = new File("zoneinfo.res");
|
||||
|
||||
public static String TZ_LOCAL_VERSION = null;
|
||||
|
||||
public static URL TZ_BASE_URL = null;
|
||||
|
||||
public static URL TZ_LOCAL_URL = null;
|
||||
|
||||
static {
|
||||
// cannot make TZ_BASE_URL and TZ_LOCAL_URL final since url creations
|
||||
// need to be try-catched
|
||||
try {
|
||||
TZ_BASE_URL = new URL(TZ_BASE_URLSTRING_START);
|
||||
TZ_LOCAL_URL = new File("zoneinfo.res").toURL();
|
||||
TZ_LOCAL_URL = TZ_LOCAL_FILE.toURL();
|
||||
TZ_LOCAL_VERSION = "tobefixed"; // ICUFile.findFileTZVersion(TZ_LOCAL_FILE);
|
||||
} catch (MalformedURLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static final long serialVersionUID = 1339;
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
@ECHO OFF
|
||||
@echo *********** Welcome to the ICU4J Time Zone Update Utility (ICUTZU) ***********
|
||||
|
||||
@echo off
|
||||
rem /*
|
||||
rem *******************************************************************************
|
||||
rem * Copyright (C) 2007, International Business Machines Corporation and *
|
||||
@ -8,15 +6,35 @@ rem * others. All Rights Reserved.
|
||||
rem *******************************************************************************
|
||||
rem */
|
||||
|
||||
@echo *********** Welcome to the ICU4J Time Zone Update Utility (ICUTZU) ***********
|
||||
|
||||
rem set ICUTZU_HOME to the current directory
|
||||
rem Set ICUTZU_HOME to the current directory.
|
||||
set ICUTZU_HOME=%~dp0
|
||||
@echo ICUTZU Home: %ICUTZU_HOME%
|
||||
|
||||
|
||||
rem Make sure certain files are present.
|
||||
IF NOT EXIST "%ICUTZU_HOME%icutzu.jar" GOTO MissingICUTZUJAR
|
||||
IF NOT EXIST "%ICUTZU_HOME%icu4j.jar" GOTO MissingICU4JJAR
|
||||
Goto ICUTZUENV
|
||||
IF NOT EXIST "%ICUTZU_HOME%runicutzuenv.bat" GOTO MissingICUTZUENV
|
||||
|
||||
rem Set environmental variables.
|
||||
call "%ICUTZU_HOME%runicutzuenv.bat"
|
||||
rem Double-check that JAVA_HOME is set.
|
||||
@echo Java Home: %JAVA_HOME%
|
||||
|
||||
IF EXIST "%ICUTZU_HOME%\Temp" GOTO Next
|
||||
rem Create a temporary directory.
|
||||
mkdir "%ICUTZU_HOME%\Temp"
|
||||
:Next
|
||||
|
||||
rem Run the ICUTZU tool.
|
||||
@echo Launching the ICU4J Time Zone Update Utility (ICUTZU) ...
|
||||
@echo "%JAVA_HOME%\bin\java.exe" -cp "%ICUTZU_HOME%icu4j.jar";"%ICUTZU_HOME%icutzu.jar" -Dnogui=%NOGUI% -Ddiscoveronly=%DISCOVERONLY% -Dsilentpatch=%SILENTPATCH% com.ibm.icu.dev.tool.tzu.ICUTZUMain --recurse --backup "%ICUTZU_HOME%Temp"
|
||||
"%JAVA_HOME%\bin\java.exe" -cp "%ICUTZU_HOME%icu4j.jar";"%ICUTZU_HOME%icutzu.jar" -Dnogui=%NOGUI% -Ddiscoveronly=%DISCOVERONLY% -Dsilentpatch=%SILENTPATCH% com.ibm.icu.dev.tool.tzu.ICUTZUMain --recurse --backup "%ICUTZU_HOME%Temp"
|
||||
|
||||
GOTO Exit
|
||||
|
||||
|
||||
|
||||
:MissingICUTZUJAR
|
||||
@echo The ICU4J Time Zone Update Utility (icutzu.jar) doesn't exist in %ICUTZU_HOME%.
|
||||
@ -27,30 +45,11 @@ GOTO Exit
|
||||
@echo ICU for Java (icu4j.jar) doesn't exist in %ICUTZU_HOME%.
|
||||
GOTO Exit
|
||||
|
||||
:ICUTZUENV
|
||||
rem set JAVA_HOME to the Java installation directory
|
||||
IF NOT EXIST "%ICUTZU_HOME%runicutzuenv.bat" GOTO MissingICUTZUENV
|
||||
call "%ICUTZU_HOME%runicutzuenv.bat"
|
||||
@echo Java Home: %JAVA_HOME%
|
||||
GOTO Temp
|
||||
|
||||
:MissingICUTZUENV
|
||||
@echo runjtzuenv.bat file doesn't exist in %ICUTZU_HOME%.
|
||||
GOTO Exit
|
||||
|
||||
:Temp
|
||||
IF EXIST "%ICUTZU_HOME%\Temp" GOTO Next
|
||||
|
||||
rem Create a temporary directory
|
||||
mkdir "%ICUTZU_HOME%\Temp"
|
||||
|
||||
:Next
|
||||
rem Run the ICUTZU tool
|
||||
@echo Launching the ICU4J Time Zone Update Utility (ICUTZU) ...
|
||||
|
||||
@echo "%JAVA_HOME%\bin\java.exe" -cp "%ICUTZU_HOME%icu4j.jar";"%ICUTZU_HOME%icutzu.jar" -Dnogui=%NOGUI% -Ddiscoveronly=%DISCOVERONLY% -Dsilentpatch=%SILENTPATCH% com.ibm.icu.dev.tool.tzu.ICUCLI --backup "%ICUTZU_HOME%\Temp"
|
||||
"%JAVA_HOME%\bin\java.exe" -cp "%ICUTZU_HOME%icu4j.jar";"%ICUTZU_HOME%icutzu.jar" -Dnogui=%NOGUI% -Ddiscoveronly=%DISCOVERONLY% -Dsilentpatch=%SILENTPATCH% com.ibm.icu.dev.tool.tzu.ICUCLI --backup "%ICUTZU_HOME%\Temp"
|
||||
|
||||
:Exit
|
||||
@echo End of ICU4J Time Zone Update Utility (ICUTZU).
|
||||
|
||||
|
@ -5,14 +5,14 @@ rem * others. All Rights Reserved.
|
||||
rem *******************************************************************************
|
||||
rem */
|
||||
|
||||
rem set JAVA_HOME to the a Java installation directory
|
||||
rem Set JAVA_HOME to the Java installation directory.
|
||||
set JAVA_HOME=C:\Program Files\Java\jre1.6.0
|
||||
|
||||
rem set NOGUI
|
||||
rem Set whether the GUI will be run or not.
|
||||
set NOGUI=true
|
||||
|
||||
rem set DISCOVERONLY
|
||||
rem Set whether the cmd-line utility will only discover update icu4j files.
|
||||
set DISCOVERONLY=false
|
||||
|
||||
rem set SILENTPATCH
|
||||
rem Set whether the cmd-line utility will run silently.
|
||||
set SILENTPATCH=false
|
||||
|
Loading…
Reference in New Issue
Block a user