Index: src/org/eclipse/core/internal/content/ContentTypeManager.java =================================================================== RCS file: /home/eclipse/org.eclipse.core.runtime/src/org/eclipse/core/internal/content/ContentTypeManager.java,v retrieving revision 1.31 diff -u -r1.31 ContentTypeManager.java --- src/org/eclipse/core/internal/content/ContentTypeManager.java 16 Jun 2004 23:33:55 -0000 1.31 +++ src/org/eclipse/core/internal/content/ContentTypeManager.java 18 Jun 2004 20:32:35 -0000 @@ -368,4 +368,20 @@ builder.startup(); builder.buildContentTypes(); } + + /* (non-Javadoc) + * @see IContentTypeManager#addContentTypeChangeListener(IContentTypeChangeListener) + */ + public void addContentTypeChangeListener(IContentTypeChangeListener listener) { + // TODO https://bugs.eclipse.org/bugs/show_bug.cgi?id=67884 + // Content type change events not reported + } + + /* (non-Javadoc) + * @see IContentTypeManager#removeContentTypeChangeListener(IContentTypeChangeListener) + */ + public void removeContentTypeChangeListener(IContentTypeChangeListener listener) { + // TODO https://bugs.eclipse.org/bugs/show_bug.cgi?id=67884 + // Content type change events not reported + } } Index: src/org/eclipse/core/runtime/content/IContentTypeManager.java =================================================================== RCS file: /home/eclipse/org.eclipse.core.runtime/src/org/eclipse/core/runtime/content/IContentTypeManager.java,v retrieving revision 1.14 diff -u -r1.14 IContentTypeManager.java --- src/org/eclipse/core/runtime/content/IContentTypeManager.java 3 Jun 2004 14:25:14 -0000 1.14 +++ src/org/eclipse/core/runtime/content/IContentTypeManager.java 18 Jun 2004 20:32:35 -0000 @@ -11,6 +11,7 @@ package org.eclipse.core.runtime.content; import java.io.*; +import java.util.EventObject; import org.eclipse.core.runtime.QualifiedName; /** @@ -24,6 +25,65 @@ * @since 3.0 */ public interface IContentTypeManager { + + /** + * A listener to be used to receive content type change events. + *

+ * Clients who reference the org.eclipse.core.resources + * bundle are encouraged not to use this listener mechanism to + * listen to content type changes. The Core Resources bundle will + * propagate changes to content types and notify clients appropriately + * via the resource change mechanism. + *

+ *

+ * Clients may implement this interface. + *

+ * + * @since 3.0 + */ + public interface IContentTypeChangeListener { + + /** + * Notification that a content type has changed in the content type manager. + * The given event object contains the content type which changed and must not + * be null. + * + * @param event the content type change event + */ + public void contentTypeChanged(ContentTypeChangeEvent event); + } + + /** + * An event object which describes the details of a change to a + * content type. + *

+ * Types of changes include a change in the file associations or + * a change in the encoding setting. + *

+ * + * @since 3.0 + */ + public final class ContentTypeChangeEvent extends EventObject { + + /** + * Constructor for a new content type change event. + * + * @param source the content type that changed + */ + public ContentTypeChangeEvent(IContentType source) { + super(source); + } + + /** + * Return the content type object associated with this change event. + * + * @return the content type + */ + public IContentType getContentType() { + return (IContentType) source; + } + } + /** * Content type identifier constant for platform's primary * text-based content type: org.eclipse.core.runtime.text. @@ -41,6 +101,17 @@ public final static String CT_TEXT = "org.eclipse.core.runtime.text"; //$NON-NLS-1$ /** + * Register the given listener for notification of content type changes. + * Calling this method multiple times with the same listener has no effect. The + * given listener argument must not be null. + * + * @param listener the content type change listener to register + * @see #removeContentTypeChangeListener(IContentTypeChangeListener) + * @see IContentTypeChangeListener + */ + public void addContentTypeChangeListener(IContentTypeChangeListener listener); + + /** * Returns the preferred content type for the given contents and file name. *

* Returns null if no associated content types are @@ -172,4 +243,15 @@ * @see IContentDescription */ public IContentDescription getDescriptionFor(Reader contents, String fileName, QualifiedName[] options) throws IOException; + + /** + * De-register the given listener from receiving notification of content type changes. + * Calling this method multiple times with the same listener has no + * effect. The given listener argument must not be null. + * + * @param listener the content type change listener to remove + * @see #addContentTypeChangeListener(IContentTypeChangeListener) + * @see IContentTypeChangeListener + */ + public void removeContentTypeChangeListener(IContentTypeChangeListener listener); }