=Embedded Editors= Papyrus provides embedded editors to edit UML Elements. Of course these editors allows to edit the name of the elements, but they allow to edit much more than this. ==UML ValueSpecification editor== This editor allows to edit UMLValueSpecification. ValueSpecifications are used to define the default value of a Property or to define the multiplicity of a MultiplicityElement (lower and upper values). Papyrus provides an Xtext Editor for UML ValueSpecification. This editor provides completion (CTRL+SPACE) to help the user to define the value to set crossing easily the model. You can use this editors in Papyrus table or in papyrus Property View for example. The developer documentation for this editors is available [[Papyrus_Developer_Guide/Papyrus_Embedded_Editors_Documentation/Value_Specification_Xtext_editor#Parser_definition|here]]. ===Usage=== The default grammar of the XText parser for the Value Specification is the following: (visibility)? (name'=')? value The values accepted for the differents attributes are the following: {| class="wikitable" border="1" cellspacing="0" ! style="width:20%" | Attribute ! style="width:10%" | Required ! style="width:60%" | Values accepted |- | '''visibility''' | align="center" | No | * + (public) * # (protected) * ~ (package) * - (private) |- | '''name''' | align="center" | No | String representing an ID (i.e. XText grammar: '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*) |- | '''value''' | align="center" | Yes | * true or false (LiteralBoolean) * positive integer (LiteralUnlimitedNatural) * negative integer (LiteralInteger) * double (LiteralReal) * null (LiteralNull) * String with quote (LiteralSting). The quote (') is essential for 2 reasons: ** The XText parser cannot define the difference between the name representing an InstanceSpecification and a simple string value ** A Non-valid value won't be defined as an OpaqueExpression without quote but always as a LiteralString value * Instance Specification name (InstanceValue) * or empty (null) |} If the text filled is not compatible with the grammar of XText parser, an OpaqueExpression will be created. The XText parser for Value Specification is not restrictive with the text filled, i.e. the different features setted on an existing Value Specification will be kept if possible. For example: If an existing Value Specification is a LiteralBoolean named 'testBoolean' with the visibility 'public' and the value setted to true, the text +testBoolean=false and false have the same result: the value of LiteralBoolean existing will pass to false (the name and the visilibity don't change). The XText parser reacts differently instead of the type of the Value Specification's container: ====Example: Without defined type on Value Specification's container==== If the type of Value Specification's container is not defined, the default behaviour will be applied. Here, some examples: {| class="wikitable" border="1" cellspacing="0" ! style="width:15%" rowspan="2" | Text filled ! style="width:20%" rowspan="2" | Namely ! style="width:65%" rowspan="1" colspan="4" | Created ValueSpecification |- ! style="width:15%" rowspan="1" colspan="1" | Type ! style="width:8%" rowspan="1" colspan="1" | Visibility ! style="width:15%" rowspan="1" colspan="1" | Name ! style="width:27%" rowspan="1" colspan="1" | Value |- | rowspan="2" | +testInstanceValue=InstanceSpec1 | 'InstanceSpec1' is an InstanceSpecification existing in the model | InstanceValue | public | testInstanceValue | 'instance' attribute of InstanceValue is a reference to the existing InstanceSpecification named 'InstanceSpec1' |- | No InstanceSpecification exist in the model | OpaqueExpression | public | +testInstanceValue=InstanceSpec1 | |- | +testBoolean=true | | LiteralBoolean | public | testBoolean | true |- | #testUnlimitedNatural=5 | | LiteralUnlimitedNatural | protected | testUnlimitedNatural | 5 |- | ~testInteger=-8 | | LiteralInteger | package | testInteger | -8 |- | -testReal=12.34 | | LiteralReal | private | testReal | 12.34 |- | ~testNull=null | | LiteralNull | package | testNull | null |- | -testString="foo" | | LiteralString | private | testString | foo |- | ##testString="foo" | | OpaqueExpression | public | ##testString="foo" | |} ====Example: With defined type on Value Specification's container==== If the type of Value Specification's container is setted, the same text filled will be have different behaviour depending to the type. In fact, the value filled must be consistent to the type, otherwise an OpaqueExpression will be created. The different types corresponding to LiteralSpecification are the following: {| class="wikitable" border="1" cellspacing="0" ! style="width:50%" | LiteralSpecification ! style="width:50%" | Types corresponding |- | LiteralBoolean | * JavaPrimitiveTypes::boolean * EcorePrimitiveTypes::EBoolean * EcorePrimitiveTypes::EBooleanObject * PrimitiveTypes::Boolean * XMLPrimitiveTypes::Boolean * XMLPrimitiveTypes::BooleanObject |- | LiteralUnlimitedNatural | * PrimitiveTypes::UnlimitedNatural |- | LiteralInteger | * JavaPrimitiveTypes::int * EcorePrimitiveTypes::EInt * EcorePrimitiveTypes::EIntegerObject * PrimitiveTypes::Integer * XMLPrimitiveTypes::Int * XMLPrimitiveTypes::Integer * XMLPrimitiveTypes::IntObject |- | LiteralReal | * JavaPrimitiveTypes::double * EcorePrimitiveTypes::EDouble * EcorePrimitiveTypes::EDoubleObject * PrimitiveTypes::Real * XMLPrimitiveTypes::Double * XMLPrimitiveTypes::DoubleObject |- | LiteralString | * EcorePrimitiveTypes::EString * PrimitiveTypes::String * XMLPrimitiveTypes::String |} Here, some examples: {| class="wikitable" border="1" cellspacing="0" ! style="width:15%" rowspan="2" | Text filled ! style="width:20%" rowspan="2" | Value Specification's container type ! style="width:65%" rowspan="1" colspan="4" | Created ValueSpecification |- ! style="width:15%" rowspan="1" colspan="1" | Type ! style="width:8%" rowspan="1" colspan="1" | Visibility ! style="width:15%" rowspan="1" colspan="1" | Name ! style="width:27%" rowspan="1" colspan="1" | Value |- | rowspan="2" | +testBoolean=true | PrimitiveTypes::Boolean | LiteralBoolean | public | testBoolean | true |- | PrimitiveTypes::Integer | OpaqueExpression | public | +testBoolean=true | |- | rowspan="4" | -testUnlimitedNatural=8 | PrimitiveTypes::UnlimitedNatural | LiteralUnlimitedNatural | private | testUnlimitedNatural | 8 |- | PrimitiveTypes::Integer | LiteralInteger | private | testUnlimitedNatural | 8 |- | PrimitiveTypes::Real | LiteralReal | private | testUnlimitedNatural | 8.0 |- | PrimitiveTypes::Boolean | OpaqueExpression | public | -testUnlimitedNatural=8 | |- | rowspan="4" | #testInteger=-6 | PrimitiveTypes::UnlimitedNatural | OpaqueExpression | public | #testInteger=6 | |- | PrimitiveTypes::Integer | LiteralInteger | protected | testInteger | 6 |- | PrimitiveTypes::Real | LiteralReal | protected | testInteger | 6.0 |- | PrimitiveTypes::Boolean | OpaqueExpression | public | #testInteger=6 | |- | rowspan="3" | -testReal=4.5 | PrimitiveTypes::Integer | OpaqueExpression | public | -testReal=4.5 | |- | PrimitiveTypes::Real | LiteralReal | private | testReal | 4.5 |} ==Textual Editor For Named Element== Since Papyrus 1.1.0 (Eclipse Mars), Papyrus provides a new texutal editor to edit references to UML NamedElement. This editor works only for references which are not in containment. This editor has not been developed using XText. It use a custom string parser and provide a completion (CTRL+SPACE) to help the user to find the named elements to reference in the model. You can use this editor in Property View or in Papyrus table for example. Developer documentation is available [[Papyrus_Developer_Guide/Papyrus_Embedded_Editors_Documentation/Textual_Editor_For_NamedElement|here]]. ===Usage=== * This editors allows to find named element typing its name. * In case of several elements to found, the separator to use is the comma ' * If the name of the element contains a comma, you should prefix and suffix its name by a quote '. * The value will not be set if the element can't be found is the model ===Example=== If you have 3 Classes in your model, named Class1, Class2 and Clas,s3. {| class="wikitable" border="1" cellspacing="0" ! style="font-weight: bold;" | typed text ! style="font-weight: bold;" | completion proposal ! style="font-weight: bold;" | explanation |- | empty string | , ... | we look for nothing, so we provide the value and ... to ask to the user to write more text |- | Clas | ,Class1,Class2,Clas,s3 | 3 classes matches the string, is always proposed |- | Class | ,Class1,Class2 | 3 classes matches the string, is always proposed |- | 'Clas | , Clas,s3 | the string starts with a quote and Clas,s3 contains a comma, so we propose Clas,s3; is always proposed |- | Clas, | ,... | interpreted as a list of value, the first value is Clas, and we have no information for the second one, for the completion it is an empty string |}