Adding a child edit part ??? [message #218827] |
Mon, 03 July 2006 13:32 |
Mark Robinson Messages: 37 Registered: July 2009 |
Member |
|
|
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 #218917 is a reply to message #218911] |
Tue, 04 July 2006 19:38 |
Eclipse User |
|
|
|
Originally posted by: reinalt.gmail.com
hi mark...
can u help??
i'm trying to add Shapes figures(children) to a Container
figure(Parent).Problem is i want to use FlowLayoutEditPolicy for the
parent Figure but dont know what Figure shud the ContainerEditPart draw.
Shud it b FreeformLayer or smthng else.how to use
FlowLayout?? Also wot r the other things tht shud be taken care of wen
adding children figures to the parentFigure???
thnx,
ronald
|
|
|
|
Re: Adding a child edit part ??? [message #219031 is a reply to message #219015] |
Thu, 06 July 2006 13:00 |
Eclipse User |
|
|
|
Originally posted by: reinalt.gmail.com
Thnx a lot Mark...
i have another problem in Shapes Example.If i add a new Panel Figure to
the Container figure ,it doesn't reflect in the Editor ....
protected IFigure createFigure() {
Figure f = new FreeformLayer();
f.setBorder(new MarginBorder(3));
f.setLayoutManager(new FreeformLayout());
Panel panel = new Panel();
panel.setBackgroundColor(ColorConstants.lightBlue);
f.add(panel);
return f;
}
reinalt.
|
|
|
|
Re: Adding a child edit part ??? [message #219047 is a reply to message #219038] |
Thu, 06 July 2006 13:35 |
Eclipse User |
|
|
|
Originally posted by: reinalt.gmail.com
ok tht was maah mistake....
panel was getting added but its bounds were (0,0,0,0).
So it worked after setting new bounds...
thnx newyayz...
protected IFigure createFigure() {
FreeformLayer f = new FreeformLayer();
f.setBorder(new MarginBorder(3));
f.setLayoutManager(new FreeformLayout());
Panel panel = new Panel();
panel.setLayoutManager(new FreeformLayout());
panel.setBounds(new Rectangle(0,0,500,500));
panel.setBackgroundColor(ColorConstants.gray);
return f;
}
reinalt
|
|
|
Please !!! [message #224013 is a reply to message #218827] |
Wed, 11 October 2006 08:16 |
Eclipse User |
|
|
|
Originally posted by: abrahamalon.gmail.com
I need to add a child to a container Shape (not to the root container) and I don't know how to do it. If you have get it please show me how, If you could let me see your code pleaseeeee
|
|
|
Re: Adding a child edit part ??? [message #707913 is a reply to message #218827] |
Tue, 02 August 2011 08:04 |
Karthikeyan Missing name Messages: 47 Registered: July 2011 |
Member |
|
|
Hi,
Myself able to add new Shape in the container using notifychanged method, but when i try to createChangeConstraintCommand in editpolicy, it does not call the notifychanged method ie refreshVisuals not being called because its bounds reflect in model code, so it does not reflect in the editor container. Can you tell me what may be the problem.
Regards,
Karthikeyan
[Updated on: Wed, 10 August 2011 04:19] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04133 seconds