Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » request and Action
request and Action [message #192633] Sat, 20 August 2005 21:25 Go to next message
Eclipse UserFriend
Originally posted by: tankun.web.de

hi all,
i have a problem about the relation between request(editpolicy) and Action.
is there a essential relation between the request(editpolicy) and Action?
because i see all the Actions(for examlpe in logic) get the their command
via editpart(request).

can actions directly initial their command and then excucte()?

because i have done some experiment about this,but there is a streng
problem:

i excute a action via contextmenu,but the correlative command will not be
excuted.at first i think the command is not in the commandstack.but then i
find,wenn i click "undo",the undo() in the command will be excuted,and the
redo() too.

can u give me a tipp,where i mistake made.

thanks
Re: request and Action [message #192641 is a reply to message #192633] Sun, 21 August 2005 16:14 Go to previous messageGo to next message
Andreas Holtz is currently offline Andreas HoltzFriend
Messages: 53
Registered: July 2009
Member
tan kun schrieb am 20.08.2005 23:25:
> hi all,
> i have a problem about the relation between request(editpolicy) and Action.
> is there a essential relation between the request(editpolicy) and Action?
> because i see all the Actions(for examlpe in logic) get the their
> command via editpart(request).

A request is given to an Editpart which ask all his edipolicies, if one does understand it. If an editpolicy understands a request it will
create a command for it.

> can actions directly initial their command and then excucte()?

yes. at least the logic example handles it that way. If you implement you action, you can get the command for example like this:

private Command getCommand() {
List editparts = getSelectedObjects();
CompoundCommand cc = new CompoundCommand();
cc.setDebugLabel("Increment/Decrement LEDs");//$NON-NLS-1$
for (int i=0; i < editparts.size(); i++) {
EditPart part = (EditPart)editparts.get(i);
cc.add(part.getCommand(request));
}
return cc;
}

you execute the command within the run()-method of the action:

public void run() {
execute(getCommand());
}

This is taken from IncrementDecrementAction which extends org.eclipse.gef.ui.actions.SelectionAction and it works for me ;-)

>
> because i have done some experiment about this,but there is a streng
> problem:
>
> i excute a action via contextmenu,but the correlative command will not
> be excuted.at first i think the command is not in the commandstack.but
> then i find,wenn i click "undo",the undo() in the command will be
> excuted,and the redo() too.

set a breakpoint in the execute()-method of your command or even in the corresponding getCommand()-method of your editpolicy and see, if all
informations a correctly set.
Re: request and Action [message #192657 is a reply to message #192641] Mon, 22 August 2005 10:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tankun.web.de

thank u for ur help:)
i have the getCommand() like this,
private commnad getCommand()
...
...
...
Command commd=new XYZCommnad();
...
CompoundCommand cc = new CompoundCommand();
cc.add(commd);
..
..

the command is realized directly in the getCommand(),not via a
editpolicy(request) Format.


and i do set a breakpoint on the command.excute(),but the method is not be
called.
Re: request and Action [message #192858 is a reply to message #192657] Tue, 23 August 2005 10:02 Go to previous messageGo to next message
Andreas Holtz is currently offline Andreas HoltzFriend
Messages: 53
Registered: July 2009
Member
tan kun schrieb am 22.08.2005 12:32:
> thank u for ur help:)
> i have the getCommand() like this,
> private commnad getCommand()
> ...
> ...
> ...
> Command commd=new XYZCommnad();
> ...
> CompoundCommand cc = new CompoundCommand();
> cc.add(commd);
> ..
> ..
>
> the command is realized directly in the getCommand(),not via a
> editpolicy(request) Format.
>
>
> and i do set a breakpoint on the command.excute(),but the method is not
> be called.
>
>
>

do you execute the CompoundCommand in the run()-method of your action?
and getCommand() must return the CompoundCommand.
Re: request and Action [message #193697 is a reply to message #192858] Sat, 27 August 2005 00:11 Go to previous message
Eclipse UserFriend
Originally posted by: tankun.web.de

thanks ur help!!

it is running.
i make a very lowly mistake.
Previous Topic:Accessible edit parts drag?
Next Topic:draw2d-Figures no visible after changing from GEF3.0 to GEF 3.1
Goto Forum:
  


Current Time: Fri Apr 26 15:19:34 GMT 2024

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

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

Back to the top