Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Reorder child Editparts
Reorder child Editparts [message #210727] Fri, 07 November 2008 11:06 Go to next message
Eclipse UserFriend
Originally posted by: d.kleinrath.inode.at

Hi,

I want to extend FlowLayoutEditPolicy so I can change the order of the
children by moving them to a new position in the container (something like
the LogicFlowEditPolicy in the logic example of GEF). I already tested my
EditPolicy with a command that removes the child EditPart from the parent
and afterwards inserts it at the new position and it seems to work but of
course this information is not stored in the model.

I think the initial order of child EditParts is determined by the order in
the notation model but I couldn't find out how to change and store this
order. I tried changing the order of the EList in my semantic model but
this didn't work. The order gets stored in the semantic model but not in
the notation model if I do this. Using a RepositionEObjectCommand on the
notation model also doesn't work because the EList where the children are
stored returns an UnsupportedOperationException() for the move method.

Does anyone know how to change the order of children in the notation model?
Is there perhaps a better approach for achieving what I want?

Thanks for any help,

Dieter
Re: Reorder child Editparts [message #210734 is a reply to message #210727] Fri, 07 November 2008 11:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: d.kleinrath.inode.at

I just found out how to solve this. I used getChildren() on the View and
tried to change its order but this doesn't work. You need to use
getPersistedChildren() instead.

Dieter


Am 07.11.2008, 12:06 Uhr, schrieb Dieter Kleinrath <d.kleinrath@inode.at>:

> Hi,
>
> I want to extend FlowLayoutEditPolicy so I can change the order of the
> children by moving them to a new position in the container (something
> like the LogicFlowEditPolicy in the logic example of GEF). I already
> tested my EditPolicy with a command that removes the child EditPart from
> the parent and afterwards inserts it at the new position and it seems to
> work but of course this information is not stored in the model.
>
> I think the initial order of child EditParts is determined by the order
> in the notation model but I couldn't find out how to change and store
> this order. I tried changing the order of the EList in my semantic model
> but this didn't work. The order gets stored in the semantic model but
> not in the notation model if I do this. Using a RepositionEObjectCommand
> on the notation model also doesn't work because the EList where the
> children are stored returns an UnsupportedOperationException() for the
> move method.
>
> Does anyone know how to change the order of children in the notation
> model?
> Is there perhaps a better approach for achieving what I want?
>
> Thanks for any help,
>
> Dieter
Re: Reorder child Editparts [message #210776 is a reply to message #210727] Sun, 09 November 2008 18:41 Go to previous messageGo to next message
Viktor Kazakov is currently offline Viktor KazakovFriend
Messages: 14
Registered: July 2009
Junior Member
My question is more general: how do I work with notation model without
touching the semantic model?

For example, I want to show or hide the nodes that correspond to the
model elements. How to do that without removing the elements from the
semantic model? What is the best practice?

Thanks!

Viktor

Dieter Kleinrath пишет:
> Hi,
>
> I want to extend FlowLayoutEditPolicy so I can change the order of the
> children by moving them to a new position in the container (something
> like the LogicFlowEditPolicy in the logic example of GEF). I already
> tested my EditPolicy with a command that removes the child EditPart
> from the parent and afterwards inserts it at the new position and it
> seems to work but of course this information is not stored in the model.
>
> I think the initial order of child EditParts is determined by the
> order in the notation model but I couldn't find out how to change and
> store this order. I tried changing the order of the EList in my
> semantic model but this didn't work. The order gets stored in the
> semantic model but not in the notation model if I do this. Using a
> RepositionEObjectCommand on the notation model also doesn't work
> because the EList where the children are stored returns an
> UnsupportedOperationException() for the move method.
>
> Does anyone know how to change the order of children in the notation
> model?
> Is there perhaps a better approach for achieving what I want?
>
> Thanks for any help,
>
> Dieter
Re: Reorder child Editparts [message #210797 is a reply to message #210776] Mon, 10 November 2008 11:54 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Viktor,

> For example, I want to show or hide the nodes that correspond to the
> model elements. How to do that without removing the elements from the
Try calling View.setVisible(false).

-----------------
Alex Shatalin
Re: Reorder child Editparts [message #210847 is a reply to message #210797] Tue, 11 November 2008 09:55 Go to previous messageGo to next message
Viktor Kazakov is currently offline Viktor KazakovFriend
Messages: 14
Registered: July 2009
Junior Member
OK, that works. Thanks!

And how to create and display the node, that corresponds to the semantic
model element, without linking it to the root semantic model element?

I'll explain...

For now the creation of nodes in the notation model is made like this:

public static void createInstanceElement(SchemaEditPart containerEp,
final Instance instance) {
final Schema schema = (Schema) ((View)
containerEp.getModel()).getElement();
TransactionalEditingDomain editingDomain =
containerEp.getEditingDomain();
editingDomain.getCommandStack().execute(new
RecordingCommand(editingDomain) {
protected void doExecute() {
schema.getRootInstances().add(instance);
}
});
}

Schema is a root class in the notation model. Instance is some other
class, whose object can be referenced (but not always) by the Schema object.

With the above method each object of Instance becomes referenced by
Schema root object just to be displayed. But this is not right.

Is there a more correct way to create and display the nodes in the
notation model? This will help me to completely separate the Model and
the View.

Would greatly appreciate your help!

Viktor

Alex Shatalin пишет:
> Hello Viktor,
>
>> For example, I want to show or hide the nodes that correspond to the
>> model elements. How to do that without removing the elements from the
> Try calling View.setVisible(false).
>
> -----------------
> Alex Shatalin
>
>
Re: Reorder child Editparts [message #210872 is a reply to message #210847] Tue, 11 November 2008 11:18 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Viktor,

Looks like you need to generate non-synchronized diagram with the possibility
to create "shortcut" diagram element pointing to the domain model element
located elsewhere.

- set property synchronized = false for GenDiagram in .gmfgen model
- set properties "contains shortcuts to"/"shortcuts provided for" (see http://wiki.eclipse.org/GMF_GenModel_Hints#Diagram_group
for the details)
- regenerate diagram

- try to D&D domain model node from EMF-generated tree editor or from the
domain model file structure exposed in Project Explorer onto the diagram
-> shortcut to this very node should be created.

AFAIU, this is exactly whar you are looking for - this action will add a
reference to the existing domain model element onto the diagram, but will
not modify actual domain model content.

-----------------
Alex Shatalin
Re: Reorder child Editparts [message #211341 is a reply to message #210872] Sat, 15 November 2008 21:32 Go to previous messageGo to next message
Viktor Kazakov is currently offline Viktor KazakovFriend
Messages: 14
Registered: July 2009
Junior Member
> AFAIU, this is exactly whar you are looking for - this action will add
> a reference to the existing domain model element onto the diagram, but
> will not modify actual domain model content.
No, not exactly, but it's closer. In our application the user cannot
create the nodes himself. Neither he can make shortcuts. This is done by
the plugin. The point is that depending on the user actions the model
should be represented differently. This representation dynamically
changes. This will be not actually an editor, but a monitoring tool.

About generating non-synchronized model - yep, it works. Nothing is
shown now :)
The only thing to figure out: how to create the nodes on the Notation
mode? (which will be "shortcuts" to the Symantic model elements)
You mentioned CreateElementRequest, but it only creates an empty node
with a corresponding empty domain EObject. But how to create a node,
corresponding to an existing element? (with all it's properties and so on)

Viktor
Re: Reorder child Editparts [message #211422 is a reply to message #211341] Tue, 18 November 2008 12:22 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Viktor,

See org.eclipse.gmf.ecore.part.CreateShortcutAction (from org.eclipse.gmf.ecore.editor
GMF example). I think you can copy some code from there.

-----------------
Alex Shatalin
Re: Reorder child Editparts [message #211486 is a reply to message #211422] Tue, 18 November 2008 20:57 Go to previous messageGo to next message
Viktor Kazakov is currently offline Viktor KazakovFriend
Messages: 14
Registered: July 2009
Junior Member
Alex,

Where can I find these example sources? In the downloads section there
is only a binary plugin...

Viktor

Alex Shatalin пишет:
> Hello Viktor,
>
> See org.eclipse.gmf.ecore.part.CreateShortcutAction (from
> org.eclipse.gmf.ecore.editor GMF example). I think you can copy some
> code from there.
>
> -----------------
> Alex Shatalin
>
>
Re: Reorder child Editparts [message #211511 is a reply to message #211486] Wed, 19 November 2008 10:38 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Viktor,

In CVS:
:pserver:anonymous@dev.eclipse.org:/cvsroot/modeling co org.eclipse.gmf/examples/org.eclipse.gmf.ecore.editor

You can use web access to CVS as well.

-----------------
Alex Shatalin
Previous Topic:How do I add/remove tools on the palette dynamically?
Next Topic:Does adding color children to figures Still work or do i have to do it programatically ?
Goto Forum:
  


Current Time: Thu Apr 25 10:51:02 GMT 2024

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

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

Back to the top