Adding a child edit part ??? [message #218827] |
Mon, 03 July 2006 09:32  |
Eclipse User |
|
|
|
Hi,
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
flowlayouteditpolicy.
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 ...
The layoutpolicy:
protected Command getCreateCommand (CreateRequest request)
{
ChildPubCreateCommand cmd = new ChildPublisherCreateCommand();
PublFigModel pubFigMod = (PubFigModel)request.getNewObject ();
DomPartFigModel domPartFigMod =
(DomPartFigModel)getHost().getModel();
EditPart after = getInsertionReference(request);
DSContentAdapter modelListener = new DSContentAdapter(getHost());
domPartFigMod.getDomainParticipant().eAdapters().add (modelListener);
cmd.setChild (pubFigMod);
//cmd.setParent ((Diagram) (getHost ().getModel ()));
cmd.setParent (domPartFigMod, (DomPartEditPart) getHost ());
int index = getHost ().getChildren ().indexOf (after);
cmd.setIndex (index);
cmd.setIndex (1);
return cmd;
}
//-------------------------------------
ChildPubCreateCommand:
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
(m_child.getPub());
}
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
packages:
1. There is the Figure Model - which holds all the figure details
(location, etc).
2. There is the actual data Model. The data is an ERefernce in the figure
model.
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.
Mark Robinson
|
|
|
|
|
|
|
|
|
|
|
Re: Adding a child edit part ??? [message #718683 is a reply to message #707913] |
Thu, 25 August 2011 00:20  |
Eclipse User |
|
|
|
Hi,
It has been solved, the problem is the changes does not reflect in model, so myself added a line like object.setId(object.getId()), then notifychanged has been called.
Regards,
Karthikeyan
|
|
|
Powered by
FUDForum. Page generated in 0.05067 seconds