Allows one to add a predefined language descriptor.
A language descriptor has following uses:
<!ELEMENT extension (language)>
<!ATTLIST extension
point CDATA #REQUIRED
id CDATA #IMPLIED
name CDATA #IMPLIED>
<!ELEMENT descriptor EMPTY>
<!ATTLIST descriptor
descriptorClass CDATA #REQUIRED>
The IUMLLanguageDescriptor that will constitute a predefined language.
<!ELEMENT id EMPTY>
<!ATTLIST id
id CDATA #REQUIRED>
A unique identifier used solely to facilitate overriding of language descriptors.
<!ELEMENT language (id , descriptor , override?)>
The language element consists of:
1) an ID (to be specified by others in the override attribute if needed)
2) the descriptor - The language implementation
3) Optionally, an override, in case one wants to replace an existing language descriptor with their own.
<!ELEMENT override EMPTY>
<!ATTLIST override
id CDATA #IMPLIED>
This element allows one to remove another language descriptor from being added which will essentially replace that descriptor with the instance of this descriptor.
Here is an example of an extension point used to define a new language descriptor:
/*
*+------------------------------------------------------------------------+
*| Licensed Materials - Property of IBM |
*| Copyright IBM Corp. 2008. All Rights Reserved. |
*| |
*| Note to US Government Users Restricted Rights: Use, duplication or |
*| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. |
*+------------------------------------------------------------------------+
*/
package test.example;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.eclipse.emf.common.util.URI;
import com.ibm.xtools.uml.msl.lang.AbstractLanguageDescriptor;
/**
* This is an example descriptor for a static language 'xyz'. This descriptor identifies needed libraries
* available primitive types, capabilities and profiles needed for a modeling with this language.
*
* Note: The identified libraries, primitive types, capabilities and profiles are all fictional and do not exist.
*
* @author aneal (Adam R. Neal)
*/
public class ExampleLanguageDescriptor extends AbstractLanguageDescriptor {
/**
* Public, parameterless constructor
*/
public ExampleLanguageDescriptor() {
super(EXAMPLE_ID, EXAMPLE_ID, EXAMPLE_EXTENSION);
}
/**
* This is our languageID. We also will re-use it at the display name.
*/
public static final String EXAMPLE_ID = "xyz"; //$NON-NLS-1$
/**
* We have consider files of type "x" to be the extension for language "xyz"
*/
public static final String EXAMPLE_EXTENSION = "x"; //$NON-NLS-1$
/**
* One way to identify an existing library with predefined classes that we want to include.
* This library will be added as an element import to the root package/model.
*/
public static final URI EXAMPLE_CLASSES_URI = URI
.createURI("platform:/plugin/test.example/libraries/ExamplePredefinedClasses.emx"); //$NON-NLS-1$
/**
* One way to identify a library who defines primitive types. This library will be added as
* an element import to the root package/model.
*/
public static final URI PRIMITIVE_TYPES_URI = URI
.createURI("platform:/plugin/test.example/libraries/ExamplePrimitiveDatatypes.emx"); //$NON-NLS-1$
/** One way to identify a profile that should be applied */
public static final URI EXAMPLE_PROFILE_URI = URI.
createURI("platform:/plugin/test.example/profiles/ExampleProfile.epx"); //$NON-NLS-1$
/** The Root Package name in our Primitive Types Library that contains our predefined primitive types */
public static final String PRIMITIVE_TYPES_NAME = "ExamplePrimitiveDataTypesLibrary"; //$NON-NLS-1$
/** Specialized capability we want enabled */
public static final String EXAMPLE_MODELING_ACTIVITY = "test.example.activities.exampleModelingActivity"; //$NON-NLS-1$
/**
* Here we specify that we want to create element imports to the libraries (root packages) defined in the
* two URIs specified.
*
* {@inheritDoc}
*/
@Override
public Collection<URI> getLanguageLibraryURIs() {
List<URI> libraries = new ArrayList<URI>();
libraries.add(EXAMPLE_CLASSES_URI);
libraries.add(PRIMITIVE_TYPES_URI);
return libraries;
}
/**
* Here we are specifying that we want the given capability enabled to properly model with this language.
* {@inheritDoc}
*/
@Override
public Collection<String> getLanguageActivityIDs() {
return Collections.singleton(EXAMPLE_MODELING_ACTIVITY);
}
/**
* We want this profile to be applied to the model if someone sets this language as the 'default' language
* of the root package/model.
*/
@Override
public Collection<URI> getProfileURIs() {
return Collections.singleton(EXAMPLE_PROFILE_URI);
}
/**
* Here we identify the name of the library containing the primitive types. We
* will let our super class worry about finding the library and extracting the
* types.
*
* {@inheritDoc}
*/
@Override
protected Collection<String> getPrimitiveTypeLibraryNames() {
return Collections.singleton(PRIMITIVE_TYPES_NAME);
}
}
Licensed Materials - Property of IBM
Copyright IBM Corp. 2008. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.