Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Getting EditPart size in Command
Getting EditPart size in Command [message #222077] Thu, 24 August 2006 23:45 Go to next message
Eclipse UserFriend
Originally posted by: mike.aol.com

I have an editor to display a topology diagram, and it has an underlying
model (based on EMF). One of the operations I need to implement is to
create multiple edit parts and then arrange them. The problem is that
command implementation that does the arranging needs to get the size of
the edit parts. But EditPart.getFigure() returns 0 width and height
during the command execution. After the command is finished the width
and height are initialized as expected. I've tried chaining a command
for the arrange step and executing a separate command for the
add/arrange action, to no avail.

Is there a way to get an edit part's size sometime during the lifetime
of the action that creates it?

Thanks,
Mike Gering
Re: Getting EditPart size in Command [message #222085 is a reply to message #222077] Fri, 25 August 2006 00:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: guen.my-lounge.net

Mike Gering schrieb:
> I have an editor to display a topology diagram, and it has an underlying
> model (based on EMF). One of the operations I need to implement is to
> create multiple edit parts and then arrange them. The problem is that
> command implementation that does the arranging needs to get the size of
> the edit parts. But EditPart.getFigure() returns 0 width and height
> during the command execution. After the command is finished the width
> and height are initialized as expected. I've tried chaining a command
> for the arrange step and executing a separate command for the
> add/arrange action, to no avail.
>
> Is there a way to get an edit part's size sometime during the lifetime
> of the action that creates it?
>
> Thanks,
> Mike Gering

Hi Mike,

I didn't get the hole problem and Iam a newbie with GEF but maybe I can
help - if you are arranging the figure when you creating them you got
the constraints from the request in the EditPolicy
(getConstraintFor(request)). If the figures are already created you
couldn't get the constraint with figure.getBounds() ? Maybe you can get
the constraint from the model of the figure.

Greetings
Christian
Re: Getting EditPart size in Command [message #222131 is a reply to message #222085] Fri, 25 August 2006 12:11 Go to previous message
Eclipse UserFriend
Originally posted by: mike.aol.com

Christian,

Thanks for your suggestions. I think I have a solution, but I suspect it
is not the best one. In a little more detail:

I have an action that, when executed, performs two things: 1) it
determines the set of objects to be placed in the editor, and 2)
rearranges all nodes in the editor (using the draw2d.DirectedGraph
functions). The figures for the edit parts representing the objects are
subclasses of org.eclipse.draw2d.Label. I have an image and text for the
Labels.

When the action executes two Commands: 1) the command that creates the
edit parts and adds them to the editor, 2) the command that rearranges
the edit parts in the editor. I chain them. When the first command is
run, it causes the EditPart.createFigure() to be called. This is where I
call Label.setIcon() and Label.setText(). After initializing the Label
with these methods, the Label.getBounds() returns (0, 0, 0, 0) -- I
don't know why it doesn't reflect the size of the image and text.

When the second command to arrange the edit parts runs, the Label
figures all still have uninitialized bounds. After both commands have
finished, and the action is finished the Label figures have correctly
initialized bounds().

My solution is to use the Figure.getPreferredSize() in the arrange
command. The initialization is far enough along to return a good value.

I'm very much a newbie to GEF, so I may be misguided with this approach
to begin with.

Thanks,
Mike Gering
Previous Topic:Custom EType
Next Topic:A job for GEF?
Goto Forum:
  


Current Time: Fri Jan 24 17:53:27 GMT 2025

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

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

Back to the top