|Adding a child edit part ??? [message #218827]
||Mon, 03 July 2006 13:32
| Mark Robinson
Registered: July 2009
I'm having problems adding a child editpart to a parent editpart.
The parent editpart:
1. Has a figure that uses a toolbar layout.
2. Has only one policy - a layoutpolicy that subclasses the
3. Extends AbstractGraphicalEditPart and implements Adapter, Internal.
The problem I have is that the child editpart is added to the Diagram
editpart, not to the editpart that is supposed to be the parent? The real
parent figure updates and adds the child to the figure (although it is
added to the top of the figure and not the bottom - due to the index
always being -1, because the parent figure's children member is always
null - and you cannot select any of the newly added children).
I'm not sure where I'm going wrong?
1. Does the parent editpart need to implement NodeEditPart?
2. Does the parent editpart need anymore policies?
3. Am I doing something wrong in the create command?
Here's the relevant code parts ...
protected Command getCreateCommand (CreateRequest request)
ChildPubCreateCommand cmd = new ChildPublisherCreateCommand();
PublFigModel pubFigMod = (PubFigModel)request.getNewObject ();
DomPartFigModel domPartFigMod =
EditPart after = getInsertionReference(request);
DSContentAdapter modelListener = new DSContentAdapter(getHost());
//cmd.setParent ((Diagram) (getHost ().getModel ()));
cmd.setParent (domPartFigMod, (DomPartEditPart) getHost ());
int index = getHost ().getChildren ().indexOf (after);
public void setChild(PubFigModel child)
m_child = child;
public void setParent(DomPartFigModel parent, DomPartEditPart editPart)
m_parent = parent;
m_parentEditPart = editPart;
public void execute ()
//m_diagram.getFigures ().add (m_child);
boolean add = m_parent.getDomPart ().getPubs ().add
I'm not sure if I'm using execute correctly? From my understanding,
execute updates the model. The model I'm using is split into different
1. There is the Figure Model - which holds all the figure details
2. There is the actual data Model. The data is an ERefernce in the figure
So, in execute the m_parent is the figureModel, which gets the relavant
datatype EReference (in the data package), which gets a list member then
adds m_child.getPub() to the list (m_child being the figure model, which
is getting the EReference data from the data package).
I'm new to GEF/EMF and I sure I'm missing something basic here; and/or
doing something daft?
Thanks in advance.
Powered by FUDForum
. Page generated in 0.04195 seconds