How can I initializing diagrams with elements [message #226459] |
Thu, 16 April 2009 18:43  |
Eclipse User |
|
|
|
I would like my diagrams to always contain certain default figures. (These
figures are supposed to be the "start" and "end" elements of a workflow
illustrated via the diagram)
How can I achieve this? Is there a listener that could be registered with
the diagram's DiagramEditPart class? Or can I use the diagram's
DiagramEditPart's handleNotification() method somehow? I experimented with
both but couldn't find a handler or notification type that would
successfully represent the event that I'm looking for.
I though about doing the initializing in the diagram's creation wizard,
but this is not sufficient for the following reason: Some of the elements
in the main diagram can be double-clicked and edited in a sub-diagram. And
for these sub-diagrams I need the initialization functionality, too (and
there is no wizard creating these subdiagrams).
Any ideas? Thanks heaps in advance,
Thomas
|
|
|
|
|
|
|
|
Re: How can I initializing diagrams with elements [message #226907 is a reply to message #226842] |
Tue, 21 April 2009 17:19  |
Eclipse User |
|
|
|
Yep, that worked. I overwrote the EditPart's refreshBounds() method
instead of the notifyChanged() one and then it works also for the second
automatically inserted diagram element:
protected void refreshBounds() {
int width = ((Integer)
getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_ Width())).intValue();
int height = ((Integer)
getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_ Height())).intValue();
Dimension size = new Dimension(width, height);
int x = FIXED_X;
int y = FIXED_Y;
Point loc = new Point(x, y);
((GraphicalEditPart) getParent()).setLayoutConstraint(this,
getFigure(), new Rectangle(loc, size));
}
Thanks heaps for the help!
|
|
|
Powered by
FUDForum. Page generated in 0.05118 seconds