z-index of figures [message #248120] |
Tue, 07 April 2009 07:45  |
Eclipse User |
|
|
|
Originally posted by: juergen.scheffler.gmx.de
Hi,
how do I change the z-index of figures f.e.: bringing sth one step to
front or total front.
G
Juergen
|
|
|
|
|
|
|
|
Re: z-index of figures [message #248539 is a reply to message #248526] |
Wed, 22 April 2009 12:16   |
Eclipse User |
|
|
|
Hi Jurgen,
OK, so let's say you've got the following,
com.your.product.model.Stack
com.your.product.model.StackChild
com.your.product.parts.StackEditPart
com.your.product.parts.StackChildEditPart
First, take GEF out of the picture. Think of this as a model operation.
Your Stack model needs to maintain an ordered list composed of
StackChild objects. When you first create this list, it should be in
whatever the default order is. When your action runs, you need to
modify this list to put the appropriate Child in the right slot.
First, you need to encapsulate that logic in a GEF Command. The Command
need only know about the Stack and the StackChild.
For your Action, most likely it will be easiest to subclass
org.eclipse.gef.ui.actions.SelectionAction. There are methods on that
class (and its superclass) to get the selected EditPart, and then
execute a Command. Take a look at the DeleteAction as an example.
If you need help understanding how to hook up the SelectionAction, look
at how DeleteAction is used in the Logic example. It just needs a
reference to the IEditorPart that is wrapping your GraphicalViewer.
So, full circle:
1. Action executes a Command
2. Command modifies the model
3. The Stack model class must send a notification to its listeners. One
of those listeners must be the StackEditPart. The StackEditPart must
respond to this event by refreshing itself (using refresh() or similar).
This will cause it to get a new properly ordered set of
StackChildEditPart objects. Then your figures will be in the right order
automatically.
You will find this is a very standard workflow in GEF. The Command
modifies the model, which notifies the edit parts, which update their
visuals accordingly.
Good luck!
Ben
Jürgen Scheffler wrote:
> I want to have a button in the toolbar (later in context menu) like
> "bring to front". I know how to make those actions in my
> "EditorWithPalette.java". So, I select a figure and press the "bring to
> front"-button. So the EditorWithPalette.java has the control. Do I have
> to find the selected Element there or only later in the Editpart?
|
|
|
|
Re: z-index of figures [message #248555 is a reply to message #248545] |
Wed, 22 April 2009 15:12  |
Eclipse User |
|
|
|
No need to mess with getModelChildren at all. Let the model be the guide.
Jürgen Scheffler wrote:
> Super Ben! thx a lot!
> I had lost the clear view on the MVC of GEF. You gave it back!
> 1. and 2. will be not very hard. I just hope I get 3. done, but I think
> its connected correct.
>
> Ok, so, I change the model in a command. I sort the childs in the
> correct order for the parent stack and the editparts get notified
> because of the adapter.
>
> Whats the benefit of the Editpart getmodelchildren method then?
> So I dont need to code there?!
> Who needs to overwrite this method? or is it only for the first view
> until there are changes to the model?!
>
> G
>
> Jürgen
|
|
|
Powered by
FUDForum. Page generated in 0.05659 seconds