jh: refactor RichText Editor to be its own feature
diff --git a/org.eclipse.epf.common.service/.classpath b/org.eclipse.epf.common.service/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/org.eclipse.epf.common.service/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.epf.common.service/.project b/org.eclipse.epf.common.service/.project
new file mode 100644
index 0000000..62bfa73
--- /dev/null
+++ b/org.eclipse.epf.common.service/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.epf.common.service</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.epf.common.service/META-INF/MANIFEST.MF b/org.eclipse.epf.common.service/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..4053200
--- /dev/null
+++ b/org.eclipse.epf.common.service/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.epf.common.service;singleton:=true
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.eclipse.epf.common.service.ServicePlugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.epf.common;visibility:=reexport
+Eclipse-LazyStart: true
+Bundle-Vendor: %providerName
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.epf.common.service.utils,
+ org.eclipse.epf.common.service.versioning
diff --git a/org.eclipse.epf.common.service/build.properties b/org.eclipse.epf.common.service/build.properties
new file mode 100644
index 0000000..d67426f
--- /dev/null
+++ b/org.eclipse.epf.common.service/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ schema/,\
+ plugin.properties
diff --git a/org.eclipse.epf.common.service/plugin.properties b/org.eclipse.epf.common.service/plugin.properties
new file mode 100644
index 0000000..f212da5
--- /dev/null
+++ b/org.eclipse.epf.common.service/plugin.properties
@@ -0,0 +1,15 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2000, 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial implementation.
+#-------------------------------------------------------------------------------
+# NLS_MESSAGEFORMAT_VAR
+
+# Plug-in
+pluginName=EPF Common Service
+providerName=Eclipse.org
diff --git a/org.eclipse.epf.common.service/plugin.xml b/org.eclipse.epf.common.service/plugin.xml
new file mode 100644
index 0000000..b08b78d
--- /dev/null
+++ b/org.eclipse.epf.common.service/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="version" name="Version" schema="schema/org.eclipse.epf.common.version.exsd"/>
+ <extension-point id="commandLineRunners" name="CommandLineRunners" schema="schema/commandLineRunners.exsd"/>
+ <extension
+ id="epf"
+ point="org.eclipse.epf.common.service.version">
+ <versions
+ class="org.eclipse.epf.common.service.versioning.EPFVersions"/>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.epf.common.service/schema/commandLineRunners.exsd b/org.eclipse.epf.common.service/schema/commandLineRunners.exsd
new file mode 100644
index 0000000..26fc73a
--- /dev/null
+++ b/org.eclipse.epf.common.service/schema/commandLineRunners.exsd
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.epf.common">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.epf.common" id="commandLineRunners" name="CommandLineRunners"/>
+ </appInfo>
+ <documentation>
+ ICommandLineRunner object that can be accessed and run from RunUtil, provided with runnerId
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="commandLineRunner" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="commandLineRunner">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="runnerId" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 1.2
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ org.eclipse.epf.common.utils.ICommandLineRunner
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ //------------------------------------------------------------------------------
+// Copyright (c) 2005, 2007 IBM Corporation and others.
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// Contributors:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.epf.common.service/schema/org.eclipse.epf.common.version.exsd b/org.eclipse.epf.common.service/schema/org.eclipse.epf.common.version.exsd
new file mode 100644
index 0000000..a5e25a9
--- /dev/null
+++ b/org.eclipse.epf.common.service/schema/org.eclipse.epf.common.version.exsd
@@ -0,0 +1,135 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.epf.common">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.epf.common" id="org.eclipse.epf.common.version" name="Version"/>
+ </appInfo>
+ <documentation>
+ Define schema/tool versions
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="versions" minOccurs="0" maxOccurs="1"/>
+ <element ref="libraryExtensionVersionCheck" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="versions">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.epf.common.serviceability.Versions"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="libraryExtensionVersionCheck">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.epf.common.serviceability.ILibraryExtensionVersionCheck"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/ServicePlugin.java b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/ServicePlugin.java
new file mode 100644
index 0000000..f9eb497
--- /dev/null
+++ b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/ServicePlugin.java
@@ -0,0 +1,46 @@
+package org.eclipse.epf.common.service;
+
+import org.eclipse.epf.common.plugin.AbstractPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ServicePlugin extends AbstractPlugin {
+
+ // The shared plug-in instance.
+ private static ServicePlugin plugin;
+
+ /**
+ * Creates a new instance.
+ */
+ public ServicePlugin() {
+ super();
+ plugin = this;
+ }
+
+ /**
+ * @see org.eclipse.epf.common.plugin.AbstractPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * @see org.eclipse.epf.common.plugin.AbstractPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Gets the shared instance.
+ *
+ * @return the shared plug-in instance
+ */
+ public static ServicePlugin getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/utils/CommandLineRunUtil.java b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/utils/CommandLineRunUtil.java
new file mode 100644
index 0000000..76ecabc
--- /dev/null
+++ b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/utils/CommandLineRunUtil.java
@@ -0,0 +1,109 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2007 IBM Corporation and others.
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// Contributors:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.common.service.utils;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+
+/**
+ * Utility class for excuting a ICommandLineRunner object's execute method
+ *
+ * @author Weiping Lu
+ * @since 1.2
+ */
+public class CommandLineRunUtil {
+
+ private static CommandLineRunUtil instance = new CommandLineRunUtil();
+ private boolean needToRun = false;
+
+ public static CommandLineRunUtil getInstance() {
+ return instance;
+ }
+
+ public CommandLineRunUtil() {
+ }
+
+ public boolean execute(String[] args) {
+ //For general case, args should be parsed here to call on right runnerId.
+ //for now, just hard code it with "commandLinePluginImporter"
+ executeCommandRunner(args, "commandLinePluginImporter"); //$NON-NLS-1$
+ return false;
+ }
+
+ protected boolean executeCommandRunner(String[] args, String runnerId) {
+ ICommandLineRunner runner = getRunner(runnerId);
+ if (runner != null) {
+ return runner.execute(args);
+ }
+ return false;
+ }
+
+ private static final ICommandLineRunner getRunner(String id) {
+ IExtensionRegistry extensionRegistry = Platform
+ .getExtensionRegistry();
+ IExtensionPoint extensionPoint = extensionRegistry
+ .getExtensionPoint(
+ "org.eclipse.epf.common", "commandLineRunners"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (extensionPoint == null) {
+ return null;
+ }
+
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IExtension extension = extensions[i];
+ String pluginId = extension.getNamespaceIdentifier();
+ Bundle bundle = Platform.getBundle(pluginId);
+ IConfigurationElement[] configElements = extension
+ .getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+ IConfigurationElement configElement = configElements[j];
+ String runnerId = configElement.getAttribute("runnerId"); //$NON-NLS-1$
+ if (runnerId == null) {
+ continue;
+ }
+ runnerId = runnerId.trim();
+ if (! runnerId.equals(id)) {
+ continue;
+ }
+ String className = configElement.getAttribute("class"); //$NON-NLS-1$
+ if (className == null) {
+ continue;
+ }
+ className = className.trim();
+ try {
+ ICommandLineRunner runner = (ICommandLineRunner) bundle.loadClass(className).newInstance();
+ return runner;
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public boolean isNeedToRun() {
+ return needToRun;
+ }
+
+ public void setNeedToRun(boolean needToRun) {
+ this.needToRun = needToRun;
+ }
+
+ public static void setInstance(CommandLineRunUtil instance) {
+ CommandLineRunUtil.instance = instance;
+ }
+
+
+}
diff --git a/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/utils/CommandLineRunner.java b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/utils/CommandLineRunner.java
new file mode 100644
index 0000000..505fb7e
--- /dev/null
+++ b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/utils/CommandLineRunner.java
@@ -0,0 +1,56 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2007 IBM Corporation and others.
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// Contributors:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.common.service.utils;
+
+import java.io.File;
+
+/**
+ * Base implementation for ICommandLineRunner
+ *
+ * @author Weiping Lu
+ * @since 1.2
+ */
+public class CommandLineRunner implements ICommandLineRunner {
+ protected static boolean localDebug = true;
+
+ private File inputFile;
+
+ public boolean execute(String[] args) {
+ if (localDebug) {
+ System.out.println("LD> CommandLinePluginImporter.execute, args: "); //$NON-NLS-1$
+ for (int i = 0; i < args.length; i++) {
+ System.out.println("LD> args[" + i + "]: " + args[i]); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ }
+
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equalsIgnoreCase("-batch")) { //$NON-NLS-1$
+ if (i + 1 < args.length) {
+ String path = args[i + 1];
+ inputFile = new File(path);
+ if (!inputFile.exists()) {
+ String msg = "Cannot fine the file: " + path; //$NON-NLS-1$
+ System.out.println("Error> " + msg); //$NON-NLS-1$
+ return false;
+ }
+ break;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ protected File getInputFile() {
+ return inputFile;
+ }
+
+}
diff --git a/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/utils/ICommandLineRunner.java b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/utils/ICommandLineRunner.java
new file mode 100644
index 0000000..7b6f7f7
--- /dev/null
+++ b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/utils/ICommandLineRunner.java
@@ -0,0 +1,21 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2007 IBM Corporation and others.
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// Contributors:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.common.service.utils;
+
+/**
+ * Interface for excuting a command line
+ *
+ * @author Weiping Lu
+ * @since 1.2
+ */
+public interface ICommandLineRunner {
+ boolean execute(String[] args);
+}
diff --git a/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/EPFVersion.java b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/EPFVersion.java
new file mode 100644
index 0000000..9694436
--- /dev/null
+++ b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/EPFVersion.java
@@ -0,0 +1,148 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2006 IBM Corporation and others.
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// Contributors:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.common.service.versioning;
+
+import org.osgi.framework.Version;
+
+/**
+ * This class represents a single version of EPF Composer.
+ * It contains all the versions of the sub-components of EPF.
+ *
+ * @author Jeff Hardy
+ * @sicne 1.0
+ */
+public class EPFVersion {
+
+ // the tool version
+ protected Version toolVersion;
+
+ // the library version
+ protected Version libraryVersion;
+
+ // the schema version
+ protected Version xmlSchemaVersion;
+
+
+ public EPFVersion() {
+ this.toolVersion = Version.emptyVersion;
+ this.libraryVersion = Version.emptyVersion;
+ this.xmlSchemaVersion = Version.emptyVersion;
+ };
+
+ public EPFVersion(String toolVersion, String libraryVersion, String xmlSchemaVersion) {
+ this.toolVersion = new Version(toolVersion);
+ this.libraryVersion = new Version(libraryVersion);
+ this.xmlSchemaVersion = new Version(xmlSchemaVersion);
+ }
+
+ /**
+ * @return the tool version
+ */
+ public Version getToolVersion() {
+ return toolVersion;
+ }
+
+ /**
+ * @return the library version
+ */
+ public Version getLibraryVersion() {
+ return libraryVersion;
+ }
+
+ /**
+ * @return the XML schema version
+ */
+ public Version getXMLSchemaVersion() {
+ return xmlSchemaVersion;
+ }
+
+ /**
+ * Compares the given tool version to this one
+ *
+ * @see org.osgi.framework.Version#compareTo()
+ *
+ * @param schemaVersion The schema version to be compared.
+ * @return A negative integer if this tool version is less than the given one<br />
+ * Zero if the this tool version is the same as the given one<br />
+ * A positive integer if this tool version is greater than the given one<br />
+ *
+ */
+ public int compareToolVersionTo(Version toolVersion) {
+ if (!VersionUtil.isVersionCheckingDisabled())
+ return getToolVersion().compareTo(toolVersion);
+ else
+ return 0;
+ }
+
+ /**
+ * Compares the given library version to this one
+ *
+ * @see org.osgi.framework.Version#compareTo()
+ *
+ * @param schemaVersion The schema version to be compared.
+ * @return A negative integer if this library version is less than the given one<br />
+ * Zero if the this library version is the same as the given one<br />
+ * A positive integer if this library version is greater than the given one<br />
+ *
+ */
+ public int compareLibraryVersionTo(Version libraryVersion) {
+ if (!VersionUtil.isVersionCheckingDisabled())
+ return getLibraryVersion().compareTo(libraryVersion);
+ else
+ return 0;
+ }
+
+ /**
+ * Compares the given XML Schema version to this one
+ *
+ * @see org.osgi.framework.Version#compareTo()
+ *
+ * @param schemaVersion The schema version to be compared.
+ * @return A negative integer if this XML Schema version is less than the given one<br />
+ * Zero if the this XML Schema version is the same as the given one<br />
+ * A positive integer if this XML Schema version is greater than the given one<br />
+ *
+ */
+ public int compareXMLSchemaVersionTo(Version XMLSchemaVersion) {
+ if (!VersionUtil.isVersionCheckingDisabled())
+ return getXMLSchemaVersion().compareTo(XMLSchemaVersion);
+ else
+ return 0;
+ }
+
+ public String toString() {
+ return getToolVersion().toString() + "," + //$NON-NLS-1$
+ getLibraryVersion().toString() + "," + //$NON-NLS-1$
+ getXMLSchemaVersion().toString();
+ }
+
+ public boolean equals(Object object) {
+ if (object == this) { // quicktest
+ return true;
+ }
+
+ if (!(object instanceof EPFVersion)) {
+ return false;
+ }
+
+ EPFVersion other = (EPFVersion) object;
+ return (getToolVersion().equals(other.getToolVersion())) && (getLibraryVersion().equals(other.getLibraryVersion()))
+ && (getXMLSchemaVersion().equals(other.getXMLSchemaVersion()));
+ }
+
+ @Override
+ public int hashCode() {
+ int result = toolVersion.hashCode();
+ result ^= libraryVersion.hashCode();
+ result ^= xmlSchemaVersion.hashCode();
+ return result;
+ }
+}
diff --git a/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/EPFVersions.java b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/EPFVersions.java
new file mode 100644
index 0000000..bbdd958
--- /dev/null
+++ b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/EPFVersions.java
@@ -0,0 +1,132 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2007 IBM Corporation and others.
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// Contributors:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.common.service.versioning;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.osgi.framework.Version;
+
+/**
+ * This class stores all of the version information for the known EPF versions.
+ *
+ * @author Jeff Hardy
+ * @since 1.0
+ */
+public class EPFVersions {
+
+ public static final String TOOL_ID = "epf"; //$NON-NLS-1$
+
+ // the name space URI string for the TOOL_ID
+ private static String nsUri = "http://www.eclipse.org/epf"; //$NON-NLS-1$
+
+ // EPF 1.0
+ private static EPFVersion EPF_10 = new EPFVersion("1.0", //$NON-NLS-1$ tool version
+ "1.0.3.0", //$NON-NLS-1$ library version
+ "1.0.0"); //$NON-NLS-1$ xml schema version
+
+ // EPF 1.1 - This is EPF 1.2 Iteration 1
+ private static EPFVersion EPF_11 = new EPFVersion("1.1", //$NON-NLS-1$ tool version
+ "1.0.4.0", //$NON-NLS-1$ library version
+ "1.0.0"); //$NON-NLS-1$ xml schema version
+
+ // EPF 1.2 release
+ private static EPFVersion EPF_12 = new EPFVersion("1.2", //$NON-NLS-1$ tool version
+ "1.0.4.1", //$NON-NLS-1$ library version
+ "1.0.1"); //$NON-NLS-1$ xml schema version
+
+ private static EPFVersion currentVersion = EPF_12;
+
+ public EPFVersion getCurrentVersion() {
+ return currentVersion;
+ }
+
+ public EPFVersion getVersion(String toolVersion) {
+ if (toolVersion != null) {
+ for (Iterator iter = getAllVersions().iterator(); iter.hasNext();) {
+ EPFVersion ver = (EPFVersion) iter.next();
+ if (ver.getToolVersion().equals(new Version(toolVersion))) {
+ return ver;
+ }
+ }
+ }
+ return null;
+ }
+
+ public Collection getAllVersions() {
+ List<EPFVersion> versions = new ArrayList<EPFVersion>();
+ versions.add(EPF_10);
+ versions.add(EPF_11);
+ versions.add(EPF_12);
+ return versions;
+ }
+
+ /**
+ *
+ * @param libraryVersion
+ * @return the minimum tool version that uses the specified library version
+ */
+ public EPFVersion getMinToolVersionForLibraryVersion(Version libraryVersion) {
+ for (Iterator iter = getAllVersions().iterator(); iter.hasNext();) {
+ EPFVersion versionInfo = (EPFVersion) iter.next();
+ if (versionInfo.getLibraryVersion().compareTo(libraryVersion) == 0) {
+ return versionInfo;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return the minimum tool version that uses the current library version
+ */
+ public EPFVersion getMinToolVersionForCurrentLibraryVersion() {
+ Version libraryVersion = getCurrentVersion().getLibraryVersion();
+ return getMinToolVersionForLibraryVersion(libraryVersion);
+ }
+
+ /**
+ *
+ * @param xmlSchemaVersion
+ * @return the minimum tool version that uses the specified XML Schema
+ * version
+ */
+ public EPFVersion getMinToolVersionForXMLSchemaVersion(
+ Version xmlSchemaVersion) {
+ for (Iterator iter = getAllVersions().iterator(); iter.hasNext();) {
+ EPFVersion versionInfo = (EPFVersion) iter.next();
+ if (versionInfo.getXMLSchemaVersion().compareTo(xmlSchemaVersion) == 0) {
+ return versionInfo;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return the minimum tool version that uses the current XML Schema version
+ */
+ public EPFVersion getMinToolVersionForCurrentXMLSchemaVersion() {
+ Version xmlSchemaVersion = getCurrentVersion().getXMLSchemaVersion();
+ return getMinToolVersionForXMLSchemaVersion(xmlSchemaVersion);
+ }
+
+ /**
+ *
+ * @return the name space URI string for the TOOL_ID
+ */
+ public String getNsURI() {
+ return nsUri;
+ }
+
+}
diff --git a/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/ILibraryExtensionVersionCheck.java b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/ILibraryExtensionVersionCheck.java
new file mode 100644
index 0000000..3ca9bab
--- /dev/null
+++ b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/ILibraryExtensionVersionCheck.java
@@ -0,0 +1,37 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2006 IBM Corporation and others.
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// Contributors:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.common.service.versioning;
+
+import java.io.File;
+
+import org.eclipse.epf.common.service.versioning.VersionUtil.VersionCheckInfo;
+
+/**
+ * The interface for performing method library version check.
+ *
+ * @author Jeff Hardy
+ * @since 1.0
+ */
+public interface ILibraryExtensionVersionCheck {
+
+ /**
+ * Checks and returns the version information associated with a method
+ * library.
+ *
+ * @param file
+ * a method library XMI file
+ * @return <code>null</code> if the library XMI file does not contain the
+ * version information of the tool that created it; or
+ * <code>VersionCheckInfo</code> object
+ */
+ public VersionCheckInfo checkLibraryVersion(File libPath);
+
+}
diff --git a/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/VersionMismatchException.java b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/VersionMismatchException.java
new file mode 100644
index 0000000..2a22329
--- /dev/null
+++ b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/VersionMismatchException.java
@@ -0,0 +1,47 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2006 IBM Corporation and others.
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// Contributors:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.common.service.versioning;
+
+import org.osgi.framework.Version;
+
+/**
+ * Signals that the current version of the tool is not compatible with the
+ * method library it is trying to open.
+ *
+ * @author Jeff Hardy
+ * @since 1.0
+ */
+public class VersionMismatchException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ private Version expected;
+
+ private Version actual;
+
+ public VersionMismatchException(Version expected, String actual) {
+ super();
+ this.expected = expected;
+ if (actual == null) {
+ this.actual = Version.emptyVersion;
+ } else {
+ this.actual = new Version(actual);
+ }
+ }
+
+ public Version getActual() {
+ return actual;
+ }
+
+ public Version getExpected() {
+ return expected;
+ }
+}
diff --git a/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/VersionUtil.java b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/VersionUtil.java
new file mode 100644
index 0000000..4db9295
--- /dev/null
+++ b/org.eclipse.epf.common.service/src/org/eclipse/epf/common/service/versioning/VersionUtil.java
@@ -0,0 +1,473 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2007 IBM Corporation and others.
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// Contributors:
+// IBM Corporation - initial implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.common.service.versioning;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.epf.common.CommonPlugin;
+import org.eclipse.epf.common.utils.FileUtil;
+import org.eclipse.epf.common.utils.StrUtil;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ * Provides utilities to query a method library schema and the version of the
+ * tool that created it.
+ *
+ * @author Jeff Hardy
+ * @since 1.0
+ */
+public class VersionUtil {
+
+ public static class VersionCheckInfo {
+ public VersionCheckInfo(String id, String toolVersion,
+ String currentMinToolVersion, int result) {
+ this.toolID = id;
+ this.toolVersion = toolVersion;
+ this.currentMinToolVersion = currentMinToolVersion;
+ this.result = result;
+ }
+
+ public String toolID;
+
+ public String toolVersion;
+
+ public String currentMinToolVersion;
+
+ /**
+ * < 0: fileToolVersion is older than currentMinToolVersion <br/> == 0:
+ * match <br/> > 0 : fileToolVersion is newer than currentMinToolVersion
+ * <br/>
+ */
+ public int result;
+ }
+
+ /**
+ * The extension point namespace.
+ */
+ public static final String EXTENSION_POINT_NAMESPACE = CommonPlugin.class
+ .getPackage().getName();
+
+ /**
+ * The extension point name.
+ */
+ public static final String EXTENSION_POINT_NAME = "version"; //$NON-NLS-1$
+
+ public static final String EXTENSION_VERSIONS_INFO = "versions"; //$NON-NLS-1$
+
+ public static final String EXTENSION_LIB_EXTENSION_CHECK = "libraryExtensionVersionCheck"; //$NON-NLS-1$
+
+ private static final String DISABLE_VERSION_CHECKING_PREF = "disable_version_checking"; //$NON-NLS-1$
+
+ public static Map<String, EPFVersions> versions = new LinkedHashMap<String, EPFVersions>();
+
+ public static Map<String, ILibraryExtensionVersionCheck> libExtCheckers = new LinkedHashMap<String, ILibraryExtensionVersionCheck>();
+
+ protected static boolean versionCheckingDisabled = false;
+
+ /**
+ * List of toolIDs to check, in order
+ */
+ private static List<String> toolIDsCheckList = new ArrayList<String>();
+
+ static {
+ toolIDsCheckList.add(EPFVersions.TOOL_ID);
+
+ // read properties file
+ try {
+ String valueStr = CommonPlugin.getDefault().getPreferenceStore()
+ .getString(DISABLE_VERSION_CHECKING_PREF);
+ versionCheckingDisabled = Boolean.valueOf(valueStr).booleanValue();
+ } catch (MissingResourceException e) {
+ versionCheckingDisabled = false;
+ }
+
+ // Process the "org.eclipse.epf.common.version" extension point
+ // contributors.
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(
+ EXTENSION_POINT_NAMESPACE, EXTENSION_POINT_NAME);
+ if (extensionPoint != null) {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IExtension extension = extensions[i];
+ initExtension(extension);
+ }
+ }
+
+ }
+
+ protected static void initExtension(IExtension extension) {
+ String extensionID = extension.getSimpleIdentifier();
+ String pluginId = extension.getNamespaceIdentifier();
+ Bundle bundle = Platform.getBundle(pluginId);
+ IConfigurationElement[] configElements = extension
+ .getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+ IConfigurationElement configElement = configElements[j];
+ try {
+ if (EXTENSION_VERSIONS_INFO.equals(configElement.getName())) {
+ String className = configElement.getAttribute("class"); //$NON-NLS-1$
+ if (className != null) {
+ versions.put(extensionID, (EPFVersions) bundle
+ .loadClass(className).newInstance());
+ break;
+ }
+ }
+ if (EXTENSION_LIB_EXTENSION_CHECK.equals(configElement
+ .getName())) {
+ String className = configElement.getAttribute("class"); //$NON-NLS-1$
+ if (className != null) {
+ libExtCheckers.put(extensionID,
+ (ILibraryExtensionVersionCheck) bundle
+ .loadClass(className).newInstance());
+ break;
+ }
+ }
+ } catch (Exception e) {
+ CommonPlugin.getDefault().getLogger().logError(e);
+ }
+ }
+ }
+
+ /**
+ *
+ * @return the map of Tool IDs-to-Versions class
+ */
+ public static Map getVersionsMap() {
+ return Collections.unmodifiableMap(versions);
+ }
+
+ /**
+ *
+ * @return a Set of all known Tool IDs
+ */
+ public static Set<String> getAllToolIDs() {
+ return Collections.unmodifiableSet(versions.keySet());
+ }
+
+ /**
+ *
+ * @param toolID
+ * @return The Versions class for the given Tool ID
+ */
+ public static EPFVersions getVersions(String toolID) {
+ return (EPFVersions) versions.get(toolID);
+ }
+
+ /**
+ *
+ * @return true iff version checking is disabled
+ */
+ public static boolean isVersionCheckingDisabled() {
+ return versionCheckingDisabled;
+ }
+
+ public static final Pattern p_XMIVersionPattern = Pattern.compile(
+ "(\\w+?):version=\"(.+?)\"", Pattern.DOTALL); //$NON-NLS-1$
+
+ public static final Pattern p_XMLVersionAttributePattern = Pattern.compile(
+ "tool=\"(.*?)\"", Pattern.DOTALL); //$NON-NLS-1$
+
+ public static final Pattern p_XMI_ELEMENT_START_TAG = Pattern
+ .compile("<?xml version=\".+?\" encoding=\".+?\"?>"); //$NON-NLS-1$
+
+ public static final String XML_ELEMENT_END_TAG = ">"; //$NON-NLS-1$
+
+ public static final String XMI_ATTRIBUTE_TAG = "xmi"; //$NON-NLS-1$
+
+ public static final String XML_ELEMENT_START_TAG = "<uma:MethodLibrary"; //$NON-NLS-1$
+
+ public static final String XML_VERSIONS_SEPARATOR = ";"; //$NON-NLS-1$
+
+ public static final String XML_TOOL_VERSION_SEPARATOR = "="; //$NON-NLS-1$
+
+ /**
+ * Given an XML file, will read the tool="foo=a.b.c.d;bar=w.x.y.z"
+ * attributes and return a map of the id-to-versions.
+ *
+ * @param xmlFile
+ * file to process
+ * @return null if no versions found; a map of the id-to-versions otherwise
+ */
+ protected static Map readVersionsFromXMLFile(File xmlFile) {
+ Map<String, String> versions = new LinkedHashMap<String, String>();
+ StringBuffer buf = null;
+ try {
+ buf = FileUtil.readFile(xmlFile, FileUtil.ENCODING_UTF_8);
+ } catch (Exception ex) {
+ CommonPlugin.getDefault().getLogger().logError(ex);
+ }
+ if (buf != null) {
+ int xmiElementStartIdx = buf.indexOf(XML_ELEMENT_START_TAG);
+ if (xmiElementStartIdx != -1) {
+ int xmiElementEndIdx = buf.indexOf(XML_ELEMENT_END_TAG,
+ xmiElementStartIdx + XML_ELEMENT_START_TAG.length());
+ if (xmiElementEndIdx != -1) {
+ String rootElement = buf.substring(xmiElementStartIdx,
+ xmiElementEndIdx);
+ Matcher mAttribute = p_XMLVersionAttributePattern
+ .matcher(rootElement);
+ if (mAttribute.find()) {
+ String toolsAttribute = mAttribute.group(1);
+ if (toolsAttribute != null
+ && toolsAttribute.length() > 0) {
+ String[] versionsArray = StrUtil.split(
+ toolsAttribute, XML_VERSIONS_SEPARATOR);
+ for (int i = 0; i < versionsArray.length; i++) {
+ if (versionsArray[i] != null
+ && versionsArray[i].length() > 0) {
+ String[] versionInfoArray = StrUtil.split(
+ versionsArray[i],
+ XML_TOOL_VERSION_SEPARATOR);
+ if (versionInfoArray.length != 2)
+ continue;
+ String toolID = versionInfoArray[0];
+ String toolVersion = versionInfoArray[1];
+ if (toolID != null
+ && toolID.trim().length() > 0
+ && toolVersion != null
+ && toolVersion.trim().length() > 0)
+ versions.put(toolID, toolVersion);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (versions.size() == 0) {
+ return null;
+ } else {
+ return versions;
+ }
+ }
+
+ /**
+ * Given an XMI file, will read the foo:version="x.x.x" attributes and
+ * return a map of the id-to-versions.
+ *
+ * @param xmlFile
+ * file to process
+ * @return null if no versions found; a map of the id-to-versions otherwise
+ */
+ protected static Map readVersionsFromXMIFile(File xmiFile) {
+ Map<String, String> versions = new LinkedHashMap<String, String>();
+ StringBuffer buf = null;
+ try {
+ buf = FileUtil.readFile(xmiFile, FileUtil.ENCODING_UTF_8);
+ } catch (Exception ex) {
+ CommonPlugin.getDefault().getLogger().logError(ex);
+ }
+ if (buf != null) {
+ Matcher docStartMatcher = p_XMI_ELEMENT_START_TAG.matcher(buf);
+ if (docStartMatcher.find()) {
+ int docHeaderEndIdx = docStartMatcher.end();
+ int xmiElementEndIdx = buf.indexOf(XML_ELEMENT_END_TAG,
+ docHeaderEndIdx);
+ if (xmiElementEndIdx != -1) {
+ String rootElement = buf.substring(docHeaderEndIdx,
+ xmiElementEndIdx + 1);
+ Matcher m = p_XMIVersionPattern.matcher(rootElement);
+ while (m.find()) {
+ String toolID = m.group(1);
+ if (toolID.equals(XMI_ATTRIBUTE_TAG))
+ continue;
+ String toolVersion = m.group(2);
+ if (toolID != null && toolID.trim().length() > 0
+ && toolVersion != null
+ && toolVersion.trim().length() > 0)
+ versions.put(toolID, toolVersion);
+ }
+ }
+ }
+ }
+ if (versions.size() == 0) {
+ return null;
+ } else {
+ return versions;
+ }
+ }
+
+ /**
+ * Given a file, will read version information and return a map of the
+ * id-to-versions.
+ *
+ * @param file
+ * file to process
+ * @return null if no versions found; a map of the id-to-versions otherwise
+ */
+ public static Map readVersionsFromFile(File file) {
+ if (file.getName().toUpperCase().endsWith("XMI")) { //$NON-NLS-1$
+ return readVersionsFromXMIFile(file);
+ } else if (file.getName().toUpperCase().endsWith("XML")) { //$NON-NLS-1$
+ return readVersionsFromXMLFile(file);
+ } else {
+ Map versions = readVersionsFromXMIFile(file);
+ if (versions != null)
+ return versions;
+ versions = readVersionsFromXMLFile(file);
+ if (versions != null)
+ return versions;
+ }
+ return null;
+ }
+
+ /**
+ * Given a file, will compare with current XML Schema version.
+ *
+ * @param file
+ * @return null if file tool version can not be found; a VersionCheckInfo
+ * object otherwise
+ */
+ public static VersionCheckInfo checkXMLVersion(File file) {
+ Map versionMap = VersionUtil.readVersionsFromFile(file);
+ if (versionMap == null) {
+ return null;
+ } else {
+ VersionCheckInfo vci = null;
+ for (Iterator iter = toolIDsCheckList.iterator(); iter.hasNext();) {
+ String toolID = (String) iter.next();
+ if (versionMap.get(toolID) != null) {
+ String toolVersion = (String) versionMap.get(toolID);
+ vci = _checkXMLVersion(toolID, toolVersion);
+ if (vci != null)
+ return vci;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static VersionCheckInfo _checkXMLVersion(String toolID,
+ String toolVersion) {
+ // get the class that stores all the version info for this tool ID
+ EPFVersions versions = getVersions(toolID);
+ if (versions != null) {
+ EPFVersion minCurrVersion = versions
+ .getMinToolVersionForCurrentXMLSchemaVersion();
+ int result = minCurrVersion.compareToolVersionTo(new Version(
+ toolVersion));
+ String currentMinToolVersion = minCurrVersion.getToolVersion()
+ .toString();
+ return new VersionCheckInfo(toolID, toolVersion,
+ currentMinToolVersion, -result);
+ }
+ return null;
+ }
+
+ /**
+ * Given a file, compares with current library schema version
+ *
+ * @param file
+ * @return null if file tool version can not be found; a VersionCheckInfo
+ * object otherwise
+ */
+ public static VersionCheckInfo checkLibraryVersion(File file) {
+ if (file.getName().equals("library.xmi")) { //$NON-NLS-1$
+ // check library extensions first
+ for (Iterator iter = toolIDsCheckList.iterator(); iter.hasNext();) {
+ String toolID = (String) iter.next();
+ if (libExtCheckers.get(toolID) != null) {
+ VersionCheckInfo vci = null;
+ ILibraryExtensionVersionCheck extCheck = (ILibraryExtensionVersionCheck) libExtCheckers
+ .get(toolID);
+ vci = extCheck.checkLibraryVersion(file.getParentFile());
+ if (vci != null)
+ return vci;
+ }
+ }
+ }
+ Map versionMap = VersionUtil.readVersionsFromFile(file);
+ if (versionMap == null) {
+ return null;
+ } else {
+ VersionCheckInfo vci = null;
+ for (Iterator iter = toolIDsCheckList.iterator(); iter.hasNext();) {
+ String toolID = (String) iter.next();
+ if (versionMap.get(toolID) != null) {
+ String toolVersion = (String) versionMap.get(toolID);
+ vci = _checkLibVersion(toolID, toolVersion);
+ if (vci != null)
+ return vci;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static VersionCheckInfo _checkLibVersion(String toolID,
+ String toolVersion) {
+ // get the class that stores all the version info for this tool ID
+ EPFVersions versions = getVersions(toolID);
+ if (versions != null) {
+ EPFVersion minCurrVersion = versions
+ .getMinToolVersionForCurrentLibraryVersion();
+ int result = minCurrVersion.compareToolVersionTo(new Version(
+ toolVersion));
+ String currentMinToolVersion = minCurrVersion.getToolVersion()
+ .toString();
+ return new VersionCheckInfo(toolID, toolVersion,
+ currentMinToolVersion, -result);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return the first toolID that is checked. In most cases, the ID of the
+ * currently running application
+ */
+ public static String getPrimaryToolID() {
+ return (String) toolIDsCheckList.get(0);
+ }
+
+ /**
+ * Adds a tool ID to the order of tools to check.
+ *
+ * @param toolID
+ * toolID to add
+ * @param toolIDfollowing
+ * if null, adds toolID to front of list. otherwise, adds toolID
+ * before the specified ID
+ * @return false iff toolIDfollowing is not null and could not be found in
+ * list; true otherwise
+ */
+ public static boolean addToolID(String toolID, String toolIDfollowing) {
+ if (toolIDfollowing != null) {
+ int idx = toolIDsCheckList.indexOf(toolIDfollowing);
+ if (idx != -1) {
+ toolIDsCheckList.add(idx, toolID);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ toolIDsCheckList.add(0, toolID);
+ return true;
+ }
+
+}