Papyrus Module

Module used to interact with Papyrus Editor.

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
control() Use the control function of papyrus.
createDiagram() Create a new empty diagram WARNING: For now only Package and class diagram are implemented.
createResource() Create a new resource to hold model elements
createURI() Create a new URI.
eInstanceOf() The same as eInstanceOf of the Ecore model.
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.
getModel() Get the UML model from the current active editor
getModelSet() Return the model set (ResourceSet) of the current model open in Papyrus
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).
getSelectionElement() Return the UML element from the selection
getSelectionView() Return the select view element (Notation metamodel)
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 This is really help ful to manipulate a model using transaction
save() The the current Papyrus editor.
save() Save: The current editor if no eObject is passed in argument The resource containing the eObject passed in argument
selectFromList() Display a dialog which ask the user to select between a list of Object

Methods

addErrorMarker

void addErrorMarker([org.eclipse.emf.ecore.EObject eObject], [java.lang.String message])

Add an error marker on a EObject

Parameter Type Description
eObject org.eclipse.emf.ecore.EObject The Object you want to add a error marker
Optional: defaults to <>.
message java.lang.String Message of the marker
Optional: defaults to <>.

addInfoMarker

void addInfoMarker([org.eclipse.emf.ecore.EObject eObject], [java.lang.String message])

Add an Information marker on a EObject

Parameter Type Description
eObject org.eclipse.emf.ecore.EObject The Object you want to add a error marker
Optional: defaults to <>.
message java.lang.String Message of the marker
Optional: defaults to <>.

addWarningMarker

void addWarningMarker([org.eclipse.emf.ecore.EObject eObject], [java.lang.String message])

Add a Warning marker on a EObject

Parameter Type Description
eObject org.eclipse.emf.ecore.EObject The Object you want to add a error marker
Optional: defaults to <>.
message java.lang.String Message of the marker
Optional: defaults to <>.

control

void control(org.eclipse.emf.ecore.EObject semanticElement, [java.lang.String fileName])

Use the control function of papyrus. That is to say that all contained element diagrams will be stored in a different resource.

Parameter Type Description
semanticElement org.eclipse.emf.ecore.EObject The semantic element to control (That is to say an UML element)
fileName java.lang.String The name of the new file
Optional: defaults to <>.

createDiagram

void createDiagram(org.eclipse.emf.ecore.EObject semanticElement, [java.lang.String diagramType], [java.lang.String newDiagram], [boolean open])

Create a new empty diagram WARNING: For now only Package and class diagram are implemented.

Parameter Type Description
semanticElement org.eclipse.emf.ecore.EObject UML or Sysml element of the diagram
diagramType java.lang.String
Optional: defaults to <>.
newDiagram java.lang.String The name of the diagram (Optional set the name to newDiagram)
Optional: defaults to <"NewDiagram">.
open boolean True if the diagram shall be open (Optional default = false)
Optional: defaults to <>.

createResource

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

Create a new resource to hold model elements

Parameter Type Description
name java.lang.String Name of the resource (Optional parameter ask dynamically to the user)
Optional: defaults to <null>.
uri java.lang.String URI locating the container of the resource (Optional parameter ask dynamically to the user)
Optional: defaults to <null>.

Returns:org.eclipse.emf.ecore.resource.Resource ...

createURI

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

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

Parameter Type Description
containerURI java.lang.String path of the container of the new resource. (Optional Ask dynamically to the user)
Optional: defaults to <null>.
fileName java.lang.String name of the new resource. (Optional Ask dynamically to the user)
Optional: defaults to <null>.

Returns:org.eclipse.emf.common.util.URI ...

eInstanceOf

boolean eInstanceOf([org.eclipse.emf.ecore.EObject eObject], [java.lang.String type])

The same as eInstanceOf of the Ecore model. However it will look into UML and Notation metamodel

Parameter Type Description
eObject org.eclipse.emf.ecore.EObject
Optional: defaults to <>.
type java.lang.String
Optional: defaults to <>.

Returns:boolean

eInstanceOf

boolean eInstanceOf([org.eclipse.emf.ecore.EObject eObject], [java.lang.String type])

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

Parameter Type Description
eObject org.eclipse.emf.ecore.EObject The EObject you want to test.
Optional: defaults to <>.
type java.lang.String
Optional: defaults to <>.

Returns:boolean ... true if the EObject is instance of typeName

ePrint

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

Print an EObject using label providers

Parameter Type Description
target org.eclipse.emf.ecore.EObject

Returns:java.lang.String ...

getEPackage

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

Get the EPackage of the selected meta model

Returns:org.eclipse.emf.ecore.EPackage ...

getFactory

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

Get the factory of selected meta model.

Returns:org.eclipse.emf.ecore.EFactory ...

getModel

org.eclipse.uml2.uml.Model getModel()

Get the UML model from the current active editor

Returns:org.eclipse.uml2.uml.Model ...

getModelSet

org.eclipse.papyrus.infra.core.resource.ModelSet getModelSet()

Return the model set (ResourceSet) of the current model open in Papyrus

Returns:org.eclipse.papyrus.infra.core.resource.ModelSet ...

getSelection

org.eclipse.emf.ecore.EObject getSelection([java.lang.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).

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

Returns:org.eclipse.emf.ecore.EObject ... 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.

getSelectionElement

org.eclipse.uml2.uml.Element getSelectionElement()

Return the UML element from the selection

Returns:org.eclipse.uml2.uml.Element ...

getSelectionView

org.eclipse.gmf.runtime.notation.View getSelectionView()

Return the select view element (Notation metamodel)

Returns:org.eclipse.gmf.runtime.notation.View ...

getUsages

java.util.Collection 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

Parameter Type Description
eObject org.eclipse.emf.ecore.EObject
Optional: defaults to <>.

Returns:java.util.Collection ...

initEPackage

void initEPackage([java.lang.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.

Parameter Type Description
nsURI java.lang.String of the metamodel
Optional: defaults to <>.

runOperation

void runOperation([java.lang.Runnable operation], [java.lang.String operationName])

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

Parameter Type Description
operation java.lang.Runnable the operation to run
Optional: defaults to <>.
operationName java.lang.String the name to give to the operation execution
Optional: defaults to <"Script Operation">.

save

void save([java.lang.Object object])

The the current Papyrus editor. The object parameter is useless

Parameter Type Description
object java.lang.Object
Optional: defaults to <null>.

save

void save([java.lang.Object target])

Save: The current editor if no eObject is passed in argument The resource containing the eObject passed in argument

Parameter Type Description
target java.lang.Object
Optional: defaults to <null>.

selectFromList

java.lang.Object selectFromList(java.util.List inputs)

Display a dialog which ask the user to select between a list of Object

Parameter Type Description
inputs java.util.List List of choice for the user

Returns:java.lang.Object ... The selected object