Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Show referenced Node name on Label
Show referenced Node name on Label [message #482429] Wed, 26 August 2009 14:09 Go to next message
Tianhai Liu is currently offline Tianhai LiuFriend
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
Re: Show referenced Node name on Label [message #482608 is a reply to message #482429] Thu, 27 August 2009 09:36 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Tianhai,

MessageFormatParser is able to display only direct attributes of underlying
object.
What you need is: implement your own parser and plug it in aither by modifying
createScalarAttribute_3001Parser() method or using your own parser provider.

-----------------
Alex Shatalin
Re: Show referenced Node name on Label [message #485060 is a reply to message #482608] Thu, 10 September 2009 12:05 Go to previous messageGo to next message
Tianhai Liu is currently offline Tianhai LiuFriend
Messages: 4
Registered: July 2009
Junior Member
Alex Shatalin wrote:
> Hello Tianhai,
>
> MessageFormatParser is able to display only direct attributes of
> underlying object.
> What you need is: implement your own parser and plug it in aither by
> modifying createScalarAttribute_3001Parser() method or using your own
> parser provider.
>
> -----------------
> Alex Shatalin
>
>

Thank you very much! It works.
Re: Show referenced Node name on Label [message #485061 is a reply to message #482608] Thu, 10 September 2009 12:06 Go to previous message
Tianhai Liu is currently offline Tianhai LiuFriend
Messages: 4
Registered: July 2009
Junior Member
Alex Shatalin wrote:
> Hello Tianhai,
>
> MessageFormatParser is able to display only direct attributes of
> underlying object.
> What you need is: implement your own parser and plug it in aither by
> modifying createScalarAttribute_3001Parser() method or using your own
> parser provider.
>
> -----------------
> Alex Shatalin
>
>
Hi, Alex, it works. Thank you very much!
Previous Topic:Create Diagram from xml source
Next Topic:diagram initialized incorrectly
Goto Forum:
  


Current Time: Fri Apr 26 00:19:12 GMT 2024

Powered by FUDForum. Page generated in 0.03184 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top