public class TGContentType extends Object implements Comparable<TGContentType>
New content types are contributed using the extension point info.textgrid.lab.core.contentTypes
To register a new content type, you need to define an extension to the extension point info.textgrid.lab.core.contentTypes. Open your plugin manifest, go to the Extensions tab, click add and select info.textgrid.lab.core.contentTypes. You can now right-click the corresponding entry and add a new contentType element. Select the element and hover the fields for a description of the individual values.
Some notes for specific fields:
TextGridObject
s of your type to Eclipse, (2) as file
extension when exporting objects of your type, or (3) in the content type
detection heuristics of the import wizard. The latter is a reason to not
reuse the extension of another content type
(don't use xml or I will change it), otherwise the
heuristics just takes the first available content type.
Modifier and Type | Field and Description |
---|---|
static String |
UNKNOWN_ID
A default type identifying unknown content types
|
Constructor and Description |
---|
TGContentType(IConfigurationElement element)
Creates a content type from the extension point
|
TGContentType(String id,
String description,
String extension,
String additionalTypes,
boolean internal,
String eclipseContentType) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(TGContentType contentType)
Compares this
TGContentType with the specified TGContentType for order. |
static TGContentType |
findByEclipseType(IContentType type)
Tries to find a suitable TextGrid content type for the given Eclipse
content type
|
static TGContentType |
findByExtension(String extension)
Tries to find a matching content type the given file extension.
|
static TGContentType |
findMatchingContentType(String id)
Tries to find a content type for the given ID.
|
Pattern |
getAdditionalTypes()
Returns a pattern that matches additional content type strings that might
describe this content type.
|
static TGContentType |
getByFilename(String filename)
Returns or creates a content type for the given file name.
|
static TGContentType |
getContentType(String id)
Returns the content type with the given id.
|
static TGContentType[] |
getContentTypes()
Deprecated.
Use
getContentTypes(boolean) instead |
static TGContentType[] |
getContentTypes(boolean onlyPublic)
Returns a copy of the list of content types.
|
static TGContentType[] |
getContentTypes(com.google.common.base.Predicate<TGContentType> filter)
Returns a subset of content types.
|
IContributor |
getContributor() |
static String |
getDebugInfo() |
String |
getDescription()
Returns a human-readable description for this content type.
|
IContentType |
getEclipseContentType() |
String |
getEclipseContentTypeID()
Returns Eclipse's content type ID for this content type, if applicable
|
String |
getExtension()
Returns the file extension to append to link names of this content type
|
String |
getId()
Returns the content type's MIME id.
|
Image |
getImage(boolean fallback)
Returns an image representing the object.
|
ImageDescriptor |
getImageDescriptor()
Returns an image descriptor representing an icon for objects of this
content type.
|
boolean |
isAdHoc()
A content type is an ad hoc content type if it has been
automatically created from a file extension or from a content type id,
without proper configuration from an extension point etc.
|
boolean |
isCreatable()
Returns whether the TextGridLab can create new objects of this content type.
|
boolean |
isInternal()
If true, files of this type are created internally by the lab and should
not show up in the New dialog etc.
|
boolean |
isUnknown()
If true, this is the special content type representing unknown mime
types.
|
protected static void |
loadContentTypes() |
static TGContentType |
of(String id)
Returns a content type for the given MIME type.
|
protected void |
setImageDescriptor(ImageDescriptor imageDescriptor)
Registers the given image descriptor for use with this content type.
|
String |
toDebugString(String delimiter)
Returns a debug string for the current object, containing of the
following fields in order, delimited by the given delimiter:
getDescription()
getId()
flags, if present: internal,
creatable, ad-hoc,
unknown
getExtension()
getEclipseContentTypeID()
the contributing plugin's ID. |
String |
toString()
Returns a human-readable string describing the content type.
|
public static final String UNKNOWN_ID
public TGContentType(String id, String description, String extension, String additionalTypes, boolean internal, String eclipseContentType) throws CoreException
id
- the MIME type, see getId()
description
- a human readable description, see getDescription()
extension
- TODOadditionalPattern
- TODOCoreException
- when the content type could not be created.public TGContentType(IConfigurationElement element) throws InvalidRegistryObjectException, CoreException
element
- CoreException
- When the content type could not be created.InvalidRegistryObjectException
public boolean isCreatable()
public boolean isAdHoc()
public String getExtension()
public Pattern getAdditionalTypes()
public String getId()
public String getDescription()
public String getEclipseContentTypeID()
public IContentType getEclipseContentType()
public boolean isInternal()
public IContributor getContributor()
public ImageDescriptor getImageDescriptor()
If the contributor specifies an image attribute in its extension, this image is used. Otherwise we try to find this object's default editor and use its icon.
Clients might want to use getImage(boolean)
, which delivers an
image managed by this plugin's ImageRegistry
.
null
, if no appropriate icon
could be found.public Image getImage(boolean fallback)
fallback
- if true
, return a default image if no image could
be found.Image
or null
, if none found and
fallback is false
.getImageDescriptor()
protected void setImageDescriptor(ImageDescriptor imageDescriptor)
imageDescriptor
- protected static void loadContentTypes()
public static String getDebugInfo()
public static TGContentType getContentType(String id)
id
- findMatchingContentType(String)
public static TGContentType findMatchingContentType(String id)
id
- A content type identifier.public static TGContentType of(String id) throws IllegalArgumentException
TGContentType
with the given ID could be found in the
registry, it is returned. Otherwise, we try to create an
ad-hoc content type for the given and return
that.
If we create a new content type object, it is also added to the registry
as non-creatable and ad-hoc.id
- a MIME type for which to return a TGContentType objectTGContentType
for the given id, either as returned by
findMatchingContentType(String)
or created ad hoc.IllegalArgumentException
@Deprecated public static TGContentType[] getContentTypes()
getContentTypes(boolean)
insteadpublic static TGContentType[] getContentTypes(boolean onlyPublic)
onlyPublic
- If true, internal content types are
not included.public static TGContentType[] getContentTypes(com.google.common.base.Predicate<TGContentType> filter)
filter
- a Predicate
that returns true for each content type that should be returnedpublic String toString()
toString
in class Object
Object.toString()
public boolean isUnknown()
public static TGContentType findByExtension(String extension)
getByFilename(String)
instead.extension
- the file extension, case insensitive without the leading dot.
May not be null.public static TGContentType getByFilename(String filename)
findByExtension(String)
on the filename's
extensionMimetypesFileTypeMap
) for the MIME type and searchiong for that
in our registry.ContentType
is created. We try to
guess the new type's attributes. New types will be
ad-hoc and not
creatable. The new content type is added to the registry, it will be
returned by future calls of getContentTypes(false)
and considered in future calls of
the content type retrieval methods.filename
- The name of the file for which we're looking for a content
type.public static TGContentType findByEclipseType(IContentType type)
An
- eclipse content type to look forTGContentType
that is associated with the given Eclipse
content type or some parent type of that, or null
.public String toDebugString(String delimiter)
getDescription()
getId()
getExtension()
getEclipseContentTypeID()
delimiter
- string used to separate the fields.public int compareTo(TGContentType contentType)
TGContentType
with the specified TGContentType
for order.compareTo
in interface Comparable<TGContentType>
contentType
- the content type to be compared