How do I add text to notation model only? [message #529319] |
Fri, 23 April 2010 19:26 |
Pettax Messages: 7 Registered: April 2010 |
Junior Member |
|
|
Hi,
I'm just two weeks old in this game so you have to excuse me if I don't get the terminology completely right now in my first post.
I am trying to extend a diagram type made by a third-party. I'd like to contribute a few new notation symbols that should not affect the underlying semantic model. I've extended the element type registry with a few entries looking something like below:
<specializationType
id="myId"
name="myName"
kind="org.eclipse.gmf.runtime.diagram.ui.util.INotationType "
edithelperadvice="com.mycompany.MyTypeHelperAdvice">
<specializes id="org.eclipse.gmf.runtime.emf.type.core.null"/>
<param name="semanticHint" value="myName"/>
</specializationType>
I use the INotationType kind not to affect the semantic model and specialize org.eclipse.gmf.runtime.emf.type.core.null to add a completely new element to the picture. This all works fine for adding my new shapes. I can place them in the diagram without affecting the semantic model. However, when I try to add a child with a text compartment to the shapes it does not work that well any more. The original (third-party) figures on the diagram gets in a direct edit mode where I can enter a name for the nodes but my new figures will not show the label at all. It is selectable somehow in the middle of the shape but I cannot edit it.
In my investigations so far I've seen that the EditPart that corresponds to the text child signals that it is not editable (TextCompartmentEditPart.isEditable()). This in turn is caused by that the method GraphicalEditPart.resolveSemanticElement() returns null. I can sort of understand this because I do not have a semantic element, right? How should I proceed with my project to be able to add text that is attached to my figures and only save the text in the diagram without affecting the underlying model?
I should add that all code is handwritten so far (ie using GMF runtime).
Any help is appreciated!
Br,
Pettax
[Updated on: Fri, 30 April 2010 14:00] Report message to a moderator
|
|
|
Re: How do I add text to notation model only? [message #530676 is a reply to message #529319] |
Fri, 30 April 2010 13:56 |
Pettax Messages: 7 Registered: April 2010 |
Junior Member |
|
|
Let me answer myself for the record.
The fairly straight forward answer (as it seems) is to add a child view to the main view (from the view factory) created with the help of the common parser hint "Description". Something like below:
public class MyTypeViewFactory extends AbstractShapeViewFactory {
@Override
protected void decorateView(View containerView, View view, IAdaptable element, String semanticHint, int index, boolean persisted) {
super.decorateView(containerView, view, element, semanticHint, index, persisted);
getViewService().createNode(element, view, CommonParserHint.DESCRIPTION, ViewUtil.APPEND, persisted, getPreferencesHint());
}
Br,
Pettax
|
|
|
Powered by
FUDForum. Page generated in 0.02129 seconds