Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jem.util/jemutil')
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/EMFWorkbenchContextFactory.java172
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/ProjectResourceSetImpl.java274
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceHandler.java147
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceNotifier.java73
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nature/EMFNatureRegistry.java74
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nls/EMFWorkbenchResourceHandler.java63
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/CharacterUtil.java279
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/NotPresentPerformanceMonitor.java55
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PerformanceMonitorUtil.java280
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PresentPerformanceMonitor.java79
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/RegistryReader.java156
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/TimerTests.java352
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UIContextDetermination.java189
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UITester.java31
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/EMFWorkbenchContextBase.java193
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/IEMFContextContributor.java46
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ISynchronizerExtender.java44
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectResourceSet.java117
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java754
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceHandler.java65
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceSetWorkbenchSynchronizer.java191
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchByteArrayOutputStream.java148
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchResourceHelperBase.java694
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverter.java154
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverterImpl.java514
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/nature/EMFNature.java554
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/AbstractWorkBenchRenderer.java472
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/ConsoleLogRenderer.java67
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/DefaultPluginTraceRenderer.java113
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/EclipseLogger.java123
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/IMsgLogger.java26
-rw-r--r--plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/plugin/JEMUtilPlugin.java399
32 files changed, 0 insertions, 6898 deletions
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/EMFWorkbenchContextFactory.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/EMFWorkbenchContextFactory.java
deleted file mode 100644
index 698a4352b..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/EMFWorkbenchContextFactory.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: EMFWorkbenchContextFactory.java,v $$
- * $$Revision: 1.4 $$ $$Date: 2005/06/16 20:14:27 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectNature;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import org.eclipse.jem.internal.util.emf.workbench.nls.EMFWorkbenchResourceHandler;
-import org.eclipse.jem.util.RegistryReader;
-import org.eclipse.jem.util.emf.workbench.*;
-import org.eclipse.jem.util.emf.workbench.nature.EMFNature;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-
-public class EMFWorkbenchContextFactory {
- public static final EMFWorkbenchContextFactory INSTANCE;
-
- static {
- INSTANCE = createFactoryInstance();
- }
- private final Class CONTRIBUTOR_CLASS = IEMFContextContributor.class;
- protected Map emfContextCache = new WeakHashMap();
-
-
- private static EMFWorkbenchContextFactory createFactoryInstance() {
- EMFWorkbenchContextFactory factory = createFactoryInstanceFromExtension();
- if (factory == null)
- factory = new EMFWorkbenchContextFactory();
- return factory;
- }
-
- private static EMFWorkbenchContextFactory createFactoryInstanceFromExtension() {
- final EMFWorkbenchContextFactory[] factoryHolder = new EMFWorkbenchContextFactory[1];
- RegistryReader reader = new RegistryReader(JEMUtilPlugin.ID, "internalWorkbenchContextFactory") { //$NON-NLS-1$
- public boolean readElement(IConfigurationElement element) {
- if (element.getName().equals("factoryClass")) //$NON-NLS-1$
- try {
- factoryHolder[0] = (EMFWorkbenchContextFactory)element.createExecutableExtension("name"); //$NON-NLS-1$
- return true;
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
- return false;
- }
- };
- reader.readRegistry();
- return factoryHolder[0];
- }
-
- /**
- * Constructor for EMFNatureFactory.
- */
- protected EMFWorkbenchContextFactory() {
- super();
-
- }
-
-
- protected void cacheEMFContext(IProject aProject, EMFWorkbenchContextBase emfContext) {
- if (aProject != null && emfContext != null)
- emfContextCache.put(aProject, emfContext);
- }
-
- protected EMFWorkbenchContextBase getCachedEMFContext(IProject aProject) {
- if (aProject != null)
- return (EMFWorkbenchContextBase) emfContextCache.get(aProject);
- return null;
- }
-
- /**
- * <code>aProject</code> is either being closed or deleted so we need to cleanup our cache.
- */
- public void removeCachedProject(IProject aProject) {
- if (aProject != null)
- emfContextCache.remove(aProject);
-
- }
- /**
- * Return a new or existing EMFNature on <code>aProject</code>. Allow the <code>contributor</code>
- * to contribute to the new or existing nature prior to returning.
- */
- public EMFWorkbenchContextBase createEMFContext(IProject aProject, IEMFContextContributor contributor) {
- if (aProject == null)
- throw new IllegalStateException("[EMFWorkbenchContextBase]" + EMFWorkbenchResourceHandler.getString("EMFWorkbenchContextFactory_UI_0")); //$NON-NLS-1$ //$NON-NLS-2$
- if (!aProject.isAccessible())
- throw new IllegalStateException("[EMFWorkbenchContextBase]" + EMFWorkbenchResourceHandler.getString("EMFWorkbenchContextFactory_UI_1", new Object[]{aProject.getName()})); //$NON-NLS-1$ //$NON-NLS-2$
- EMFWorkbenchContextBase context = getCachedEMFContext(aProject);
- boolean contributorFound = false;
- if (context == null) {
- context = primCreateEMFContext(aProject);
- cacheEMFContext(aProject, context);
- contributorFound = initializeEMFContextFromContributors(aProject, context, contributor);
- }
- if (contributor != null && context != null && !contributorFound)
- contributor.primaryContributeToContext(context);
- return context;
- }
-
- protected boolean initializeEMFContextFromContributors(IProject aProject, EMFWorkbenchContextBase emfContext, IEMFContextContributor contributor) {
- boolean contributorFound = false;
- if (aProject == null || emfContext == null)
- return contributorFound;
- List runtimes = EMFNature.getRegisteredRuntimes(aProject);
- for (int i = 0; i < runtimes.size(); i++) {
- IProjectNature nature = (IProjectNature) runtimes.get(i);
- if (nature != null && CONTRIBUTOR_CLASS.isInstance(nature)) {
- if (nature == contributor)
- contributorFound = true;
- ((IEMFContextContributor) nature).primaryContributeToContext(emfContext);
- }
- }
- return contributorFound;
- }
-
- protected boolean isNatureEnabled(IProject aProject, String natureId) {
- try {
- return aProject.isNatureEnabled(natureId);
- } catch (CoreException e) {
- return false;
- }
- }
-
- protected String[] getNatureIds(IProject aProject) {
- try {
- if (aProject.isAccessible())
- return aProject.getDescription().getNatureIds();
- } catch (CoreException e) {
- }
- return null;
- }
-
- protected IProjectNature getNature(IProject aProject, String natureId) {
- try {
- return aProject.getNature(natureId);
- } catch (CoreException e) {
- return null;
- }
- }
-
- protected EMFWorkbenchContextBase primCreateEMFContext(IProject aProject) {
- return new EMFWorkbenchContextBase(aProject);
- }
- /**
- * Return an existing EMFNature on <code>aProject</code>.
- */
- public EMFWorkbenchContextBase getEMFContext(IProject aProject) {
- return getCachedEMFContext(aProject);
- }
-
- public ResourceSetWorkbenchSynchronizer createSynchronizer(ResourceSet aResourceSet, IProject aProject) {
- return new ResourceSetWorkbenchSynchronizer(aResourceSet, aProject);
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/ProjectResourceSetImpl.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/ProjectResourceSetImpl.java
deleted file mode 100644
index 36c8f4df4..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/ProjectResourceSetImpl.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: ProjectResourceSetImpl.java,v $$
- * $$Revision: 1.8 $$ $$Date: 2005/03/18 18:52:06 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench;
-
-import java.io.IOException;
-import java.util.*;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.NotificationImpl;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-
-import org.eclipse.jem.util.emf.workbench.*;
-import org.eclipse.jem.util.emf.workbench.nature.EMFNature;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-public class ProjectResourceSetImpl extends ResourceSetImpl implements ProjectResourceSet {
- private boolean isReleasing = false;
- private IProject project;
- protected List resourceHandlers = new ArrayList();
- protected ResourceSetWorkbenchSynchronizer synchronizer;
- protected ProjectResourceSetImpl() {
- setURIResourceMap(new HashMap(10)); // Tell it to cache uri->resource access.
- getLoadOptions().put(XMLResource.OPTION_USE_PARSER_POOL, EMFNature.SHARED_PARSER_POOL);
- }
- public ProjectResourceSetImpl(IProject aProject) {
- this();
- setProject(aProject);
- initializeSharedCacheListener();
- }
- protected void initializeSharedCacheListener() {
- JEMUtilPlugin.getSharedCache().beginListening(this);
- }
- protected boolean isReleasing() {
- return isReleasing;
- }
- /**
- * @see org.eclipse.emf.ecore.resource.impl.ResourceSetImpl#delegatedGetResource(URI, boolean)
- */
- protected Resource delegatedGetResource(URI uri, boolean loadOnDemand) {
- Resource res = super.delegatedGetResource(uri, loadOnDemand);
- if (res == null)
- res = getResourceFromHandlers(uri);
- return res;
- }
- public Resource createResource(URI uri) {
- if (isReleasing) return null;
- //Check the map first when creating the resource and do not
- //normalize if a value is found.
- boolean isMapped = !(((URIConverterImpl.URIMap)getURIConverter().getURIMap()).getURI(uri).equals(uri));
- URI converted = uri;
- if (!isMapped)
- converted = getURIConverter().normalize(uri);
- Resource result = createResourceFromHandlers(converted);
- if (result == null)
- result = super.createResource(converted);
-
- return result;
- }
- /**
- * @see org.eclipse.emf.ecore.resource.impl.ResourceSetImpl#demandLoad(Resource)
- */
- protected void demandLoad(Resource resource) throws IOException {
- if (!isReleasing)
- super.demandLoad(resource);
- }
-
- /**
- * See if any resource handlers from the WorkbenchContext
- * decide to create the Resource in another manner.
- */
- protected Resource createResourceFromHandlers(URI uri) {
- Resource resource = null;
- ResourceHandler handler = null;
- for (int i = 0; i < resourceHandlers.size(); i++) {
- handler = (ResourceHandler) resourceHandlers.get(i);
- resource = handler.createResource(this, uri);
- if (resource != null)
- return resource;
- }
- return null;
- }
- /**
- * See if any resource handlers from the WorkbenchContext
- * can return a Resource from a <code>uri</code>.
- */
- protected Resource getResourceFromHandlers(URI uri) {
- if (isReleasing) return null;
- for (int i = 0; i < resourceHandlers.size(); i++) {
- Resource resource = ((ResourceHandler) resourceHandlers.get(i)).getResource(this, uri);
- if (resource != null)
- return resource;
- }
- return null;
- }
-
- public void release() {
- // Send out notification of release.
- if (eNotificationRequired()) {
- eNotify(new NotificationImpl(SPECIAL_NOTIFICATION_TYPE, null, null, Notification.NO_INDEX, false) {
- /* (non-Javadoc)
- * @see org.eclipse.emf.common.notify.impl.NotificationImpl#getFeatureID(java.lang.Class)
- */
- public int getFeatureID(Class expectedClass) {
- return PROJECTRESOURCESET_ABOUT_TO_RELEASE_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.emf.common.notify.impl.NotificationImpl#getNotifier()
- */
- public Object getNotifier() {
- return ProjectResourceSetImpl.this;
- }
- });
- }
- setIsReleasing(true);
- if (synchronizer != null)
- synchronizer.dispose();
- synchronizer = null;
- removeAndUnloadAllResources();
- resourceHandlers = null;
- eAdapters().clear();
- setProject(null);
- JEMUtilPlugin.getSharedCache().stopListening(this);
- }
- protected void removeAndUnloadAllResources() {
- boolean caughtException = false;
- if (getResources().isEmpty()) return;
- List list = new ArrayList(getResources());
- getResources().clear();
- Resource res;
- int size = list.size();
- for (int i = 0; i < size; i++) {
- res = (Resource) list.get(i);
- try {
- res.unload();
- } catch (RuntimeException ex) {
- Logger.getLogger().logError(ex);
- caughtException = true;
- }
- }
- if (caughtException)
- throw new RuntimeException("Exception(s) unloading resources - check log files"); //$NON-NLS-1$
- }
- protected void setIsReleasing(boolean aBoolean) {
- isReleasing = aBoolean;
- }
- /**
- * Gets the project.
- * @return Returns a IProject
- */
- public IProject getProject() {
- return project;
- }
- /**
- * Sets the project.
- * @param project The project to set
- */
- protected void setProject(IProject project) {
- this.project = project;
- }
- /*
- * Javadoc copied from interface.
- */
- public EObject getEObject(URI uri, boolean loadOnDemand) {
- if (isReleasing) return null;
- Resource resource = getResource(uri.trimFragment(), loadOnDemand);
- EObject result = null;
- if (resource != null && resource.isLoaded())
- result = resource.getEObject(uri.fragment());
- if (result == null)
- result = getEObjectFromHandlers(uri, loadOnDemand);
- return result;
- }
- /**
- * See if any resource handlers from the WorkbenchContext
- * can return a EObject from a <code>uri</code> after
- * failing to find it using the normal mechanisms.
- */
- protected EObject getEObjectFromHandlers(URI uri, boolean loadOnDemand) {
- EObject obj = null;
- ResourceHandler handler = null;
- for (int i = 0; i < resourceHandlers.size(); i++) {
- handler = (ResourceHandler) resourceHandlers.get(i);
- obj = handler.getEObjectFailed(this, uri, loadOnDemand);
- if (obj != null)
- return obj;
- }
- return null;
- }
-
- public boolean add(ResourceHandler resourceHandler) {
- return resourceHandlers.add(resourceHandler);
- }
- public void addFirst(ResourceHandler resourceHandler) {
- resourceHandlers.add(0, resourceHandler);
- }
- public boolean remove(ResourceHandler resourceHandler) {
- return resourceHandlers.remove(resourceHandler);
- }
- /**
- * Returns the synchronizer.
- * @return ResourceSetWorkbenchSynchronizer
- */
- public ResourceSetWorkbenchSynchronizer getSynchronizer() {
- return synchronizer;
- }
- /**
- * Sets the synchronizer.
- * @param synchronizer The synchronizer to set
- */
- public void setSynchronizer(ResourceSetWorkbenchSynchronizer synchronizer) {
- this.synchronizer = synchronizer;
- }
- /**
- * @see org.eclipse.emf.ecore.resource.ResourceSet#setResourceFactoryRegistry(Resource.Factory.Registry)
- */
- public void setResourceFactoryRegistry(Resource.Factory.Registry factoryReg) {
- if (resourceFactoryRegistry != null && factoryReg != null) {
- preserveEntries(factoryReg.getExtensionToFactoryMap(), resourceFactoryRegistry.getExtensionToFactoryMap());
- preserveEntries(factoryReg.getProtocolToFactoryMap(), resourceFactoryRegistry.getProtocolToFactoryMap());
- }
- super.setResourceFactoryRegistry(factoryReg);
- }
- /*
- * Preserve the entries from map2 in map1 if no collision.
- */
- protected void preserveEntries(Map map1, Map map2) {
- if (map2.isEmpty())
- return;
- Iterator it = map2.entrySet().iterator();
- Map.Entry entry;
- while (it.hasNext()) {
- entry = (Map.Entry) it.next();
- if (!map1.containsKey(entry.getKey()))
- map1.put(entry.getKey(), entry.getValue());
- }
- }
- /*
- * Javadoc copied from interface.
- */
- public Resource getResource(URI uri, boolean loadOnDemand) {
- if (isReleasing) return null;
- return super.getResource(uri, loadOnDemand);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.util.emf.workbench.ProjectResourceSet#resetNormalizedURICache()
- */
- public void resetNormalizedURICache() {
- if (getURIResourceMap() != null)
- getURIResourceMap().clear();
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceHandler.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceHandler.java
deleted file mode 100644
index 923412358..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceHandler.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: WorkspaceResourceHandler.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-
-import org.eclipse.jem.util.emf.workbench.ResourceHandler;
-import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-/**
- * The main purpose of this class is to redirect, if necessary, to another
- * ResourceSet. This class should be used in conjunction with the WorkbenchURIConverter
- * so that the URIs passed will use the platform protocol. Anything else will be considered
- * to be ambiguous and we will not be able to redirect.
- */
-public class WorkspaceResourceHandler implements ResourceHandler {
- /**
- * Constructor for WorkspaceResourceHandler.
- */
- public WorkspaceResourceHandler() {
- super();
- }
- /*
- * @see IResourceHandler#getResource(ResourceSet, URI)
- */
- public Resource getResource(ResourceSet originatingResourceSet, URI uri) {
- if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri))
- return getResourceForPlatformProtocol(originatingResourceSet, uri);
- URI mappedURI = ((URIConverterImpl.URIMap)originatingResourceSet.getURIConverter().getURIMap()).getURI(uri);
- if (isGlobalPluginLoad(mappedURI))
- return getResourceForPlatformPluginProtocol(originatingResourceSet, uri);
- return null;
- }
- /**
- * Redirect to the correct project based on the project name in the <code>uri</code>.
- * The <code>uri</code> will be in the following format: platform:/resource/[project name].
- */
- protected Resource createResourceForPlatformProtocol(ResourceSet originatingResourceSet, URI uri) {
- String projectName = uri.segment(1);
- IProject project = getProject(projectName);
- if (project != null && project.isAccessible()) {
- ResourceSet set = WorkbenchResourceHelperBase.getResourceSet(project);
- if (originatingResourceSet != set)
- return createResource(uri, set);
- }
- return null;
- }
- /**
- * Redirect to the correct project based on the project name in the <code>uri</code>.
- * The <code>uri</code> will be in the following format: platform:/resource/[project name].
- */
- protected Resource createResourceForPlatformPluginProtocol(ResourceSet originatingResourceSet, URI uri) {
-
- ResourceSet set = JEMUtilPlugin.getPluginResourceSet();
- return createResource(uri, set);
- }
- protected Resource createResource(URI uri, ResourceSet redirectedResourceSet) {
- return redirectedResourceSet.createResource(uri);
- }
- /**
- * Redirect to the correct project based on the first segment in the file name.
- * This is for compatability purposes for people using the platform:/resource protocol.
- */
- protected Resource getResourceForPlatformProtocol(ResourceSet originatingResourceSet, URI uri) {
- String projectName = uri.segment(1);
- IProject project = getProject(projectName);
- if (project != null && project.isAccessible()) {
- ResourceSet set = WorkbenchResourceHelperBase.getResourceSet(project);
- if (originatingResourceSet != set)
- return getResource(uri, set);
- }
- return null;
- }
- /**
- * Redirect to the correct project based on the first segment in the file name.
- * This is for compatability purposes for people using the platform:/resource protocol.
- */
- protected Resource getResourceForPlatformPluginProtocol(ResourceSet originatingResourceSet, URI uri) {
-
- ResourceSet set = JEMUtilPlugin.getPluginResourceSet();
- return getResource(uri, set);
-
- }
- protected Resource getResource(URI uri, ResourceSet redirectedResourceSet) {
- return redirectedResourceSet.getResource(uri, false);
- }
-
- protected IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
- protected IProject getProject(String projectName) {
- IWorkspace ws = getWorkspace();
- if (ws == null)
- return null;
- return ws.getRoot().getProject(projectName);
- }
- protected IProject getProject(ResourceSet resourceSet) {
- return WorkbenchResourceHelperBase.getProject(resourceSet);
- }
- /**
- * @see org.eclipse.jem.util.ResourceHandler#createResource(ResourceSet, URI)
- */
- public Resource createResource(ResourceSet originatingResourceSet, URI uri) {
- if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri))
- return createResourceForPlatformProtocol(originatingResourceSet, uri);
- URI mappedURI = ((URIConverterImpl.URIMap)originatingResourceSet.getURIConverter().getURIMap()).getURI(uri);
- if (isGlobalPluginLoad(mappedURI))
- return createResourceForPlatformPluginProtocol(originatingResourceSet, uri);
- return null;
- }
- /**
- * @see org.eclipse.jem.util.ResourceHandler#getEObjectFailed(ResourceSet, URI, boolean)
- * Subclasses may override.
- */
- public EObject getEObjectFailed(ResourceSet originatingResourceSet, URI uri, boolean loadOnDemand) {
- return null;
- }
-
- protected boolean isGlobalPluginLoad(URI aURI) {
- if (WorkbenchResourceHelperBase.isPlatformPluginResourceURI(aURI)) {
- String[] globalPlugins = JEMUtilPlugin.getGlobalLoadingPluginNames();
- for (int i=0;i<globalPlugins.length;i++) {
- if (aURI.segment(1).startsWith(globalPlugins[i]))
- return true;
- }
- }
- return false;
- }
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceNotifier.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceNotifier.java
deleted file mode 100644
index 6c10afe60..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/WorkspaceResourceNotifier.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: WorkspaceResourceNotifier.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench;
-
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.notify.impl.NotifierImpl;
-
-import org.eclipse.jem.util.emf.workbench.ProjectResourceSet;
-
-/**
- * This class is used to capture all ADD and REMOVE notifications from each ProjectResourceSet
- * and forward it on to any interrested listeners. This is to allow you to listen to one object
- * to gain all ADD and REMOVE notifications for each ResourceSet within the system.
- */
-public class WorkspaceResourceNotifier extends NotifierImpl {
- protected Adapter projectAdapter = new WorkspaceResourceCacheAdapter();
-
- class WorkspaceResourceCacheAdapter extends AdapterImpl {
- /**
- * Forward ADD and REMOVE notification.
- */
- public void notifyChanged(Notification msg) {
- switch (msg.getEventType()) {
- case Notification.ADD :
- case Notification.ADD_MANY :
- case Notification.REMOVE :
- case Notification.REMOVE_MANY :
- eNotify(msg);
- break;
- }
- }
- }
-
- /**
- * Constructor for WorkspaceResourceCache.
- */
- public WorkspaceResourceNotifier() {
- super();
- }
-
- /**
- * Begin listening to a ProjectResourceSet.
- */
- public void beginListening(ProjectResourceSet aResourceSet) {
- if (aResourceSet != null) {
- if (aResourceSet.eAdapters() == null ||
- !aResourceSet.eAdapters().contains(projectAdapter))
- aResourceSet.eAdapters().add(projectAdapter);
- }
- }
- /**
- * Stop listening to a ProjectResourceSet.
- */
- public void stopListening(ProjectResourceSet aResourceSet) {
- if (aResourceSet != null)
- aResourceSet.eAdapters().remove(projectAdapter);
- }
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nature/EMFNatureRegistry.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nature/EMFNatureRegistry.java
deleted file mode 100644
index f85f7b056..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nature/EMFNatureRegistry.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: EMFNatureRegistry.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench.nature;
-
-import java.util.HashSet;
-import java.util.Set;
-
-
-import org.eclipse.core.runtime.*;
-
-import org.eclipse.jem.internal.util.emf.workbench.nls.EMFWorkbenchResourceHandler;
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-public class EMFNatureRegistry {
-
- private static final String NATURE_REGISTRATION_POINT = "org.eclipse.jem.util.nature_registration"; //$NON-NLS-1$
- private static final String NATURE = "nature"; //$NON-NLS-1$
- private static final String STATIC_ID = "id"; //$NON-NLS-1$
-
- /**
- * Constructor
- */
- private EMFNatureRegistry() {
- super();
- readRegistry();
- }
-
- private static EMFNatureRegistry singleton;
-
- public final Set REGISTERED_NATURE_IDS = new HashSet();
-
- public static EMFNatureRegistry singleton() {
- if (singleton == null)
- singleton = new EMFNatureRegistry();
- return singleton;
- }
-
- protected void readRegistry() {
- // register Nature IDs for the J2EENatures
- IExtensionRegistry r = Platform.getExtensionRegistry();
- IConfigurationElement[] ce = r.getConfigurationElementsFor(NATURE_REGISTRATION_POINT);
- String natureId;
- for (int i=0; i<ce.length; i++) {
- if (ce[i].getName().equals(NATURE)) {
- natureId = ce[i].getAttribute(STATIC_ID);
- if (natureId != null)
- registerNatureID(natureId);
- }
- }
- }
-
- /**
- * @param natureId
- */
- private void registerNatureID(String natureId) {
- if (!REGISTERED_NATURE_IDS.contains(natureId))
- REGISTERED_NATURE_IDS.add(natureId);
- else
- Logger.getLogger().logError(EMFWorkbenchResourceHandler.getString("EMFNatureRegistry_ERROR_0", new Object[] {natureId})); //$NON-NLS-1$
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nls/EMFWorkbenchResourceHandler.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nls/EMFWorkbenchResourceHandler.java
deleted file mode 100644
index 31a8e45bd..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/internal/util/emf/workbench/nls/EMFWorkbenchResourceHandler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: EMFWorkbenchResourceHandler.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.internal.util.emf.workbench.nls;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class EMFWorkbenchResourceHandler {
-
- private static ResourceBundle fgResourceBundle;
-
- /**
- * Returns the resource bundle used by all classes in this Project
- */
- public static ResourceBundle getResourceBundle() {
- try {
- return ResourceBundle.getBundle("emfworkbench");//$NON-NLS-1$
- } catch (MissingResourceException e) {
- // does nothing - this method will return null and
- // getString(String, String) will return the key
- // it was called with
- }
- return null;
- }
- public static String getString(String key) {
- if (fgResourceBundle == null) {
- fgResourceBundle= getResourceBundle();
- }
-
- if (fgResourceBundle != null) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$
- }
- } else {
- return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$
- }
- }
-public static String getString(String key, Object[] args) {
-
- try {return MessageFormat.format(getString(key), args);}
- catch (IllegalArgumentException e) {return getString(key);}
-
-}
-public static String getString(String key, Object[] args, int x) {
-
- return getString(key);
- }
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/CharacterUtil.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/CharacterUtil.java
deleted file mode 100644
index afe727998..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/CharacterUtil.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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 API and implementation
- *******************************************************************************/
-/*
- * $RCSfile: CharacterUtil.java,v $
- * $Revision: 1.1 $ $Date: 2006/02/24 17:32:14 $
- */
-package org.eclipse.jem.util;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import com.ibm.icu.text.UTF16;
-
-
-/**
- * Static helper to handle characters in the new UTF multi-char format.
- * It is needed because ICU4J currently doesn't handle some correctly yet that we
- * need to have working. As ICU4J gets them working, the methods here will become
- * deprecated.
- *
- * @since 1.2.0
- */
-public class CharacterUtil {
-
- private CharacterUtil() {
-
- }
-
-
- /**
- * TODO So until ICU4J does work correctly this util will be needed. It will
- * stay around because it is API, but at that time it will be marked deprecated. It should
- * also then reroute to ICU4J instead of doing the method reflections.
- */
- private static Method METHOD_JAVA_IDENTIFIER_START, METHOD_JAVA_IDENTIFIER_PART;
-
- static {
- // Try to get the Character.isJavaIdentifier(int) method. If there, then we are in 1.5 or above. Else use the char form.
- try {
- METHOD_JAVA_IDENTIFIER_START = Character.class.getMethod("isJavaIdentifierStart", new Class[] {Integer.TYPE});
- } catch (SecurityException e) {
- // Default to use (char) type instead.
- METHOD_JAVA_IDENTIFIER_START = null;
- } catch (NoSuchMethodException e) {
- // Default to use (char) type instead.
- METHOD_JAVA_IDENTIFIER_START = null;
- }
- try {
- METHOD_JAVA_IDENTIFIER_PART = Character.class.getMethod("isJavaIdentifierPart", new Class[] {Integer.TYPE});
- } catch (SecurityException e) {
- // Default to use (char) type instead.
- METHOD_JAVA_IDENTIFIER_PART = null;
- } catch (NoSuchMethodException e) {
- // Default to use (char) type instead.
- METHOD_JAVA_IDENTIFIER_PART = null;
- }
- }
-
- /**
- * Is start of java identifier
- * @param intChar int character (UTF multi-char is valid)
- * @return <code>true</code> if start of java identifier.
- *
- * @see Character#isJavaIdentifierStart(char)
- * @since 1.2.0
- */
- public static boolean isJavaIdentifierStart(int intChar) {
- if (METHOD_JAVA_IDENTIFIER_START != null) {
- try {
- return ((Boolean) METHOD_JAVA_IDENTIFIER_START.invoke(null, new Object[] {new Integer(intChar)})).booleanValue();
- } catch (IllegalArgumentException e) {
- } catch (IllegalAccessException e) {
- } catch (InvocationTargetException e) {
- }
- }
- return Character.isJavaIdentifierStart((char) intChar);
- }
-
- /**
- * Is start of java identifier
- * @param intChar int character (UTF multi-char is valid)
- * @return <code>true</code> if start of java identifier.
- *
- * @see Character#isJavaIdentifierStart(char)
- * @since 1.2.0
- */
- public static boolean isJavaIdentifierPart(int intChar) {
- if (METHOD_JAVA_IDENTIFIER_PART != null) {
- try {
- return ((Boolean) METHOD_JAVA_IDENTIFIER_PART.invoke(null, new Object[] {new Integer(intChar)})).booleanValue();
- } catch (IllegalArgumentException e) {
- } catch (IllegalAccessException e) {
- } catch (InvocationTargetException e) {
- }
- }
- return Character.isJavaIdentifierPart((char) intChar);
- }
-
- public static abstract class AbstractCharIterator {
-
-
- protected final CharSequence charSeq;
- private int pos = 0;
- private int lastCharIndex = 0;
-
- /**
- * Create with a string.
- * @param charSeq
- *
- * @since 1.2.0
- */
- public AbstractCharIterator(CharSequence charSeq) {
- this.charSeq = charSeq;
- }
-
- /**
- * Set the next char index.
- * @param index
- *
- * @since 1.2.0
- */
- public void setIndex(int index) {
- pos = index;
- }
-
- /**
- * Has another char.
- * @return <code>true</code> if there is another char to return.
- *
- * @since 1.2.0
- */
- public boolean hasNext() {
- return pos < charSeq.length();
- }
-
- /**
- * Has another char before the current position. Doing previous
- * will return the char that was just returned.
- * @return
- *
- * @since 1.2.0
- */
- public boolean hasPrevious() {
- return pos > 0;
- }
-
- /**
- * Return next char from the one that was just returned.
- * @return next char.
- *
- * @since 1.2.0
- */
- public int next() {
- if (!hasNext())
- throw new IllegalStateException();
-
- int next = utfCharAt(pos);
- lastCharIndex = pos;
- pos += UTF16.getCharCount(next);
- return next;
- }
-
- /**
- * Return the UTF-32 char at the given position.
- * @param pos
- * @return
- *
- * @since 1.2.0
- */
- protected abstract int utfCharAt(int pos);
-
- /**
- * Return the previous character from the one that was just returned.
- * @return
- *
- * @since 1.2.0
- */
- public int previous() {
- if (!hasPrevious())
- throw new IllegalStateException();
-
- int next;
- if (UTF16.isTrailSurrogate(charSeq.charAt(--pos))) {
- if (pos > 0)
- next = utfCharAt(--pos);
- else
- next = charSeq.charAt(pos);
- } else {
- next = charSeq.charAt(pos);
- }
- lastCharIndex = pos;
- return next;
- }
-
- /**
- * Return the UTF16 character position of the char that was just returned from either
- * previous or next.
- * This is the (char) position not the
- * position of logical int chars returned. For example a standard string of
- * <code>"abc"</code> the position of the char 'b' is 1. But take the string
- * <code>"ab1b2c"</code> where "b1b2" is one UTF-32 char, then the position
- * of 'c' is 3. It would not be 2, which is what the logical char position
- * would be if taking UFT32 into account.
- * @return
- *
- * @since 1.2.0
- */
- public int getPosition() {
- return lastCharIndex;
- }
-
- }
-
- /**
- * Special char iterator that returns ints instead of chars for
- * walking strings that can contain UTF multi-chars. This is
- * a limited version of {@link java.text.CharacterIterator}.
- *
- * @since 1.2.0
- */
- public static class StringIterator extends AbstractCharIterator {
-
-
- /**
- * Create with a string.
- * @param str
- *
- * @since 1.2.0
- */
- public StringIterator(String str) {
- super(str);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.util.CharacterUtil.AbstractCharIterator#utfCharAt(int)
- */
- protected int utfCharAt(int pos) {
- return UTF16.charAt((String) charSeq, pos);
- }
-
- }
-
- /**
- * Special char iterator that returns ints instead of chars for
- * walking strings that can contain UTF multi-chars. This is
- * a limited version of {@link java.text.CharacterIterator}.
- *
- * @since 1.2.0
- */
- public static class StringBufferIterator extends AbstractCharIterator {
-
-
- /**
- * Create with a string.
- * @param strBuffer
- *
- * @since 1.2.0
- */
- public StringBufferIterator(StringBuffer strBuffer) {
- super(strBuffer);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.util.CharacterUtil.AbstractCharIterator#utfCharAt(int)
- */
- protected int utfCharAt(int pos) {
- return UTF16.charAt((StringBuffer) charSeq, pos);
- }
-
- }
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/NotPresentPerformanceMonitor.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/NotPresentPerformanceMonitor.java
deleted file mode 100644
index 54af2bd09..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/NotPresentPerformanceMonitor.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.eclipse.jem.util;
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: NotPresentPerformanceMonitor.java,v $$
- * $$Revision: 1.3 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-/**
- * This is the instantiation to use if the performance monitor plugin is not installed. It basically does nothing.
- *
- * <p>
- * This class is not intended to be instantiated by clients.
- * </p>
- *
- * @since 1.0.0
- */
-public class NotPresentPerformanceMonitor extends PerformanceMonitorUtil {
-
- /*
- * Only instantiated from this package.
- */
- NotPresentPerformanceMonitor() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#setVar(java.lang.String)
- */
- public void setVar(String var) {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#doSnapshot(int, int)
- */
- protected void doSnapshot(int step, int types) {
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#doSnapshot(int)
- */
- protected void doSnapshot(int step) {
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PerformanceMonitorUtil.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PerformanceMonitorUtil.java
deleted file mode 100644
index a76fdd079..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PerformanceMonitorUtil.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $RCSfile: PerformanceMonitorUtil.java,v $
- * $Revision: 1.7 $ $Date: 2005/08/24 21:10:34 $
- */
-package org.eclipse.jem.util;
-import java.util.EventObject;
-
-import org.eclipse.perfmsr.core.IPerformanceMonitor;
-
-/**
- * This is a simplified wrapper to the IPerformanceMonitor that hides it so that the actual plugin can be optional and not required.
- *
- * <p>
- * This class is not meant to be subclassed by clients.
- * </p>
- *
- * @since 1.0.0
- */
-public abstract class PerformanceMonitorUtil {
- /**
- * Event for PerformanceListener notification.
- *
- * @since 1.1.0
- */
- public static class PerformanceEvent extends EventObject {
-
- /**
- * Comment for <code>serialVersionUID</code>
- *
- * @since 1.1.0
- */
- private static final long serialVersionUID = -4680071462750180339L;
-
- PerformanceEvent(Object source, int step) {
- super(source);
- snapshowWithTypes = false;
- this.step = step;
- this.types = 0; // Not set.
- }
-
- PerformanceEvent(Object source, int step, int types) {
- super(source);
- snapshowWithTypes = true;
- this.step = step;
- this.types = types;
- }
-
-
- /**
- * Snapshot with types if <code>true</code>.
- * @since 1.1.0
- */
- public final boolean snapshowWithTypes;
-
- /**
- * Step of snapshot
- * @since 1.1.0
- */
- public final int step;
-
- /**
- * types of snapshot.
- * @since 1.1.0
- */
- public final int types;
- }
-
- /**
- * Performance Listener interface
- *
- * @since 1.1.0
- */
- public interface PerformanceListener {
- /**
- * Snapshot was called.
- * @param event
- *
- * @since 1.1.0
- */
- public void snapshot(PerformanceEvent event);
- }
-
- private PerformanceListener[] listeners;
-
- public interface Types {
-
- /**
- * 1 - Write out the performance counters from the operating system. These include working set, peak working set, elapsed time, user time, and
- * kernel time.
- */
- int OperatingSystemCounters = IPerformanceMonitor.Types.OperatingSystemCounters;
-
- /**
- * 2 - Write out the global performance info. This includes things like the total committed memory for the entire system.
- *
- * This function depends on the GetPerformanceInfo() function being available in the Windows psapi.dll. This is available in XP but is usually
- * not available in Win/2000. If it is not available then this function throws an UnsupportedOperationException.
- */
- int GlobalSystemCounters = IPerformanceMonitor.Types.GlobalSystemCounters;
-
- /**
- * 4 - Write out the size of the Java Heap.
- */
- int JavaHeapSize = IPerformanceMonitor.Types.JavaHeapSize;
-
- /**
- * 8 - Write out how much of the Java heap is being used. This calls the garbage collector so it may skew timing results.
- */
- int JavaHeapUsed = IPerformanceMonitor.Types.JavaHeapUsed;
-
- /**
- * 16 - The plugin startup and size information.
- */
- int PluginInfo = IPerformanceMonitor.Types.PluginInfo;
-
- /** 0xffff - Everything. */
- int All = IPerformanceMonitor.Types.All;
- }
-
- private static PerformanceMonitorUtil sharedMonitor;
-
- public static PerformanceMonitorUtil getMonitor() {
- if (sharedMonitor == null) {
- try {
- Class.forName("org.eclipse.perfmsr.core.PerfMsrCorePlugin"); // This just tests if the performance plugin is available. Throws //$NON-NLS-1$
- // exception otherwise.
- Class presentClass = Class.forName("org.eclipse.jem.util.PresentPerformanceMonitor"); // Get the class we use wrapper it. //$NON-NLS-1$
- sharedMonitor = (PerformanceMonitorUtil) presentClass.newInstance();
- if (!sharedMonitor.isValid())
- sharedMonitor = null;
- } catch (RuntimeException e) {
- // If any runtime exception, just use the not present one.
- } catch (ClassNotFoundException e) {
- // If class not found, then plugin not available, so just use the not present one.
- } catch (InstantiationException e) {
- // Problem instantiating, so just use the not present one.
- } catch (IllegalAccessException e) {
- // Some illegal access, so just use the not present one.
- }
- if (sharedMonitor == null) {
- // Couldn't get the performance one for some reason. Use not present one instead.
- sharedMonitor = new NotPresentPerformanceMonitor();
- }
- }
- return sharedMonitor;
- }
-
- protected boolean isValid() {
- return true;
- }
-
- /**
- * Set the variations that are in effect.
- *
- * @param var
- * a comma delimited string of variation numbers
- */
- public abstract void setVar(String var);
-
- /**
- * Take a snapshot of some default performance measurements.
- *
- * @param step
- * this identifies the step that the snapshot is for
- */
- public final void snapshot(int step) {
- doSnapshot(step);
- if (listeners != null)
- notifySnapshot(new PerformanceEvent(this, step));
- }
-
- private void notifySnapshot(PerformanceEvent event) {
- PerformanceListener[] list = listeners;
- for (int i = 0; i < list.length; i++) {
- list[i].snapshot(event);
- }
- }
-
- /**
- * Do the actual snapshot
- * @param step
- *
- * @see #snapshot(int)
- * @since 1.1.0
- */
- protected abstract void doSnapshot(int step);
-
- /**
- * Take a snapshot of the selected performance measurements.
- *
- * @param step
- * this identifies the step that the snapshot is for
- *
- * @param types
- * This controls which measurements are selected. It is an or'd together list of the IPerformanceMonitor.Types constants.
- *
- * @see IPerformanceMonitor.Types
- */
- public void snapshot(int step, int types) {
- doSnapshot(step, types);
- if (listeners != null)
- notifySnapshot(new PerformanceEvent(this, step, types));
- }
-
- /**
- * Do the actual snapshot
- * @param step
- *
- * @see #snapshot(int, int)
- * @since 1.1.0
- */
- protected abstract void doSnapshot(int step, int types);
-
- /**
- * Add listener to list.
- * @param listener
- *
- * @since 1.1.0
- */
- public void addPerformanceListener(PerformanceListener listener) {
- if (findListener(listener) != -1)
- return;
- PerformanceListener[] newList = new PerformanceListener[listeners != null ? listeners.length+1 : 1];
- if (listeners != null)
- System.arraycopy(listeners, 0, newList, 0, listeners.length);
- newList[newList.length-1] = listener;
- listeners = newList;
- }
-
- private int findListener(PerformanceListener listener) {
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- if (listeners[i] == listener)
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Remove the listener from the list.
- * @param listener
- *
- * @since 1.1.0
- */
- public void removePerformanceListener(PerformanceListener listener) {
- int index = findListener(listener);
- if (index != -1) {
- if (listeners.length == 1) {
- listeners = null;
- return;
- }
- PerformanceListener[] newList = new PerformanceListener[listeners.length-1];
- System.arraycopy(listeners, 0, newList, 0, index);
- System.arraycopy(listeners, index+1, newList, index, newList.length-index);
- listeners = newList;
- }
- }
- /**
- * Upload the results to the server. This causes the file to be
- * closed, and the monitor to be placed into the finished state.
- *
- * This method can only be called if the uploadhost, uploadport and uploaduserid
- * have been configured before hand.
- *
- * @param description an optional description (it can be null)
- *
- */
- public boolean upload(String description){return false;}
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PresentPerformanceMonitor.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PresentPerformanceMonitor.java
deleted file mode 100644
index 3ee5b0532..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/PresentPerformanceMonitor.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $RCSfile: PresentPerformanceMonitor.java,v $
- * $Revision: 1.5 $ $Date: 2005/08/24 21:10:34 $
- */
-package org.eclipse.jem.util;
-import org.eclipse.perfmsr.core.IPerformanceMonitor;
-import org.eclipse.perfmsr.core.PerfMsrCorePlugin;
-
-/**
- * This is the version used when the performance plugin is available.
- *
- * <p>
- * This class is not meant to be instantiated by clients.
- * </p>
- *
- * @since 1.0.0
- */
-public class PresentPerformanceMonitor extends PerformanceMonitorUtil {
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#upload(java.lang.String)
- */
- public boolean upload(String description) {
- return monitor.upload(description).success;
- }
-
- private IPerformanceMonitor monitor;
-
- /*
- * So that only instantiated by this package.
- */
- PresentPerformanceMonitor() {
- monitor = PerfMsrCorePlugin.getPerformanceMonitor(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#isValid()
- */
- protected boolean isValid() {
- return monitor != null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#setVar(java.lang.String)
- */
- public void setVar(String var) {
- monitor.setVar(var);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#doSnapshot(int)
- */
- protected void doSnapshot(int step) {
- monitor.snapshot(step);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jem.util.PerformanceMonitorUtil#doSnapshot(int, int)
- */
- protected void doSnapshot(int step, int types) {
- monitor.snapshot(step, types);
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/RegistryReader.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/RegistryReader.java
deleted file mode 100644
index b149c4018..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/RegistryReader.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: RegistryReader.java,v $$
- * $$Revision: 1.4 $$ $$Date: 2006/02/21 17:16:30 $$
- */
-package org.eclipse.jem.util;
-import org.eclipse.core.runtime.*;
-import org.osgi.framework.Bundle;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-/**
- * Class to read a registry. It is meant to be subclassed to provide specific function.
- *
- * @since 1.0.0
- */
-public abstract class RegistryReader {
-
- String pluginId;
-
- String extensionPointId;
-
- private static Bundle systemBundle;
-
- /**
- * Utility method to get the plugin id of a configuation element
- *
- * @param configurationElement
- * @return plugin id of configuration element
- * @since 1.0.0
- */
- public static String getPluginId(IConfigurationElement configurationElement) {
- String pluginId = null;
-
- if (configurationElement != null) {
- IExtension extension = configurationElement.getDeclaringExtension();
-
- if (extension != null)
- pluginId = extension.getContributor().getName();
- }
-
- return pluginId;
- }
-
- /**
- * Constructor for RegistryReader taking a registry, plugin id, and extension point id.
- *
- * @param registry
- * @param pluginID
- * @param extensionPoint
- *
- * @deprecated Use RegistryReader(plugin, extensionPoint) instead. The registry passed in is ignored.
- * @since 1.0.0
- */
- public RegistryReader(IPluginRegistry registry, String pluginID, String extensionPoint) {
- this(pluginID, extensionPoint);
- }
-
- /**
- * Constructor for RegistryReader taking the plugin id and extension point id.
- *
- * @param pluginID
- * @param extensionPoint
- *
- * @since 1.0.0
- */
- public RegistryReader(String pluginID, String extensionPoint) {
- super();
- this.pluginId = pluginID;
- extensionPointId = extensionPoint;
- }
-
- private void internalReadElement(IConfigurationElement element) {
- boolean recognized = this.readElement(element);
- if (!recognized) {
- logError(element, "Error processing extension: " + element); //$NON-NLS-1$
- }
- }
-
- /*
- * Logs the error in the desktop log using the provided text and the information in the configuration element.
- */
- protected void logError(IConfigurationElement element, String text) {
- IExtension extension = element.getDeclaringExtension();
- StringBuffer buf = new StringBuffer();
- buf.append("Plugin " + extension.getContributor().getName() + ", extension " + extension.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append("\n" + text); //$NON-NLS-1$
- Logger.getLogger().logError(buf.toString());
- }
-
- /*
- * Logs a very common registry error when a required attribute is missing.
- */
- protected void logMissingAttribute(IConfigurationElement element, String attributeName) {
- logError(element, "Required attribute '" + attributeName + "' not defined"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /*
- * Implement this method to read element attributes. If this element has subelements, the reader will recursively cycle through them and call this
- * method so don't do it here.
- */
- public abstract boolean readElement(IConfigurationElement element);
-
- /**
- * Read the extension point and parse it.
- *
- * @since 1.0.0
- */
- public void readRegistry() {
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(pluginId, extensionPointId);
- if (point == null)
- return;
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- internalReadElement(elements[i]);
- }
- }
-
- /**
- * Tests to see if it is valid at this point in time to create an executable extension. A valid reason not to would be that the workspace is
- * shutting donw.
- *
- * @param element
- * @return <code>true</code> if it is valid point to create an executable extension.
- *
- * @since 1.0.0
- */
- public static boolean canCreateExecutableExtension(IConfigurationElement element) {
- if (Platform.isRunning() && getSystemBundle().getState() != Bundle.STOPPING)
- return true;
- return false;
- }
-
- /**
- * Get the system bundle
- *
- * @return system bundle.
- *
- * @since 1.0.0
- */
- protected static Bundle getSystemBundle() {
- if (systemBundle == null)
- systemBundle = Platform.getBundle("org.eclipse.osgi"); //$NON-NLS-1$
- return systemBundle;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/TimerTests.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/TimerTests.java
deleted file mode 100644
index 9757c840c..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/TimerTests.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $RCSfile: TimerTests.java,v $
- * $Revision: 1.7 $ $Date: 2006/02/15 23:40:59 $
- */
-package org.eclipse.jem.util;
-
-import java.text.NumberFormat;
-import java.util.*;
-
-/**
- *
- * @since 1.0.2
- */
-public class TimerTests {
-
- /**
- * Default TimerTests class to use when not using your own. It's a global.
- */
- public static TimerTests basicTest = new TimerTests();
-
- public static final String CURRENT_PARENT_ID = "current parent"; //$NON-NLS-1$
- protected String currentParentId = null;
-
-
- protected static class TimerStep {
- static final int START = 0;
- static final int STOP = 1;
- static final int START_CUMULATIVE = 2;
- static final int STOP_CUMULATIVE = 3;
- static final int START_ACCUMULATING = 4;
- static final int STOP_ACCUMULATING = 5;
- protected String id;
- protected int type;
- protected long currentTime;
- protected int threadId;
-}
-
- protected boolean testOn = false;
- protected List steps;
-
- public synchronized boolean startStep(String id) {
- if (!testOn)
- return true;
-
- TimerStep step = createTimerStep(id, TimerStep.START);
- return step != null;
- }
-
- protected TimerStep createTimerStep(String id, int stepType) {
- TimerStep newStep = new TimerStep();
- newStep.threadId = Thread.currentThread().hashCode();
- newStep.id = id;
- newStep.type = stepType;
- newStep.currentTime = System.currentTimeMillis();
- steps.add(newStep);
-
- return newStep;
- }
-
- public synchronized boolean stopStep(String id) {
- if (!testOn)
- return true;
- TimerStep step = createTimerStep(id, TimerStep.STOP);
- return step != null;
- }
-
- public synchronized boolean startAccumulating(String id) {
- if (!testOn)
- return true;
-
- return createTimerStep(id, TimerStep.START_ACCUMULATING) != null;
- }
-
- public synchronized boolean stopAccumulating(String id) {
- if (!testOn)
- return true;
-
- return createTimerStep(id, TimerStep.STOP_ACCUMULATING) != null;
- }
- public synchronized boolean startCumulativeStep(String id) {
- if (!testOn)
- return true;
-
- return createTimerStep(id, TimerStep.START_CUMULATIVE) != null;
- }
-
- public synchronized boolean stopCumulativeStep(String id) {
- if (!testOn)
- return true;
- return createTimerStep(id, TimerStep.STOP_CUMULATIVE) != null;
- }
-
- /**
- * Clear the tests so that you can restart and do some more tests.
- *
- *
- * @since 1.0.2
- */
- public synchronized void clearTests() {
- if (!testOn)
- return;
- steps.clear();
- currentParentId = null;
- }
-
- /**
- * Turn this test on. If not turned on then all calls will quickly return with no errors. This allows the code to stay in place even when not
- * debugging.
- * <p>
- * When turned off, it will clear the test.
- *
- * @param on
- *
- * @since 1.0.2
- */
- public synchronized void testState(boolean on) {
- if (on == testOn)
- return;
- if (on) {
- testOn = true;
- if (steps == null)
- steps = new ArrayList();
- } else {
- testOn = false;
- steps = null;
- }
- currentParentId = null;
- }
- private static class CumulativeInformation {
- public TimerStep currentCumulativeStep;
- public long cumTime;
- public int cumCount;
- public int cumCountNonZero;
- public long maxTime;
- public long minTime = Integer.MAX_VALUE;
- public long minTimeNonZero = Integer.MAX_VALUE;
- }
- public synchronized void printIt() {
- if (!testOn)
- return;
- if (steps == null)
- return;
- Map stepInfoByThreadId = new HashMap();
- Map indentsByThreadId = new HashMap();
- Map cumSteps;
- TimerStep prevStep = null;
- TimerStep startStep;
- NumberFormat percentFormatter = NumberFormat.getPercentInstance();
- double totalTime = 0;
- StringBuffer strb = new StringBuffer(150);
- if (steps.size() > 2){
- totalTime = ((TimerStep)steps.get(steps.size()-1)).currentTime - ((TimerStep)steps.get(0)).currentTime;
- }
- for (int i = 0; i < steps.size(); i++) {
- TimerStep step = (TimerStep) steps.get(i);
- Integer threadId = new Integer(step.threadId);
- switch (step.type) {
- case TimerStep.START:
- case TimerStep.STOP:
- Integer threadIndent = (Integer) indentsByThreadId.get(threadId);
- int indent = 0;
- if (step.type == TimerStep.START) {
- if (threadIndent != null)
- indent = threadIndent.intValue() + 1;
- indentsByThreadId.put(threadId, new Integer(indent));
- } else {
- if (threadIndent != null)
- indent = threadIndent.intValue();
- if (indent > 0)
- indentsByThreadId.put(threadId, new Integer(indent - 1));
- else {
- indentsByThreadId.remove(threadId);
- indent = 0;
- }
- }
- strb.setLength(0);
- strb.append(step.currentTime);
- strb.append("\t"); //$NON-NLS-1$
- for (int j = 0; j < indent; j++) {
- strb.append(" "); //$NON-NLS-1$
- }
- switch (step.type) {
- case TimerStep.START:
- strb.append("Start"); //$NON-NLS-1$
- break;
-
- case TimerStep.STOP:
- strb.append("Stop "); //$NON-NLS-1$
- break;
- default:
- break;
- }
- ;
- strb.append(" \""); //$NON-NLS-1$
- strb.append(step.id);
- strb.append("\" id("); //$NON-NLS-1$
- strb.append(step.threadId);
- strb.append(")"); //$NON-NLS-1$
- Map startSteps = (Map) stepInfoByThreadId.get(threadId);
- if (startSteps == null)
- stepInfoByThreadId.put(threadId, startSteps = new HashMap());
- if (step.type == TimerStep.START) {
- // Store the start step for later lookup when calulating the total time
- startSteps.put(step.id, step);
- } else {
- // This is the stop time for a step. We need to find
- // the corresponding start time and calculate the total time.
- Object item = startSteps.remove(step.id);
- if (item instanceof TimerStep) {
- startStep = (TimerStep) item;
- if (startStep != null) {
- int addchars = 100 - strb.length();
- for (int j = 0; j < addchars; j++) {
- strb.append(" "); //$NON-NLS-1$
- }
- long delta = step.currentTime - startStep.currentTime;
- strb.append(" Total = " + delta + " ms"); //$NON-NLS-1$ //$NON-NLS-2$
- if (totalTime > 0)
- strb.append(" " + percentFormatter.format(delta/totalTime)); //$NON-NLS-1$
- }
- } else
- strb.append(" ---> Couldn't find Starting point for \"" + step.id + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (i > 0 && (step.currentTime - prevStep.currentTime) > 0)
- System.out.println("-- " + (step.currentTime - prevStep.currentTime) + " ms --"); //$NON-NLS-1$ //$NON-NLS-2$
- prevStep = step;
- System.out.println(strb);
- break;
-
- case TimerStep.START_ACCUMULATING:
- cumSteps = (Map) stepInfoByThreadId.get(threadId);
- if (cumSteps == null)
- stepInfoByThreadId.put(threadId, cumSteps = new HashMap());
- cumSteps.put(step.id, new CumulativeInformation());
- threadIndent = (Integer) indentsByThreadId.get(threadId);
- indent = 0;
- if (threadIndent != null)
- indent = threadIndent.intValue();
- strb.setLength(0);
- strb.append(step.currentTime);
- strb.append("\t"); //$NON-NLS-1$
- for (int j = 0; j < indent; j++) {
- strb.append(" "); //$NON-NLS-1$
- }
- strb.append("Start Accumulating"); //$NON-NLS-1$
- strb.append(" \""); //$NON-NLS-1$
- strb.append(step.id);
- strb.append("\" id("); //$NON-NLS-1$
- strb.append(step.threadId);
- strb.append(")"); //$NON-NLS-1$
- if (i > 0 && (step.currentTime - prevStep.currentTime) > 0)
- System.out.println("-- " + (step.currentTime - prevStep.currentTime) + " ms --"); //$NON-NLS-1$ //$NON-NLS-2$
- prevStep = step;
- System.out.println(strb);
- break;
-
- case TimerStep.START_CUMULATIVE:
- cumSteps = (Map) stepInfoByThreadId.get(threadId);
- if (cumSteps != null) {
- Object info = cumSteps.get(step.id);
- if (info instanceof CumulativeInformation)
- ((CumulativeInformation) info).currentCumulativeStep = step;
- }
- break;
-
- case TimerStep.STOP_CUMULATIVE:
- cumSteps = (Map) stepInfoByThreadId.get(threadId);
- if (cumSteps != null) {
- Object info = cumSteps.get(step.id);
- if (info instanceof CumulativeInformation) {
- CumulativeInformation cumInfo = (CumulativeInformation) info;
- if (cumInfo.currentCumulativeStep != null) {
- cumInfo.cumCount++;
- long delta = step.currentTime - cumInfo.currentCumulativeStep.currentTime;
- cumInfo.cumTime += delta;
- if (cumInfo.maxTime < delta)
- cumInfo.maxTime = delta;
- if (delta < cumInfo.minTime)
- cumInfo.minTime = delta;
- if (delta != 0) {
- cumInfo.cumCountNonZero++;
- if (delta < cumInfo.minTimeNonZero)
- cumInfo.minTimeNonZero = delta;
- }
- }
- }
- }
- break;
-
- case TimerStep.STOP_ACCUMULATING:
- threadIndent = (Integer) indentsByThreadId.get(threadId);
- indent = 0;
- if (threadIndent != null)
- indent = threadIndent.intValue();
- strb.setLength(0);
- strb.append(step.currentTime);
- strb.append("\t"); //$NON-NLS-1$
- for (int j = 0; j < indent; j++) {
- strb.append(" "); //$NON-NLS-1$
- }
- strb.append("Stop Accumulating"); //$NON-NLS-1$
- strb.append(" \""); //$NON-NLS-1$
- strb.append(step.id);
- strb.append("\" id("); //$NON-NLS-1$
- strb.append(step.threadId);
- strb.append(")"); //$NON-NLS-1$
- cumSteps = (Map) stepInfoByThreadId.get(threadId);
- if (cumSteps != null) {
- Object info = cumSteps.get(step.id);
- if (info instanceof CumulativeInformation) {
- CumulativeInformation cumInfo = (CumulativeInformation) info;
- if (cumInfo.currentCumulativeStep != null) {
- strb.append(" cumulative time="); //$NON-NLS-1$
- strb.append(cumInfo.cumTime);
- strb.append(" cumulative count="); //$NON-NLS-1$
- strb.append(cumInfo.cumCount);
- strb.append(" max time="); //$NON-NLS-1$
- strb.append(cumInfo.maxTime);
- strb.append(" min time="); //$NON-NLS-1$
- strb.append(cumInfo.minTime);
- strb.append(" avg time="); //$NON-NLS-1$
- strb.append(((double) cumInfo.cumTime)/cumInfo.cumCount);
- strb.append(" NonZero times: cumulative ~0 count="); //$NON-NLS-1$
- strb.append(cumInfo.cumCountNonZero);
- if (cumInfo.cumCountNonZero != 0) {
- strb.append(" min ~0 time="); //$NON-NLS-1$
- strb.append(cumInfo.minTimeNonZero);
- strb.append(" avg ~0 time="); //$NON-NLS-1$
- strb.append(((double) cumInfo.cumTime) / cumInfo.cumCountNonZero);
- }
- }
- }
- }
- if (i > 0 && (step.currentTime - prevStep.currentTime) > 0)
- System.out.println("-- " + (step.currentTime - prevStep.currentTime) + " ms --"); //$NON-NLS-1$ //$NON-NLS-2$
- prevStep = step;
- System.out.println(strb);
- break;
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UIContextDetermination.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UIContextDetermination.java
deleted file mode 100644
index 45e754ba4..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UIContextDetermination.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: UIContextDetermination.java,v $$
- * $$Revision: 1.3 $$ $$Date: 2005/05/18 21:58:34 $$
- */
-package org.eclipse.jem.util;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.*;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * Static utility class for UIContext determination.
- *
- * @since 1.0.0
- */
-public class UIContextDetermination {
-
- private static final int UNKNOWN = 100;
-
- public static final String HEADLESS_CONTEXT_LITERAL = "Headless"; //$NON-NLS-1$
-
- public static final String UI_CONTEXT_LITERAL = "UI"; //$NON-NLS-1$
-
- public static final int HEADLESS_CONTEXT = 102;
-
- public static final int UI_CONTEXT = 100;
-
- private static Map cachedExtensions = null;
-
- private static int currentContext = UNKNOWN;
-
- private UIContextDetermination() {
- }
-
- /**
- * Returns an instance of a given class based on the UI or Headless context.
- *
- * @param key
- * @return new class instance for the given key.
- * @throws IllegalArgumentException
- * If the key is invalid (e.g. no extension is found for the key)
- */
- public static Object createInstance(String key) {
- Object result = null;
- if (cachedExtensions == null)
- initExtensions();
- IConfigurationElement contextSensitiveClass = (IConfigurationElement) cachedExtensions.get(key);
- try {
- if (contextSensitiveClass != null)
- result = contextSensitiveClass
- .createExecutableExtension(UIContextDeterminationRegistryReader.UI_CONTEXT_SENSTIVE_CLASS_CLASSNAME_ATTR);
- } catch (CoreException e) {
- Logger.getLogger().logError("Problem loading extension not found for key \"" + key + "\"."); //$NON-NLS-1$ //$NON-NLS-2$
- Logger.getLogger().logError(e);
- }
- if (result == null)
- Logger.getLogger().logError("Extension not found for key \"" + key + "\"."); //$NON-NLS-1$ //$NON-NLS-2$
- return result;
- }
-
- /**
- * Returns the current context -- determines the value if necessary.
- *
- * @return current context
- * @see #HEADLESS_CONTEXT
- * @see #UI_CONTEXT
- */
- public static int getCurrentContext() {
- if (currentContext == UNKNOWN) {
- currentContext = HEADLESS_CONTEXT;
- new UITesterRegistryReader().readRegistry();
- }
- return currentContext;
- }
-
- /*
- * Invokes the UIContextDeterminationRegistryReader to cache all of the extensions, if necessary.
- *
- */
- private static void initExtensions() {
- if (cachedExtensions == null) {
- cachedExtensions = new HashMap();
- new UIContextDeterminationRegistryReader().readRegistry();
- }
- }
-
- /*
- * Converts the input to one of UI_CONTEXT or HEADLESS_CONTEXT. Defaults to HEADLESS on invalid input
- *
- * @param literal @return
- */
- private static int convertLiteral(String literal) {
- return (UI_CONTEXT_LITERAL.equals(literal)) ? UI_CONTEXT : HEADLESS_CONTEXT;
- }
-
- /*
- * Reads the registration of UI Context-sensitive class extensions and initializes the cache of the UIContextDetermination object.
- *
- * @author mdelder
- */
- private static class UIContextDeterminationRegistryReader extends RegistryReader {
-
- public static final String UI_CONTEXT_SENSTIVE_CLASS_ELEMENT = "uiContextSensitiveClass"; //$NON-NLS-1$
-
- public static final String UI_CONTEXT_SENSTIVE_CLASS_KEY_ATTR = "key"; //$NON-NLS-1$
-
- public static final String UI_CONTEXT_SENSTIVE_CLASS_CLASSNAME_ATTR = "className"; //$NON-NLS-1$
-
- public static final String UI_CONTEXT_SENSTIVE_CLASS_CONTEXT_ATTR = "context"; //$NON-NLS-1$
-
- public UIContextDeterminationRegistryReader() {
- super(JEMUtilPlugin.PLUGIN_ID, JEMUtilPlugin.UI_CONTEXT_EXTENSION_POINT);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
- */
- public boolean readElement(IConfigurationElement element) {
- boolean result = false;
- if (element.getName().equals(UI_CONTEXT_SENSTIVE_CLASS_ELEMENT)) {
-
- String key = element.getAttribute(UI_CONTEXT_SENSTIVE_CLASS_KEY_ATTR);
- String context = element.getAttribute(UI_CONTEXT_SENSTIVE_CLASS_CONTEXT_ATTR);
-
- if (!cachedExtensions.containsKey(key) || getCurrentContext() == convertLiteral(context))
- cachedExtensions.put(key, element);
- result = true;
- }
- return result;
- }
- }
-
- /*
- * Reads the uiTester extension and instantiate the any of the UITester classes it finds.
- *
- * The implementation has the side effect that if multiple UITesters are registered, any of them can trip the currentContext into the UI_CONTEXT
- * state.
- *
- * @author mdelder
- */
- private static class UITesterRegistryReader extends RegistryReader {
-
- public static final String UI_TESTER_ELEMENT = "uiTester"; //$NON-NLS-1$
-
- public static final String UI_TESTER_CLASSNAME_ATTR = "className"; //$NON-NLS-1$
-
- public UITesterRegistryReader() {
- super(JEMUtilPlugin.PLUGIN_ID, JEMUtilPlugin.UI_TESTER_EXTENSION_POINT);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf.workbench.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
- */
- public boolean readElement(IConfigurationElement element) {
- boolean result = false;
- if (element.getName().equals(UI_TESTER_ELEMENT)) {
- result = true;
- try {
- if (canCreateExecutableExtension(element)) {
- UITester tester = (UITester) element.createExecutableExtension(UI_TESTER_CLASSNAME_ATTR);
- if (tester.isCurrentContextUI())
- currentContext = UI_CONTEXT;
- }
- } catch (Throwable t) {
- Logger.getLogger().log("UIContextDetermination is proceeding in HEADLESS mode"); //$NON-NLS-1$
- }
- }
- return result;
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UITester.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UITester.java
deleted file mode 100644
index 54517e800..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/UITester.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.eclipse.jem.util;
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: UITester.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-/**
- * Interface for a UITester. The "classname" attribute on the "uiTester" extension point should implement this class.
- *
- * @since 1.0.0
- */
-public interface UITester {
-
- /**
- * Answer if the current context is an UI context.
- *
- * @return <code>true</code> if an UI context.
- *
- * @since 1.0.0
- */
- public boolean isCurrentContextUI();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/EMFWorkbenchContextBase.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/EMFWorkbenchContextBase.java
deleted file mode 100644
index bedff60f2..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/EMFWorkbenchContextBase.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: EMFWorkbenchContextBase.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-
-import org.eclipse.jem.internal.util.emf.workbench.*;
-import org.eclipse.jem.internal.util.emf.workbench.nls.EMFWorkbenchResourceHandler;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * ContextBase for EMFWorkbench.
- *
- * <p>
- * This is meant to be subclassed as needed for additional or override function. It will be instantiated by default.
- * </p>
- *
- * @since 1.0.0
- */
-public class EMFWorkbenchContextBase {
-
- protected IProject project;
-
- protected ProjectResourceSet resourceSet;
-
- /**
- * Construct with a project.
- *
- * @param aProject
- *
- * @since 1.0.0
- */
- public EMFWorkbenchContextBase(IProject aProject) {
- if (aProject == null)
- throw new IllegalArgumentException(EMFWorkbenchResourceHandler.getString("EMFWorkbenchContextBase_ERROR_1")); //$NON-NLS-1$
- project = aProject;
- }
-
- /**
- * Dispose of the context base.
- *
- *
- * @since 1.0.0
- */
- public void dispose() {
- if (resourceSet != null)
- resourceSet.release();
- resourceSet = null;
- project = null;
- }
-
- /**
- * Get the project this context is associated with.
- *
- * @return project
- *
- * @since 1.0.0
- */
- public IProject getProject() {
- return project;
- }
-
- /**
- * Return the resource set (creating if needed) for context.
- *
- * @return resource set
- *
- * @since 1.0.0
- */
- public ProjectResourceSet getResourceSet() {
- if (resourceSet == null) {
- resourceSet = createResourceSet();
- initializeResourceSet(resourceSet);
- }
- return resourceSet;
- }
-
- /**
- * Used for optimization; answer whether a resourceSet has been created
- *
- * @return <code>true</code> if a resource set has been created.
- *
- * @since 1.0.0
- */
- public boolean hasResourceSet() {
- return resourceSet != null;
- }
-
- /**
- * Initialize the resource set.
- *
- * @param aResourceSet
- *
- * @since 1.0.0
- */
- protected void initializeResourceSet(ProjectResourceSet aResourceSet) {
- createResourceSetSynchronizer(aResourceSet);
- aResourceSet.setURIConverter(createURIConverter(aResourceSet));
- aResourceSet.add(new WorkspaceResourceHandler());
- JEMUtilPlugin.getDefault().addExtendedResourceHandlers(aResourceSet);
-
- }
-
- /**
- * Create the resource set. By default it is a ProjectResourceSetImpl.
- *
- * @return project's new resource set.
- *
- * @since 1.0.0
- */
- protected ProjectResourceSet createResourceSet() {
- if (project == null)
- throw new IllegalStateException(EMFWorkbenchResourceHandler.getString("EMFWorkbenchContextBase_ERROR_2")); //$NON-NLS-1$
- return new ProjectResourceSetImpl(project);
- }
-
- /**
- * Create a URIConverter for the resource set.
- *
- * @param aResourceSet
- * @return a uri converter.
- *
- * @since 1.0.0
- */
- protected WorkbenchURIConverter createURIConverter(ProjectResourceSet aResourceSet) {
- return new WorkbenchURIConverterImpl(getProject(), aResourceSet.getSynchronizer());
- }
-
- /**
- * Create a resource set workbench synchronizer.
- *
- * @param aResourceSet
- * @return a resource set workbench synchronizer.
- *
- * @since 1.0.0
- */
- protected ResourceSetWorkbenchSynchronizer createResourceSetSynchronizer(ProjectResourceSet aResourceSet) {
- return EMFWorkbenchContextFactory.INSTANCE.createSynchronizer(aResourceSet, getProject());
- }
-
- /**
- * Delete the resource from the workspace.
- *
- * @param aResource
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public void deleteResource(Resource aResource) throws CoreException {
- if (aResource != null)
- deleteFile(aResource);
- }
-
- /**
- * Delete the file associated with the resource.
- *
- * @param resource
- *
- * @since 1.0.0
- */
- public void deleteFile(Resource resource) {
- throw new UnsupportedOperationException(EMFWorkbenchResourceHandler.getString("EMFWorkbenchContextBase_ERROR_0")); //$NON-NLS-1$
- }
-
- /**
- * Get resource (with the given URI) from the project resource set. Load it if not already loaded.
- *
- * @param uri
- * @return resource for the uri, or <code>null</code> if not found.
- *
- * @since 1.0.0
- */
- public Resource getResource(URI uri) {
- return this.resourceSet.getResource(uri, true);
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/IEMFContextContributor.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/IEMFContextContributor.java
deleted file mode 100644
index 465d7fa0c..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/IEMFContextContributor.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: IEMFContextContributor.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-
-package org.eclipse.jem.util.emf.workbench;
-
-/**
- * EMF Context Contributor interface. Implimenters are called to contribute to the context.
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase#createEMFContext(IProject, IEMFContextContributor)
- * @since 1.0.0
- */
-public interface IEMFContextContributor {
-
- /**
- * This is your opportunity to add a primary EMFNature. Typically you would add to the WorkbenchContext held by <code>aNature</code> in order to
- * change the container for the WorkbenchURIConverter or add adapter factories to the ResourceSet or anything else that is needed.
- *
- * @param aNature
- *
- * @since 1.0.0
- */
- void primaryContributeToContext(EMFWorkbenchContextBase aNature);
-
- /**
- * This is your opportunity to add a secondary EMFNature. Typically you would add to the WorkbenchContext held by <code>aNature</code> in order
- * to change the container for the WorkbenchURIConverter or add adapter factories to the ResourceSet or anything else that is needed.
- *
- * @param aNature
- *
- * @since 1.0.0
- */
- void secondaryContributeToContext(EMFWorkbenchContextBase aNature);
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ISynchronizerExtender.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ISynchronizerExtender.java
deleted file mode 100644
index f70dd1e78..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ISynchronizerExtender.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: ISynchronizerExtender.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import org.eclipse.core.resources.IResourceDelta;
-
-/**
- * Implimenters allows clients, eg {@link org.eclipse.jem.util.emf.workbench.EMFNatureContributor}, to extend the behavior of the
- * ResourceSetWorkbenchSynchronizer.
- *
- * @see org.eclipse.jem.util.emf.workbench.ResourceSetWorkbenchSynchronizer#addExtender(ISynchronizerExtender)
- * @since 1.0.0
- */
-public interface ISynchronizerExtender {
-
- /**
- * Notification that project has changed.
- *
- * @param delta
- *
- * @since 1.0.0
- */
- void projectChanged(IResourceDelta delta);
-
- /**
- * Notification that project has been closed.
- *
- *
- * @since 1.0.0
- */
- void projectClosed();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectResourceSet.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectResourceSet.java
deleted file mode 100644
index 68c9735d2..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectResourceSet.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: ProjectResourceSet.java,v $$
- * $$Revision: 1.3 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-/**
- * A ResourceSet for an entire project. It allows sharing of resources from multiple editors/viewers for a project.
- * <p>
- * An additional Notification type is sent out by ProjectResourceSet's of project resource set about to be released. A release is
- * called when projects are about to be closed. They release all of the resources and unload them. This notification can be used
- * to know that this is about to happen and to do something before the resources become invalid. It will be sent out just before the
- * resource set will be released.
- *
- * @see ProjectResourceSet#SPECIAL_NOTIFICATION_TYPE
- * @see ProjectResourceSet#PROJECTRESOURCESET_ABOUT_TO_RELEASE_ID
- * @since 1.0.0
- */
-
-public interface ProjectResourceSet extends ResourceSet {
-
- IProject getProject();
-
- /**
- * Notification type in notifications from the ProjectResourceSet for
- * special notifications, and not the standard ones from ResourceSet.
- *
- * @see org.eclipse.emf.common.notify.Notification#getEventType()
- * @since 1.1.0
- */
- static int SPECIAL_NOTIFICATION_TYPE = Notification.EVENT_TYPE_COUNT+4;
-
- /**
- * Notification Feature ID for resource set about to be released.
- * Use {@link org.eclipse.emf.common.notify.Notification#getFeatureID(java.lang.Class)} to
- * get this id. The getFeature() on notification will return null.
- *
- * @since 1.1.0
- */
- static int PROJECTRESOURCESET_ABOUT_TO_RELEASE_ID = 1000;
-
- /**
- * Call when the ResourceSet is no longer to be used.
- *
- *
- * @since 1.0.0
- */
- void release();
-
- /**
- * Add the <code>resourceHandler</code> to the end of the list of resourceHandlers.
- *
- * @param resourceHandler
- * IResourceHandler
- * @return boolean Return <code>true</code> if it was added.
- * @since 1.0.0
- */
- boolean add(ResourceHandler resourceHandler);
-
- /**
- * Add the <code>resourceHandler</code> to the front of the list of resourceHandlers.
- *
- * @param resourceHandler
- * IResourceHandler
- * @since 1.0.0
- */
- void addFirst(ResourceHandler resourceHandler);
-
- /**
- * Remove the <code>resourceHandler</code> from the list of resourceHandlers.
- *
- * @param resourceHandler
- * IResourceHandler
- * @return boolean Return true if it was removed.
- * @since 1.0.0
- */
- boolean remove(ResourceHandler resourceHandler);
-
- /**
- * Return the ResourceSet synchronizer that will synchronize the ResourceSet with changes from the Workbench.
- *
- * @return ResourceSetWorkbenchSynchronizer
- * @since 1.0.0
- */
- ResourceSetWorkbenchSynchronizer getSynchronizer();
-
- /**
- * Set the ResourceSet synchronizer that will synchronize the ResourceSet with changes from the Workbench.
- *
- * @param aSynchronizer
- * @return ResourceSetWorkbenchSynchronizer
- * @since 1.0.0
- */
- void setSynchronizer(ResourceSetWorkbenchSynchronizer aSynchronizer);
-
- /**
- * This should be called by clients whenever the structure of the project changes such that any cached URIs will be invalid. For example, if the
- * source folders within the URIConverter change.
- *
- * @since 1.0.0
- */
- void resetNormalizedURICache();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java
deleted file mode 100644
index b339d880a..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java
+++ /dev/null
@@ -1,754 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: ProjectUtilities.java,v $$
- * $$Revision: 1.4 $$ $$Date: 2005/05/11 19:01:24 $$
- */
-
-package org.eclipse.jem.util.emf.workbench;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.*;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * EMF Workbench Project Utilities.
- *
- * @since 1.0.0
- */
-
-public class ProjectUtilities {
-
- /**
- * Project control file name in project.
- *
- * @since 1.0.0
- */
- public final static String DOT_PROJECT = ".project"; //$NON-NLS-1$
-
- /**
- * Classpath control file name in project.
- *
- * @since 1.0.0
- */
- public final static String DOT_CLASSPATH = ".classpath"; //$NON-NLS-1$
-
- public ProjectUtilities() {
- }
-
- /**
- * Add the nature id to the project ahead of all other nature ids.
- *
- * @param proj
- * @param natureId
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public static void addNatureToProject(IProject proj, String natureId) throws CoreException {
- IProjectDescription description = proj.getDescription();
- String[] prevNatures = description.getNatureIds();
- String[] newNatures = new String[prevNatures.length + 1];
- System.arraycopy(prevNatures, 0, newNatures, 1, prevNatures.length);
- newNatures[0] = natureId;
- description.setNatureIds(newNatures);
- proj.setDescription(description, null);
- }
-
- /**
- * Add the nature id after all of the other nature ids for the project.
- *
- * @param proj
- * @param natureId
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public static void addNatureToProjectLast(IProject proj, String natureId) throws CoreException {
- IProjectDescription description = proj.getDescription();
- String[] prevNatures = description.getNatureIds();
- String[] newNatures = new String[prevNatures.length + 1];
- System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
- newNatures[prevNatures.length] = natureId;
- description.setNatureIds(newNatures);
- proj.setDescription(description, null);
- }
-
- /**
- * Remove the nature id from the project.
- *
- * @param project
- * @param natureId
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public static void removeNatureFromProject(IProject project, String natureId) throws CoreException {
- IProjectDescription description = project.getDescription();
- String[] prevNatures = description.getNatureIds();
- int size = prevNatures.length;
- int newsize = 0;
- String[] newNatures = new String[size];
- boolean matchfound = false;
- for (int i = 0; i < size; i++) {
- if (prevNatures[i].equals(natureId)) {
- matchfound = true;
- continue;
- } else
- newNatures[newsize++] = prevNatures[i];
- }
- if (!matchfound)
- throw new CoreException(new Status(IStatus.ERROR, JEMUtilPlugin.ID, 0,
- "The nature id " + natureId + " does not exist on the project " + project.getName(), null)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- else {
- String[] temp = newNatures;
- newNatures = new String[newsize];
- System.arraycopy(temp, 0, newNatures, 0, newsize);
- description.setNatureIds(newNatures);
- project.setDescription(description, null);
- }
- }
-
- /**
- * Add the list of projects to end of the "referenced projects" list from the project's description.
- *
- * @param project
- * @param toBeAddedProjectsList
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public static void addReferenceProjects(IProject project, List toBeAddedProjectsList) throws CoreException {
-
- IProjectDescription description = project.getDescription();
- IProject[] projects = description.getReferencedProjects();
-
- ArrayList projectsList = new ArrayList();
-
- for (int i = 0; i < projects.length; i++) {
- projectsList.add(projects[i]);
- }
-
- for (int i = 0; i < toBeAddedProjectsList.size(); i++) {
- projectsList.add(toBeAddedProjectsList.get(i));
- }
-
- IProject[] refProjects = new IProject[projectsList.size()];
-
- for (int i = 0; i < refProjects.length; i++) {
- refProjects[i] = (IProject) (projectsList.get(i));
- }
-
- description.setReferencedProjects(refProjects);
- project.setDescription(description, null);
- }
-
- /**
- * Add the single project to the end of the "referenced projects" list from the project's description.
- *
- * @param project
- * @param projectToBeAdded
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public static void addReferenceProjects(IProject project, IProject projectToBeAdded) throws CoreException {
- IProjectDescription description = project.getDescription();
- IProject[] projects = description.getReferencedProjects();
-
- ArrayList projectsList = new ArrayList();
-
- for (int i = 0; i < projects.length; i++) {
- projectsList.add(projects[i]);
- }
-
- projectsList.add(projectToBeAdded);
-
- IProject[] refProjects = new IProject[projectsList.size()];
-
- for (int i = 0; i < refProjects.length; i++) {
- refProjects[i] = (IProject) (projectsList.get(i));
- }
-
- description.setReferencedProjects(refProjects);
- project.setDescription(description, null);
- }
-
- /**
- * Force a an immediate build of the project.
- *
- * @param project
- * @param progressMonitor
- *
- * @since 1.0.0
- */
- public static void forceAutoBuild(IProject project, IProgressMonitor progressMonitor) {
- try {
- project.build(IncrementalProjectBuilder.FULL_BUILD, progressMonitor);
- } catch (CoreException ce) {
- //Revisit: Need to use a Logger
- //Logger.getLogger().logError(ce);
- }
- }
-
- /**
- * Return if auto build is turned on.
- *
- * @return <code>true</code> if auto build is turned on.
- *
- * @since 1.0.0
- */
- public static boolean getCurrentAutoBuildSetting() {
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceDescription wd = workspace.getDescription();
- return wd.isAutoBuilding();
- }
-
- /**
- * Get the project associated with the given object.
- *
- * @param object
- * may be an <code>IProject, IResource, IAdaptable (to an IProject), EObject (gets IProject if object is in a ProjectResourceSet</code>.
- * @param natureId
- * if <code>null</code> then returns project. If not <code>null</code> then returns project only if project has this nature id.
- * @return project associated with the object or <code>null</code> if not found.
- *
- * @since 1.0.0
- */
- public static IProject getProject(Object object, String natureId) {
- IProject result = getProject(object);
- if (natureId == null)
- return result;
- if (result != null && result.isAccessible() && natureId != null)
- try {
- if (result.hasNature(natureId))
- return result;
- } catch (CoreException e) {
- Logger.getLogger().logError(e);
- }
- return null;
- }
-
- /**
- * Get the project associated with the given object.
- *
- * @param object
- * may be an <code>IProject, IResource, IAdaptable (to an IProject), EObject (gets IProject if object is in a ProjectResourceSet</code>.
- * @return project associated with the object or <code>null</code> if not found.
- *
- * @since 1.0.0
- */
- public static IProject getProject(Object object) {
- IProject result = null;
-
- if (object instanceof IProject)
- result = (IProject) object;
- else if (object instanceof IResource)
- result = ((IResource) object).getProject();
- else if (object instanceof IAdaptable)
- result = (IProject) ((IAdaptable) object).getAdapter(IProject.class);
- else if (object instanceof EObject)
- result = getProject((EObject) object);
-
- return result;
- }
-
- /**
- * Get the project associated with the given EObject. (If in a ProjectResourceSet, then the project from that resource set).
- *
- * @param aRefObject
- * @return project if associated or <code>null</code> if not found.
- *
- * @since 1.0.0
- */
- public static IProject getProject(EObject aRefObject) {
- if (aRefObject != null) {
- Resource resource = aRefObject.eResource();
- return getProject(resource);
- }
- return null;
- }
-
- /**
- * Get the project associated with the given Resource. (If in a ProjectResourceSet, then the project from that resource set).
- *
- * @param resource
- * @return project if associated or <code>null</code> if not found.
- *
- * @since 1.0.0
- */
- public static IProject getProject(Resource resource) {
- ResourceSet set = resource == null ? null : resource.getResourceSet();
- if (set instanceof ProjectResourceSet)
- return ((ProjectResourceSet) set).getProject();
- URIConverter converter = set == null ? null : set.getURIConverter();
- if (converter != null && converter instanceof WorkbenchURIConverter && ((WorkbenchURIConverter) converter).getOutputContainer() != null)
- return ((WorkbenchURIConverter) converter).getOutputContainer().getProject();
- else
- return null;
- }
-
- /**
- * Remove the list of projects from the list of "referenced projects" in the project's description.
- *
- * @param project
- * @param toBeRemovedProjectList
- * @throws org.eclipse.core.runtime.CoreException
- *
- * @since 1.0.0
- */
- public static void removeReferenceProjects(IProject project, List toBeRemovedProjectList) throws org.eclipse.core.runtime.CoreException {
- IProjectDescription description = project.getDescription();
- IProject[] projects = description.getReferencedProjects();
-
- ArrayList projectsList = new ArrayList();
-
- for (int i = 0; i < projects.length; i++) {
- projectsList.add(projects[i]);
- }
-
- for (int i = 0; i < toBeRemovedProjectList.size(); i++) {
- projectsList.remove(toBeRemovedProjectList.get(i));
- }
-
- IProject[] refProjects = new IProject[projectsList.size()];
-
- for (int i = 0; i < refProjects.length; i++) {
- refProjects[i] = (IProject) (projectsList.get(i));
- }
-
- description.setReferencedProjects(refProjects);
- project.setDescription(description, null);
- }
-
- /**
- * Remove the project from the list of "referenced projects" in the description for the given project.
- *
- * @param project
- * @param toBeRemovedProject
- * @throws org.eclipse.core.runtime.CoreException
- *
- * @since 1.0.0
- */
- public static void removeReferenceProjects(IProject project, IProject toBeRemovedProject) throws org.eclipse.core.runtime.CoreException {
- IProjectDescription description = project.getDescription();
- IProject[] projects = description.getReferencedProjects();
-
- ArrayList projectsList = new ArrayList();
-
- for (int i = 0; i < projects.length; i++) {
- projectsList.add((projects[i]));
- }
-
- projectsList.remove(toBeRemovedProject);
-
- IProject[] refProjects = new IProject[projectsList.size()];
-
- for (int i = 0; i < refProjects.length; i++) {
- refProjects[i] = (IProject) (projectsList.get(i));
- }
-
- description.setReferencedProjects(refProjects);
- project.setDescription(description, null);
- }
-
- /**
- * Turn auto-building off.
- *
- *
- * @since 1.0.0
- */
- public static void turnAutoBuildOff() {
- try {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceDescription wd = workspace.getDescription();
- wd.setAutoBuilding(false);
- workspace.setDescription(wd);
- } catch (CoreException ce) {
- //Logger.getLogger().logError(ce);
- }
- }
-
- /**
- * Turn auto-building on.
- *
- *
- * @since 1.0.0
- */
- public static void turnAutoBuildOn() {
- try {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceDescription wd = workspace.getDescription();
- wd.setAutoBuilding(true);
- workspace.setDescription(wd);
- } catch (CoreException ce) {
- //Logger.getLogger().logError(ce);
- }
- }
-
- /**
- * Set the auto-building state.
- *
- * @param aBoolean
- * <code>true</code> to turn auto-building on.
- *
- * @since 1.0.0
- */
- public static void turnAutoBuildOn(boolean aBoolean) {
- try {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceDescription wd = workspace.getDescription();
- wd.setAutoBuilding(aBoolean);
- workspace.setDescription(wd);
- } catch (CoreException ce) {
- //Logger.getLogger().logError(ce);
-
- }
- }
-
- /**
- * Adds a builder to the build spec for the given project.
- *
- * @param builderID
- * The id of the builder.
- * @param project
- * Project to add to.
- * @return whether the builder id was actually added (it may have already existed)
- * @throws CoreException
- * @since 1.0.0
- */
- public static boolean addToBuildSpec(String builderID, IProject project) throws CoreException {
- return addToBuildSpecBefore(builderID, null, project);
- }
-
- /**
- * Adds a builder to the build spec for the given project, immediately before the specified successor builder.
- *
- * @param builderID
- * The id of the builder.
- * @param successorID
- * The id to put the builder before.
- * @return whether the builder id was actually added (it may have already existed)
- * @throws CoreException
- * @since 1.0.0
- */
- public static boolean addToBuildSpecBefore(String builderID, String successorID, IProject project) throws CoreException {
- IProjectDescription description = project.getDescription();
- ICommand[] commands = description.getBuildSpec();
- boolean found = false;
- for (int i = 0; i < commands.length; ++i) {
- if (commands[i].getBuilderName().equals(builderID)) {
- found = true;
- break;
- }
- }
- if (!found) {
- boolean successorFound = false;
- ICommand command = description.newCommand();
- command.setBuilderName(builderID);
- ICommand[] newCommands = new ICommand[commands.length + 1];
- for (int j = 0, index = 0; j < commands.length; j++, index++) {
- if (successorID != null && commands[j].getBuilderName().equals(successorID)) {
- successorFound = true;
- newCommands[index++] = command;
- }
- newCommands[index] = commands[j];
- }
- if (!successorFound)
- newCommands[newCommands.length - 1] = command;
- description.setBuildSpec(newCommands);
- project.setDescription(description, null);
- }
- return !found;
- }
-
- /**
- * Remove the builder from the build spec.
- *
- * @param builderID
- * The id of the builder.
- * @param project
- * Project to remove from.
- * @return boolean if the builder id was found and removed
- * @throws CoreException
- * @since 1.0.0
- */
- public static boolean removeFromBuildSpec(String builderID, IProject project) throws CoreException {
- IProjectDescription description = project.getDescription();
- ICommand[] commands = description.getBuildSpec();
- boolean found = false;
- for (int i = 0; i < commands.length; ++i) {
- if (commands[i].getBuilderName().equals(builderID)) {
- found = true;
- break;
- }
- }
- if (found) {
- ICommand[] newCommands = new ICommand[commands.length - 1];
- int newCount = 0;
- for (int i = 0; i < commands.length; ++i) {
- if (!(commands[i].getBuilderName().equals(builderID))) {
- //Add the existng to the new array
- newCommands[newCount] = commands[i];
- newCount++;
- }
- }
-
- description.setBuildSpec(newCommands);
- project.setDescription(description, null);
-
- }
- return found;
-
- }
-
- /**
- * Ensure the container is not read-only.
- * <p>
- * For Linux, a Resource cannot be created in a ReadOnly folder. This is only necessary for new files.
- *
- * @param resource
- * workspace resource to make read/write
- * @since 1.0.0
- */
- public static void ensureContainerNotReadOnly(IResource resource) {
- if (resource != null && !resource.exists()) { //it must be new
- IContainer container = resource.getParent();
- ResourceAttributes attr = container.getResourceAttributes();
- while (attr != null && !attr.isReadOnly()) {
- container = container.getParent();
- if (container == null)
- break;
- attr = container.getResourceAttributes();
- }
- if (container != null && attr != null)
- attr.setReadOnly(false);
- }
- }
-
- /**
- * Get projects from primary nature.
- *
- * @param natureID
- * @return All projects that have the given nature id as the first nature id.
- *
- * @since 1.0.0
- */
- public static IProject[] getProjectsForPrimaryNature(String natureID) {
- IProject[] projectsWithNature = new IProject[] {};
- List result = new ArrayList();
- IProject[] projects = getAllProjects();
- for (int i = 0; i < projects.length; i++) {
- if (isProjectPrimaryNature(projects[i], natureID))
- result.add(projects[i]);
- }
- return (IProject[]) result.toArray(projectsWithNature);
- }
-
- /**
- * Get all projects in the workspace
- *
- * @return all workspace projects
- *
- * @since 1.0.0
- */
- public static IProject[] getAllProjects() {
- return ResourcesPlugin.getWorkspace().getRoot().getProjects();
- }
-
- /**
- * Is this nature id the primary nature id for the project
- *
- * @param project
- * @param natureID
- * @return <code>true</code> if first nature id for the project.
- *
- * @since 1.0.0
- */
- public static boolean isProjectPrimaryNature(IProject project, String natureID) {
- String[] natures = null;
- try {
- natures = project.getDescription().getNatureIds();
- } catch (Exception e1) {
- }
- return (natures != null && natures.length > 0 && natures[0].equals(natureID));
- }
-
- protected static IPath createPath(IProject p, String defaultSourceName) {
- IPath path = new Path(p.getName());
- path = path.append(defaultSourceName);
- path = path.makeAbsolute();
- return path;
- }
-
- /**
- * Returns a list of existing files which will be modified if the classpath changes for the given proeject.
- *
- * @param p
- * project
- * @return list of affected files.
- *
- * @since 1.0.0
- */
- public static List getFilesAffectedByClasspathChange(IProject p) {
- List result = new ArrayList(2);
- addFileIfExists(p, result, DOT_CLASSPATH);
- addFileIfExists(p, result, DOT_PROJECT);
- return result;
- }
-
- protected static void addFileIfExists(IProject p, List aList, String filename) {
- IFile aFile = p.getFile(filename);
- if (aFile != null && aFile.exists())
- aList.add(aFile);
- }
-
- /**
- * Strip off a leading "/" from each project name in the array, if it has one.
- *
- * @param projecNames
- * @return array of project names with all leading '/' removed.
- *
- * @since 1.0.0
- */
- public static String[] getProjectNamesWithoutForwardSlash(String[] projecNames) {
- String[] projNames = new String[projecNames.length];
- List temp = java.util.Arrays.asList(projecNames);
- for (int i = 0; i < temp.size(); i++) {
- String name = (String) (temp.get(i));
- if (name.startsWith("/")) { //$NON-NLS-1$
- projNames[i] = name.substring(1, name.length());
- } else {
- projNames[i] = name;
- }
- }
- return projNames;
- }
-
- protected static URL createFileURL(IPath path) {
- try {
- return path.toFile().toURL();
- } catch (MalformedURLException e) {
- Logger.getLogger().log(e, Level.WARNING);
- return null;
- }
- }
-
- /**
- * Find first newObject that is not in the oldObjects array (using "==").
- *
- * @param oldObjects
- * @param newObjects
- * @return first newObject not found in oldObjects, or <code>null</code> if all found.
- *
- * @since 1.0.0
- */
- public static Object getNewObject(Object[] oldObjects, Object[] newObjects) {
- if (oldObjects != null && newObjects != null && oldObjects.length < newObjects.length) {
- for (int i = 0; i < newObjects.length; i++) {
- boolean found = false;
- Object object = newObjects[i];
- for (int j = 0; j < oldObjects.length; j++) {
- if (oldObjects[j] == object) {
- found = true;
- break;
- }
- }
- if (!found)
- return object;
- }
- }
- if (oldObjects == null && newObjects != null && newObjects.length == 1)
- return newObjects[0];
- return null;
- }
-
- /**
- * List of all files in the project.
- * <p>
- * Note: A more efficient way to do this is to use {@link IResource#accept(org.eclipse.core.resources.IResourceProxyVisitor, int)}
- *
- * @param 1.0.0
- * @return list of files in the project
- *
- * @see IResource#accept(org.eclipse.core.resources.IResourceProxyVisitor, int)
- * @since 1.0.0
- */
- public static List getAllProjectFiles(IProject project) {
- List result = new ArrayList();
- if (project == null)
- return result;
- try {
- result = collectFiles(project.members(), result);
- } catch (CoreException e) {
- }
- return result;
- }
-
- private static List collectFiles(IResource[] members, List result) throws CoreException {
- // recursively collect files for the given members
- for (int i = 0; i < members.length; i++) {
- IResource res = members[i];
- if (res instanceof IFolder) {
- collectFiles(((IFolder) res).members(), result);
- } else if (res instanceof IFile) {
- result.add(res);
- }
- }
- return result;
- }
-
- /**
- * Get the project.
- *
- * @param projectName
- * @return a IProject given the projectName
- * @since 1.0.0
- */
- public static IProject getProject(String projectName) {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- }
-
- /**
- * Return whether the given builder name is attached to the project.
- *
- * @param project
- * @param builderName
- * @return <code>true</code> if builder name is attached to the project.
- *
- * @since 1.0.0
- */
- public static boolean hasBuilder(IProject project, String builderName) {
- try {
- ICommand[] builders = project.getDescription().getBuildSpec();
- for (int i = 0; i < builders.length; i++) {
- ICommand builder = builders[i];
- if (builder != null) {
- if (builder.getBuilderName().equals(builderName))
- return true;
- }
- }
- } catch (Exception e) {
- }
- return false;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceHandler.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceHandler.java
deleted file mode 100644
index 0170780cc..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceHandler.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: ResourceHandler.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-/**
- * Implementers of this interface are provide extension capabilities on resource set. Such as looking or creating in other resource sets for a
- * resource or an EObject.
- *
- * @see org.eclipse.jem.util.emf.workbench.ProjectResourceSet#add(ResourceHandler)
- * @since 1.0.0
- */
-public interface ResourceHandler {
-
- /**
- * Each ResourceHandler for a WorkbenchContext (which holds a ProjectResourceSet) will get an oportunity to get the Resource given the uriString
- * prior to the originatingResourceSet getting it in the normal manner.
- *
- * If this handler loaded a Resource in its create(ResourceSet, uriString) then this method should be able to return it as well.
- *
- * @param originatingResourceSet
- * @param uri
- * @return resource if found or <code>nulll/code> if this handler didn't find it.
- *
- * @since 1.0.0
- */
- Resource getResource(ResourceSet originatingResourceSet, URI uri);
-
- /**
- * Get the EObject for the given URI, if it can. Load the resource if loadOnDemand is <code>true</code>.
- *
- * @param originatingResourceSet
- * @param uri
- * uri of EObject being requested
- * @param loadOnDemand
- * <code>true</code> if resource should be loaded
- * @return eobject if found or <code>null</code> if not.
- */
- EObject getEObjectFailed(ResourceSet originatingResourceSet, URI uri, boolean loadOnDemand);
-
- /**
- * Create the resource pointed to be the URI if this handler will handle it.
- *
- * @param originatingResourceSet
- * @param uri
- * @return resource if created, or <code>null</code> if handler doesn't handle this type.
- */
- Resource createResource(ResourceSet originatingResourceSet, URI uri);
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceSetWorkbenchSynchronizer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceSetWorkbenchSynchronizer.java
deleted file mode 100644
index 1781936c3..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ResourceSetWorkbenchSynchronizer.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: ResourceSetWorkbenchSynchronizer.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-
-package org.eclipse.jem.util.emf.workbench;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import org.eclipse.jem.internal.util.emf.workbench.EMFWorkbenchContextFactory;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * Synchronizer on the workbench. It listens for the project to see if it is closed or deleted. If it does it notifies this out.
- *
- * @since 1.0.0
- */
-public class ResourceSetWorkbenchSynchronizer implements IResourceChangeListener {
-
- protected IProject project;
-
- protected ResourceSet resourceSet;
-
- /** Extenders that will be notified after a pre build resource change */
- protected List extenders;
-
- /** The delta for this project that will be broadcast to the extenders */
- protected IResourceDelta currentProjectDelta;
-
- private int currentEventType = -1;
-
- /**
- * Constructor taking a resource set and project.
- *
- * @param aResourceSet
- * @param aProject
- *
- * @since 1.0.0
- */
- public ResourceSetWorkbenchSynchronizer(ResourceSet aResourceSet, IProject aProject) {
- resourceSet = aResourceSet;
- project = aProject;
- if (aResourceSet != null && aResourceSet instanceof ProjectResourceSet)
- ((ProjectResourceSet) aResourceSet).setSynchronizer(this);
- initialize();
- }
-
- /**
- * Get the project for this synchronizer
- *
- * @return project
- *
- * @since 1.0.0
- */
- public IProject getProject() {
- return project;
- }
-
- /*
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- currentEventType = event.getType();
- currentProjectDelta = null;
- if ((currentEventType == IResourceChangeEvent.PRE_CLOSE || currentEventType == IResourceChangeEvent.PRE_DELETE)
- && event.getResource().equals(getProject())) {
- release();
- notifyExtendersOfClose();
- }
- }
-
- protected void notifyExtendersIfNecessary() {
- if (currentEventType != IResourceChangeEvent.POST_CHANGE || extenders == null || currentProjectDelta == null)
- return;
- for (int i = 0; i < extenders.size(); i++) {
- ISynchronizerExtender extender = (ISynchronizerExtender) extenders.get(i);
- extender.projectChanged(currentProjectDelta);
- }
- }
-
- protected void notifyExtendersOfClose() {
- if (extenders != null && !extenders.isEmpty()) {
- for (int i = 0; i < extenders.size(); i++) {
- ISynchronizerExtender extender = (ISynchronizerExtender) extenders.get(i);
- extender.projectClosed();
- }
- }
- }
-
- protected IWorkspace getWorkspace() {
- if (getProject() == null)
- return ResourcesPlugin.getWorkspace();
- return getProject().getWorkspace();
- }
-
- protected void initialize() {
- getWorkspace().addResourceChangeListener(this,
- IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_BUILD);
- }
-
- /**
- * Dispose of the synchronizer. Called when no longer needed.
- *
- *
- * @since 1.0.0
- */
- public void dispose() {
- getWorkspace().removeResourceChangeListener(this);
- }
-
- /**
- * The project is going away so we need to cleanup ourself and the ResourceSet.
- */
- protected void release() {
- if (JEMUtilPlugin.isActivated()) {
- try {
- if (resourceSet instanceof ProjectResourceSet)
- ((ProjectResourceSet) resourceSet).release();
- } finally {
- EMFWorkbenchContextFactory.INSTANCE.removeCachedProject(getProject());
- dispose();
- }
- }
- }
-
- /**
- * Add an extender to be notified of events.
- *
- * @param extender
- *
- * @since 1.0.0
- */
- public void addExtender(ISynchronizerExtender extender) {
- if (extenders == null)
- extenders = new ArrayList(3);
- extenders.add(extender);
- }
-
- /**
- * Remove extender from notification of events.
- *
- * @param extender
- *
- * @since 1.0.0
- */
- public void removeExtender(ISynchronizerExtender extender) {
- if (extenders == null)
- return;
- extenders.remove(extender);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return getClass().getName() + '(' + ((getProject() != null) ? getProject().getName() : "null") + ')'; //$NON-NLS-1$
- }
-
- /**
- * Tell Synchronizer that a file is about to be saved. This method should be called prior to writing to an IFile from an EMF resource.
- * <p>
- * Default does nothing, but subclasses can do something.
- * </p>
- *
- * @param aFile
- * file about to be saved.
- *
- * @since 1.0.0
- */
- public void preSave(IFile aFile) {
- //Default is do nothing
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchByteArrayOutputStream.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchByteArrayOutputStream.java
deleted file mode 100644
index 9d72f5141..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchByteArrayOutputStream.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: WorkbenchByteArrayOutputStream.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-
-/**
- * ByteArray OutputStream for the Workbench. It works with the synchronizer {@link org.eclipse.jem.util.emf.workbench.ResourceSetWorkbenchSynchronizer}to
- * notify of a save. It also changes all of the line separators to the current system line separator, i.e. if there are some '\r' and we are on
- * Windows(R) then they will be converted to '\n\r'), if the setting for the stream is to do eol conversion.
- *
- * @since 1.0.0
- */
-public class WorkbenchByteArrayOutputStream extends URIConverterImpl.PlatformResourceOutputStream {
-
- private boolean fConvertEOL = false;
-
- protected ResourceSetWorkbenchSynchronizer synchronizer;
-
- /**
- * Construct with an IFile
- *
- * @param aFile
- *
- * @since 1.0.0
- */
- public WorkbenchByteArrayOutputStream(IFile aFile) {
- this(aFile, null);
- }
-
- /**
- * Construct with a IFile and a synchronizer. This way synchronizer will know when file is about to be saved.
- *
- * @param aFile
- * @param aSynchronizer
- *
- * @since 1.0.0
- */
- public WorkbenchByteArrayOutputStream(IFile aFile, ResourceSetWorkbenchSynchronizer aSynchronizer) {
- super(aFile, false, true, null);
- synchronizer = aSynchronizer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.OutputStream#close()
- */
- public void close() throws IOException {
- if (synchronizer != null)
- synchronizer.preSave(file);
- super.close();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.resource.impl.URIConverterImpl.PlatformResourceOutputStream#flush()
- */
- public void flush() throws IOException {
- if (synchronizer != null)
- synchronizer.preSave(file);
- super.flush();
- }
-
- /*
- * Convert the end of line characters.
- */
- private int convertEOL(byte[] data) {
- // Algorithm:
- // Remove all '\r' chars
- // Replace all '\n' chars with line seperator chars
-
- String EOL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
- byte[] EOLBytes = EOL.getBytes();
-
- int out = 0;
-
- for (int in = 0; in < data.length; in++) {
- if (data[in] == '\r') {
- // don't output (ie, throw the char away)
- } else if (data[in] == '\n') {
- // The code does not currently handle expanding the array
- if ((in - out + 1) < EOLBytes.length)
- throw new UnsupportedOperationException("WorkbenchByteArrayOutputStream: Expanding EOL chars not implemented"); //$NON-NLS-1$
-
- for (int i = 0; i < EOLBytes.length; i++) {
- data[out++] = EOLBytes[i];
- }
- } else {
- // Just copy the data
- data[out++] = data[in];
- }
- }
-
- return out;
- }
-
- /**
- * Is EOL conversion turned on.
- *
- * @return <code>true</code> if EOL conversion is turned on.
- *
- * @since 1.0.0
- */
- public boolean isConvertEOLChars() {
- return fConvertEOL;
- }
-
- /**
- * Set the EOL conversion flag.
- *
- * @param set
- * <code>true</code> if EOL should be converted to current line separator.
- *
- * @since 1.0.0
- */
- public void setConvertEOLChars(boolean set) {
- fConvertEOL = set;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.ByteArrayOutputStream#toByteArray()
- */
- public synchronized byte[] toByteArray() {
- byte[] contents = super.toByteArray();
- if (isConvertEOLChars())
- convertEOL(contents);
- return contents;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchResourceHelperBase.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchResourceHelperBase.java
deleted file mode 100644
index 260165087..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchResourceHelperBase.java
+++ /dev/null
@@ -1,694 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: WorkbenchResourceHelperBase.java,v $$
- * $$Revision: 1.4 $$ $$Date: 2005/10/14 20:57:31 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.WrappedException;
-import org.eclipse.emf.ecore.*;
-import org.eclipse.emf.ecore.resource.*;
-import org.eclipse.emf.ecore.util.InternalEList;
-
-import org.eclipse.jem.internal.util.emf.workbench.EMFWorkbenchContextFactory;
-import org.eclipse.jem.internal.util.emf.workbench.WorkspaceResourceHandler;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * Workbench resource helper
- *
- * @since 1.0.0
- */
-public class WorkbenchResourceHelperBase {
-
- /**
- * Everything is static, don't know why there is an instance here.
- */
- public static final WorkbenchResourceHelperBase INSTANCE = new WorkbenchResourceHelperBase();
-
- protected static WorkspaceResourceHandler workspaceURILoader = new WorkspaceResourceHandler();
-
- protected static void resolveContainedProxies(EObject refObject) {
- List contained = refObject.eContents();
- EObject mofObject;
- for (int i = 0; i < contained.size(); i++) {
- mofObject = (EObject) contained.get(i);
- resolveProxies(mofObject);
- }
- }
-
- protected static void resolveNonContainedProxies(EObject refObject) {
- List references = refObject.eClass().getEAllReferences();
- EReference reference;
- for (int i = 0; i < references.size(); i++) {
- reference = (EReference) references.get(i);
- if (!reference.isContainment()) {
- if (reference.isMany()) {
- List value = (List) refObject.eGet(reference);
- for (int j = 0; j < value.size(); j++)
- value.get(j);
- } else {
- refObject.eGet(reference);
- }
- }
- }
- }
-
- /**
- * Force all of the proxies with <code>resource</code> to be resolved.
- *
- * @param resource
- *
- * @since 1.0.0
- */
- public static void resolveProxies(Resource resource) {
- if (resource != null) {
- List topLevels = resource.getContents();
- EObject mofObject;
- for (int i = 0; i < topLevels.size(); i++) {
- mofObject = (EObject) topLevels.get(i);
- resolveProxies(mofObject);
- }
- }
- }
-
- /**
- * Return a List of proxies that are contained by the <code>resource</code>.
- *
- * @param resource
- * @return list of proxies.
- *
- * @since 1.0.0
- */
- public static List gatherProxies(Resource resource) {
- if (resource == null)
- return Collections.EMPTY_LIST;
- List list = new ArrayList();
- List topLevels = resource.getContents();
- int size = topLevels.size();
- EObject mofObject;
- for (int i = 0; i < size; i++) {
- mofObject = (EObject) topLevels.get(i);
- gatherProxies((InternalEObject) mofObject, list);
- }
- return list;
- }
-
- protected static void gatherProxies(InternalEObject refObject, List proxies) {
- if (refObject == null)
- return;
- List contains = refObject.eClass().getEAllContainments();
- if (contains != null) {
- int size = contains.size();
- EStructuralFeature sf = null;
- for (int i = 0; i < size; i++) {
- sf = (EStructuralFeature) contains.get(i);
- gatherProxies(refObject, sf, proxies);
- }
- }
- }
-
- protected static void gatherProxies(InternalEObject refObject, EStructuralFeature sf, List proxies) {
- Object value = null;
- InternalEObject proxy = null;
- if (sf.isMany() || refObject.eIsSet(sf)) {
- value = refObject.eGet(sf, false);
- if (value != null) {
- if (sf.isMany()) {
- Iterator j = ((InternalEList) value).basicIterator();
- while (j.hasNext()) {
- proxy = (InternalEObject) j.next();
- if (proxy.eIsProxy())
- proxies.add(proxy);
- }
- } else if (((InternalEObject) value).eIsProxy())
- proxies.add(value);
- }
- }
- }
-
- protected static void resolveProxies(EObject refObject) {
- if (refObject != null) {
- resolveNonContainedProxies(refObject);
- resolveContainedProxies(refObject);
- }
- }
-
- /**
- * Return an existing context base on <code>aProject</code>.
- *
- * @param aProject
- * @return the context base for the project or <code>null</code> if none.
- *
- * @since 1.0.0
- */
- public static EMFWorkbenchContextBase getEMFContext(IProject aProject) {
- return EMFWorkbenchContextFactory.INSTANCE.getEMFContext(aProject);
- }
-
- /**
- * Create a resource from the URI. The URI must contain the project name, either as the first segment, or if in platform resource url protocol.
- * {@link #getResourceSet(URI)}
- *
- * @param uri
- * @return a new resource for the uri or <code>null</code> if not a project uri
- *
- * @since 1.0.0
- */
- public static Resource createResource(URI uri) {
- ResourceSet set = getResourceSet(uri);
- if (set != null)
- return set.createResource(uri);
- return null;
- }
-
- /**
- * Check for a cached Resource for the given URI, if none is found, create a new Resource for with the URI against the proper ResourceSet.
- *
- * @param uri The URI MUST be either a "<b>platform:/resource/</b>project-name/...." type URI or it
- * must be of type "project-name/...". This method will only return resources that are workbench project resources.
- * Any other type of URI will cause <code>null</code> to be returned.
- * @return resource or <code>null</code> if not a project uri.
- *
- * @since 1.0.0
- */
- public static Resource getExistingOrCreateResource(URI uri) {
- return getExistingOrCreateResource(uri, getResourceSet(uri));
- }
-
- /**
- * Get the IFile for the URI. The URI must be a workbench project style URI.
- * @param uri The URI MUST be either a "<b>platform:/resource/</b>project-name/...." type URI or it
- * must be of type "project-name/...". This method will only return resources that are workbench project resources.
- * Any other type of URI will cause <code>null</code> to be returned.
- * @return the IFile if the URI is a project form, <code>null</code> if not a project form, OR the project doesn't exist. The IFile returned doesn't necessarily exist. Use {@link IFile#exists()} to test that.
- *
- * @since 1.2.0
- */
- public static IFile getIFile(URI uri) {
- IProject project = getProject(uri);
- if (project != null) {
- IPath path;
- if (isPlatformResourceURI(uri)) {
- // Need to get the path and remove the first two segments (/resource/project name/).
- path = new Path(URI.decode(uri.path())).removeFirstSegments(2);
- } else {
- // Need to get the path and remove the first segment (/project name/).
- path = new Path(URI.decode(uri.path())).removeFirstSegments(1);
- }
- return project.getFile(path);
- } else
- return null;
- }
-
- /**
- * Check for a cached Resource for the given URI, if none is found, create a new Resource for with the URI against the given ResourceSet.
- *
- * @param uri
- * @param set
- * @return resource or <code>null</code> if set was <code>null</code>.
- *
- * @since 1.0.0
- */
- public static Resource getExistingOrCreateResource(URI uri, ResourceSet set) {
- if (set != null) {
- Resource res = set.getResource(uri, false);
- if (res == null)
- res = set.createResource(uri);
- return res;
- } else
- return null;
- }
-
- /**
- * Return a new or existing context base on <code>aProject</code>. Allow the <code>contributor</code> to contribute to the new or existing
- * nature prior to returning.
- *
- * @param aProject
- * @param contributor
- * @return the context base for the project.
- *
- * @since 1.0.0
- */
- public static EMFWorkbenchContextBase createEMFContext(IProject aProject, IEMFContextContributor contributor) {
- return EMFWorkbenchContextFactory.INSTANCE.createEMFContext(aProject, contributor);
- }
-
- /**
- * Does the passed URI have the form platform:/resource/... ?
- *
- * @param uri
- * @return <code>true</code> if it is a platform resource protocol.
- *
- * @since 1.0.0
- */
- public static boolean isPlatformResourceURI(URI uri) {
- return JEMUtilPlugin.PLATFORM_PROTOCOL.equals(uri.scheme()) && JEMUtilPlugin.PLATFORM_RESOURCE.equals(uri.segment(0));
- }
-
- /**
- * This api may be used to cache a Resource if it has a URI that is Workspace relative. Return true if it is cached.
- *
- * @param aResource
- * @return <code>true</code> if it was successful to cache.
- *
- * @since 1.0.0
- */
- public static boolean cacheResource(Resource aResource) {
- if (aResource != null) {
- ResourceSet set = getResourceSet(aResource.getURI());
- if (set != null)
- return set.getResources().add(aResource);
- }
- return false;
- }
-
- /**
- * This api is used if you create a new MOF resource and you want to add it to the correct ResourceSet. In order to do that, we need the IProject
- * that you want aResource to be cached within as well as the IPath which is the full path of the location of the new Resource.
- *
- * @param aProject
- * @param aResource
- * @param fullPath
- * @return <code>true</code> if resource was cached.
- *
- * @since 1.0.0
- */
- public static boolean cacheResource(IProject aProject, Resource aResource, IPath fullPath) {
- if (aProject == null || aResource == null || !aProject.isAccessible())
- return false;
- ResourceSet set = getResourceSet(aProject);
- if (set != null) {
- URI converted = set.getURIConverter().normalize(aResource.getURI());
- if (converted != aResource.getURI())
- aResource.setURI(converted);
- return set.getResources().add(aResource);
- }
- return false;
- }
-
- /**
- * Get the path of the project resource relative to the workspace or relative to the list of containers in this project.
- *
- * @param aResource
- * @return path
- *
- * @since 1.0.0
- */
- public static String getActualProjectRelativeURI(IResource aResource) {
- if (aResource == null || !aResource.isAccessible())
- return null;
- IProject project = aResource.getProject();
- IPath path = getPathInProject(project, aResource.getFullPath());
- return path.makeRelative().toString();
- }
-
- /**
- * Return an IPath that can be used to load a Resource using the <code>fullPath</code>. This will be a project relative path.
- *
- * @param project
- * @param fullPath
- * @return path
- *
- * @since 1.0.0
- */
- public static IPath getPathInProject(IProject project, IPath fullPath) {
- List containers = getProjectURIConverterContainers(project);
- if (!containers.isEmpty())
- return getPathFromContainers(containers, fullPath);
- return fullPath;
- }
-
- protected static List getProjectURIConverterContainers(IProject project) {
- EMFWorkbenchContextBase nature = createEMFContext(project, null);
- if (nature != null) {
- WorkbenchURIConverter conv = (WorkbenchURIConverter) nature.getResourceSet().getURIConverter();
- if (conv != null)
- return conv.getInputContainers();
- }
- return Collections.EMPTY_LIST;
- }
-
- /**
- * If this path is contained within one of the listed containers, then return the path relative to the container.
- *
- * @param containers
- * @param fullPath
- * @return path relative to a container, or unchanged path if not in a container.
- *
- * @since 1.0.0
- */
- public static IPath getPathFromContainers(List containers, IPath fullPath) {
- IContainer container = null;
- IPath result;
- int size = containers.size();
- int matching = -1;
- IPath containerPath;
- for (int i = 0; i < size; i++) {
- container = (IContainer) containers.get(i);
- containerPath = container.getFullPath();
- matching = fullPath.matchingFirstSegments(containerPath);
- if (matching > 0 && matching == containerPath.segmentCount()) {
- result = fullPath.removeFirstSegments(matching);
- result = result.makeRelative();
- return result;
- }
- }
- return fullPath;
- }
-
- /**
- * Return true if the <code>uri</code> has its container segments visible from the input containers for the <code>project</code>.
- *
- * @param project
- * @param uri
- * @return <code>true</code> if the uri is visible from the input containers.
- *
- * @since 1.0.0
- */
- public static boolean hasContainerStructure(IProject project, URI uri) {
- if (project != null && uri != null) {
- IPath path = new Path(uri.toString());
- List containers = getProjectURIConverterContainers(project);
- int segmentCount = path.segmentCount();
- IPath containerPath = segmentCount > 1 ? path.removeLastSegments(1) : null;
- IContainer container = null;
- for (int i = 0; i < containers.size(); i++) {
- container = (IContainer) containers.get(i);
- if (!container.isAccessible())
- continue;
- if (segmentCount == 1) {
- if (container == project)
- return true;
- } else if (containerPath != null) {
- IFolder folder = container.getFolder(containerPath);
- if (folder != null && folder.isAccessible())
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Get the resource for the uri. The URI MUST be either a "<b>platform:/resource/</b>project-name/...." type URI or it
- * must be of type "project-name/...". This method will only return resources that are workbench project resources.
- * Any other type of URI will cause <code>null</code> to be returned. It will be loaded if not already loaded. If it is not to
- * be loaded if not loaded use {@link #getResource(URI, boolean)} instead.
- *
- * @param uri must be either a "<b>platform:/resource/</b>project-name/..." form or it must be "project-name/...". Any other form will be invalid.
- * @return resource if uri is for a valid workbench project resource or <code>null</code> if project not found or not a valid project resource.
- *
- * @throws WrappedException if valid project format URI but file not found or some other error on load.
- * @since 1.0.0
- */
- public static Resource getResource(URI uri) {
- return getResource(uri, true);
- }
-
- /**
- * Return the Resource for the passed IFile without forcing a load.
- *
- * @param aFile
- * @return
- *
- * @since 1.0.0
- */
- public static Resource getResource(IFile aFile) {
- return getResource(aFile, false);
- }
-
- /**
- * Return the Resource for the passed IFile, forcing a load if <code>loadOnDemand</code> says so.
- *
- * @param aFile
- * @param loadOnDemand
- * <code>true</code> will force a load of resource if not loaded.
- * @return
- *
- * @since 1.0.0
- */
- public static Resource getResource(IFile aFile, boolean loadOnDemand) {
- if (aFile != null)
- return getResource(URI.createPlatformResourceURI(aFile.getFullPath().toString()), loadOnDemand);
- return null;
- }
-
- /**
- * Return the Resource for the passed IFile without a load if not loaded.
- *
- * @param aFile
- * @return
- *
- * @since 1.0.0
- */
- public static Resource load(IFile aFile) {
- return getResource(aFile, true);
- }
-
- /**
- * Get the resource for the uri. The URI MUST be either a "<b>platform:/resource/</b>project-name/...." type URI or it
- * must be of type "project-name/...". This method will only return resources that are workbench project resources.
- * Any other type of URI will cause <code>null</code> to be returned.
- *
- * @param uri must be either a "<b>platform:/resource/</b>project-name/..." form or it must be "project-name/...". Any other form will be invalid.
- * @param loadOnDemand <code>true</code> will cause resource to be loaded if not already loaded.
- * @return resource if uri is for a valid workbench project resource, or <code>null</code> if project not found, or not a valid project resource uri.
- *
- * @throws WrappedException if valid project format URI but file not found or some other error on load if loadOnDemand is true.
- * @since 1.0.0
- */
- public static Resource getResource(URI uri, boolean loadOnDemand) {
- ResourceSet set = getResourceSet(uri);
- if (set != null)
- return set.getResource(uri, loadOnDemand);
- return null;
- }
-
- /**
- * Return a ResourceSet for the passed URI. The URI should be in the format platform:/resource/{project name}/... or {project name}/... for this
- * api to work.
- *
- * @param uri
- * @return the resource set or <code>null</code> if not of correct form or project doesn't have a resource set.
- *
- * @since 1.0.0
- */
- public static ResourceSet getResourceSet(URI uri) {
- IProject project = getProject(uri);
- if (project != null && project.isAccessible())
- return getResourceSet(project);
- else
- return null;
- }
-
- /*
- * Get the project for the uri if the uri is a valid workbench project format uri. null otherwise.
- */
- private static IProject getProject(URI uri) {
- String projectName;
- if (isPlatformResourceURI(uri))
- projectName = uri.segment(1);
- else if (uri.scheme() == null) {
- projectName = new Path(uri.path()).segment(0); //assume project name is first in the URI
- } else
- return null;
- IProject project = getWorkspace().getRoot().getProject(URI.decode(projectName));
- if (project != null && project.isAccessible())
- return project;
- else
- return null;
- }
-
- /**
- * Return the ResourceSet for the passed IProject.
- *
- * @param project
- * @return resource set
- */
- public static ResourceSet getResourceSet(IProject project) {
- EMFWorkbenchContextBase nat = createEMFContext(project, null);
- if (nat != null)
- return nat.getResourceSet();
- return null;
- }
-
- /**
- * Get the workspace. (just use {@link ResourcesPlugin#getWorkspace()}).
- *
- * @return
- *
- * @since 1.0.0
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Get the project associated with the resource set.
- *
- * @param set
- * @return project or <code>null</code> if resource set not associated with a project.
- *
- * @since 1.0.0
- */
- public static IProject getProject(ResourceSet set) {
- if (set != null) {
- if (set instanceof ProjectResourceSet) {
- ProjectResourceSet pset = (ProjectResourceSet) set;
- return pset.getProject();
- }
- }
- return null;
- }
-
- protected static boolean isRegisteredURIMapping(String href) {
- if (href != null) {
- String file = href;
- int index = href.indexOf('#');
- if (index > -1)
- file = href.substring(0, index);
- return URIConverter.URI_MAP.get(file) != null;
- }
- return false;
- }
-
- /**
- * Remove all of the resources from the resource set and then unload them. Unload forces all of the objects to become proxies so next resolve will
- * reload the resource.
- *
- * @param resources
- * @param aSet
- *
- * @since 1.0.0
- */
- public static void removeAndUnloadAll(List resources, ResourceSet aSet) {
- if (aSet == null || resources == null || resources.isEmpty())
- return;
- aSet.getResources().removeAll(resources);
- Resource res;
- for (int i = 0; i < resources.size(); i++) {
- res = (Resource) resources.get(i);
- res.unload();
- }
- }
-
- /**
- * Turn object into a proxy.
- *
- * @param anObject
- * @return <code>true</code> if object was able to become a proxy.
- *
- * @since 1.0.0
- */
- public static boolean becomeProxy(EObject anObject) {
- if (anObject != null) {
- Resource res = anObject.eResource();
- if (res != null) {
- URI uri = res.getURI();
- ((InternalEObject) anObject).eSetProxyURI(uri.appendFragment(res.getURIFragment(anObject)));
- //anObject.eAdapters().clear();
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return true if the WrappedException is actually a Resource Not Found.
- *
- * @param wrappedEx
- * @return <code>true</code> is exception wrappers a resource not found.
- * @since 1.0.0
- */
- public static boolean isResourceNotFound(WrappedException wrappedEx) {
- Exception excep = wrappedEx.exception();
- while (excep instanceof WrappedException) {
- excep = ((WrappedException) excep).exception();
- }
- return primIsResourceNotFound(excep);
- }
-
- private static boolean primIsResourceNotFound(Exception excep) {
- if (excep instanceof CoreException) {
- IStatus status = ((CoreException) excep).getStatus();
- return status.getCode() == IResourceStatus.RESOURCE_NOT_FOUND && ResourcesPlugin.PI_RESOURCES.equals(status.getPlugin());
- }
- return false;
- }
-
- /**
- * Return true if the WrappedException is actually a Resource Not Found.
- *
- * @param wrappedEx
- * @return <code>true</code> is exception wrappers a resource not found.
- * @since 1.0.0
- */
- public static boolean isResourceNotFound(Resource.IOWrappedException wrappedEx) {
- return primIsResourceNotFound(wrappedEx.getWrappedException());
- }
-
- /**
- * Return a URI represenation of the platformURI without the leading "platform:/resource/" if present.
- *
- * @param platformURI
- * @return uri
- * @since 1.0.0
- */
- public static URI getNonPlatformURI(URI platformURI) {
- if (isPlatformResourceURI(platformURI)) {
- String uriString = primGetNonPlatformURIString(platformURI);
- return URI.createURI(uriString);
- }
- return platformURI;
- }
-
- /**
- * Return a String represenation of the platformURI without the leading "platform:/resource/" if present.
- *
- * @param platformURI
- * @return
- * @since 1.0.0
- */
- public static String getNonPlatformURIString(URI platformURI) {
- if (isPlatformResourceURI(platformURI)) { return primGetNonPlatformURIString(platformURI); }
- return platformURI.toString();
- }
-
- /*
- * Remove "platform:/resource/" from the front of the platformURI and return the remaining String.
- */
- private static String primGetNonPlatformURIString(URI platformURI) {
- String uriString = platformURI.toString();
- //"platform:/resource/" is 19 characters.
- return uriString.substring(19, uriString.length());
- }
-
- /**
- * Does the passed URI have the form platform:/plugin/... ?
- *
- * @param uri
- * @return <code>true</code> if uri is platform plugin protocol.
- *
- * @since 1.0.0
- */
- public static boolean isPlatformPluginResourceURI(URI uri) {
- return JEMUtilPlugin.PLATFORM_PROTOCOL.equals(uri.scheme()) && JEMUtilPlugin.PLATFORM_PLUGIN.equals(uri.segment(0));
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverter.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverter.java
deleted file mode 100644
index e556851ca..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverter.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: WorkbenchURIConverter.java,v $$
- * $$Revision: 1.2 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.emf.ecore.resource.URIConverter;
-
-/**
- * Implementers of this interface are WorkbenchURI converters. Workbench URI converters handle references to files in the project's containers.
- * This converter is only necessary to resolve old ambiguous workbench URIs.
- * @since 1.0.0
- */
-public interface WorkbenchURIConverter extends URIConverter {
-
- /**
- * Add input container to to the converter.
- *
- * @param aContainer
- *
- * @since 1.0.0
- */
- void addInputContainer(IContainer aContainer);
-
- /**
- * Add list of containers to the converter.
- *
- * @param containers
- * list of <code>IContainer</code>
- *
- * @since 1.0.0
- */
- void addInputContainers(List containers);
-
- /**
- * Get the file relative to a container.
- *
- * @param uri
- * @return file relative to a container or <code>null</code> if not.
- *
- * @since 1.0.0
- */
- IFile getFile(String uri);
-
- /**
- * Get first input container
- *
- * @return first input container or <code>null</code> if none set.
- *
- * @since 1.0.0
- */
- IContainer getInputContainer();
-
- /**
- * Get all input containers.
- *
- * @return all input containers.
- *
- * @since 1.0.0
- */
- List getInputContainers();
-
- /**
- * Get the output container if set.
- *
- * @return output container or <code>null</code> if not set.
- *
- * @since 1.0.0
- */
- IContainer getOutputContainer();
-
- /**
- * Set the output container.
- *
- * @param container
- *
- * @since 1.0.0
- */
- void setOutputContainer(IContainer container);
-
- /**
- * Return an IFile for
- *
- * @aPath. If we have a parent and we do not contain the first segment of the aPath, forward to the parent to retrieve the file.
- * @param aPath
- * @return
- *
- * @since 1.0.0
- */
- IFile getOutputFile(IPath aPath);
-
- /**
- * Get output file with mapping applied.
- *
- * @param uri
- * @return
- *
- * @since 1.0.0
- */
- IFile getOutputFileWithMappingApplied(String uri);
-
- /**
- * Remove input container from list.
- *
- * @param aContainer
- * @return <code>true</code> if removed.
- *
- * @since 1.0.0
- */
- boolean removeInputContainer(IContainer aContainer);
-
- /**
- * Return true if we can retrieve the resource used to open an input stream on.
- *
- * @param aFileName
- * @return <code>true</code> if filename is valid for file stream access.
- * @since 1.0.0
- *
- */
- boolean canGetUnderlyingResource(String aFileName);
-
- /**
- * Is force save relative flag turned on.
- *
- * @return <code>true</code> if force save relative is turned on.
- *
- * @since 1.0.0
- */
- boolean isForceSaveRelative();
-
- /**
- * Set to true if you do not want any path manipulation when creating the output stream..
- *
- * @param forceSaveRelative
- * <code>true</code> to force saves as relative.
- */
- void setForceSaveRelative(boolean forceSaveRelative);
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverterImpl.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverterImpl.java
deleted file mode 100644
index 4eaaee19d..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/WorkbenchURIConverterImpl.java
+++ /dev/null
@@ -1,514 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: WorkbenchURIConverterImpl.java,v $$
- * $$Revision: 1.5 $$ $$Date: 2006/02/06 22:05:46 $$
- */
-package org.eclipse.jem.util.emf.workbench;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * A default implementation of the WorkbenchURIConverter interface.
- *
- * @since 1.0.0
- */
-public class WorkbenchURIConverterImpl extends URIConverterImpl implements WorkbenchURIConverter {
-
- private final static IWorkspaceRoot WORKSPACE_ROOT = URIConverterImpl.workspaceRoot;
- private final static String WORKSPACE_ROOT_LOCATION = WORKSPACE_ROOT.getLocation().toString();
-
- private static final String FILE_PROTOCOL = "file"; //$NON-NLS-1$
-
- private static final IPath INVALID_PATH = new Path("!!!!~!!!!"); //$NON-NLS-1$
-
- private static final IFile INVALID_FILE = WORKSPACE_ROOT.getFile(INVALID_PATH.append(INVALID_PATH));
-
- //Used to avoid trying to fixup the URI when getting the
- //OutputStream
- protected boolean forceSaveRelative = false;
-
- protected List inputContainers;
-
- protected IContainer outputContainer;
-
- protected ResourceSetWorkbenchSynchronizer resourceSetSynchronizer;
-
- /*
- * KLUDGE: We need to know the meta data area. This is so that any uri that starts with the metadata directory
- * is considered a file uri and NOT a workspace uri. The metadata is where plugin's store their working data.
- * It is not part of the workspace root.
- *
- * There is no request for simply the metadata area. The log file is in the metadata directory. So we will
- * get the log file location and just remove the log file name. That should leave us with the metadata directory
- * only. If Eclipse ever decides to move it from here, this will no longer work. But it hasn't moved in three
- * versions.
- *
- * @since 1.1.0
- */
- static protected final String METADATA_LOCATION = Platform.getLogFileLocation().removeLastSegments(1).toString();
-
- /**
- * Default converter constructor, no containers.
- *
- *
- * @since 1.0.0
- */
- public WorkbenchURIConverterImpl() {
- super();
- }
-
- /**
- * Construct with an input container.
- *
- * @param anInputContainer
- *
- * @since 1.0.0
- */
- public WorkbenchURIConverterImpl(IContainer anInputContainer) {
- this(anInputContainer, (ResourceSetWorkbenchSynchronizer) null);
- }
-
- /**
- * Construct with an input container and a synchronzier.
- *
- * @param aContainer
- * @param aSynchronizer
- *
- * @since 1.0.0
- */
- public WorkbenchURIConverterImpl(IContainer aContainer, ResourceSetWorkbenchSynchronizer aSynchronizer) {
- this(aContainer, null, aSynchronizer);
- }
-
- /**
- * Construct with an input container and an output container.
- *
- * @param anInputContainer
- * @param anOutputContainer
- *
- * @since 1.0.0
- */
- public WorkbenchURIConverterImpl(IContainer anInputContainer, IContainer anOutputContainer) {
- this(anInputContainer, anOutputContainer, null);
- }
-
- /**
- * Construct with an input container, output container, and a synchronizer.
- *
- * @param anInputContainer
- * @param anOutputContainer
- * @param aSynchronizer
- *
- * @since 1.0.0
- */
- public WorkbenchURIConverterImpl(IContainer anInputContainer, IContainer anOutputContainer, ResourceSetWorkbenchSynchronizer aSynchronizer) {
- addInputContainer(anInputContainer);
- setOutputContainer(anOutputContainer);
- resourceSetSynchronizer = aSynchronizer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#addInputContainer(org.eclipse.core.resources.IContainer)
- */
- public void addInputContainer(IContainer aContainer) {
- if (aContainer != null && !getInputContainers().contains(aContainer))
- getInputContainers().add(aContainer);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#addInputContainers(java.util.List)
- */
- public void addInputContainers(List containers) {
- for (int i = 0; i < containers.size(); i++) {
- addInputContainer((IContainer) containers.get(i));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#removeInputContainer(org.eclipse.core.resources.IContainer)
- */
- public boolean removeInputContainer(IContainer aContainer) {
- return getInputContainers().remove(aContainer);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getInputContainers()
- */
- public List getInputContainers() {
- if (inputContainers == null)
- inputContainers = new ArrayList();
- return inputContainers;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getInputContainer()
- */
- public IContainer getInputContainer() {
- if (!getInputContainers().isEmpty())
- return (IContainer) getInputContainers().get(0);
- else
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getOutputContainer()
- */
- public IContainer getOutputContainer() {
- if (outputContainer == null)
- outputContainer = getInputContainer();
- return outputContainer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#setOutputContainer(org.eclipse.core.resources.IContainer)
- */
- public void setOutputContainer(IContainer newOutputContainer) {
- outputContainer = newOutputContainer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getOutputFile(org.eclipse.core.runtime.IPath)
- */
- public IFile getOutputFile(IPath aPath) {
- IFile file = null;
- if (getOutputContainer() != null) {
- if (forceSaveRelative)
- return primGetOutputFile(aPath);
- file = getOutputFileForPathWithContainerSegments(aPath);
- if (file != null)
- return file;
- else
- return primGetOutputFile(aPath);
- }
- return file;
- }
-
- protected IFile primGetOutputFile(IPath aPath) {
- return primGetFile(getOutputContainer(), aPath);
- }
-
- protected IFile getOutputFileForPathWithContainerSegments(IPath aPath) {
- IContainer out = getOutputContainer();
- return getFileForPathWithContainerSegments(aPath, out, false);
- }
-
- protected IFile getFileForPathWithContainerSegments(IPath aPath, IContainer container, boolean testExists) {
- IPath containerPath = null;
- IFile file = null;
- if (testExists) {
- containerPath = container.getProjectRelativePath();
- if (!containerPath.isEmpty()) {
- file = getFileForMatchingPath(aPath, containerPath, container);
- if (file != null && file.exists())
- return file;
- }
- }
- containerPath = container.getFullPath();
- file = getFileForMatchingPath(aPath, containerPath, container);
- return file;
- }
-
- protected IFile getFileForMatchingPath(IPath containerPath, IPath sourcePath, IContainer container) {
- int matches = 0;
- matches = containerPath.matchingFirstSegments(sourcePath);
- if (matches > 0 && matches == sourcePath.segmentCount()) {
- IPath loadPath = containerPath.removeFirstSegments(matches);
- return primGetFile(container, loadPath);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getFile(java.lang.String)
- */
- public IFile getFile(String uri) {
- return getFile(new Path(uri));
- }
-
- /**
- * Get the file from the path.
- *
- * @param path
- * @return
- * @see WorkbenchURIConverter#getFile(String)
- * @since 1.0.0
- */
- public IFile getFile(IPath path) {
- IFile file = null;
- if (getInputContainer() != null) {
- path = path.makeRelative();
- java.util.Iterator it = getInputContainers().iterator();
- while (it.hasNext()) {
- IContainer con = (IContainer) it.next();
- file = getInputFile(con, path);
- if (file != null && file.exists())
- return file;
- }
- }
- if (file == null)
- return INVALID_FILE;
- return file;
- }
-
- /**
- * Get output file from string path.
- *
- * @param uri
- * @return
- *
- * @see WorkbenchURIConverter#getOutputFile(IPath)
- * @since 1.0.0
- */
- public IFile getOutputFile(String uri) {
- return getOutputFile(new Path(uri));
- }
-
- /**
- * Get the input file from the container and path.
- *
- * @param con
- * @param path
- * @return
- *
- * @since 1.0.0
- */
- public IFile getInputFile(IContainer con, IPath path) {
- IFile file = null;
- if (WORKSPACE_ROOT.equals(con) && path.segmentCount() < 2)
- path = INVALID_PATH.append(path);
- file = primGetFile(con, path);
- if (file == null || !file.exists())
- file = getFileForPathWithContainerSegments(path, con, true);
- return file;
- }
-
- protected IFile primGetFile(IContainer container, IPath path) {
- try {
- return container.getFile(path);
- } catch (IllegalArgumentException ex) {
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#canGetUnderlyingResource(java.lang.String)
- */
- public boolean canGetUnderlyingResource(String aFileName) {
- IFile file = getFile(aFileName);
- return file != null && file.exists();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#isForceSaveRelative()
- */
- public boolean isForceSaveRelative() {
- return forceSaveRelative;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#setForceSaveRelative(boolean)
- */
- public void setForceSaveRelative(boolean forceSaveRelative) {
- this.forceSaveRelative = forceSaveRelative;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.resource.URIConverter#normalize(org.eclipse.emf.common.util.URI)
- */public URI normalize(URI uri) {
- URI result = uri;
- String fragment = null;
- if (uri.hasFragment()) {
- fragment = uri.fragment();
- result = uri.trimFragment();
- }
- result = getInternalURIMap().getURI(result);
- if (WorkbenchResourceHelperBase.isPlatformResourceURI(result))
- return appendFragment(result, fragment);
- if (WorkbenchResourceHelperBase.isPlatformPluginResourceURI(result)) {
- URI normalized = normalizePluginURI(result, fragment);
- return (normalized != null) ? normalized : uri;
- }
- String protocol = result.scheme();
- URI fileSearchURI = null;
- if (protocol == null) {
- fileSearchURI = normalizeEmptyProtocol(result, fragment);
- if (fileSearchURI != null)
- return fileSearchURI;
- } else if (FILE_PROTOCOL.equals(protocol)) {
- fileSearchURI = normalizeFileProtocol(result, fragment);
- if (fileSearchURI != null)
- return fileSearchURI;
- } else if (JEMUtilPlugin.WORKSPACE_PROTOCOL.equals(protocol))
- return normalizeWorkspaceProtocol(result, fragment);
- return super.normalize(uri);
- }
-
- /*
- * Resolves a plugin format into the actual.
- */
- protected URI normalizePluginURI(URI uri, String fragment) {
- if (uri.segmentCount() < 2)
- return uri; // Invalid, just let it go on.
- // See if already normalized.
- int u_scoreNdx = uri.segment(1).lastIndexOf('_');
- if (u_scoreNdx != -1) {
- // Not normalized. Remove the version to make it normalized.
- String[] segments = uri.segments();
- segments[1] = segments[1].substring(0, u_scoreNdx);
- return URI.createHierarchicalURI(uri.scheme(), uri.authority(), uri.device(), segments, uri.query(), fragment);
- } else
- return uri;
- }
-
- protected URI normalizeWorkspaceProtocol(URI aWorkspaceURI, String fragment) {
- URI result;
- String uriString = aWorkspaceURI.toString();
- uriString = uriString.substring(JEMUtilPlugin.WORKSPACE_PROTOCOL.length() + 1);
- result = URI.createPlatformResourceURI(uriString);
- if (fragment != null)
- result = appendFragment(aWorkspaceURI, fragment);
- return result;
- }
-
- protected URI normalizeEmptyProtocol(URI aFileUri, String fragment) {
- //Make the relative path absolute and return a platform URI.
- IPath path = new Path(aFileUri.toString());
- return normalizeToWorkspaceURI(path, fragment);
- }
-
- private URI normalizeToWorkspaceURI(IPath path, String fragment) {
- URI result = null;
- IFile file = getFile(path);
- if (file == null || !file.exists())
- file = getOutputFile(path);
- if (file != null) {
- result = URI.createPlatformResourceURI(file.getFullPath().toString());
- result = appendFragment(result, fragment);
- }
- return result;
- }
-
- protected URI normalizeFileProtocol(URI aFileUri, String fragment) {
- URI result = null;
- //Make the relative path absolute and return a platform URI.
- String devicePath = aFileUri.devicePath();
- //Test for workspace location.
- if (!devicePath.startsWith(METADATA_LOCATION) &&
- devicePath.startsWith(WORKSPACE_ROOT_LOCATION) && devicePath.length() > WORKSPACE_ROOT_LOCATION.length()) {
- //test for workspace location
- result = normalizeToWorkspaceURI(new Path(devicePath.substring(WORKSPACE_ROOT_LOCATION.length())), fragment);
- } else if (aFileUri.isRelative()) {
- result = normalizeToWorkspaceURI(new Path(aFileUri.toString()), fragment);
- } else {
- result = aFileUri;
- }
- return result;
- }
-
- protected URI appendFragment(URI result, String fragment) {
- if (fragment != null)
- return result.appendFragment(fragment);
- else
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.emf.workbench.WorkbenchURIConverter#getOutputFileWithMappingApplied(java.lang.String)
- */
- public IFile getOutputFileWithMappingApplied(String uri) {
- URI converted = getInternalURIMap().getURI(URI.createURI(uri));
- return getOutputFile(new Path(converted.toString()));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.resource.impl.URIConverterImpl#createPlatformResourceOutputStream(java.lang.String)
- */
- public OutputStream createPlatformResourceOutputStream(String platformResourcePath) throws IOException {
- IFile file = WORKSPACE_ROOT.getFile(new Path(platformResourcePath));
- ProjectUtilities.ensureContainerNotReadOnly(file);
- return new WorkbenchByteArrayOutputStream(file, resourceSetSynchronizer);
- }
-
- protected URI getContainerRelativeURI(IFile aFile) {
- IPath path = WorkbenchResourceHelperBase.getPathFromContainers(inputContainers, aFile.getFullPath());
- if (path != null)
- return URI.createURI(path.toString());
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.resource.impl.URIConverterImpl#createPlatformResourceInputStream(java.lang.String)
- */
- public InputStream createPlatformResourceInputStream(String platformResourcePath) throws IOException {
- IFile file = WORKSPACE_ROOT.getFile(new Path(platformResourcePath));
- try {
- if (!file.isSynchronized(IResource.DEPTH_ONE)) {
- try {
- File iofile = file.getFullPath().toFile();
- if (iofile.exists() || file.exists())
- file.refreshLocal(IResource.DEPTH_ONE, null);
- } catch (CoreException ce) {
- if (ce.getStatus().getCode() != IResourceStatus.WORKSPACE_LOCKED)
- throw ce;
- }
- }
- // CHANGED from <no-args> to <true> [94015]
- return file.getContents(true);
- } catch (CoreException exception) {
- throw new Resource.IOWrappedException(exception);
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/nature/EMFNature.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/nature/EMFNature.java
deleted file mode 100644
index f7f288af1..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/nature/EMFNature.java
+++ /dev/null
@@ -1,554 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: EMFNature.java,v $$
- * $$Revision: 1.4 $$ $$Date: 2005/02/15 23:04:14 $$
- */
-package org.eclipse.jem.util.emf.workbench.nature;
-
-import java.util.*;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.common.util.*;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.xmi.XMLParserPool;
-import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl;
-
-import org.eclipse.jem.internal.util.emf.workbench.nature.EMFNatureRegistry;
-import org.eclipse.jem.util.emf.workbench.*;
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-/**
- * The base EMFNature.
- * <p>
- * This is expected to be subclassed by clients, but there are default subclasses available.
- * </p>
- *
- * @since 1.0.0
- */
-public abstract class EMFNature implements IProjectNature, IEMFContextContributor {
-
- protected IProject project;
-
- protected EMFWorkbenchContextBase emfContext;
-
- protected boolean hasConfigured = false;
-
- public static XMLParserPool SHARED_PARSER_POOL = new XMLParserPoolImpl();
-
- public EMFNature() {
- super();
- }
-
- /**
- * Add the nature id to the project.
- *
- * @param proj
- * @param natureId
- * @throws CoreException
- *
- * @since 1.0.0
- */
- protected static void addNatureToProject(IProject proj, String natureId) throws CoreException {
- ProjectUtilities.addNatureToProject(proj, natureId);
- }
-
- /**
- * Configures the project with this nature. This is called by <code>IProject.addNature</code> and should not be called directly by clients. The
- * nature extension id is added to the list of natures on the project by <code>IProject.addNature</code>, and need not be added here.
- *
- * <p>
- * All subtypes must call super. The better way for subtypes is to override primConfigure instead.
- * </p>
- *
- * @throws CoreException
- * @since 1.0.0
- */
- public void configure() throws org.eclipse.core.runtime.CoreException {
- if (!hasConfigured) {
- hasConfigured = true;
- primConfigure();
- }
- }
-
- /**
- * Called from configure the first time configure is called on the nature. Default is do nothing. Subclasses should override and add in their own
- * configuration.
- *
- * @throws org.eclipse.core.runtime.CoreException
- *
- * @since 1.0.0
- */
- protected void primConfigure() throws org.eclipse.core.runtime.CoreException {
-
- }
-
- /**
- * Create an EMF context for the project.
- *
- * @throws CoreException
- *
- * @since 1.0.0
- */
- protected void createEmfContext() throws CoreException {
- WorkbenchResourceHelperBase.createEMFContext(getProject(), this);
- }
-
- /**
- * Create a folder relative to the project based on aProjectRelativePathString.
- *
- * @param aProjectRelativePathString
- * @return
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public IFolder createFolder(String aProjectRelativePathString) throws CoreException {
- if (aProjectRelativePathString != null && aProjectRelativePathString.length() > 0)
- return createFolder(new Path(aProjectRelativePathString));
- return null;
- }
-
- /**
- * Create a folder relative to the project based on aProjectRelativePathString.
- *
- * @param aProjectRelativePath
- * @return
- * @throws CoreException
- *
- * @since 1.0.0
- */
- public IFolder createFolder(IPath aProjectRelativePath) throws CoreException {
- if (aProjectRelativePath != null && !aProjectRelativePath.isEmpty()) {
- IFolder folder = getWorkspace().getRoot().getFolder(getProjectPath().append(aProjectRelativePath));
- if (!folder.exists()) {
- ProjectUtilities.ensureContainerNotReadOnly(folder);
- folder.create(true, true, null);
- }
- return folder;
- }
- return null;
- }
-
- /**
- * Removes this nature from the project, performing any required deconfiguration. This is called by <code>IProject.removeNature</code> and
- * should not be called directly by clients. The nature id is removed from the list of natures on the project by
- * <code>IProject.removeNature</code>, and need not be removed here.
- *
- * @throws CoreException
- * @since 1.0.0
- */
- public void deconfigure() throws org.eclipse.core.runtime.CoreException {
- emfContext = null;
- }
-
- /**
- * Return true if the IFile with the given name exists in this project.
- *
- * @param aFileName
- * filename can be relative to one of the input file paths for the WorkbenchURIConverter.
- * @return <code>true</code> if filename exists in this project
- *
- * @since 1.0.0
- */
- public boolean fileExists(String aFileName) {
- if (aFileName == null)
- return false;
-
- IPath path = new Path(aFileName);
- if (path.isAbsolute())
- return ResourcesPlugin.getWorkspace().getRoot().getFile(path).exists();
- else
- return getWorkbenchURIConverter().canGetUnderlyingResource(aFileName);
- }
-
- /**
- * Get the resource set for the project
- *
- * @return
- *
- * @since 1.0.0
- */
- public ResourceSet getResourceSet() {
- return getEmfContextBase().getResourceSet();
- }
-
- /**
- * Returns the EMF root folder for the project. Defaults to the project. Subclasses can override.
- *
- * @return EMF root folder for the project.
- *
- * @since 1.0.0
- */
- public IContainer getEMFRoot() {
- return getProject();
- }
-
- /**
- * Used for optimizations; answers whether a mof context for this nature has exists yet
- *
- * @deprecated use hasResourceSet();
- * @since 1.0.0
- */
- public boolean hasContext() {
- return hasResourceSet();
- }
-
- /**
- * Is there a resource set yet for the project.
- *
- * @return <code>true</code> if there is a resource set for the project.
- *
- * @since 1.0.0
- */
- public boolean hasResourceSet() {
- return emfContext != null && emfContext.hasResourceSet();
- }
-
- /**
- * Lazy initializer; for migration of existing workspaces where configure will never get called.
- *
- * @return context base for the project.
- *
- * @since 1.0.0
- */
- protected EMFWorkbenchContextBase getEmfContextBase() {
- if (emfContext == null) {
- try {
- createEmfContext();
- } catch (CoreException ex) {
- Logger.getLogger().logError(ex);
- }
- }
- return emfContext;
- }
-
- /**
- * Get the IFile with the given name if it is in this project.
- *
- * @param aFileName
- * filename can be relative to one of the input file paths for the WorkbenchURIConverter.
- * @return file it it is in this project, or <code>null</code> if it doesn't.
- *
- * @since 1.0.0
- */
- public IFile getFile(String aFileName) {
- return getWorkbenchURIConverter().getFile(aFileName);
- }
-
- /**
- * Return the nature's ID.
- *
- * @return nature id
- *
- * @since 1.0.0
- */
- public abstract String getNatureID();
-
- /**
- * Return the ID of the plugin that this nature is contained within.
- *
- * @return
- *
- * @since 1.0.0
- */
- protected abstract String getPluginID();
-
- /**
- * Returns the project to which this project nature applies.
- *
- * @return the project handle
- * @since 1.0.0
- */
- public org.eclipse.core.resources.IProject getProject() {
- return project;
- }
-
- /**
- * Return the full path of the project.
- *
- * @return full project path (relative to workspace)
- * @since 1.0.0
- */
- public IPath getProjectPath() {
- return getProject().getFullPath();
- }
-
- /**
- * Get the server property of the project from the supplied key
- *
- * @param key
- * java.lang.String
- * @deprecated we cannont use persistent properties because they are not stored in the repository
- * @since 1.0.0
- */
- protected String getProjectServerValue(String key) {
- if (key == null)
- return null;
- try {
- QualifiedName wholeName = qualifiedKey(key);
- return getProject().getPersistentProperty(wholeName);
- } catch (CoreException exception) {
- //If we can't find it assume it is null
- exception.printStackTrace();
- return null;
- }
- }
-
- /**
- * Get WorkbenchURIConverter for this project.
- * <p>
- * This method assumes the URIConverter on the ResourceSet is the one that was created for the ResourceSet on behalf of this nature runtime.
- * </p>
- *
- * @return
- *
- * @since 1.0.0
- */
- protected WorkbenchURIConverter getWorkbenchURIConverter() {
- return (WorkbenchURIConverter) getResourceSet().getURIConverter();
- }
-
- public IWorkspace getWorkspace() {
- return getProject().getWorkspace();
- }
-
- /**
- * @deprecated use getResource(URI)
- */
- public Resource getXmiResource(String uri) {
- return getResource(URI.createURI(uri));
- }
-
- /**
- * Get the resource for this uri. It will use the resource set of the project to find it. It will load if not already loaded.
- *
- * @param uri
- * @return resource or <code>null</code> if resource is not found.
- *
- * @since 1.0.0
- */
- public Resource getResource(URI uri) {
- try {
- return getResourceSet().getResource(uri, true);
- } catch (WrappedException ex) {
- if (!WorkbenchResourceHelperBase.isResourceNotFound(ex))
- throw ex;
- }
- return null;
- }
-
- /**
- * @deprecated use getResourceSet()
- */
- public ResourceSet getXmiResourceSet() {
- return getResourceSet();
- }
-
- /**
- * Make sure that all dependent components are initialized before creating the ResourceSet.
- */
- protected void initializeDependentComponents() {
- //com.ibm.etools.java.init.JavaInit.init();
- }
-
- /**
- * @deprecated use createResource(URI)
- */
- public Resource makeXmiResource(String uri) {
- return createResource(URI.createURI(uri));
- }
-
- /**
- * @deprecated use createResource(URI)
- */
- public Resource makeXmiResource(String uri, EList anExtent) {
- Resource res = makeXmiResource(uri);
- if (res != null)
- res.getContents().addAll(anExtent);
- return res;
- }
-
- /**
- * Create the resource for this uri. It will use the resource set of the project to create it.
- *
- * @param uri
- * @return resource
- *
- * @since 1.0.0
- */
- public Resource createResource(URI uri) {
- return getResourceSet().createResource(uri);
- }
-
- /*
- * Return the QualifedValue for key for storage in the repository. The key is qualifed with the package name to avoid collision. @return
- * QualifedName @param key java.lang.String
- */
- private QualifiedName qualifiedKey(String key) {
- return new QualifiedName(getPluginID(), key);
- }
-
- /**
- * Register the given nature id as an EMFNature.
- *
- * @param natureID
- *
- * @since 1.0.0
- */
- public static void registerNatureID(String natureID) {
- EMFNatureRegistry.singleton().REGISTERED_NATURE_IDS.add(natureID);
- }
-
- /**
- * Sets the project to which this nature applies. Used when instantiating this project nature runtime. This is called by
- * <code>IProject.addNature</code> and should not be called directly by clients.
- *
- * @param project
- * the project to which this nature applies
- *
- * @since 1.0.0
- */
- public void setProject(org.eclipse.core.resources.IProject newProject) {
- project = newProject;
- }
-
- /**
- * Set the server property of the project from the supplied value
- *
- * @param key
- * java.lang.String
- * @param value
- * String
- * @deprecated we cannont use persistent properties because they are not stored in the repository
- */
- protected void setProjectServerValue(String key, String value) {
- if (key != null) {
- try {
- QualifiedName wholeName = qualifiedKey(key);
- getProject().setPersistentProperty(wholeName, value);
- } catch (CoreException exception) {
- //If we can't find it assume it is null
- exception.printStackTrace();
- return;
- }
- }
- }
-
- /**
- * Shutdown the EMF nature
- *
- *
- * @since 1.0.0
- */
- public void shutdown() {
- if (getResourceSet() != null)
- ((ProjectResourceSet) getResourceSet()).release();
- }
-
- /**
- * Return a list of EMFNatures based on the natures that have been configured for this project.
- *
- * @return List of EMFNatures
- * @param project
- * @return list of natures configured for the project.
- * @since 1.0.0
- */
- public static List getRegisteredRuntimes(IProject project) {
- List result = null;
- EMFNature nature = null;
- if (project != null && project.isAccessible()) {
- String natureID;
- Iterator it = EMFNatureRegistry.singleton().REGISTERED_NATURE_IDS.iterator();
- while (it.hasNext()) {
- natureID = (String) it.next();
- try {
- nature = (EMFNature) project.getNature(natureID);
- } catch (CoreException e) {
- }
- if (nature != null) {
- if (result == null)
- result = new ArrayList(2);
- result.add(nature);
- }
- }
- }
- return result == null ? Collections.EMPTY_LIST : result;
- }
-
- /**
- * Return a list of nature ids based on the natures that have been configured for this project.
- *
- * @return list of configured nature ids.
- * @param project
- */
- public static List getRegisteredRuntimeIDs(IProject project) {
- List result = null;
- String natureID = null;
- if (project != null && project.isAccessible()) {
- Iterator it = EMFNatureRegistry.singleton().REGISTERED_NATURE_IDS.iterator();
- while (it.hasNext()) {
- natureID = (String) it.next();
- try {
- if (project.hasNature(natureID)) {
- if (result == null)
- result = new ArrayList(2);
- result.add(natureID);
- }
- } catch (CoreException e) {
- }
- }
- }
- return result == null ? Collections.EMPTY_LIST : result;
- }
-
- /**
- * Return if the project has the given nature.
- *
- * @param project
- * @param natureId
- * @return <code>true</code> if project has given nature
- *
- * @since 1.0.0
- */
- public static boolean hasRuntime(IProject project, String natureId) {
- if (project == null || !project.isAccessible())
- return false;
- try {
- return project.hasNature(natureId);
- } catch (CoreException e) {
- return false;
- }
- }
-
- /**
- * Return if the project has any one of the possible given nature ids.
- *
- * @param project
- * @param possibleNatureIds
- * @return <code>true</code> if at least one of the possible natures id is configured for the project.
- *
- * @since 1.0.0
- */
- public static boolean hasRuntime(IProject project, String[] possibleNatureIds) {
- if (project != null) {
- for (int i = 0; i < possibleNatureIds.length; i++) {
- if (hasRuntime(project, possibleNatureIds[i]))
- return true;
- }
- }
- return false;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/AbstractWorkBenchRenderer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/AbstractWorkBenchRenderer.java
deleted file mode 100644
index 428556607..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/AbstractWorkBenchRenderer.java
+++ /dev/null
@@ -1,472 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $RCSfile: AbstractWorkBenchRenderer.java,v $
- * $Revision: 1.5 $ $Date: 2005/12/14 21:24:26 $
- */
-package org.eclipse.jem.util.logger.proxyrender;
-
-import java.lang.reflect.Field;
-import java.util.logging.Level;
-
-import org.eclipse.core.runtime.*;
-import org.osgi.framework.Bundle;
-
-import org.eclipse.jem.util.logger.proxy.*;
-
-
-/**
- * Base log renderer that logs to the workbench.
- *
- * @since 1.1.0
- */
-public abstract class AbstractWorkBenchRenderer implements ILogRenderer2 {
-
- private boolean fTraceMode = false; // will we actually punch trace messaged or not
-
- private boolean fSettingTrace = false;
-
- protected Bundle fMyBundle = null;
-
- protected Logger fMyLogger = null;
-
- protected ILog fWorkBenchLogger = null;
-
- /**
- * Constructer taking a logger.
- *
- * @param logger
- *
- * @since 1.1.0
- */
- public AbstractWorkBenchRenderer(Logger logger) {
- super();
- fMyLogger = logger;
- fTraceMode = fMyLogger.getTraceMode();
-
- String pluginID = fMyLogger.getPluginID();
- fMyBundle = Platform.getBundle(pluginID);
- if (fMyBundle == null)
- throw new RuntimeException("Invalid Plugin ID"); //$NON-NLS-1$
-
- fWorkBenchLogger = Platform.getLog(fMyBundle);
- setTraceMode(fMyLogger.getTraceMode() || isDebugging(fMyBundle));
- fMyLogger.setRenderer(this);
- }
-
- /*
- * This used to come from the Plugin instance. But in new OSGi, there is not necessarily a Plugin instance. So use the same logic they use.
- */
- private boolean isDebugging(Bundle bundle) {
- String symbolicName = bundle.getSymbolicName();
- if (symbolicName != null) {
- String key = symbolicName + "/debug"; //$NON-NLS-1$
- String value = Platform.getDebugOption(key);
- return value == null ? false : value.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
- return false;
- }
-
- /**
- * Is the console log for eclipse turned on to sysout. If true, then we shouldn't log to console anything already logged because Eclipse would of
- * logged it for us. This comes from the -Declipse.consoleLog="true" which is the default when starting eclipse from PDE.
- */
- protected static final boolean consoleLogOn;
- static {
- String consologPropertyName = null;
- try {
- // Accessing an internal field, so using reflection. This way if changes in future we won't crash.
- Class eclipseStarter = Class.forName("org.eclipse.core.runtime.adaptor.EclipseStarter"); //$NON-NLS-1$
- Field consolelog = eclipseStarter.getDeclaredField("PROP_CONSOLE_LOG"); //$NON-NLS-1$
- consologPropertyName = (String) consolelog.get(null);
- } catch (SecurityException e) {
- } catch (IllegalArgumentException e) {
- } catch (ClassNotFoundException e) {
- } catch (NoSuchFieldException e) {
- } catch (IllegalAccessException e) {
- }
- consoleLogOn = consologPropertyName != null && "true".equals(System.getProperty(consologPropertyName)) ; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer#setTraceMode(boolean)
- */
- public void setTraceMode(boolean flag) {
- if (fSettingTrace)
- return; // Do not allow cycles
-
- fSettingTrace = true;
- fTraceMode = flag;
- fMyLogger.setTraceMode(flag);
- fSettingTrace = false;
- }
-
- // The following methods are for historical renderers in case this has been subclassed outside
- // of util.
-
- /**
- * Log a string to the trace.
- *
- * @param param
- * @return
- *
- * @since 1.0.0
- */
- public abstract String log(String param);
-
- /**
- * Default one that log a string to the trace given a level. Default simply passes it to log(String) so that we don't break old subclasses.
- * <p>
- * If loggedToWorkbench is true, then it shouldn't be logged to console if consoleLogOn is true because workbench already logged to console.
- *
- * @param msg
- * @param l
- *
- * @since 1.0.0
- */
- protected void log(String msg, Level l, boolean loggedToWorkbench) {
- log(msg);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer#log(java.lang.String, int)
- */
- public String log(String msg, int type) {
-
- String target = logWorkBench(msg, type);
- if (fTraceMode || target.equals(NOLOG_DESCRIPTION))
- return log(msg);
- else
- return target;
- }
-
- /**
- * Log to workbench, a string of the given level <code>ILogRenderer.LOG_</code>. levels.
- *
- * @param msg
- * @param type
- * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code>
- *
- * @see ILogRenderer#LOG_ERROR and all of the other log types.
- * @see ILogRenderer#CONSOLE_DESCRIPTION
- * @since 1.0.0
- */
- public String logWorkBench(String msg, int type) {
-
- try {
- int ErrCode;
- if (fWorkBenchLogger != null) {
- switch (type) {
- case (ILogRenderer.LOG_ERROR):
- ErrCode = IStatus.ERROR;
- break;
- case (ILogRenderer.LOG_WARNING):
- ErrCode = IStatus.WARNING;
- break;
- case (ILogRenderer.LOG_INFO):
- ErrCode = IStatus.INFO;
- break;
- case (ILogRenderer.LOG_TRACE):
- ErrCode = IStatus.OK;
- break;
- default:
- throw new RuntimeException("Invalid Log Type"); //$NON-NLS-1$
- }
- Status status = new Status(ErrCode, fMyBundle.getSymbolicName(), IStatus.OK, msg, null);
- fWorkBenchLogger.log(status);
- return WORKBENCH_DESCRIPTION;
- } else
- return NOLOG_DESCRIPTION;
- } catch (Throwable t) {
- return NOLOG_DESCRIPTION;
- }
- }
-
- // Default implentation of the ILogRenderer2 interface.
- protected boolean isLogging(Level level) {
- return fTraceMode || fMyLogger.isLoggingLevel(level);
- }
-
- private static final int[] STATUS_LEVEL;
-
- private static final Level[] STATUS_LEVEL_LOOKUP;
-
- private static final Level[] LEVEL_STATUS;
-
- static {
- // Status levels that correspond to the log levels, from finest to none, same indexes as from STATUS_LEVEL_LOOKUP.
- STATUS_LEVEL_LOOKUP = new Level[] { Level.INFO, Level.WARNING, Level.SEVERE};
- STATUS_LEVEL = new int[] { IStatus.INFO, IStatus.WARNING, IStatus.ERROR};
-
- // Levels that correspond to the IStatus levels.
- int maxID = Math.max(IStatus.OK, Math.max(IStatus.INFO, Math.max(IStatus.WARNING, IStatus.ERROR)));
- LEVEL_STATUS = new Level[maxID + 1];
- LEVEL_STATUS[IStatus.OK] = Level.FINE;
- LEVEL_STATUS[IStatus.INFO] = Level.INFO;
- LEVEL_STATUS[IStatus.WARNING] = Level.WARNING;
- LEVEL_STATUS[IStatus.ERROR] = Level.SEVERE;
- }
-
- /**
- * Return the Java Level for the status code from the given IStatus.
- *
- * @param status
- * @return the Java Level
- *
- * @since 1.0.0
- */
- protected Level getLogLevel(IStatus status) {
- return LEVEL_STATUS[status.getSeverity()];
- }
-
- /**
- * Return the IStatus status code for the given Java Level.
- *
- * @param logLevel
- * @return the IStatus status code.
- *
- * @since 1.0.0
- */
- protected int getStatusSeverity(Level logLevel) {
- for (int i = 0; i < STATUS_LEVEL_LOOKUP.length; i++) {
- if (STATUS_LEVEL_LOOKUP[i] == logLevel)
- return STATUS_LEVEL[i];
- }
- return IStatus.OK; // Default to ok.
- }
-
- /**
- * Log the string to the workbench for the given level
- *
- * @param msg
- * @param level
- * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code>
- *
- * @since 1.1.0
- */
- protected String logWorkbench(String msg, Level level) {
- String result = NOLOG_DESCRIPTION;
- // Test again because we could be here simply due to trace mode, in which case we
- // don't want to workbench log it.
- if (fMyLogger.isLoggingLevel(level)) {
- Platform.getLog(fMyBundle).log(new Status(getStatusSeverity(level), fMyBundle.getSymbolicName(), 0, msg, null));
- result = WORKBENCH_DESCRIPTION;
- if (fTraceMode)
- log(msg, level, true);
- } else if (fTraceMode)
- log(msg, level, false);
- return result;
- }
-
- private String getStatusMsg(IStatus s, Level l) {
- if (s.getException() != null)
- return fMyLogger.getGenericMsg(s.toString() + fMyLogger.fLineSeperator + fMyLogger.exceptionToString(s.getException()), l);
- else
- return fMyLogger.getGenericMsg(s.toString(), l);
- }
-
- /**
- * Log the IStatus to the workbench at the given level.
- *
- * @param s
- * @param level
- * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code>
- *
- * @since 1.0.0
- */
- protected String logWorkbench(IStatus s, Level level) {
- if (level == DEFAULT)
- level = getLogLevel(s);
- String result = NOLOG_DESCRIPTION;
- // Test again because we could be here simply due to trace mode, in which case we
- // don't want to workbench log it.
- if (fMyLogger.isLoggingLevel(level)) {
- Platform.getLog(fMyBundle).log(s);
- result = WORKBENCH_DESCRIPTION;
- if (fTraceMode)
- log(getStatusMsg(s, level), level, true);
- } else if (fTraceMode)
- log(getStatusMsg(s, level), level, false);
- return result;
- }
-
- /**
- * Log to the workbench the Throwable at the given level.
- *
- * @param t
- * @param level
- * @return description of the log's destination e.g., <code>CONSOLE_DESCRIPTION</code>
- *
- * @since 1.0.0
- */
- protected String logWorkbench(Throwable t, Level level) {
- String result = NOLOG_DESCRIPTION;
- // Test again because we could be here simply due to trace mode, in which case we
- // don't want to workbench log it.
- if (fMyLogger.isLoggingLevel(level)) {
- Platform.getLog(fMyBundle).log(new Status(getStatusSeverity(level), fMyBundle.getSymbolicName(), 0, "Exception thrown.", t)); //$NON-NLS-1$
- result = WORKBENCH_DESCRIPTION;
- if (fTraceMode)
- log(fMyLogger.getGenericMsg(fMyLogger.exceptionToString(t), level), level, true);
- } else if (fTraceMode)
- log(fMyLogger.getGenericMsg(fMyLogger.exceptionToString(t), level), level, false);
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(byte, java.util.logging.Level)
- */
- public String log(boolean b, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(b), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(byte, java.util.logging.Level)
- */
- public String log(byte b, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(b), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(char, java.util.logging.Level)
- */
- public String log(char c, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(c), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(double, java.util.logging.Level)
- */
- public String log(double d, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(d), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(float, java.util.logging.Level)
- */
- public String log(float f, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(f), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(int, java.util.logging.Level)
- */
- public String log(int i, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(i), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(long, java.util.logging.Level)
- */
- public String log(long l, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(l), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(java.lang.Object, java.util.logging.Level)
- */
- public String log(Object o, Level level) {
- if (o instanceof IStatus)
- return logWorkbench((IStatus) o, level);
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(o), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(short, java.util.logging.Level)
- */
- public String log(short s, Level level) {
- if (level == DEFAULT)
- level = Level.FINEST;
- if (isLogging(level))
- return logWorkbench(fMyLogger.getGenericMsg(String.valueOf(s), level), level);
- else
- return NOLOG_DESCRIPTION;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxy.ILogRenderer2#log(java.lang.Throwable, java.util.logging.Level)
- */
- public String log(Throwable t, Level level) {
- if (t instanceof CoreException)
- return logWorkbench(((CoreException) t).getStatus(), level);
- if (level == DEFAULT)
- level = Level.SEVERE;
- if (isLogging(level)) {
- return logWorkbench(t, level);
- } else
- return NOLOG_DESCRIPTION;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/ConsoleLogRenderer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/ConsoleLogRenderer.java
deleted file mode 100644
index 90b2963e7..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/ConsoleLogRenderer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $RCSfile: ConsoleLogRenderer.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util.logger.proxyrender;
-
-import java.util.logging.Level;
-
-import org.eclipse.jem.util.logger.proxy.ILogRenderer;
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-/**
- * Log renderer to the console.
- *
- * @since 1.0.0
- */
-public class ConsoleLogRenderer extends AbstractWorkBenchRenderer {
-
- /**
- * Constructor taking a logger.
- *
- * @param logger
- *
- * @since 1.0.0
- */
- public ConsoleLogRenderer(Logger logger) {
- super(logger);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String)
- */
- public String log(String msg) {
-
- System.out.println(msg);
- return ILogRenderer.CONSOLE_DESCRIPTION;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String, java.util.logging.Level, boolean)
- */
- protected void log(String msg, Level l, boolean loggedToWorkbench) {
- if (!loggedToWorkbench || !consoleLogOn) {
- if (l == Level.SEVERE)
- System.err.println(msg);
- else
- System.out.println(msg);
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/DefaultPluginTraceRenderer.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/DefaultPluginTraceRenderer.java
deleted file mode 100644
index bedf203c7..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/DefaultPluginTraceRenderer.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $RCSfile: DefaultPluginTraceRenderer.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util.logger.proxyrender;
-
-import java.io.*;
-import java.util.logging.Level;
-
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-/**
- * Logger that also logs to a trace file in the plugin's metadata area.
- *
- * @since 1.0.0
- */
-public class DefaultPluginTraceRenderer extends AbstractWorkBenchRenderer {
-
- /**
- * Name of the trace file in the metadata area.
- *
- * @since 1.0.0
- */
- public static final String PluginTraceFileName = "/.log"; //$NON-NLS-1$
-
- private String fTraceFile = null;
-
- private PrintWriter traceFile = null;
-
- /**
- * DefaultUILogRenderer constructor.
- *
- * @param logger
- */
- public DefaultPluginTraceRenderer(Logger logger) {
- super(logger);
-
- fTraceFile = Platform.getStateLocation(fMyBundle).toString() + PluginTraceFileName;
- (new File(fTraceFile)).delete(); // Start from fresh ... do not want to leak on disk space
-
- }
-
- private void closeTraceFile() {
- if (traceFile == null)
- return;
- try {
- traceFile.flush();
- traceFile.close();
- } finally {
- traceFile = null;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String)
- */
- public String log(String msg) {
-
- System.out.println(msg);
-
- openTraceFile();
- if (traceFile != null) {
- traceFile.println(msg);
- closeTraceFile();
- }
- return fTraceFile;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jem.util.logger.proxyrender.AbstractWorkBenchRenderer#log(java.lang.String, java.util.logging.Level, boolean)
- */
- protected void log(String msg, Level l, boolean loggedToWorkbench) {
- if (!loggedToWorkbench || !consoleLogOn) {
- if (l == Level.SEVERE)
- System.err.println(msg);
- else
- System.out.println(msg);
- }
-
- openTraceFile();
- if (traceFile != null) {
- traceFile.println(msg);
- closeTraceFile();
- }
- }
-
- private void openTraceFile() {
- try {
- traceFile = new PrintWriter(new FileOutputStream(fTraceFile, true));
- } catch (IOException e) {
- // there was a problem opening the log file so log to the console
- traceFile = null;
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/EclipseLogger.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/EclipseLogger.java
deleted file mode 100644
index 9e40f90f6..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/EclipseLogger.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $RCSfile: EclipseLogger.java,v $
- * $Revision: 1.4 $ $Date: 2005/08/24 21:10:34 $
- */
-package org.eclipse.jem.util.logger.proxyrender;
-
-import java.util.logging.Level;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.Bundle;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-
-
-/**
- * Get an Eclipse logger. This gets a logger that knows it is for a plugin.
- *
- * For each plugin, the following can be specified in the .option file:
- * {plugin-id}/debug/logTrace
- * The values valid for this are "true", "false", or "default". If true then loggers will be set into
- * trace mode. This means everything logged (even those that are filtered out due to not meeting log level)
- * will be traced out. If the value is "true" they will be traced to the system console.
- * If it is "default" or not set at all, then it will be the value in the "org.eclipse.jem.util/debug/logTrace" .options setting.
- * If not set there, then default value will be false.
- *
- * {plugin-id}/debug/logTraceFile
- * The values valid for this are "true", "false", or "default". If true then loggers will trace to
- * the system console AND to the ".log" file in the plugins work area in the metadata section of the workspace.
- * If "false" then not traced to a trace file.
- * If it is "default" or not set at all, then it will be the value in the "org.eclipse.jem.util/debug/logTraceFile" .options setting.
- * If not set there, then default value will be false.
- *
- * {plugin-id}.debug/logLevel
- * The values valid for this are the names from <code>java.util.logging.Level</code>, and "default". These
- * are the trace cutoff levels to use. For instance, if the level was SEVERE, then only level SEVERE msgs
- * are logged. The rest are skipped. Or if the level was WARNING, then only level SEVERE and WARNING are
- * logged.
- * If it is "default" or not set at all, then it will be the value in the "org.eclipse.jem.util/debug/logLevel" .options setting.
- * If not set there, then default value will be WARNING.
- *
- *
- * @since 1.0.0
- */
-public class EclipseLogger extends Logger {
-
- public static final String DEBUG_TRACE_OPTION = "/debug/logtrace"; //$NON-NLS-1$
- public static final String DEBUG_TRACE_FILE_OPTION = "/debug/logtracefile"; //$NON-NLS-1$
- public static final String DEBUG_LOG_LEVEL_OPTION = "/debug/loglevel"; // The logging level to use when no Hyaedes. (which we don't support at this time). //$NON-NLS-1$
- public static final String DEFAULT_OPTION = "default"; // If option value is this, then the value from WTP Common plugin options will be used for both logTrace and logLevel. //$NON-NLS-1$
-
- /**
- * Return a logger based upon the Plugin.
- * @param plugin
- * @return
- *
- * @since 1.0.0
- */
- public static Logger getEclipseLogger(Plugin plugin) {
- return getEclipseLogger(plugin.getBundle());
- }
-
- /**
- * Return a logger based upon the bundle.
- *
- * @param bundle
- * @return
- *
- * @since 1.0.0
- */
- public static Logger getEclipseLogger(Bundle bundle) {
- String id = bundle.getSymbolicName();
- Logger logger = getLoggerIfExists(id);
- if (logger != null)
- return logger;
-
- logger = getLogger(id); // Create one, we will now customize it.
-
- String pluginOption = Platform.getDebugOption(id + DEBUG_TRACE_OPTION);
- if (pluginOption == null || "default".equalsIgnoreCase(pluginOption)) //$NON-NLS-1$
- pluginOption = Platform.getDebugOption(JEMUtilPlugin.getDefault().getBundle().getSymbolicName() + DEBUG_TRACE_OPTION);
- boolean logTrace = "true".equalsIgnoreCase(pluginOption); //$NON-NLS-1$
-
- pluginOption = Platform.getDebugOption(id + DEBUG_TRACE_FILE_OPTION);
- if (pluginOption == null || "default".equalsIgnoreCase(pluginOption)) //$NON-NLS-1$
- pluginOption = Platform.getDebugOption(JEMUtilPlugin.getDefault().getBundle().getSymbolicName() + DEBUG_TRACE_FILE_OPTION);
- boolean logTraceFile = "true".equalsIgnoreCase(pluginOption); //$NON-NLS-1$
-
- pluginOption = Platform.getDebugOption(id + DEBUG_LOG_LEVEL_OPTION);
- if (pluginOption == null || "default".equalsIgnoreCase(pluginOption)) //$NON-NLS-1$
- pluginOption = Platform.getDebugOption(JEMUtilPlugin.getDefault().getBundle().getSymbolicName() + DEBUG_LOG_LEVEL_OPTION);
-
- Level logLevel = Level.WARNING;
- if (pluginOption != null) {
- try {
- logLevel = Level.parse(pluginOption);
- } catch (IllegalArgumentException e) {
- }
- }
-
- if (logTrace)
- logger.setTraceMode(true);
- logger.setLevel(logLevel);
- if (!logTraceFile)
- logger.setRenderer(new ConsoleLogRenderer(logger));
- else
- logger.setRenderer(new DefaultPluginTraceRenderer(logger));
-
- return logger;
- }
-
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/IMsgLogger.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/IMsgLogger.java
deleted file mode 100644
index 972ecdd17..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/logger/proxyrender/IMsgLogger.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $RCSfile: IMsgLogger.java,v $
- * $Revision: 1.2 $ $Date: 2005/02/15 23:04:14 $
- */
-package org.eclipse.jem.util.logger.proxyrender;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-/**
- * Interface for a message logger.
- *
- * @since 1.0.0
- */
-public interface IMsgLogger {
- public Logger getMsgLogger();
-}
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/plugin/JEMUtilPlugin.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/plugin/JEMUtilPlugin.java
deleted file mode 100644
index 3e1731e8b..000000000
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/plugin/JEMUtilPlugin.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 API and implementation
- *******************************************************************************/
-/*
- * $$RCSfile: JEMUtilPlugin.java,v $$
- * $$Revision: 1.4 $$ $$Date: 2006/02/21 17:16:30 $$
- */
-package org.eclipse.jem.util.plugin;
-
-import java.io.File;
-import java.text.MessageFormat;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.osgi.framework.Bundle;
-
-import org.eclipse.jem.internal.util.emf.workbench.ProjectResourceSetImpl;
-import org.eclipse.jem.internal.util.emf.workbench.WorkspaceResourceNotifier;
-import org.eclipse.jem.internal.util.emf.workbench.nls.EMFWorkbenchResourceHandler;
-import org.eclipse.jem.util.emf.workbench.ProjectResourceSet;
-import org.eclipse.jem.util.emf.workbench.ResourceHandler;
-import org.eclipse.jem.util.logger.proxy.Logger;
-
-
-/**
- * Plugin for EMFWorkbench utils.
- *
- * @since 1.0.0
- */
-public class JEMUtilPlugin extends Plugin {
-
- public static final String ID = "org.eclipse.jem.util"; //$NON-NLS-1$
-
- /**
- * Plugin id of this plugin.
- *
- * @since 1.0.0
- */
- public static final String PLUGIN_ID = ID;
-
- /**
- * UI Context extension point.
- *
- * @since 1.0.0
- */
- public static final String UI_CONTEXT_EXTENSION_POINT = "uiContextSensitiveClass"; //$NON-NLS-1$
-
- /**
- * UITester element name.
- *
- * @since 1.0.0
- */
- public static final String UI_TESTER_EXTENSION_POINT = "uiTester"; //$NON-NLS-1$
-
- /**
- * Protocol for workspace
- *
- * @since 1.0.0
- */
- public static final String WORKSPACE_PROTOCOL = "workspace"; //$NON-NLS-1$
-
- /**
- * Protocol for platform uri's. i.e. "platform:/..."
- *
- * @since 1.0.0
- *
- */
- public static final String PLATFORM_PROTOCOL = "platform"; //$NON-NLS-1$
-
- /**
- * Resource indication in platform protocol. Indicates url is for a resource in the workspace. i.e. "platform:/resource/projectname/..."
- *
- * @since 1.0.0
- */
- public static final String PLATFORM_RESOURCE = "resource"; //$NON-NLS-1$
-
- /**
- * Plugin indication in platform protocol. Indicates url is for a file/directory in the plugins area. i.e. "platform:/plugin/pluginid/..."
- *
- * @since 1.0.0
- */
- public static final String PLATFORM_PLUGIN = "plugin"; //$NON-NLS-1$
-
- private static WorkspaceResourceNotifier sharedCache;
-
- private static ResourceSet pluginResourceSet;
-
- private static String[] GLOBAL_LOADING_PLUGIN_NAMES;
-
- private static JEMUtilPlugin DEFAULT;
-
- public JEMUtilPlugin() {
- super();
- DEFAULT = this;
- }
-
- /**
- * Get the workspace. Just use ResourcePlugin.getWorkspace() instead.
- *
- * @return
- *
- * @since 1.0.0
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Get the plugin instance.
- *
- * @return plugin instance.
- *
- * @since 1.0.0
- */
- public static JEMUtilPlugin getDefault() {
- return DEFAULT;
- }
-
- /**
- * Gets the sharedCache.
- * <p>
- * This is not meant to be called by clients.
- * </p>
- *
- * @return a WorkspaceResourceNotifier
- * @since 1.0.0
- */
- public static WorkspaceResourceNotifier getSharedCache() {
- if (sharedCache == null)
- sharedCache = new WorkspaceResourceNotifier();
- return sharedCache;
- }
-
- /**
- * Sets the sharedCache.
- * <p>
- * This is not meant to be called by clients.
- * </p>
- *
- * @param sharedCache
- * The sharedCache to set
- * @since 1.0.0
- */
- public static void setSharedCache(WorkspaceResourceNotifier aSharedCache) {
- sharedCache = aSharedCache;
- }
-
- /**
- * @deprecated use createIsolatedResourceSet(IProject)
- */
- public static ResourceSet createIsolatedResourceSet() {
- return null;
- }
-
- /**
- * Add an Adapter. You can use this api to listen for any shared resource being loaded or removed from any ProjectResourceSet in the Workbench
- * instead of trying to listen to each individual ProjectResourceSet.
- *
- * @param adapter
- *
- * @since 1.0.0
- */
- public static void addWorkspaceEMFResourceListener(Adapter adapter) {
- if (adapter != null && !getSharedCache().eAdapters().contains(adapter))
- getSharedCache().eAdapters().add(adapter);
- }
-
- /**
- * Removes the adapter.
- *
- * @param adapter
- *
- * @see #addWorkspaceEMFResourceListener(Adapter)
- * @since 1.0.0
- */
- public static void removeWorkspaceEMFResourceListener(Adapter adapter) {
- if (adapter != null)
- getSharedCache().eAdapters().remove(adapter);
- }
-
- /**
- * Is this plugin active.
- *
- * @return <code>true</code> if active
- *
- * @since 1.0.0
- */
- public static boolean isActivated() {
- Bundle bundle = Platform.getBundle(ID);
- if (bundle != null)
- return bundle.getState() == Bundle.ACTIVE;
- return false;
- }
-
- /**
- * This method will be called when a WorkbenchContext is instantiated on an EMFNature.
- * <p>
- * This not meant to be called by clients.
- * </p>
- *
- * @param aResourceSet
- *
- * @see plugin.xml#ResourceHandlerExtension extension point.
- * @since 1.0.0
- */
- public void addExtendedResourceHandlers(ProjectResourceSet aResourceSet) {
- if (aResourceSet == null)
- return;
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint pct = registry.getExtensionPoint(getBundle().getSymbolicName(), "ResourceHandlerExtension"); //$NON-NLS-1$
- IExtension[] extension = pct.getExtensions();
- IExtension config;
- for (int l = 0; l < extension.length; ++l) {
- config = extension[l];
- IConfigurationElement[] cElems = config.getConfigurationElements();
- ResourceHandler handler = null;
- for (int i = 0; i < cElems.length; i++) {
- try {
- handler = (ResourceHandler) cElems[i].createExecutableExtension("run"); //$NON-NLS-1$
-
- } catch (Exception ex) {
- handler = null;
- }
- if (handler != null)
- aResourceSet.add(handler);
- }
- }
- }
-
- /**
- * Delete the contents of the directory (and the directory if deleteRoot is true).
- * @param root
- * @param deleteRoot <code>true</code> to delete the root directory too.
- * @param monitor
- * @return <code>true</code> if there was an error deleting anything.
- *
- * @since 1.1.0
- */
- public static boolean deleteDirectoryContent(File root, boolean deleteRoot, IProgressMonitor monitor) {
- boolean error = false;
- if (root.canRead()) {
- if (root.isDirectory()) {
- File[] files = root.listFiles();
- monitor.beginTask(MessageFormat.format(EMFWorkbenchResourceHandler.getString("ProjectUtil_Delete_1"), new Object[] {root.getName()}), files.length+(deleteRoot ? 1 : 0)); //$NON-NLS-1$
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory())
- error |= deleteDirectoryContent(files[i], true, new SubProgressMonitor(monitor, 1));
- else {
- error |= !files[i].delete();
- }
- monitor.worked(1);
- }
- } else {
- monitor.beginTask(MessageFormat.format(EMFWorkbenchResourceHandler.getString("ProjectUtil_Delete_1"), new Object[] {root.getName()}), 1); //$NON-NLS-1$
- }
- if (deleteRoot) {
- error |= !root.delete();
- monitor.worked(1);
- }
- monitor.done();
- } else {
- error = true;
- }
- return error;
- }
-
- /**
- * Add a clean resource changelistener.
- * @param listener
- * @param eventMask mask of event types to listen for in addition to ones that are necessary for clean. Use 0 if no additional ones.
- *
- * @since 1.1.0
- */
- public static void addCleanResourceChangeListener(CleanResourceChangeListener listener, int eventMask) {
- // PRE_BUILD: Handle Clean.
- // TODO Until https://bugs.eclipse.org/bugs/show_bug.cgi?id=101942 is fixed, we must do POST_BUILD, that will probably be sent because a clean will cause a build to occur which should cause a delta.
- ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, eventMask | IResourceChangeEvent.POST_BUILD);
- }
-
- /**
- * A resource listener that can be used in addition to listen for Clean requests and process them.
- * <p>
- * Use <code>{@link IResourceChangeEvent#PRE_BUILD}</code> when adding as listener to get the
- * clean events.
- * <p>
- * <b>Note</b> : TODO Until https://bugs.eclipse.org/bugs/show_bug.cgi?id=101942 is fixed, you must do POST_BUILD, that will probably be sent because a clean will cause a build to occur which should cause a delta.
- * @since 1.1.0
- */
- public abstract static class CleanResourceChangeListener implements IResourceChangeListener {
-
- public void resourceChanged(IResourceChangeEvent event) {
- // Subclasses can override this to handle more events than just clean.
- if (event.getBuildKind() == IncrementalProjectBuilder.CLEAN_BUILD) {
- if (event.getSource() instanceof IProject)
- cleanProject((IProject) event.getSource());
- else if (event.getSource() instanceof IWorkspace)
- cleanAll();
- }
- }
-
- /**
- * Clear out the project.
- * @param project
- *
- * @since 1.1.0
- */
- protected abstract void cleanProject(IProject project);
-
- /**
- * Clean all.
- * <p>
- * By default this will simply call a clean project on each open project. Subclasses should override and either
- * add more function to clear out non-project data and then call super. Or if they can handle all of the projects
- * in a faster way, then can completely handle this.
- *
- * @since 1.1.0
- */
- protected void cleanAll() {
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- if (project.isOpen()) {
- cleanProject(project);
- }
- }
- }
- }
-
- /**
- * Get the project resource set for the plugin (there is one for the whole system).
- *
- * @return system-wide resource set.
- * @since 1.0.0
- */
- public static ResourceSet getPluginResourceSet() {
- if (pluginResourceSet == null)
- pluginResourceSet = new ProjectResourceSetImpl(null);
- return pluginResourceSet;
- }
-
- /**
- * Set the system-wide resource set.
- *
- * @param set
- * @since 1.0.0
- */
- public static void setPluginResourceSet(ResourceSet set) {
- pluginResourceSet = set;
- }
-
- /**
- * Get the global loading plugin names.
- * <p>
- * This is not meant to be called by clients.
- * </p>
- *
- * @return
- *
- * @since 1.0.0
- */
- public static String[] getGlobalLoadingPluginNames() {
- if (GLOBAL_LOADING_PLUGIN_NAMES == null)
- GLOBAL_LOADING_PLUGIN_NAMES = readGlobalLoadingPluginNames();
- return GLOBAL_LOADING_PLUGIN_NAMES;
- }
-
- /**
- * Get the Logger for this plugin.
- *
- * @return logger for this plugin.
- *
- * @since 1.0.0
- */
- public static Logger getLogger() {
- return Logger.getLogger(ID);
- }
-
- private static String[] readGlobalLoadingPluginNames() {
- IExtensionRegistry reg = Platform.getExtensionRegistry();
- IExtensionPoint exPoint = reg.getExtensionPoint(ID, "globalPluginResourceLoad"); //$NON-NLS-1$
- IExtension[] extensions = exPoint.getExtensions();
- String[] names = new String[extensions.length];
- if (extensions.length > 0) {
- for (int i = 0; i < extensions.length; i++)
- names[i] = extensions[i].getContributor().getName();
- }
- return names;
- }
-
-} \ No newline at end of file

Back to the top