Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between pages "Graphical Modeling Framework/Tutorial/Part 2" and "Callisto Build and Update Tips and Tricks"

< Graphical Modeling Framework‎ | Tutorial(Difference between pages)
m (Feature Initializers)
 
 
Line 1: Line 1:
== Feature Initializers ==
+
On this page, please add any little tidbits that help with the versioning, site management, etc., that are not part of other documents.
  
When you create a new element on a diagram, there is typically a domain element created or modified as a result.  In some cases, it's necessary to provide additional initialization information to ensure that objects are properly created.  For example, the links we create between topics in our mindmap diagram come in three flavors: dependency, includes, and extends. The 'type' attribute of the Relationship class is used to hold the RelationshipType enum value for the new instance.  In our graphical definition, we will create a figure and corresponding link for each type, along with a creation tool for each in our tooling definition.  We'll then use a feature sequence initilizer in our mapping definition to properly initialize our domain objects, depending on the type of link created on the diagram.
 
  
Another possible initialization is to set the 'label' attribute of the Relationship as well, if the appearance of the link is not enough to distinguish between the types. 
+
=== Automatically versioning features appropriately ===
  
[[Image:graph_links.png|right]]
+
I haven't tried it yet, but in
 +
[[https://bugs.eclipse.org/bugs/show_bug.cgi?id=125801#c9 | bug 125801]  
 +
Andrew Niefer mentions that
  
First, create a three distinct polyline connections with properties and decorations as you see fit. For each add a connection for each of the new Dependency, Includes, and Extends links as shown in the figure. For each connection, create a Creation Tool in your mindmap.gmftool model.
+
<p><cite>
 +
When using ".qualifier", the resulting feature version can take the form of
 +
1.2.3.qualifier_suffix, where qualifier will come from the cvs tag, or date the
 +
same as for plugins.  suffix will be generated based on the qualifiers of the
 +
contained plugins.
 +
<br /><br />
 +
Whether or not to append the _suffix to the version is controlled by the
 +
property "generateFeatureVersionSuffix" in the builder's build.properties. The
 +
default value is false.
 +
</cite>
 +
</p>
  
<blockquote>
+
I personally feel that <code>generateFeatureVersionSuffix</code> should be the default, but since it isn't, thought I'd document here.  
<font color="darkblue">'''Tip''' :</font> Don't forget that you can use copy/paste to duplicate elements in your models.  This will come in handy as you create three links, connections, tools, and mappings.
+
</blockquote>
+
  
[[Image:feature_init.png|right]]
+
This is important since a feature's qualifier needs to not just change accourding to its own changes, but also needs to reflect the "most changed" plugin it contains.
  
<br style="clear:both;"/>
+
=== Do not use underscore in version qualifiers ===
  
In the mapping model, for each of your Link Mappings, create a 'Feature Seq Initializer' element.  This will hold subsequent 'Feature Value Spec' elements as seen in the figure. OCL is the language currently supported, so be careful that the body expressions you enter are valid. In the case of initializing the enumeration field, you'll enter 'RelationshipType::DEPENDENCY' while in the case of initilizing the label attribute, you'll enter the string value within single quotes. Keep in mind that the order of the 'Feature Value Spec' elements will determine the order in which they are executed.
+
I think this will all work better post M5, but certainly on 3.1.x streams, and underscore is converted to a hyphen in some places, and will at first seeem to work, but then there's problems associating source with its code, etc., so ... use with care, if not outright avoid. See [[https://bugs.eclipse.org/bugs/show_bug.cgi?id=89428 | bug 89428]] for some dicussions.
  
<br style="clear:both;"/>
+
=== Use the platform releng tool ===
  
With these steps complete, we can regenerate our mindmap.gmfgen and code. When the diagram code is generated, below is what willl be generated within the Initializers inner class of MindmapElementTypes:
+
To update your map files automatically while releasing your plug-ins, the releng tool found as a download way at the bottom of the platform download page is quite helpful.  The instructions are sparse, but it's fairly straightforward (right-click a project and select Team -> Release...).
  
<pre>
+
When using .qualifier at the end of your Bundle-Version manifest entries, your plug-ins will be versioned according to the tags entered in your map files automatically when using the release engineering tool with the PDE basebuilder.
public static final ObjectInitializer Relationship_3003 = new ObjectInitializer(
+
new FeatureInitializer[] {
+
new FeatureInitializer(
+
"RelationshipType::DEPENDENCY", //$NON-NLS-1$
+
MindmapPackage.eINSTANCE.getRelationship(),
+
MindmapPackage.eINSTANCE.getRelationship_Type()),
+
  
new FeatureInitializer(
+
=== Guide to understanding versioning ===
"'depends'", //$NON-NLS-1$
+
MindmapPackage.eINSTANCE.getRelationship(),
+
MindmapPackage.eINSTANCE
+
.getRelationship_Label())
+
  
});
+
Just because this page cannot be linked enough, look here for detailed information on when and how to apply new version numbers to your plug-ins and features: [[http://www.eclipse.org/eclipse/platform-core/documents/plugin-versioning.html Plug-in Versioning]]
</pre>
+
 
+
During link creation, the following code is executed in CreateIncomingRelationship3XXXCommand, found in the TopicItemSemanticEditPolicy class:
+
 
+
<pre>
+
protected EObject doDefaultElementCreation() {
+
Relationship newElement = (Relationship) super
+
.doDefaultElementCreation();
+
if (newElement != null) {
+
newElement.setTarget((Topic) getTarget());
+
newElement.setSource((Topic) getSource());
+
MindmapElementTypes.Initializers.Relationship_3004
+
.init(newElement);
+
}
+
return newElement;
+
}
+
</pre>
+
 
+
This generated code within FeatureInitializer will ultimately be called on each value spec you've added, which as you can see constructs an OCL query for evaluation and uses the result to initialize the field you selected.
+
 
+
<pre>
+
void init(EObject contextInstance) {
+
if (this.query == null) {
+
this.query = QueryFactory.eINSTANCE.createQuery(
+
expressionBody, contextClass);
+
}
+
Object value = query.evaluate(contextInstance);
+
if (sFeature.getEType() instanceof EEnum
+
&& value instanceof EEnumLiteral) {
+
value = ((EEnumLiteral) value).getInstance();
+
} else if (value != null && sFeature.isMany()) {
+
value = new BasicEList((Collection) value);
+
}
+
contextInstance.eSet(sFeature, value);
+
}
+
</pre>
+
 
+
<br style="clear:both;"/>
+
 
+
[[Image:runtime_init.png|right]]
+
 
+
If you launch your runtime instance and test these new initializers, you will find that the type attribute is set according to the Relationship tool selected, and that the label attribute is preset to the names you defined above.
+
 
+
<br style="clear:both;"/>
+

Revision as of 12:37, 24 February 2006

On this page, please add any little tidbits that help with the versioning, site management, etc., that are not part of other documents.


Automatically versioning features appropriately

I haven't tried it yet, but in [| bug 125801 Andrew Niefer mentions that

When using ".qualifier", the resulting feature version can take the form of 1.2.3.qualifier_suffix, where qualifier will come from the cvs tag, or date the same as for plugins. suffix will be generated based on the qualifiers of the contained plugins.

Whether or not to append the _suffix to the version is controlled by the property "generateFeatureVersionSuffix" in the builder's build.properties. The default value is false.

I personally feel that generateFeatureVersionSuffix should be the default, but since it isn't, thought I'd document here.

This is important since a feature's qualifier needs to not just change accourding to its own changes, but also needs to reflect the "most changed" plugin it contains.

Do not use underscore in version qualifiers

I think this will all work better post M5, but certainly on 3.1.x streams, and underscore is converted to a hyphen in some places, and will at first seeem to work, but then there's problems associating source with its code, etc., so ... use with care, if not outright avoid. See [| bug 89428] for some dicussions.

Use the platform releng tool

To update your map files automatically while releasing your plug-ins, the releng tool found as a download way at the bottom of the platform download page is quite helpful. The instructions are sparse, but it's fairly straightforward (right-click a project and select Team -> Release...).

When using .qualifier at the end of your Bundle-Version manifest entries, your plug-ins will be versioned according to the tags entered in your map files automatically when using the release engineering tool with the PDE basebuilder.

Guide to understanding versioning

Just because this page cannot be linked enough, look here for detailed information on when and how to apply new version numbers to your plug-ins and features: [Plug-in Versioning]

Back to the top