Package org.eclipse.core.runtime.content
Interface IContentTypeManager
- All Superinterfaces:
IContentTypeMatcher
The content type manager provides facilities for file name and content-based
type lookup and content description.
This interface is not intended to be implemented by clients.
- Since:
- 3.0
- See Also:
- Restriction:
- This interface is not intended to be implemented by clients.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
An event object which describes the details of a change to a content type.static interface
A listener to be used to receive content type change events.static interface
A policy for refining the set of content types that should be accepted during content type matching operations. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddContentType
(String contentTypeIdentifier, String name, IContentType baseType) Adds a new content-type to the registry.void
Register the given listener for notification of content type changes.Returns all content types known by the platform.getContentType
(String contentTypeIdentifier) Returns the content type with the given identifier, ornull
if no such content type is known by the platform.getMatcher
(IContentTypeManager.ISelectionPolicy customPolicy, IScopeContext context) Returns a newly created content type matcher using the given content type selection policy and preference scope.void
removeContentType
(String contentTypeIdentifier) Removes a content-type from underlying registry.void
De-register the given listener from receiving notification of content type changes.Methods inherited from interface org.eclipse.core.runtime.content.IContentTypeMatcher
findContentTypeFor, findContentTypeFor, findContentTypesFor, findContentTypesFor, getDescriptionFor, getDescriptionFor
-
Field Details
-
CT_TEXT
Content type identifier constant for platform's primary text-based content type:org.eclipse.core.runtime.text
.All text-based content types ought to be sub types of the content type identified by this string. This provides a simple way for detecting whether a content type is text-based:
IContentType text = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT); IContentType someType = ...; boolean isTextBased = someType.isKindOf(text);
- See Also:
-
-
Method Details
-
addContentTypeChangeListener
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 benull
.- Parameters:
listener
- the content type change listener to register- See Also:
-
getAllContentTypes
IContentType[] getAllContentTypes()Returns all content types known by the platform.Returns an empty array if there are no content types available.
- Returns:
- all content types known by the platform.
-
getContentType
Returns the content type with the given identifier, ornull
if no such content type is known by the platform.- Parameters:
contentTypeIdentifier
- the identifier for the content type- Returns:
- the content type, or
null
-
getMatcher
IContentTypeMatcher getMatcher(IContentTypeManager.ISelectionPolicy customPolicy, IScopeContext context) Returns a newly created content type matcher using the given content type selection policy and preference scope. If the preference scope isnull
, the default scope is used.- Parameters:
customPolicy
- a selection policycontext
- a user preference context to be used by the matcher, ornull
- Returns:
- a content type matcher that uses the given policy
- Since:
- 3.1
-
removeContentTypeChangeListener
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 benull
.- Parameters:
listener
- the content type change listener to remove- See Also:
-
addContentType
IContentType addContentType(String contentTypeIdentifier, String name, IContentType baseType) throws CoreException Adds a new content-type to the registry. The content-type identifier mustn't be used by any existing content-type.- Parameters:
contentTypeIdentifier
- the non-null content-type idname
- the non-null user readable namebaseType
- parent base type. May be null, indicating that there is no base type.- Returns:
- the newly created and registered content-type
- Throws:
CoreException
- If the type was not added due to an internal error.- Since:
- 3.6
-
removeContentType
Removes a content-type from underlying registry. The content-type must be a content-type that was previously defined with theaddContentType(String, String, IContentType)
on the same IContentTypeManager. Content-types defined via extension point cannot be removed from the registry.- Parameters:
contentTypeIdentifier
- the identifier of the content-type to remove. If no user-defined content-type exists for this identifier, the method returns changing nothing and will not throw an exception.- Throws:
IllegalArgumentException
- if the target content-type was not created by user.CoreException
- if an internal error prevented the content-type from being removed.- Since:
- 3.6
-