diff --git a/org.eclipse.emf.common/src/main/java/module-info.java b/org.eclipse.emf.common/src/main/java/module-info.java
new file mode 100644
index 0000000..58dd6af
--- /dev/null
+++ b/org.eclipse.emf.common/src/main/java/module-info.java
@@ -0,0 +1,9 @@
+module org.eclipse.emf.common
+{
+ exports org.eclipse.emf.common.command;
+ exports org.eclipse.emf.common.util;
+ exports org.eclipse.emf.common.notify;
+ exports org.eclipse.emf.common.notify.impl;
+ exports org.eclipse.emf.common;
+ exports org.eclipse.emf.common.archive;
+}
\ No newline at end of file
diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/CommonPlugin.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/CommonPlugin.java
index 162dd25..92496d1 100644
--- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/CommonPlugin.java
+++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/CommonPlugin.java
@@ -11,10 +11,7 @@
package org.eclipse.emf.common;
-import java.io.File;
-import java.io.IOException;
import java.lang.reflect.Method;
-import java.net.URL;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
@@ -27,13 +24,7 @@
import java.util.Set;
import java.util.TreeMap;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.ResourceLocator;
-import org.eclipse.emf.common.util.URI;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
/**
@@ -55,11 +46,6 @@ public final class CommonPlugin extends EMFPlugin
*/
public static final CommonPlugin INSTANCE = new CommonPlugin();
- /**
- * The one instance of this class.
- */
- private static Implementation plugin;
-
/**
* Creates the singleton instance.
*/
@@ -68,111 +54,12 @@ private CommonPlugin()
super(new ResourceLocator[] {});
}
- @Override
- public ResourceLocator getPluginResourceLocator()
- {
- return plugin;
- }
-
- /**
- * Returns the singleton instance of the Eclipse plugin.
- * @return the singleton instance.
- */
- public static Implementation getPlugin()
- {
- return plugin;
- }
-
- /**
- * Use the platform, if available, to convert to a local URI.
- */
- public static URI asLocalURI(URI uri)
- {
- return plugin == null ? uri : Implementation.asLocalURI(uri);
- }
-
- /**
- * Use the platform, if available, to resolve the URI.
- */
- public static URI resolve(URI uri)
- {
- return plugin == null ? uri : Implementation.resolve(uri);
- }
-
/**
* Use the platform, if available, to load the named class using the right class loader.
*/
public static Class> loadClass(String pluginID, String className) throws ClassNotFoundException
{
- return plugin == null ? Class.forName(className) : Implementation.loadClass(pluginID, className);
- }
-
- /**
- * Computes a list of {@link ElementRecord element records} for each requested extension point.
- * Each key in the map is extension point ID.
- *
- * The corresponding value is a list of the extension point element records associated with that extension point.
- *
- *
- * Each root element record has synthetic attributes derived from the extension point:
- *
- *
- *
{@code point}
- *
The extension point ID itself.
- *
{@code symbolicName}
- *
The symbolic name of the bundle that contains the extension point.
- *
{@code location}
- *
- * The root location URI the bundle containing the extension point.
- * For example, {@code platform:/resource/org.example.plugin} for an extension point in the workspace,
- * {@code file:/folder/org.eclipse.plugin} for folder bundle in the target platform,
- * or {@code archive:file:/file/folder/org.example.plugin.jar!/} for a jarred bundle in the target platform.
- * This is useful for resolving a relative path in attribute value to its absolute path in the bundle.
- *
- *
- *
- * This method uses the Plug-in Development Environment (PDE) to compute the results.
- * It will include results for plug-ins in the workspace as well as for plug-ins in the target platform.
- * If PDE is not available, this information cannot be computed.
- *
- *
- * @param extensionPoints a set of extension points to query; if it's {@code null} or empty, all extension points will be queried.
- * @return a map of extension point data, or {@code null} if PDE is not available.
- * @since 2.14
- */
- public static Map> getTargetPlatformExtensionPoints(Set extensionPoints)
- {
- if (IS_ECLIPSE_RUNNING && PDEHelper.IS_PDE_BUNDLE_AVAILABLE)
- {
- return PDEHelper.computeModels(extensionPoints);
- }
- else
- {
- return null;
- }
- }
-
- /**
- * Computes a map from bundle symbolic name to the bundle's location URI.
- *
- * This method uses the Plug-in Development Environment (PDE) to compute the results.
- * It will include results for plug-ins in the workspace as well as for plug-ins in the target platform.
- * If PDE is not available, this information cannot be computed.
- *
- *
- * @return a map from bundle symbolic name to the bundle's location URI, or {@code null} if PDE is not available.
- * @since 2.14
- */
- public static Map getTargetPlatformBundleMappings()
- {
- if (IS_ECLIPSE_RUNNING && PDEHelper.IS_PDE_BUNDLE_AVAILABLE)
- {
- return PDEHelper.computeTargetPlatformBundleMappings();
- }
- else
- {
- return null;
- }
+ return Class.forName(className);
}
private static final Method COLLATOR_GET_INSTANCE_METHOD;
@@ -223,130 +110,6 @@ public Comparator getComparator(Locale locale)
return (Comparator)(Comparator>)Collator.getInstance(locale);
}
- /**
- * The actual implementation of the Eclipse Plugin.
- */
- public static class Implementation extends EclipsePlugin
- {
- /**
- * Creates an instance.
- */
- public Implementation()
- {
- super();
-
- // Remember the static instance.
- //
- plugin = this;
- }
-
- /**
- * Use the platform to convert to a local URI.
- */
- protected static URI asLocalURI(URI uri)
- {
- try
- {
- String fragment = uri.fragment();
- URL url = FileLocator.toFileURL(new URL(uri.trimFragment().toString()));
- return fix(url, fragment);
- }
- catch (IOException exception)
- {
- // Ignore the exception and return the original URI.
- }
- return uri;
- }
-
- /**
- * Use the platform to convert to a local URI.
- */
- protected static URI resolve(URI uri)
- {
- String fragment = uri.fragment();
- URI uriWithoutFragment = uri.trimFragment();
- String uriWithoutFragmentToString = uriWithoutFragment.toString();
-
- URL url = null;
- try
- {
- url = FileLocator.resolve(new URL(uriWithoutFragmentToString));
- }
- catch (IOException exception1)
- {
- // Platform.resolve() doesn't work if the project is encoded.
- //
- try
- {
- uriWithoutFragmentToString = URI.decode(uriWithoutFragmentToString);
- url = FileLocator.resolve(new URL(uriWithoutFragmentToString));
- }
- catch (IOException exception2)
- {
- // Continue with the unresolved URI.
- }
- }
- if (url != null)
- {
- try
- {
- return fix(url, fragment);
- }
- catch (IOException exception)
- {
- // Return the original URI.
- }
- }
-
- return uri;
- }
-
- protected static URI fix(URL url, String fragment) throws IOException
- {
- // Only file-scheme URIs will be re-encoded. If a URI was decoded in the workaround
- // above, and Platform.resolve() didn't return a file-scheme URI, then this will return
- // an decoded URI.
- //
- URI result =
- "file".equalsIgnoreCase(url.getProtocol()) ?
- URI.createFileURI(URI.decode(url.getFile())) :
- URI.createURI(url.toString());
- if (fragment != null)
- {
- result = result.appendFragment(fragment);
- }
- return result;
- }
-
- /**
- * Use the platform to load the named class using the right class loader.
- */
- public static Class> loadClass(String pluginID, String className) throws ClassNotFoundException
- {
- Bundle bundle = Platform.getBundle(pluginID);
- if (bundle == null)
- {
- throw new ClassNotFoundException(className + " cannot be loaded because because bundle " + pluginID + " cannot be resolved");
- }
- else
- {
- return bundle.loadClass(className);
- }
- }
-
- /**
- * @since 2.10
- */
- public static class Activator extends EMFPlugin.OSGiDelegatingBundleActivator
- {
- @Override
- protected BundleActivator createBundle()
- {
- return new Implementation();
- }
- }
- }
-
/**
* A specialized {@link HashMap} map that supports {@link #getTargetPlatformValues(String,String) computing} information from the target platform, if the PDE is available.
* It is abstract because the {@link #createKey(String)} method must be specialized to convert each attribute's string value to a value of the map's key type.
@@ -378,31 +141,7 @@ public SimpleTargetPlatformRegistryImpl()
*/
protected Set getTargetPlatformValues(String extensionPoint, String attributeName)
{
- Map> targetPlatformExtensionPoints = getTargetPlatformExtensionPoints(Collections.singleton(extensionPoint));
- if (targetPlatformExtensionPoints != null)
- {
- Set result = new LinkedHashSet();
- List extensionPointElementRecords = targetPlatformExtensionPoints.get(extensionPoint);
- if (extensionPointElementRecords != null)
- {
- for (CommonPlugin.ElementRecord extensionPointRecord : extensionPointElementRecords)
- {
- for (ElementRecord elementRecord : extensionPointRecord.getChildren())
- {
- String attribute = elementRecord.getAttributes().get(attributeName);
- if (attribute != null)
- {
- result.add(createKey(attribute));
- }
- }
- }
- }
- return result;
- }
- else
- {
- return new LinkedHashSet(keySet());
- }
+ return new LinkedHashSet(keySet());
}
/**
@@ -482,376 +221,4 @@ public String toString()
return "" + name + "attributes= " + attributes + " children=" + children;
}
}
-
- private static class PDEHelper
- {
- private static final Method PLUGIN_MODEL_BASE_GET_BUNDLE_DESCRIPTION_METHOD;
-
- private static final Method PLUGIN_MODEL_BASE_GET_UNDERLYING_RESOURCE_METHOD;
-
- private static final Method RESOURCE_GET_PROJECT_METHOD;
-
- private static final Method RESOURCE_GET_FULL_PATH_METHOD;
-
- private static final Method PLUGIN_MODEL_BASE_GET_INSTALL_LOCATION_METHOD;
-
- private static final Method PLUGIN_MODEL_BASE_GET_EXTENSIONS_METHOD;
-
- private static final Method PLUGIN_REGISTRY_GET_ACTIVE_MODELS_METHOD;
-
- private static final Method BUNDLE_DESCRIPTION_GET_SYMBOLIC_NAME_METHOD;
-
- private static final Method EXTENSIONS_GET_EXTENSIONS_METHOD;
-
- private static final Method PLUGIN_EXTENSION_GET_POINT_METHOD;
-
- private static final Method PLUGIN_EXTENSION_GET_CHILDREN_METHOD;
-
- private static final Class> PLUGIN_ELEMENT_CLASS;
-
- private static final Method PLUGIN_ELEMENT_GET_ATTRIBUTES_METHOD;
-
- private static final Method PLUGIN_OBJECT_GET_NAME_METHOD;
-
- private static final Method PLUGIN_ATTRIBUTE_GET_VALUE_METHOD;
-
- private static final boolean IS_PDE_BUNDLE_AVAILABLE;
-
- static
- {
- Method pluginModelBaseGetBundleDescriptionMethod = null;
- Method pluginModelBaseGetUnderlyingResourceMethod = null;
- Method resourceGetProjectMethod = null;
- Method resourceGetFullPathtMethod = null;
- Method pluginModelBaseGetInstallLocationMethod = null;
- Method pluginModelBaseGetExtensionsMethod = null;
- Method pluginRegistryGetActiveModelsMethod = null;
- Method bundleDescriptionGetSymbolicNameMethod = null;
- Method extensionsGetExtensionsMethod = null;
- Method pluginExtensionGetPointMethod = null;
- Method pluginExtensionGetChildrenMethod = null;
- Class> pluginElementClass = null;
- Method pluginElementGetAttributesMethod = null;
- Method pluginObjectGetNameMethod = null;
- Method pluginAttributeGetValueMethod = null;
- boolean isPDEBundleAvailable = false;
-
- try
- {
- Class> pluginModelBaseClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IPluginModelBase");
- pluginModelBaseGetBundleDescriptionMethod = pluginModelBaseClass.getMethod("getBundleDescription");
- pluginModelBaseGetUnderlyingResourceMethod = pluginModelBaseClass.getMethod("getUnderlyingResource");
- resourceGetProjectMethod = pluginModelBaseGetUnderlyingResourceMethod.getReturnType().getMethod("getProject");
- resourceGetFullPathtMethod = resourceGetProjectMethod.getReturnType().getMethod("getFullPath");
- pluginModelBaseGetInstallLocationMethod = pluginModelBaseClass.getMethod("getInstallLocation");
- pluginModelBaseGetExtensionsMethod = pluginModelBaseClass.getMethod("getExtensions");
- Class> pluginRegistryClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.PluginRegistry");
- pluginRegistryGetActiveModelsMethod = pluginRegistryClass.getMethod("getActiveModels", boolean.class);
- Class> bundleDescriptionClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.osgi.service.resolver.BundleDescription");
- bundleDescriptionGetSymbolicNameMethod = bundleDescriptionClass.getMethod("getSymbolicName");
- Class> extensionsClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IExtensions");
- extensionsGetExtensionsMethod = extensionsClass.getMethod("getExtensions");
- Class> pluginExtensionClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IPluginExtension");
- pluginExtensionGetPointMethod = pluginExtensionClass.getMethod("getPoint");
- pluginExtensionGetChildrenMethod = pluginExtensionClass.getMethod("getChildren");
- pluginElementClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IPluginElement");
- pluginObjectGetNameMethod = pluginElementClass.getMethod("getName");
- pluginElementGetAttributesMethod = pluginElementClass.getMethod("getAttributes");
- Class> pluginAttributeClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IPluginAttribute");
- pluginAttributeGetValueMethod = pluginAttributeClass.getMethod("getValue");
- isPDEBundleAvailable = true;
- }
- catch (Throwable exception)
- {
- // Ignore.
- }
-
- PLUGIN_MODEL_BASE_GET_BUNDLE_DESCRIPTION_METHOD = pluginModelBaseGetBundleDescriptionMethod;
- PLUGIN_MODEL_BASE_GET_UNDERLYING_RESOURCE_METHOD = pluginModelBaseGetUnderlyingResourceMethod;
- RESOURCE_GET_PROJECT_METHOD = resourceGetProjectMethod;
- RESOURCE_GET_FULL_PATH_METHOD = resourceGetFullPathtMethod;
- PLUGIN_MODEL_BASE_GET_INSTALL_LOCATION_METHOD = pluginModelBaseGetInstallLocationMethod;
- PLUGIN_MODEL_BASE_GET_EXTENSIONS_METHOD = pluginModelBaseGetExtensionsMethod;
- PLUGIN_REGISTRY_GET_ACTIVE_MODELS_METHOD = pluginRegistryGetActiveModelsMethod;
- BUNDLE_DESCRIPTION_GET_SYMBOLIC_NAME_METHOD = bundleDescriptionGetSymbolicNameMethod;
- EXTENSIONS_GET_EXTENSIONS_METHOD = extensionsGetExtensionsMethod;
- PLUGIN_EXTENSION_GET_POINT_METHOD = pluginExtensionGetPointMethod;
- PLUGIN_EXTENSION_GET_CHILDREN_METHOD = pluginExtensionGetChildrenMethod;
- PLUGIN_ELEMENT_CLASS = pluginElementClass;
- PLUGIN_OBJECT_GET_NAME_METHOD = pluginObjectGetNameMethod;
- PLUGIN_ELEMENT_GET_ATTRIBUTES_METHOD = pluginElementGetAttributesMethod;
- PLUGIN_ATTRIBUTE_GET_VALUE_METHOD = pluginAttributeGetValueMethod;
- IS_PDE_BUNDLE_AVAILABLE = isPDEBundleAvailable && !"true".equals(System.getProperty("org.eclipse.emf.common.CommonPlugin.doNotUsePDE"));
- }
-
- @SuppressWarnings("unchecked")
- private static T invoke(Object object, Method method, Object... arguments)
- {
- try
- {
- return (T)method.invoke(object, arguments);
- }
- catch (Exception exception)
- {
- return null;
- }
- }
-
- private static Map computeTargetPlatformBundleMappings()
- {
- Map result = new TreeMap();
-
- // Iterate over all the active models in the workspace and target platform.
- //
- // IPluginModelBase[] activeModels = PluginRegistry.getActiveModels(false);
- //
- Object[] activeModels = invoke(null, PLUGIN_REGISTRY_GET_ACTIVE_MODELS_METHOD, Boolean.FALSE);
- for (Object activeModel : activeModels)
- {
- // Determine the symbolic name, underlying resource, if any, and the install location.
- //
- // BundleDescription bundleDescription = activeModel.getBundleDescription();
- // String symbolicName = bundleDescription.getSymbolicName();
- // IResource underlyingResource = activeModel.getUnderlyingResource();
- // String installLocation = activeModel.getInstallLocation();
- //
- Object bundleDescription = invoke(activeModel, PLUGIN_MODEL_BASE_GET_BUNDLE_DESCRIPTION_METHOD);
- String symbolicName = (String)invoke(bundleDescription, BUNDLE_DESCRIPTION_GET_SYMBOLIC_NAME_METHOD);
- Object underlyingResource = invoke(activeModel, PLUGIN_MODEL_BASE_GET_UNDERLYING_RESOURCE_METHOD);
- String installLocation = (String)invoke(activeModel, PLUGIN_MODEL_BASE_GET_INSTALL_LOCATION_METHOD);
-
- // The URI for the location is determined from the underlying resource or the install location, with preference to the former if available.
- //
- URI location;
- if (underlyingResource != null)
- {
- // If there is an underlying resource, use the platform resource URI referencing the project in the workspace as the location.
- // underlyingResource.getProject()
- //
- Object project = invoke(underlyingResource, RESOURCE_GET_PROJECT_METHOD);
- IPath fullPath = invoke(project, RESOURCE_GET_FULL_PATH_METHOD);
- location = URI.createPlatformResourceURI(fullPath.toString(), true);
- }
- else if (installLocation != null)
- {
- // Otherwise, the install location in the file system is used...
- //
- File file = new File(installLocation);
- if (file.isDirectory())
- {
- // If the file is a directory, create a file URI for that directory.
- //
- location = URI.createFileURI(installLocation);
- }
- else
- {
- // Otherwise, the location must be an archive, create an archive URI for the file URI of the jar.
- //
- location = URI.createURI("archive:" + URI.createFileURI(installLocation) + "!/");
- }
- }
- else
- {
- location = null;
- }
-
- if (symbolicName != null && location != null)
- {
- result.put(symbolicName, location);
- }
- }
-
- return result;
- }
-
- private static Map> computeModels(Set extensionPoints)
- {
- Map> result = new TreeMap>();
-
- // Iterate over all the active models in the workspace and target platform.
- //
- // IPluginModelBase[] activeModels = PluginRegistry.getActiveModels(false);
- //
- Object[] activeModels = invoke(null, PLUGIN_REGISTRY_GET_ACTIVE_MODELS_METHOD, Boolean.FALSE);
- for (Object activeModel : activeModels)
- {
- // Iterate over the plugin's extensions...
- //
- // IExtensions extensions = activeModel.getExtensions();
- // IPluginExtension[] pluginExtensions = extensions.getExtensions();
- //
- Object extensions = invoke(activeModel, PLUGIN_MODEL_BASE_GET_EXTENSIONS_METHOD);
- Object[] pluginExtensions = invoke(extensions, EXTENSIONS_GET_EXTENSIONS_METHOD);
- for (Object pluginExtension : pluginExtensions)
- {
- // String point = pluginExtension.getPoint();
- //
- String point = invoke(pluginExtension, PLUGIN_EXTENSION_GET_POINT_METHOD);
-
- // Process all or the specified extension pointers.
- //
- if (extensionPoints == null || extensionPoints.isEmpty() || extensionPoints.contains(point))
- {
- // Determine the symbolic name, underlying resource, if any, and the install location.
- //
- // BundleDescription bundleDescription = activeModel.getBundleDescription();
- // String symbolicName = bundleDescription.getSymbolicName();
- // IResource underlyingResource = activeModel.getUnderlyingResource();
- // String installLocation = activeModel.getInstallLocation();
- //
- Object bundleDescription = invoke(activeModel, PLUGIN_MODEL_BASE_GET_BUNDLE_DESCRIPTION_METHOD);
- String symbolicName = (String)invoke(bundleDescription, BUNDLE_DESCRIPTION_GET_SYMBOLIC_NAME_METHOD);
- Object underlyingResource = invoke(activeModel, PLUGIN_MODEL_BASE_GET_UNDERLYING_RESOURCE_METHOD);
- String installLocation = (String)invoke(activeModel, PLUGIN_MODEL_BASE_GET_INSTALL_LOCATION_METHOD);
-
- // The URI for the location is determined from the underlying resource or the install location, with preference to the former if available.
- //
- URI location;
- if (underlyingResource != null)
- {
- // If there is an underlying resource, use the platform resource URI referencing the project in the workspace as the location.
- // underlyingResource.getProject()
- //
- Object project = invoke(underlyingResource, RESOURCE_GET_PROJECT_METHOD);
- IPath fullPath = invoke(project, RESOURCE_GET_FULL_PATH_METHOD);
- location = URI.createPlatformResourceURI(fullPath.toString(), true);
- }
- else if (installLocation != null)
- {
- // Otherwise, the install location in the file system is used...
- //
- File file = new File(installLocation);
- if (file.isDirectory())
- {
- // If the file is a directory, create a file URI for that directory.
- //
- location = URI.createFileURI(installLocation);
- }
- else
- {
- // Otherwise, the location must be an archive, create an archive URI for the file URI of the jar.
- //
- location = URI.createURI("archive:" + URI.createFileURI(installLocation) + "!/");
- }
- }
- else
- {
- location = null;
- }
-
- List elementRecords = result.get(point);
- if (elementRecords == null)
- {
- elementRecords = new ArrayList();
- result.put(point, elementRecords);
- }
-
- ElementRecord elementRecord = visitElement(pluginExtension);
- if (location != null)
- {
- elementRecord.attributes.put("point", point);
- elementRecord.attributes.put("symbolicName", symbolicName);
- elementRecord.attributes.put("location", location.toString());
- }
- elementRecords.add(elementRecord);
- }
- }
- }
-
- // dump(result);
- return result;
- }
-
- private static void visitElement(Object[] children, List elementRecords)
- {
- // Visit the children.
- //
- for (Object child : children)
- {
- // if (child instanceof IPluginElement)
- //
- if (PLUGIN_ELEMENT_CLASS.isInstance(child))
- {
- elementRecords.add(visitElement(child));
- }
- }
- }
-
- private static ElementRecord visitElement(Object child)
- {
- ElementRecord elementRecord;
- if (PLUGIN_ELEMENT_CLASS.isInstance(child))
- {
- // child.getName();
- //
- String elementName = invoke(child, PLUGIN_OBJECT_GET_NAME_METHOD);
-
- // Record it by name.
- //
- elementRecord = new ElementRecord(elementName);
-
- // child.getAttributes()
- Object[] attributes = invoke(child, PLUGIN_ELEMENT_GET_ATTRIBUTES_METHOD);
- for (Object attribute : attributes)
- {
- // attribute.getName() and attribute.getValue()
- //
- String attributeName = invoke(attribute, PLUGIN_OBJECT_GET_NAME_METHOD);
- String attributeValue = invoke(attribute, PLUGIN_ATTRIBUTE_GET_VALUE_METHOD);
-
- // Record in the map.
- //
- elementRecord.attributes.put(attributeName, attributeValue);
- }
- }
- else
- {
- elementRecord = new ElementRecord("extension");
- }
-
- // Visit the child elements recursively.
- //
- Object[] elements = invoke(child, PLUGIN_EXTENSION_GET_CHILDREN_METHOD);
- if (elements.length != 0)
- {
- visitElement(elements, elementRecord.children);
- }
-
- return elementRecord;
- }
-
-// private static void dump(Map> data)
-// {
-// for (Map.Entry> entry : data.entrySet())
-// {
-// System.out.println(entry.getKey());
-// dump(entry.getValue(), " ");
-// }
-// }
-//
-// private static void dump(List data, String indent)
-// {
-// for (ElementRecord elementRecord : data)
-// {
-// System.out.print(indent + "<" + elementRecord.getName());
-// for (Map.Entry attribute : elementRecord.getAttributes().entrySet())
-// {
-// System.out.println();
-// System.out.print(indent + " " + attribute.getKey() + "='" + attribute.getValue() + "'");
-// }
-// List children = elementRecord.getChildren();
-// if (children.isEmpty())
-// {
-// System.out.println("/>");
-// }
-// else
-// {
-// System.out.println(">");
-// dump(children, indent + " ");
-// System.out.print(indent + "" + elementRecord.getName() + ">");
-// }
-// }
-// }
-
- }
}
diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/EMFPlugin.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/EMFPlugin.java
index a3e71f0..45e3ac8 100644
--- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/EMFPlugin.java
+++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/EMFPlugin.java
@@ -13,29 +13,13 @@
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
import java.util.jar.Manifest;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-
import org.eclipse.emf.common.util.DelegatingResourceLocator;
import org.eclipse.emf.common.util.Logger;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.WrappedException;
/**
@@ -57,39 +41,9 @@
*/
public abstract class EMFPlugin extends DelegatingResourceLocator implements ResourceLocator, Logger
{
- public static final boolean IS_ECLIPSE_RUNNING;
- static
- {
- boolean result = false;
- try
- {
- result = Platform.isRunning();
- }
- catch (Throwable exception)
- {
- // Assume that we aren't running.
- }
- IS_ECLIPSE_RUNNING = result;
- }
+ public static final boolean IS_ECLIPSE_RUNNING = false;
- public static final boolean IS_RESOURCES_BUNDLE_AVAILABLE;
- static
- {
- boolean result = false;
- if (IS_ECLIPSE_RUNNING)
- {
- try
- {
- Bundle resourcesBundle = Platform.getBundle("org.eclipse.core.resources");
- result = resourcesBundle != null && (resourcesBundle.getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.RESOLVED)) != 0;
- }
- catch (Throwable exception)
- {
- // Assume that it's not available.
- }
- }
- IS_RESOURCES_BUNDLE_AVAILABLE = result;
- }
+ public static final boolean IS_RESOURCES_BUNDLE_AVAILABLE = false;
protected ResourceLocator [] delegateResourceLocators;
@@ -98,16 +52,10 @@ public EMFPlugin(ResourceLocator [] delegateResourceLocators)
this.delegateResourceLocators = delegateResourceLocators;
}
- /**
- * Returns an Eclipse plugin implementation of a resource locator.
- * @return an Eclipse plugin implementation of a resource locator.
- */
- public abstract ResourceLocator getPluginResourceLocator();
-
@Override
final protected ResourceLocator getPrimaryResourceLocator()
{
- return getPluginResourceLocator();
+ return null;
}
@Override
@@ -116,27 +64,10 @@ protected ResourceLocator[] getDelegateResourceLocators()
return delegateResourceLocators;
}
- /**
- * Returns an Eclipse plugin implementation of a logger.
- * @return an Eclipse plugin implementation of a logger.
- */
- public Logger getPluginLogger()
- {
- return (Logger)getPluginResourceLocator();
- }
-
public String getSymbolicName()
{
- ResourceLocator resourceLocator = getPluginResourceLocator();
- if (resourceLocator instanceof InternalEclipsePlugin)
- {
- return ((InternalEclipsePlugin)resourceLocator).getSymbolicName();
- }
- else
- {
- String result = getClass().getName();
- return result.substring(0, result.lastIndexOf('.'));
- }
+ String result = getClass().getName();
+ return result.substring(0, result.lastIndexOf('.'));
}
/*
@@ -144,168 +75,13 @@ public String getSymbolicName()
*/
public void log(Object logEntry)
{
- Logger logger = getPluginLogger();
- if (logger == null)
+ if (logEntry instanceof Throwable)
{
- if (logEntry instanceof Throwable)
- {
- ((Throwable)logEntry).printStackTrace(System.err);
- }
- else
- {
- System.err.println(logEntry);
- }
+ ((Throwable)logEntry).printStackTrace(System.err);
}
else
{
- logger.log(logEntry);
- }
- }
-
- /**
- * This is just a bundle activator wrapper for delegating to another bundle activator.
- * It provides a {@link #createBundle() create} method for creating the delegate.
- * Any exception thrown during creation of the delegate is ignored,
- * in which case this activator does nothing for {@link #start(BundleContext) start} and {@link #stop(BundleContext) stop}.
- * The idea is to provide a bundle activator that can delegate to an Equinox-dependent bundle activator,
- * but behaves gracefully in a non-Equinox OSGi implementation.
- *
- * @since 2.10
- */
- public static abstract class OSGiDelegatingBundleActivator implements BundleActivator
- {
- private final BundleActivator bundle;
-
- public OSGiDelegatingBundleActivator()
- {
- bundle = createBundleHelper();
- }
-
- private BundleActivator createBundleHelper()
- {
- try
- {
- return createBundle();
- }
- catch (Throwable throwable)
- {
- return null;
- }
- }
-
- protected abstract BundleActivator createBundle();
-
- public final void start(BundleContext context) throws Exception
- {
- if (bundle != null)
- {
- bundle.start(context);
- }
- }
-
- public final void stop(BundleContext context) throws Exception
- {
- if (bundle != null)
- {
- bundle.stop(context);
- }
- }
- }
-
- /**
- * The actual implementation of an Eclipse Plugin.
- */
- public static abstract class EclipsePlugin extends Plugin implements ResourceLocator, Logger, InternalEclipsePlugin
- {
- /**
- * The EMF plug-in APIs are all delegated to this helper, so that code can be shared by plug-in
- * implementations with a different platform base class (e.g. AbstractUIPlugin).
- */
- protected InternalHelper helper;
-
- /**
- * Creates an instance.
- */
- public EclipsePlugin()
- {
- super();
- helper = new InternalHelper(this);
- }
-
- /**
- * Return the plugin ID.
- */
- public String getSymbolicName()
- {
- return helper.getSymbolicName();
- }
-
- /*
- * Javadoc copied from interface.
- */
- public URL getBaseURL()
- {
- return helper.getBaseURL();
- }
-
- /*
- * Javadoc copied from interface.
- */
- public Object getImage(String key)
- {
- try
- {
- return doGetImage(key);
- }
- catch (MalformedURLException exception)
- {
- throw new WrappedException(exception);
- }
- catch (IOException exception)
- {
- throw
- new MissingResourceException
- (CommonPlugin.INSTANCE.getString("_UI_StringResourceNotFound_exception", new Object [] { key }),
- getClass().getName(),
- key);
- }
- }
-
- /**
- * Does the work of fetching the image associated with the key.
- * It ensures that the image exists.
- * @param key the key of the image to fetch.
- * @exception IOException if an image doesn't exist.
- * @return the description of the image associated with the key.
- */
- protected Object doGetImage(String key) throws IOException
- {
- return helper.getImage(key);
- }
-
- public String getString(String key)
- {
- return helper.getString(key, true);
- }
-
- public String getString(String key, boolean translate)
- {
- return helper.getString(key, translate);
- }
-
- public String getString(String key, Object [] substitutions)
- {
- return helper.getString(key, substitutions, true);
- }
-
- public String getString(String key, Object [] substitutions, boolean translate)
- {
- return helper.getString(key, substitutions, translate);
- }
-
- public void log(Object logEntry)
- {
- helper.log(logEntry);
+ System.err.println(logEntry);
}
}
@@ -317,141 +93,6 @@ public static interface InternalEclipsePlugin
{
String getSymbolicName();
}
-
- /**
- * This just provides a common delegate for non-UI and UI plug-in classes.
- * It is not considered API and should not be used by clients.
- */
- public static class InternalHelper
- {
- protected Plugin plugin;
- protected ResourceBundle resourceBundle;
- protected ResourceBundle untranslatedResourceBundle;
-
- public InternalHelper(Plugin plugin)
- {
- this.plugin = plugin;
- }
-
- protected Bundle getBundle()
- {
- return plugin.getBundle();
- }
-
- protected ILog getLog()
- {
- return plugin.getLog();
- }
-
- /**
- * Return the plugin ID.
- */
- public String getSymbolicName()
- {
- return getBundle().getSymbolicName();
- }
-
- public URL getBaseURL()
- {
- return getBundle().getEntry("/");
- }
-
- /**
- * Fetches the image associated with the given key. It ensures that the image exists.
- * @param key the key of the image to fetch.
- * @exception IOException if an image doesn't exist.
- * @return the description of the image associated with the key.
- */
- public Object getImage(String key) throws IOException
- {
- URL url = new URL(getBaseURL() + "icons/" + key + extensionFor(key));
- InputStream inputStream = url.openStream();
- inputStream.close();
- return url;
- }
-
- public String getString(String key, boolean translate)
- {
- ResourceBundle bundle = translate ? resourceBundle : untranslatedResourceBundle;
- if (bundle == null)
- {
- if (translate)
- {
- bundle = resourceBundle = Platform.getResourceBundle(getBundle());
- }
- else
- {
- String bundleLocalization = (String)getBundle().getHeaders().get(Constants.BUNDLE_LOCALIZATION);
- String propertiesPath = bundleLocalization != null ? bundleLocalization + ".properties" : "plugin.properties";
- String resourceName = getBaseURL().toString() + propertiesPath;
- try
- {
- InputStream inputStream = new URL(resourceName).openStream();
- bundle = untranslatedResourceBundle = new PropertyResourceBundle(inputStream);
- inputStream.close();
- }
- catch (IOException ioException)
- {
- throw new MissingResourceException("Missing properties: " + resourceName, getClass().getName(), propertiesPath);
- }
- }
- }
- return bundle.getString(key);
- }
-
- public String getString(String key, Object [] substitutions, boolean translate)
- {
- return MessageFormat.format(getString(key, translate), substitutions);
- }
-
- public void log(Object logEntry)
- {
- IStatus status;
- if (logEntry instanceof IStatus)
- {
- status = (IStatus)logEntry;
- getLog().log(status);
- }
- else
- {
- if (logEntry == null)
- {
- logEntry = new RuntimeException(getString("_UI_NullLogEntry_exception", true)).fillInStackTrace();
- }
-
- if (logEntry instanceof Throwable)
- {
- Throwable throwable = (Throwable)logEntry;
-
- // System.err.println("Logged throwable: --------------------");
- // throwable.printStackTrace();
-
- String message = throwable.getLocalizedMessage();
- if (message == null)
- {
- Throwable cause = throwable.getCause();
- if (cause != null)
- {
- message = cause.getLocalizedMessage();
- }
- if (message == null)
- {
- message = "";
- }
- }
-
- getLog().log(new Status(IStatus.WARNING, getBundle().getSymbolicName(), 0, message, throwable));
- }
- else
- {
- // System.err.println("Logged throwable: --------------------");
- // throwable.printStackTrace();
-
- getLog().log (new Status (IStatus.WARNING, getBundle().getSymbolicName(), 0, logEntry.toString(), null));
- }
- }
- }
- }
public static void main(String[] args)
{
diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicDiagnostic.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicDiagnostic.java
index 787dedc..50d057b 100644
--- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicDiagnostic.java
+++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicDiagnostic.java
@@ -10,14 +10,9 @@
*/
package org.eclipse.emf.common.util;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.emf.common.EMFPlugin;
-
/**
* A basic implementation of a diagnostic that that also acts as a chain.
@@ -295,219 +290,6 @@ public String toString()
return result.toString();
}
- private static class StatusWrapper implements IStatus
- {
- protected static final IStatus [] EMPTY_CHILDREN = new IStatus [0];
-
- protected Throwable throwable;
- protected Diagnostic diagnostic;
- protected IStatus [] wrappedChildren;
-
- public StatusWrapper(Diagnostic diagnostic)
- {
- this.diagnostic = diagnostic;
- }
-
- public StatusWrapper(DiagnosticException diagnosticException)
- {
- throwable = diagnosticException;
- diagnostic = diagnosticException.getDiagnostic();
- }
-
- public IStatus[] getChildren()
- {
- if (wrappedChildren == null)
- {
- List children = diagnostic.getChildren();
- if (children.isEmpty())
- {
- wrappedChildren = EMPTY_CHILDREN;
- }
- else
- {
- wrappedChildren = new IStatus [children.size()];
- for (int i = 0; i < wrappedChildren.length; ++i)
- {
- wrappedChildren[i] = toIStatus(children.get(i));
- }
- }
- }
- return wrappedChildren;
- }
-
- public int getCode()
- {
- return diagnostic.getCode();
- }
-
- public Throwable getException()
- {
- return throwable != null ? throwable : diagnostic.getException();
- }
-
- public String getMessage()
- {
- return diagnostic.getMessage();
- }
-
- public String getPlugin()
- {
- return diagnostic.getSource();
- }
-
- public int getSeverity()
- {
- return diagnostic.getSeverity();
- }
-
- public boolean isMultiStatus()
- {
- return !diagnostic.getChildren().isEmpty();
- }
-
- public boolean isOK()
- {
- return diagnostic.getSeverity() == OK;
- }
-
- public boolean matches(int severityMask)
- {
- return (diagnostic.getSeverity() & severityMask ) != 0;
- }
-
- @Override
- public String toString()
- {
- return diagnostic.toString();
- }
-
- public static IStatus convert(Diagnostic diagnostic)
- {
- return
- diagnostic instanceof DiagnosticWrapper ?
- ((DiagnosticWrapper)diagnostic).status :
- new StatusWrapper(diagnostic);
- }
-
- public static IStatus create(DiagnosticException diagnosticException)
- {
- return new StatusWrapper(diagnosticException);
- }
- }
-
- /**
- * Returns the diagnostic viewed as an {@link IStatus}.
- */
- public static IStatus toIStatus(Diagnostic diagnostic)
- {
- return StatusWrapper.convert(diagnostic);
- }
-
- /**
- * Returns the diagnostic exception viewed as an {@link IStatus}.
- */
- public static IStatus toIStatus(DiagnosticException diagnosticException)
- {
- return StatusWrapper.create(diagnosticException);
- }
-
- private static class DiagnosticWrapper implements Diagnostic
- {
- protected IStatus status;
- protected List wrappedChildren;
- protected List unmodifiableWrappedChildren;
- protected List