Show referenced Node name on Label [message #482429] |
Wed, 26 August 2009 14:09 |
Tianhai Liu Messages: 4 Registered: July 2009 |
Junior Member |
|
|
Hi,
Thank you for your reading.
I have an ecore model.
<eSubpackages name="Some" nsURI="http:///Some.ecore">
<eClassifiers xsi:type="ecore:EClass" name="Sort"> <eStructuralFeatures xsi:type="ecore:EReference" name="scalarAttribute" upperBound="-1" eType="#//Some/ScalarAttribute" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ScalarAttribute">
<eStructuralFeatures xsi:type="ecore:EReference" name="valueSort" lowerBound="1" eType="#//Some/ScalarSort"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ScalarSort">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" defaultValueLiteral="String"/>
</eClassifiers>
</eSubpackages>
I want to generate an editor which looks like this, for example, there are two nodes on the canvas: (ScalarSortB, SortA)
-----------------------------
| ScalarSortB |
-----------------------------
| |
| |
|---------------------------|
-----------------------------
| SortA |
-----------------------------
|attribute : ScalarSortB |
| |
|---------------------------|
To make this goal, I change the view pattern, editorPattern and editPattern on corresponding .gmfmap file by adding {0} : {1}. However, the scalarSort is not a feature of Sort, and it is impossible to change the model. Then I modify the generated code in SomeParserProvider.java (Replacing EAttribute by EStructuralFeature and add a new line "ModelPackage.eINSTANCE.getScalarAttribute_ValueSort()"). However, the text shown on label is: "attribute : Some.ScalarSortImpl@2ce32ce3 (name: ScalarSortB, description: null, id: _1gaV8JJIEd6WEZ4cXo6aGQ) (type: String)"
But what I want is "attribute : ScalarSortB", how can I make it? :-(
protected IParser createScalarAttribute_3001Parser() {
EStructuralFeature[] features = new EStructuralFeature[] {
ModelPackage.eINSTANCE.getNamedObject_Name(),
//I make change here
ModelPackage.eINSTANCE.getScalarAttribute_ValueSort()};
Editor.Sorts.parsers.MessageFormatParser parser = new Editor.Sorts.parsers.MessageFormatParser(
features);
parser.setViewPattern("{0} : {1}");
parser.setEditorPattern("{0} : {1}");
parser.setEditPattern("{0} : {1}");
return parser;
}
Any help is a great favor for me!
Cheers,
William
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03184 seconds