Home » Modeling » GMF (Graphical Modeling Framework) » How to create edit part for specialized model object
How to create edit part for specialized model object [message #148912] |
Tue, 04 September 2007 15:37  |
Eclipse User |
|
|
|
Originally posted by: mike.aol.com
I have a problem generating a diagram from a model with the correct edit
part. In my model, I have two different classes, X and Y, and a
different edit part for each, EPX and EPY. However, class Y is a
subclass of X. When I compose a diagram using the palette, the correct
edit part, EPY, is created for Y. However, if I generate a diagram from
the model, EPX is created instead of EPY for instances of Y.
Any suggestions?
Thanks,
Mike
|
|
|
Re: How to create edit part for specialized model object [message #148932 is a reply to message #148912] |
Tue, 04 September 2007 22:09   |
Eclipse User |
|
|
|
Mike,
Are you sure that the mapping between node and tool for Y is correct?
In fact, I can't reproduce your situation.
Koji
Mike Gering wrote:
> I have a problem generating a diagram from a model with the correct edit
> part. In my model, I have two different classes, X and Y, and a
> different edit part for each, EPX and EPY. However, class Y is a
> subclass of X. When I compose a diagram using the palette, the correct
> edit part, EPY, is created for Y. However, if I generate a diagram from
> the model, EPX is created instead of EPY for instances of Y.
> Any suggestions?
> Thanks,
> Mike
|
|
|
Re: How to create edit part for specialized model object [message #149037 is a reply to message #148912] |
Wed, 05 September 2007 08:50   |
Eclipse User |
|
|
|
Originally posted by: jan.herriger.gmx.de
Sounds like an issue with VisualIDRegistry#getNodeVisualID
(xxx.part.XxxVisualIDRegistry).
In getNodeVisualID(...) you'll probably see something like:
....
case XxxModelEditPart.VISUAL_ID:
if (XxxPackage.eINSTANCE.getX().isSuperTypeOf(
domainElement.eClass())) {
return EPX.VISUAL_ID;
}
if (XxxPackage.eINSTANCE.getY().isSuperTypeOf(
domainElement.eClass())) {
return EPY.VISUAL_ID;
}
....
In this case, changing the order would help. (the second statement is
never reached, because X is super type of Y.
Mike Gering schrieb:
> I have a problem generating a diagram from a model with the correct edit
> part. In my model, I have two different classes, X and Y, and a
> different edit part for each, EPX and EPY. However, class Y is a
> subclass of X. When I compose a diagram using the palette, the correct
> edit part, EPY, is created for Y. However, if I generate a diagram from
> the model, EPX is created instead of EPY for instances of Y.
>
> Any suggestions?
>
> Thanks,
> Mike
|
|
| | |
Re: How to create edit part for specialized model object [message #149152 is a reply to message #149037] |
Wed, 05 September 2007 21:14   |
Eclipse User |
|
|
|
Jan,
That's why I could not reproduce the problem.
Thanks.
Anyway, we have to be careful if we create a diagram editor in which both
a class and its subclass can be instantiated.
Koji
Jan Herriger wrote:
> Sounds like an issue with VisualIDRegistry#getNodeVisualID
> (xxx.part.XxxVisualIDRegistry).
> In getNodeVisualID(...) you'll probably see something like:
> ....
> case XxxModelEditPart.VISUAL_ID:
> if (XxxPackage.eINSTANCE.getX().isSuperTypeOf(
> domainElement.eClass())) {
> return EPX.VISUAL_ID;
> }
> if (XxxPackage.eINSTANCE.getY().isSuperTypeOf(
> domainElement.eClass())) {
> return EPY.VISUAL_ID;
> }
> ....
> In this case, changing the order would help. (the second statement is
> never reached, because X is super type of Y.
> Mike Gering schrieb:
>> I have a problem generating a diagram from a model with the correct edit
>> part. In my model, I have two different classes, X and Y, and a
>> different edit part for each, EPX and EPY. However, class Y is a
>> subclass of X. When I compose a diagram using the palette, the correct
>> edit part, EPY, is created for Y. However, if I generate a diagram from
>> the model, EPX is created instead of EPY for instances of Y.
>>
>> Any suggestions?
>>
>> Thanks,
>> Mike
|
|
|
Re: How to create edit part for specialized model object [message #149400 is a reply to message #149098] |
Thu, 06 September 2007 07:09   |
Eclipse User |
|
|
|
Hi Mike,
The best way to deal with such situations is to declare a
DomainSpecialization constraint for the NodeMappings in the mapping
model. (The resulting code will be effectively the same, but your intent
to show Y's as EPY, not EPX will be more readily available from the model).
Best regards,
Boris
Mike Gering wrote:
> Koji Hashimoto wrote:
>> Are you sure that the mapping between node and tool for Y is correct?
>> In fact, I can't reproduce your situation.
>>
>
> Yes, the tool mapping works. I can create a node for Y from the tool
> palette. The problem is when I create a new diagram from an emf model
> using the new diagram file wizard.
>
> I here is more detail about how I've defined my gmf models. The diagram
> root object is class P and has a containment relationship to X, xrel.
> Since Y is a subclass of X, the xrel relationship also accommodates
> instances of Y in my model.
>
> I have top node references in my map for both X and Y. Each top node
> reference uses the same containment feature, xrel.
>
> I've been trying to understand what's happening by debugging. What I've
> seen so far is that the generated VisualIDRegistry.getNodeVisualID()
> method includes this code fragment:
> if ((semanticHint == null || XEditPart.VISUAL_ID == nodeVisualID)
> && ProviderPackage.eINSTANCE.getX()
> ..isSuperTypeOf(domainElementMetaclass)
> && (domainElement == null || isNodeX_1001((X) domainElement))) {
> return XEditPart.VISUAL_ID;
> }
>
> It evaluates to true and returns the X edit part.
>
> I changed the implementation of the generated code in this class to
> check for instances of Y:
>
> private static boolean isNodeX_1001(X element) {
> if(element instanceof Y) {
> return false;
> }
> return true;
> }
>
> This seems to work and solve the problem. Is it the best way to do it?
>
> Thanks,
> Mike
|
|
|
Re: How to create edit part for specialized model object [message #149443 is a reply to message #149400] |
Thu, 06 September 2007 12:09  |
Eclipse User |
|
|
|
Originally posted by: mike.aol.com
Boris,
Thanks! I took your suggestion and it works great.
Mike
Boris Blajer wrote:
> The best way to deal with such situations is to declare a
> DomainSpecialization constraint for the NodeMappings in the mapping
> model. (The resulting code will be effectively the same, but your intent
> to show Y's as EPY, not EPX will be more readily available from the model).
|
|
|
Goto Forum:
Current Time: Sun Jun 01 13:46:23 EDT 2025
Powered by FUDForum. Page generated in 0.03440 seconds
|