ECore Module

This offer to user means to handle EMF models (Create EObject, Select element, Handle resources etc..). This module need to be initialized with an nsURI referencing a metamodel usin EcoreModule.initEPackage(String).Once this module has been initialized all creation method of the factory is injected in the script.

Dependencies

This module depends on following other modules which will automatically be loaded.

Method Overview

Method Description
addErrorMarker() Add an error marker on a EObject
addInfoMarker() Add an Information marker on a EObject
addWarningMarker() Add a Warning marker on a EObject
createResource() Create a new resource to hold model elements.
createURI() Create a new URI.
eInstanceOf() Return if the current instance is a instance of an EClass define by its name.
ePrint() Print an EObject using label providers.
getEPackage() Get the EPackage of the selected meta model
getFactory() Get the factory of selected meta model.
getSelection() Returns the currently selected model element in the current editor if it is an instance of the named meta-class (or a sub-class).
getUsages() Return all object referencing this EObject.
initEPackage() Initialized the module with the correct metamodèle.
runOperation() Run an operation in the current editor's command stack.
save() Save the current editor (if no eObject is passed in argument) or the resource containing the eObject passed in argument.
selectFromList() Display a dialog which asks the user to select between a list of Objects.

Methods

addErrorMarker

void addErrorMarker(org.eclipse.emf.ecore.EObject eObject, String message) throws CoreException

Add an error marker on a EObject

eObject
The Object you want to add a error marker
message
Message of the marker
CoreException
If the marker cannot be added because of a null resource.

addInfoMarker

void addInfoMarker(org.eclipse.emf.ecore.EObject eObject, String message) throws CoreException

Add an Information marker on a EObject

eObject
The Object you want to add a error marker
message
Message of the marker
CoreException
If the marker cannot be added because of a null resource.

addWarningMarker

void addWarningMarker(org.eclipse.emf.ecore.EObject eObject, String message) throws CoreException

Add a Warning marker on a EObject

eObject
The Object you want to add a error marker
message
Message of the marker
CoreException
If the marker cannot be added because of a null resource.

createResource

org.eclipse.emf.ecore.resource.Resource createResource([String name], [String uri])

Create a new resource to hold model elements.

name
Name of the resource (Optional parameter ask dynamically to the user)Optional: defaults to <null>.
uri
URI locating the container of the resource (Optional parameter ask dynamically to the user)Optional: defaults to <null>.

the created resource

createURI

org.eclipse.emf.common.util.URI createURI([String containerURI], [String fileName])

Create a new URI. This URI is use to locate a resource.

containerURI
path of the container of the new resource. (Optional Ask dynamically to the user)Optional: defaults to <null>.
fileName
name of the new resource. (Optional Ask dynamically to the user)Optional: defaults to <null>.

the created URI

eInstanceOf

boolean eInstanceOf(org.eclipse.emf.ecore.EObject eObject, String type)

Return if the current instance is a instance of an EClass define by its name.

eObject
The EObject you want to test.
type
The name of the EClass defined in the metamodel

true if the EObject is instance of typeName

ePrint

String ePrint(org.eclipse.emf.ecore.EObject target)

Print an EObject using label providers.

target
the object to print

text provided from label provider

getEPackage

org.eclipse.emf.ecore.EPackage getEPackage()

Get the EPackage of the selected meta model

the EPackage for the meta model

getFactory

org.eclipse.emf.ecore.EFactory getFactory()

Get the factory of selected meta model.

the found factory

getSelection

org.eclipse.emf.ecore.EObject getSelection([String type])

Returns the currently selected model element in the current editor if it is an instance of the named meta-class (or a sub-class).

type
the name of a meta-class (e.g. "Property" or "Package")Optional: defaults to <null>.

the first element selected in the current editor if there is one and it is an instance of the named meta-class or a sub-class of it.

getUsages

Collection<Object[]> getUsages(org.eclipse.emf.ecore.EObject eObject)

Return all object referencing this EObject. The return value is a collection of Array of size 2. Result[0] = EStructual feature linking the two object Result[1] = The referencing object

eObject
object to look for

usages of the object

initEPackage

void initEPackage(String nsURI)

Initialized the module with the correct metamodèle. If this method is not called the module will at runtime ask with metamodel shall be used.

nsURI
of the metamodel

runOperation

void runOperation(Runnable operation, [String operationName])

Run an operation in the current editor's command stack. This is really helpful to manipulate a model using transaction

operation
the operation to run
operationName
the name to give to the operation executionOptional: defaults to <Script Operation>.

save

void save([Object target])

Save the current editor (if no eObject is passed in argument) or the resource containing the eObject passed in argument.

target
Help to locate the resource to save (Optional save the current editor)Optional: defaults to <rg.eclipse.ease.modules.ScriptParameter.nul>.

selectFromList

Object[] selectFromList(List<?extends java.lang.Object> inputs)

Display a dialog which asks the user to select between a list of Objects.

inputs
List of choice for the user

The selected object