request and Action [message #192633] |
Sat, 20 August 2005 21:25 |
Eclipse User |
|
|
|
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 |
Andreas Holtz 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 |
Eclipse User |
|
|
|
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.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04468 seconds