Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler')
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java35
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java132
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java71
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java295
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java106
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java50
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java126
7 files changed, 0 insertions, 815 deletions
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java
deleted file mode 100644
index 60a10a886f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler;
-
-/**
- * The entries in this registry are, conceptually, singleton's Since only one
- * instance is created in the registry, and then that instance returned when
- * required.
- *
- * Note that there is intentionally no 'remove' method, Since the registry
- * itself is read it when once, from the platform's plugin registry, and is
- * not intended to be modified after that. A change in an extenstion in a
- * plugin.xml will only take effect when the workbench is re-started.
- *
- */
-public interface EmbeddedTypeRegistry {
-
- /**
- * Method to return the specific type for the specific mimetype.
- */
- public EmbeddedTypeHandler getTypeFor(String mimeType);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java
deleted file mode 100644
index 8aa890f59b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler;
-
-
-/**
- *
- */
-public class EmbeddedTypeRegistryImpl implements EmbeddedTypeRegistry {
-
- private static EmbeddedTypeRegistry instance = null;
-
- public synchronized static EmbeddedTypeRegistry getInstance() {
- if (instance == null) {
- instance = new EmbeddedTypeRegistryImpl();
- }
- return instance;
- }
-
- private HashSet hashSet = null;
- private EmbeddedTypeHandler registryDefaultHandler = null;
-
- /*
- * @see ContentTypeRegistry#getTypeFor(String)
- */
- /**
- * Constructor for ContentTypeRegistryImpl.
- */
- private EmbeddedTypeRegistryImpl() {
- super();
- hashSet = new HashSet();
- new EmbeddedTypeRegistryReader().readRegistry(hashSet);
- }
-
- /**
- * @see ContentTypeRegistry#add(ContentTypeDescription)
- */
- void add(IDocumentTypeHandler contentTypeDescription) {
- hashSet.add(contentTypeDescription);
- }
-
- private EmbeddedTypeHandler getJSPDefaultEmbeddedType() {
- return getTypeFor("text/html"); //$NON-NLS-1$
- }
-
- /**
- * Method getRegistryDefault. We cache the default handler, since can't
- * change once plugin descriptors are loaded.
- *
- * @return EmbeddedTypeHandler
- */
- private EmbeddedTypeHandler getRegistryDefault() {
- if (registryDefaultHandler == null) {
- Iterator it = hashSet.iterator();
- while ((registryDefaultHandler == null) && (it.hasNext())) { // safe
- // cast
- // since
- // 'add'
- // requires
- // EmbeddedContentTypeDescription
- EmbeddedTypeHandler item = (EmbeddedTypeHandler) it.next();
- if ((item != null) && (item.isDefault())) {
- registryDefaultHandler = item;
- break;
- }
- }
- }
- return registryDefaultHandler;
- }
-
- /**
- * Finds the contentTypeDescription based on literal id. Its basically a
- * "first found first returned". Note the order is fairly unpredictable,
- * so non-unique ids would cause problems.
- */
- public EmbeddedTypeHandler getTypeFor(String mimeType) {
- // Note: the reason we have this precondition is that the
- // default is different inside the registry than when called,
- // for example, from the JSPLoader. For the JSPLoader, if there
- // is no mimetype, the default should be HTML. Here, if there is
- // some mimetype, but it is not recognized, we return a default
- // for XML. This is required for various voice xml types, etc.
- EmbeddedTypeHandler found = null;
- if (mimeType == null || mimeType.trim().length() == 0) {
- found = getJSPDefaultEmbeddedType();
- } else {
- Iterator it = hashSet.iterator();
- while ((found == null) && (it.hasNext())) { // safe cast since
- // 'add' requires
- // EmbeddedContentTypeDescription
- EmbeddedTypeHandler item = (EmbeddedTypeHandler) it.next();
- if ((item != null) && (item.getSupportedMimeTypes().contains(mimeType))) {
- found = item;
- break;
- }
- }
- // if no exact match, do the "looser" check
- if(found == null) {
- it = hashSet.iterator();
- while ((found == null) && (it.hasNext())) {
- EmbeddedTypeHandler item = (EmbeddedTypeHandler) it.next();
- if ((item != null) && (item.canHandleMimeType(mimeType))) {
- found = item;
- break;
- }
- }
- }
- }
- // no matches, use default
- if (found == null) {
- found = getRegistryDefault();
- }
- return found;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java
deleted file mode 100644
index 698f7a134f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import java.util.Set;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.core.internal.util.Assert;
-
-
-public class EmbeddedTypeRegistryReader {
- protected String ATT_CLASS = "class"; //$NON-NLS-1$
- protected String EXTENSION_POINT_ID = "embeddedTypeHandler"; //$NON-NLS-1$
-
-
- protected String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
- protected String TAG_NAME = "embeddedTypeHandler"; //$NON-NLS-1$
-
- EmbeddedTypeRegistryReader() {
- super();
- }
-
- protected EmbeddedTypeHandler readElement(IConfigurationElement element) {
-
- EmbeddedTypeHandler contentTypeDescription = null;
- if (element.getName().equals(TAG_NAME)) {
- try {
- contentTypeDescription = (EmbeddedTypeHandler) element.createExecutableExtension(ATT_CLASS);
- } catch (Exception e) {
- Logger.logException(e);
- }
- }
- Assert.isNotNull(contentTypeDescription, "Error reading content type description"); //$NON-NLS-1$
- return contentTypeDescription;
- }
-
- /**
- * We simply require an 'add' method, of what ever it is we are to read
- * into
- */
- void readRegistry(Set set) {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = extensionRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- EmbeddedTypeHandler embeddedContentType = readElement(elements[i]);
- // null can be returned if there's an error reading the
- // element
- if (embeddedContentType != null) {
- set.add(embeddedContentType);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java
deleted file mode 100644
index af83dedc8c..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.encoding.CodedIO;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.internal.util.Utilities;
-
-
-public class ModelHandlerRegistry {
- private static ModelHandlerRegistry instance = null;
- static final String INTERNAL_DEFAULT_EXTENSION = "org.eclipse.wst.xml.core.internal.modelhandler"; //$NON-NLS-1$
-
- public synchronized static ModelHandlerRegistry getInstance() {
- if (instance == null) {
- instance = new ModelHandlerRegistry();
- }
- return instance;
- }
-
- private IModelHandler defaultHandler = null;
- private ModelHandlerRegistryReader reader = new ModelHandlerRegistryReader();
-
- private ModelHandlerRegistry() {
- super();
- reader = new ModelHandlerRegistryReader().readRegistry();
- }
-
- /**
- * Finds the default model handler. Note: we still go through the registry
- * to be sure to get the existing instance, but then we do remember it, so
- * subsequent requests will be faster. The first time through, we do check
- * the whole list, to be sure there is only one.
- *
- */
- final public IModelHandler getDefault() {
- if (defaultHandler == null) {
- IConfigurationElement[] elements = reader.elements;
- for (int i = 0; i < elements.length; i++) {
- boolean ofInterest = reader.isElementDefault(elements[i]);
- if (ofInterest) {
- /*
- * If, here within the search loop we've already found one
- * defaultHandler, then something is wrong!
- */
- if (defaultHandler == null) {
- defaultHandler = reader.getInstance(elements[i]);
- }
- else {
- String errorString = "Program or configuration error. More than one default content handler found"; //$NON-NLS-1$
- Logger.log(Logger.ERROR, errorString);
- throw new IllegalStateException(errorString);
- }
- }
- }
- }
- if (defaultHandler == null) {
- String errorString = "Program or configuration error. No default content type handler found."; //$NON-NLS-1$
- Logger.log(Logger.ERROR, errorString);
- throw new IllegalStateException(errorString);
- }
- return defaultHandler;
- }
-
- /**
- * Finds a ModelHandler based on literal extension id. It's basically a
- * "first found first returned". No specific order is guaranteed and the
- * uniqueness of IDs is not considered.
- *
- * @param extensionId
- * @return the given extension, or null
- */
- private IModelHandler getHandlerExtension(String extensionId) {
- IModelHandler found = null;
- IConfigurationElement[] elements = reader.elements;
- if (elements != null) {
- for (int i = 0; i < elements.length; i++) {
- String currentId = reader.getId(elements[i]);
- if (extensionId.equals(currentId)) {
- IModelHandler item = reader.getInstance(elements[i]);
- found = item;
- }
- }
- }
- else if (Logger.DEBUG){
- Logger.log(Logger.WARNING, "There were no Model Handler found in registry"); //$NON-NLS-1$
- }
- return found;
- }
-
- /**
- * Finds the registered IModelHandler for a given named file's content
- * type.
- *
- * @param file
- * @return The IModelHandler registered for the content type of the given
- * file. If an exact match is not found, the most-specific match
- * according to IContentType.isKindOf() will be returned. If none
- * are found, either a default or null will be returned.
- * @throws CoreException
- */
- public IModelHandler getHandlerFor(IFile file) throws CoreException {
- IModelHandler modelHandler = null;
- IContentDescription contentDescription = null;
- IContentType contentType = null;
- boolean accessible = file.isAccessible();
- if (accessible) {
- /* Try the optimized method first as the description may be cached */
- contentDescription = file.getContentDescription();
- if (contentDescription != null) {
- // use the provided description
- contentType = contentDescription.getContentType();
- }
- else {
- /* use the more thorough discovery method to get a description */
- InputStream contents = null;
- try {
- contents = file.getContents(true);
- contentDescription = Platform.getContentTypeManager().getDescriptionFor(contents, file.getName(), IContentDescription.ALL);
- if (contentDescription != null) {
- contentType = contentDescription.getContentType();
- }
- }
- catch (IOException e) {
- // nothing further can be done, but will log for debugging
- Logger.logException(e);
- }
- finally {
- if (contents != null) {
- try {
- contents.close();
- }
- catch (IOException e1) {
- // nothing can be done
- }
- }
- }
- }
- }
-
- /*
- * If we couldn't get the content type from a description, try basing
- * it on just the filename
- */
- if (contentType == null) {
- contentType = Platform.getContentTypeManager().findContentTypeFor(file.getName());
- }
-
- if (contentType != null) {
- modelHandler = getHandlerForContentType(contentType);
- }
- else {
- // hard coding for null content type
- modelHandler = getHandlerExtension(INTERNAL_DEFAULT_EXTENSION); //$NON-NLS-1$
- }
-
- return modelHandler;
- }
-
-
- /**
- * Finds the registered IModelHandler for a given named InputStream.
- *
- * @param inputName
- * @param inputStream
- * @return The IModelHandler registered for the content type of the given
- * input. If an exact match is not found, the most-specific match
- * according to IContentType.isKindOf() will be returned. If none
- * are found, either a default or null will be returned.
- * @throws IOException
- */
- public IModelHandler getHandlerFor(String inputName, InputStream inputStream) throws IOException {
- InputStream iStream = Utilities.getMarkSupportedStream(inputStream);
- IModelHandler modelHandler = null;
- IContentType contentType = null;
- if (inputStream != null) {
- try {
- iStream.mark(CodedIO.MAX_MARK_SIZE);
- contentType = Platform.getContentTypeManager().findContentTypeFor(Utilities.getLimitedStream(iStream), inputName);
- }
- finally {
- if (iStream != null && iStream.markSupported()) {
- iStream.reset();
- }
- }
-
- }
- if (contentType == null) {
- contentType = Platform.getContentTypeManager().findContentTypeFor(inputName);
- }
- // if all else failed, try to detect solely on contents; done last for
- // performance reasons
- if (contentType == null) {
- contentType = Platform.getContentTypeManager().findContentTypeFor(Utilities.getLimitedStream(iStream), null);
- }
- modelHandler = getHandlerForContentType(contentType);
- return modelHandler;
- }
-
- /**
- * Finds the registered IModelHandler for a given IContentType.
- *
- * @param contentType
- * @return The IModelHandler registered for the given content type. If an
- * exact match is not found, the most-specific match according to
- * IContentType.isKindOf() will be returned. If none are found,
- * either a default or null will be returned.
- */
- private IModelHandler getHandlerForContentType(IContentType contentType) {
- IModelHandler handler = null;
- if (contentType != null) {
- IConfigurationElement exactContentTypeElement = null;
- IConfigurationElement kindOfContentTypeElement = null;
- int kindOfContentTypeDepth = 0;
- IConfigurationElement[] elements = reader.elements;
- if (elements != null) {
- for (int i = 0; i < elements.length && exactContentTypeElement == null; i++) {
- String currentId = reader.getAssociatedContentTypeId(elements[i]);
- IContentType associatedContentType = Platform.getContentTypeManager().getContentType(currentId);
- if (contentType.equals(associatedContentType)) {
- exactContentTypeElement = elements[i];
- }
- else if (contentType.isKindOf(associatedContentType)) {
- /*
- * Update the kindOfElement variable only if this
- * element's content type is "deeper" (depth test
- * ensures the first content type is remembered)
- */
- IContentType testContentType = associatedContentType;
- int testDepth = 0;
- while (testContentType != null) {
- testDepth++;
- testContentType = testContentType.getBaseType();
- }
- if (testDepth > kindOfContentTypeDepth) {
- kindOfContentTypeElement = elements[i];
- kindOfContentTypeDepth = testDepth;
- }
- }
- }
- }
- else if (Logger.DEBUG){
- Logger.log(Logger.WARNING, "There were no Model Handler found in registry"); //$NON-NLS-1$
- }
- if (exactContentTypeElement != null) {
- handler = reader.getInstance(exactContentTypeElement);
- }
- else if (kindOfContentTypeElement != null) {
- handler = reader.getInstance(kindOfContentTypeElement);
- }
- }
-
- if (handler == null) {
- // temp hard coding for null content type arguments
- handler = getHandlerExtension(INTERNAL_DEFAULT_EXTENSION); //$NON-NLS-1$
- }
- return handler;
- }
-
- /**
- * Finds the registered IModelHandler for a given content type ID. No
- * specific order is guaranteed and the uniqueness of IDs is not
- * considered.
- *
- * @param contentType
- * @return The IModelHandler registered for the given content type ID. If
- * an exact match is not found, the most-specific match according
- * to IContentType.isKindOf() will be returned. If none are found,
- * either a default or null will be returned.
- */
- public IModelHandler getHandlerForContentTypeId(String contentTypeId) {
- IContentType contentType = Platform.getContentTypeManager().getContentType(contentTypeId);
- return getHandlerForContentType(contentType);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java
deleted file mode 100644
index c6d611f255..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.AbstractModelHandler;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler;
-
-
-/**
- * This class just converts what's in the plugins registry into a form more
- * easily useable by others, the ContentTypeRegistry.
- */
-class ModelHandlerRegistryReader {
- private HashMap allReadyCreateInstances = new HashMap();
- protected String ATT_ASSOCIATED_CONTENT_TYPE = "associatedContentTypeId"; //$NON-NLS-1$
- protected String ATT_CLASS = "class"; //$NON-NLS-1$
- protected String ATT_DEFAULT = "default"; //$NON-NLS-1$
- protected String ATT_ID = "id"; //$NON-NLS-1$
- IConfigurationElement[] elements;
- protected String EXTENSION_POINT_ID = "modelHandler"; //$NON-NLS-1$
- //
- protected String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
- protected String TAG_NAME = "modelHandler"; //$NON-NLS-1$
-
- //
- /**
- * ContentTypeRegistryReader constructor comment.
- */
- ModelHandlerRegistryReader() {
- super();
- }
-
- String getAssociatedContentTypeId(IConfigurationElement element) {
- String value = element.getAttribute(ATT_ASSOCIATED_CONTENT_TYPE);
- return value;
- }
-
- String getId(IConfigurationElement element) {
- String idValue = element.getAttribute(ATT_ID);
- return idValue;
- }
-
- synchronized IModelHandler getInstance(IConfigurationElement element) {
- // May need to reconsider, but for now, we'll assume all clients must
- // subclass AbstractContentTypeIdentifier. Its easier and safer, for
- // this
- // low level "system" object. (That is, we can check and set "package
- // protected"
- // attributes.
- AbstractModelHandler modelHandler = (AbstractModelHandler) allReadyCreateInstances.get(getId(element));
- if (modelHandler == null) {
- try {
- modelHandler = (AbstractModelHandler) element.createExecutableExtension(ATT_CLASS);
- if (modelHandler != null) {
- allReadyCreateInstances.put(getId(element), modelHandler);
- String defaultValue = element.getAttribute(ATT_DEFAULT);
- if (defaultValue != null && "true".equals(defaultValue)) //$NON-NLS-1$
- modelHandler.setDefault(true);
- else
- modelHandler.setDefault(false);
- // TODO -- set and check attributes vs. created instance
- //contentTypeIdentifier.setOrCheckId(element.getAttribute(ATT_ID));
- }
- } catch (CoreException e) {
- org.eclipse.wst.sse.core.internal.Logger.logException(e);
- }
- }
- return modelHandler;
- }
-
- public boolean isElementDefault(IConfigurationElement element) {
- String defaultValue = element.getAttribute(ATT_DEFAULT);
- if (defaultValue != null && "true".equals(defaultValue)) //$NON-NLS-1$
- return true;
- else
- return false;
- }
-
- ModelHandlerRegistryReader readRegistry() {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = extensionRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null) {
- // just remember the elements, so plugins don't have to
- // be activated, unless extension matches those "of interest".
- elements = point.getConfigurationElements();
- }
- return this;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java
deleted file mode 100644
index f0b2a4bb87..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler;
-
-/**
- *
- * Likely a temporary class to be replaced by plugin, eventually.
- */
-public class ModelHandlerUtility {
-
- private static ModelHandlerRegistry contentTypeRegistry;
-
- public static IDocumentTypeHandler getContentTypeFor(String string) {
- return getContentTypeRegistry().getHandlerForContentTypeId(string);
- }
-
- private static ModelHandlerRegistry getContentTypeRegistry() {
- if (contentTypeRegistry == null) {
- contentTypeRegistry = ModelHandlerRegistry.getInstance();
- }
- return contentTypeRegistry;
- }
-
- public static EmbeddedTypeHandler getDefaultEmbeddedType() {
- return getEmbeddedContentTypeFor("text/html"); //$NON-NLS-1$
- }
-
- public static EmbeddedTypeHandler getEmbeddedContentTypeFor(String string) {
- EmbeddedTypeHandler instance = null;
- instance = EmbeddedTypeRegistryImpl.getInstance().getTypeFor(string);
- return instance;
- }
-
- public ModelHandlerUtility() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java
deleted file mode 100644
index 7d2e2dd23a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.sse.core.internal.modelhandler;
-
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.internal.SSECorePlugin;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-
-
-/**
- *
- * Clients can make use of IExecutableExtension to handle the optional adapter
- * class and key. Typically, many clients use a typical pattern of providing
- * an adapter class and key in their null argument constructor anyway, so
- * they'd only have to use IExecutableExtension if the factory was for more
- * than one.
- */
-public class PluginContributedFactoryReader {
- // protected final String ATTR_ADAPTERKEY = "adapterKeyClass";
- // //$NON-NLS-1$
- // protected final String ATTR_REGISTERADAPTER = "registerAdapters";
- // //$NON-NLS-1$
- private static PluginContributedFactoryReader reader = null;
-
- public synchronized static PluginContributedFactoryReader getInstance() {
- if (reader == null) {
- reader = new PluginContributedFactoryReader();
- }
- return reader;
- }
-
- protected final String ATTR_CLASS = "class"; //$NON-NLS-1$
- protected final String ATTR_CONTENTTYPE = "contentTypeIdentiferId"; //$NON-NLS-1$
-
- protected final String EXTENSION_POINT_ID = "contentTypeFactoryContribution"; //$NON-NLS-1$
- protected final String TAG_NAME = "factory"; //$NON-NLS-1$
-
- protected PluginContributedFactoryReader() {
- super();
- }
-
- public List getFactories(IDocumentTypeHandler handler) {
- return loadRegistry(handler.getId());
- }
-
- public List getFactories(String type) {
- return loadRegistry(type);
- }
-
- protected INodeAdapterFactory loadFactoryFromConfigurationElement(IConfigurationElement element, Object requesterType) {
- INodeAdapterFactory factory = null;
- if (element.getName().equals(TAG_NAME)) {
- String contentType = element.getAttribute(ATTR_CONTENTTYPE);
- if (!requesterType.equals(contentType))
- return null;
- String className = element.getAttribute(ATTR_CLASS);
- // String adapterKeyClass = element.getAttribute(ATTR_ADAPTERKEY);
- // String registerAdapters =
- // element.getAttribute(ATTR_REGISTERADAPTER);
-
- // if className is null, then no one defined the extension point
- // for adapter factories
- if (className != null) {
- try {
- factory = (INodeAdapterFactory) element.createExecutableExtension(ATTR_CLASS);
- } catch (CoreException e) {
- // if an error occurs here, its probably that the plugin
- // could not be found/loaded
- org.eclipse.wst.sse.core.internal.Logger.logException("Could not find class: " + className, e); //$NON-NLS-1$
- } catch (Exception e) {
- // if an error occurs here, its probably that the plugin
- // could not be found/loaded -- but in any case we just
- // want
- // to log the error and continue running and best we can.
- org.eclipse.wst.sse.core.internal.Logger.logException("Could not find class: " + className, e); //$NON-NLS-1$
- }
- // if (plugin != null) {
- // factory = oldAttributesCode(element, factory, className,
- // plugin);
- //
- }
- }
-
- return factory;
- }
-
- protected List loadRegistry(Object contentType) {
- List factoryList = null; // new Vector();
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = extensionRegistry.getExtensionPoint(SSECorePlugin.ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- if (elements.length > 0) {
- // this is called a lot, so don't create vector unless really
- // needed
- // TODO: could eventually cache in a hashtable, or something,
- // to avoid repeat processing
- factoryList = new Vector();
- for (int i = 0; i < elements.length; i++) {
- INodeAdapterFactory factory = loadFactoryFromConfigurationElement(elements[i], contentType);
- if (factory != null)
- factoryList.add(factory);
- }
- }
- }
- return factoryList;
- }
-}

Back to the top