[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.gmf] Re: How to simulate a label of a link when link and label are of different EClasses?
|
- From: alessanderbotti@xxxxxxxxx (Alessander Botti Benevides)
- Date: Wed, 3 Jun 2009 15:31:10 +0000 (UTC)
- Newsgroups: eclipse.modeling.gmf
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
Hi Alex, thank you very much for your answer!
I followed the first approach you suggested and was easy to implement, but
unfortunately I need to get EClass B in the "Properties View" when I click
on the label, and by this method I get EClass C.
I didn't tried the second solution yet, but it seems to me that it will
get the same problem, am I right?
I also have tried to create a label of EClass C and then change its
element to the automatically created element of EClass B by changing
addFixedChild(EditPart childEditPart) in CEditPart.java
The generated addFixedChild for this example:
protected boolean addFixedChild(EditPart childEditPart) {
if (childEditPart instanceof OntoUML.diagram.edit.parts.CLabelEditPart) {
((OntoUML.diagram.edit.parts.CLabelEditPart) childEditPart)
.setLabel(getPrimaryShape()
.getFigureCLabelFigure());
return true;
}
}
My alteration:
protected boolean addFixedChild(EditPart childEditPart) {
if (childEditPart instanceof OntoUML.diagram.edit.parts.CLabelEditPart) {
((OntoUML.diagram.edit.parts.CLabelEditPart) childEditPart)
.setLabel(getPrimaryShape()
.getFigureCLabelFigure());
((View) getModel()).setElement(generatedEClassB);
// From an EClass C, I can find the generated EClass B instance
// (generatedEClassB). There is an EReference from EClass C to
// EClass B that I didn't show in the metamodel, in order to make
// it more simple...
return true;
}
}
I got the following error:
Caused by: java.lang.ClassCastException: OntoUML.impl.BImpl cannot be cast
to OntoUML.C
Even if I set the element of childEditPart to the same element that it is
currently using, by doing the next line of code, I got an error:
((View) getModel()).setElement(resolveSemanticElement());
Caused by: java.lang.IllegalStateException: Cannot modify resource set
without a write transaction
As you see, I have a poor understanding of how GMF works :(
Is there a way to change the element of the label from C1 (of EClass C) to
B1 (of EClass B)?
I also have tried to change CEditPart.java in order to create a new View
for B1 as a label of C1, but having no success. I found no information of
how to programatically create Views or EditPart instances for elements.
Can you help me?
Thank you for your answer,
Best regards,
Alessander