Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Handling REQ_OPEN requests
Handling REQ_OPEN requests [message #164803] Thu, 20 January 2005 18:45 Go to next message
Nick Lerissa is currently offline Nick LerissaFriend
Messages: 6
Registered: July 2009
Junior Member
I am trying to use the Commands/EditPolicies framework for my GEF
application.
Although the concepts seems pretty straight forward, OpenCommand.execute()
is never called
(on a double click).

Here is the registration of the policy on the EditPart:

protected void createEditPolicies() {
installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new
GraphModelOpenPolicy());
}

Here is the policy itself:

public class GraphModelOpenPolicy extends AbstractEditPolicy {
public Command getCommand(Request request) {
if (understandsRequest(request)) {
return new OpenCommand();
}
return null;
}
public boolean understandsRequest(Request request) {
if (request.getType().equals(RequestConstants.REQ_OPEN)) {
return true;
}
return false;
}
}

And here is my command:

public class OpenCommand extends Command {
public void execute() {
System.err.println("OpenCommand called");
}
}

I noticed that performRequest is called on my edit part with the open
request, but nothing ever
get delegated to the policy.
Re: Handling REQ_OPEN requests [message #164843 is a reply to message #164803] Thu, 20 January 2005 19:13 Go to previous messageGo to next message
Brian Fernandes is currently offline Brian FernandesFriend
Messages: 68
Registered: July 2009
Member
Nick,
The GRAPHICAL_NODE_ROLE is used to create connections from / to your
EditPart, which is probably why you aren't seeing any delegation happening.

What exactly do you wish to achieve?

You can simply override performRequest in your EditPart directly without
an EditPolicy and handle REQ_OPEN requests.

Something like

public void performRequest(Request req) {
super.performRequest(req);
if (!(req.getType() == RequestConstants.REQ_OPEN)) return;
....
}

Best,
Brian.

Nick Lerissa wrote:

> I am trying to use the Commands/EditPolicies framework for my GEF
> application.
> Although the concepts seems pretty straight forward, OpenCommand.execute()
> is never called
> (on a double click).

> Here is the registration of the policy on the EditPart:

> protected void createEditPolicies() {
> installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new
> GraphModelOpenPolicy());
> }

> Here is the policy itself:

> public class GraphModelOpenPolicy extends AbstractEditPolicy {
> public Command getCommand(Request request) {
> if (understandsRequest(request)) {
> return new OpenCommand();
> }
> return null;
> }
> public boolean understandsRequest(Request request) {
> if (request.getType().equals(RequestConstants.REQ_OPEN)) {
> return true;
> }
> return false;
> }
> }

> And here is my command:

> public class OpenCommand extends Command {
> public void execute() {
> System.err.println("OpenCommand called");
> }
> }

> I noticed that performRequest is called on my edit part with the open
> request, but nothing ever
> get delegated to the policy.
Re: Handling REQ_OPEN requests [message #164858 is a reply to message #164843] Thu, 20 January 2005 19:48 Go to previous messageGo to next message
Nick Lerissa is currently offline Nick LerissaFriend
Messages: 6
Registered: July 2009
Junior Member
Thanks Brian,
Based on your response I need clarification on a couple of points:

"Brian Fernandes" <brian.fernandes@genuitec.com> wrote in message
news:csovsf$827$1@www.eclipse.org...
> Nick,
> The GRAPHICAL_NODE_ROLE is used to create connections from / to your
> EditPart, which is probably why you aren't seeing any delegation
> happening.
I thought that the String indentifying the role was just used to uniquely
identify the role. Isn't
every EditPolicy called to determine if a can provide a Command for a given
Request.

>
> What exactly do you wish to achieve?
The nodes on our canvas can be expanded and collapsed. What I want to
achieve is the following:
- User double clicks on a node to see a more detailed info
- The model for the node is notified it needs to get more detailed
information
- The view is updated to show the detailed info

>
> You can simply override performRequest in your EditPart directly without
> an EditPolicy and handle REQ_OPEN requests.
>
> Something like
>
> public void performRequest(Request req) {
> super.performRequest(req);
> if (!(req.getType() == RequestConstants.REQ_OPEN)) return; ....
> }
From reading the documentation, I thought the correct way to do this was to
use EditPolicies and Commands
and overriding EditPart.performRequest was a last resort way of doing this.
I'm unclear when to use EditPolicies
and when to override performRequest.

Thanks,
Nick
Re: Handling REQ_OPEN requests [message #164886 is a reply to message #164858] Fri, 21 January 2005 01:34 Go to previous messageGo to next message
Brian Fernandes is currently offline Brian FernandesFriend
Messages: 68
Registered: July 2009
Member
Nick,

You're right about the Role being a Unique Identifier.
What I was trying to say is that you would rather use GEF roles as they
are defined in the documentation along with their corresponding edit
policies. If you want to do something different, I suggest you define your
own role. (Which just boils down to another string)

I'm not too sure why your policy didn't get called; perhaps because
something else intercepted the request and handled it.

What you want to do seems just right for overriding performRequest. None
of the predefined roles fit your requirement, so I would go ahead and use
it.

The GEF documentation will give you a list of the Roles and the
EditPolicies usually associated with them. The EditPolicy section is quite
informative on the requests they handle & should give you an idea of when
to use EditPolicies. Personally, I have always used EditPolicies except
for when I need to detect and process a double click, wher I override
PerformRequest.

I'm sorry I can't be more insightful :)

Brian.





Nick Lerissa wrote:


> Thanks Brian,
> Based on your response I need clarification on a couple of points:

> "Brian Fernandes" <brian.fernandes@genuitec.com> wrote in message
> news:csovsf$827$1@www.eclipse.org...
>> Nick,
>> The GRAPHICAL_NODE_ROLE is used to create connections from / to your
>> EditPart, which is probably why you aren't seeing any delegation
>> happening.
> I thought that the String indentifying the role was just used to uniquely
> identify the role. Isn't
> every EditPolicy called to determine if a can provide a Command for a given
> Request.

>>
>> What exactly do you wish to achieve?
> The nodes on our canvas can be expanded and collapsed. What I want to
> achieve is the following:
> - User double clicks on a node to see a more detailed info
> - The model for the node is notified it needs to get more detailed
> information
> - The view is updated to show the detailed info

>>
>> You can simply override performRequest in your EditPart directly without
>> an EditPolicy and handle REQ_OPEN requests.
>>
>> Something like
>>
>> public void performRequest(Request req) {
>> super.performRequest(req);
>> if (!(req.getType() == RequestConstants.REQ_OPEN)) return; ....
>> }
> From reading the documentation, I thought the correct way to do this was to
> use EditPolicies and Commands
> and overriding EditPart.performRequest was a last resort way of doing this.
> I'm unclear when to use EditPolicies
> and when to override performRequest.

> Thanks,
> Nick
Re: Handling REQ_OPEN requests [message #165112 is a reply to message #164803] Fri, 21 January 2005 20:51 Go to previous message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Did you look at what performRequest() does? I believe the default
implementation is empty. Once you get the REQ_OPEN you can either forward
it to your EditPolicies or you can take a shortcut and do what Brian
suggested. As to your question about why GEF chose this route for this
particular request, I think it's because clients launch dialogs, new editors
and such on open requests, and may not have a command to be executed.

"Nick Lerissa" <nick_lerissa@yahoo.com> wrote in message
news:csou4h$tfv$1@www.eclipse.org...
> I am trying to use the Commands/EditPolicies framework for my GEF
> application.
> Although the concepts seems pretty straight forward, OpenCommand.execute()
> is never called
> (on a double click).
>
> Here is the registration of the policy on the EditPart:
>
> protected void createEditPolicies() {
> installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new
> GraphModelOpenPolicy());
> }
>
> Here is the policy itself:
>
> public class GraphModelOpenPolicy extends AbstractEditPolicy {
> public Command getCommand(Request request) {
> if (understandsRequest(request)) {
> return new OpenCommand();
> }
> return null;
> }
> public boolean understandsRequest(Request request) {
> if (request.getType().equals(RequestConstants.REQ_OPEN)) {
> return true;
> }
> return false;
> }
> }
>
> And here is my command:
>
> public class OpenCommand extends Command {
> public void execute() {
> System.err.println("OpenCommand called");
> }
> }
>
> I noticed that performRequest is called on my edit part with the open
> request, but nothing ever
> get delegated to the policy.
>
>
Previous Topic:Possible to change location of a child in a flowlayout?
Next Topic:Problem Scrolling in FigureCanvas
Goto Forum:
  


Current Time: Thu Apr 25 19:44:40 GMT 2024

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

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

Back to the top