Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » What is the use of ContainerEditPolicy
What is the use of ContainerEditPolicy [message #213257] Tue, 04 April 2006 13:22 Go to next message
Eclipse UserFriend
Originally posted by: shruthi.cn.in.bosch.com

Hello everybody,

I am quite new to editpolicies.
Could anyone give me a brief description of the kind of editing possible
with ContainerEditPolicy.
Also some links which have code for the ContainerEditPolicy would be
helpful to me.

I have a doubt.
Say a model object m1 has children c1, c2.
Initially i display only m1. When i double click on the figure of m1 in
the view, i want to display in the editor only the children c1, c2.
Can i achieve this with ContainerEditPolicy. If not how do i achieve this?


Thank you very much
Best Regards
Shruthi
Re: What is the use of ContainerEditPolicy [message #213390 is a reply to message #213257] Wed, 05 April 2006 19:54 Go to previous messageGo to next message
Steven R. Shaw is currently offline Steven R. ShawFriend
Messages: 128
Registered: July 2009
Senior Member
ContainerEditPolicy is used to manage creation and reparenting of elements
with-in an EditPart.

To do what you suggest, there are a couple of ideas.
- Create an EditPolicy which handles the RequestConstants.REQ_OPEN request.
You would need to create a new role for this since GEF doesn't current
handle this request by default This is the request that gets sent for a
double-click event on a target edit part.
- In the command that is returned by your new EditPolicy remove all existing
model children and repopulate the diagram with the children.
- Alternatively you could choose to open up a different editor populated
with the children.

-Steve

"Shruthi" <shruthi.cn@in.bosch.com> wrote in message
news:49d3423bc2ea748e19d65a68cb4aca16$1@www.eclipse.org...
> Hello everybody,
>
> I am quite new to editpolicies.
> Could anyone give me a brief description of the kind of editing possible
> with ContainerEditPolicy.
> Also some links which have code for the ContainerEditPolicy would be
> helpful to me.
>
> I have a doubt.
> Say a model object m1 has children c1, c2.
> Initially i display only m1. When i double click on the figure of m1 in
> the view, i want to display in the editor only the children c1, c2.
> Can i achieve this with ContainerEditPolicy. If not how do i achieve this?
>
>
> Thank you very much
> Best Regards
> Shruthi
>
Re: What is the use of ContainerEditPolicy [message #213496 is a reply to message #213390] Thu, 06 April 2006 10:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: shruthi.cn.in.bosch.com

Hello Steven Shaw,

Thanks a lot for your reply.
I tried to implement as you had said. I am little new to Editpolicies.

Actually HierarchyDisplay edit policy will handle the
RequestConstants.REQ_OPEN request as shown below.
When i debugged it, the following is happening:-

When i single click on the figure, control is going to the getCommand
method in HierarchyDisplay. The request.getType() value is "delete".
Control is also not entering the if loop present in getCommand method.

If i double click twice on the figure, then control is entering twice in
to the getCommand method. Is there anything else that i have to do? Thanks
a lot. Waiting for your reply.

Best Regards
Shruthi

protected void createEditPolicies() {
installEditPolicy(HIERARCHY_ROLE, new HierarchyDisplay());
}

private static class HierarchyDisplay extends GraphicalEditPolicy {
public Command getCommand(Request request)
{
if(request.getType().equals(RequestConstants.REQ_OPEN ))
{
System.out.println("diagram double clicked");
return new HierarchyViewCommand((Shape)
this.getTargetEditPart(request).getModel(),
request);
}
else
return null;
}
}
Re: What is the use of ContainerEditPolicy [message #213587 is a reply to message #213496] Fri, 07 April 2006 19:14 Go to previous message
Steven R. Shaw is currently offline Steven R. ShawFriend
Messages: 128
Registered: July 2009
Senior Member
A single click correctly won't invoke the REQ_OPEN request. I'm not sure
why a delete request is being invoked though...

Double-clicking twice will correctly send the REQ_OPEN request twice.

I'm not quite sure what the issue is?

-Steve

"Shruthi" <shruthi.cn@in.bosch.com> wrote in message
news:07412ae3cc4cfd8a2e2d610513f93c98$1@www.eclipse.org...
> Hello Steven Shaw,
>
> Thanks a lot for your reply.
> I tried to implement as you had said. I am little new to Editpolicies.
>
> Actually HierarchyDisplay edit policy will handle the
> RequestConstants.REQ_OPEN request as shown below.
> When i debugged it, the following is happening:-
>
> When i single click on the figure, control is going to the getCommand
> method in HierarchyDisplay. The request.getType() value is "delete".
> Control is also not entering the if loop present in getCommand method.
>
> If i double click twice on the figure, then control is entering twice in
> to the getCommand method. Is there anything else that i have to do? Thanks
> a lot. Waiting for your reply.
>
> Best Regards
> Shruthi
>
> protected void createEditPolicies() {
> installEditPolicy(HIERARCHY_ROLE, new HierarchyDisplay());
> }
>
> private static class HierarchyDisplay extends GraphicalEditPolicy {
> public Command getCommand(Request request)
> {
> if(request.getType().equals(RequestConstants.REQ_OPEN ))
> {
> System.out.println("diagram double clicked");
> return new HierarchyViewCommand((Shape)
> this.getTargetEditPart(request).getModel(),
> request);
> }
> else
> return null;
> }
> }
>
>
Previous Topic:Rotatable Elements?
Next Topic:Known bug on orangevolt xul plugin ?
Goto Forum:
  


Current Time: Mon Jan 20 17:15:26 GMT 2025

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

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

Back to the top