Home » Eclipse Projects » Rich Client Platform (RCP) » global undo
|
Re: global undo [message #444330 is a reply to message #444304] |
Mon, 13 February 2006 22:04 |
Martin Wood Messages: 28 Registered: July 2009 |
Junior Member |
|
|
Ok, well a minor update.
I notice that after I tried adding this in my view's createPartControl :
IUndoContext undoContext =
PlatformUI.getWorkbench().getOperationSupport().getUndoConte xt();
getViewSite().getActionBars().setGlobalActionHandler(ActionF actory.UNDO.getId(),
new UndoActionHandler(getSite(), undoContext));
getViewSite().getActionBars().setGlobalActionHandler(ActionF actory.REDO.getId(),
new RedoActionHandler(getSite(), undoContext));
as described in an earlier thread, then the menu items from undo / redo are
activated, but only when that view has the focus.
Is there any way to make the undo / redo menu items available no matter which
window has the focus?
I thought that using this 'global undo context' would provide for that but it
doesnt appear to..although i think that im really misunderstanding how this
system is supposed to work.
thanks,
Martin
Martin Wood wrote:
> Hello,
>
> I've searched the archives and read as much as i can but i still cant
> figure out how to get the undo and redo buttons to activate after
> performing an undoable operation.
|
|
|
Re: global undo [message #444338 is a reply to message #444330] |
Tue, 14 February 2006 05:59 |
rick cameron Messages: 9 Registered: July 2009 |
Junior Member |
|
|
Hi, Martin
I think you're trying to do the same thing I am - see my posting from 12/02.
It looks to me like the undo framework is oriented to each view or editor
having its own undo stack. Thus, the actions that are put on the menu defer
to the action handler in the active view/editor. If there is no action
handler for undo (resp. redo) in the active view/editor (or no operation to
undo/redo) the action, and therefore the menu item, is disabled.
If you want to have a single undo stack for the whole app, and have the menu
items always enabled when there is an operation to be undone or redone, I
think you'd have to write a different implementation of IAction that doesn't
defer to the active view/editor, but just queries the operation history
directly. As I said in my posting, you'd probably combine code from the
standard undo/redo actions and the standard action handlers.
If I get this going, I'll let you know.
Cheers
- rick
"Martin Wood" <flashdev@relivethefuture.com> wrote in message
news:dsqvp5$h0t$1@utils.eclipse.org...
> Ok, well a minor update.
>
> I notice that after I tried adding this in my view's createPartControl :
>
> IUndoContext undoContext =
> PlatformUI.getWorkbench().getOperationSupport().getUndoConte xt();
>
> getViewSite().getActionBars().setGlobalActionHandler(ActionF actory.UNDO.getId(),
> new UndoActionHandler(getSite(), undoContext));
>
> getViewSite().getActionBars().setGlobalActionHandler(ActionF actory.REDO.getId(),
> new RedoActionHandler(getSite(), undoContext));
>
> as described in an earlier thread, then the menu items from undo / redo
> are activated, but only when that view has the focus.
>
> Is there any way to make the undo / redo menu items available no matter
> which window has the focus?
>
> I thought that using this 'global undo context' would provide for that but
> it doesnt appear to..although i think that im really misunderstanding how
> this system is supposed to work.
>
> thanks,
>
> Martin
>
>
> Martin Wood wrote:
>> Hello,
>>
>> I've searched the archives and read as much as i can but i still cant
>> figure out how to get the undo and redo buttons to activate after
>> performing an undoable operation.
|
|
|
Re: global undo [message #444346 is a reply to message #444338] |
Tue, 14 February 2006 12:01 |
Martin Wood Messages: 28 Registered: July 2009 |
Junior Member |
|
|
rick cameron wrote:
> Hi, Martin
>
> I think you're trying to do the same thing I am - see my posting from 12/02.
ah, yes.. my thunderbird based searching abilities didnt pick that up for some
reason.
> It looks to me like the undo framework is oriented to each view or editor
> having its own undo stack. Thus, the actions that are put on the menu defer
> to the action handler in the active view/editor. If there is no action
> handler for undo (resp. redo) in the active view/editor (or no operation to
> undo/redo) the action, and therefore the menu item, is disabled.
Yeah, thats about how i understand it as well.
> If you want to have a single undo stack for the whole app, and have the menu
> items always enabled when there is an operation to be undone or redone, I
> think you'd have to write a different implementation of IAction that doesn't
> defer to the active view/editor, but just queries the operation history
> directly. As I said in my posting, you'd probably combine code from the
> standard undo/redo actions and the standard action handlers.
ok, thanks for the ideas, i'll look into it some more as well and see what i
come up with.
The situation im aiming for is to have a global undo stack combined with local
undo for particular editors. So operations that are related to View A are always
available whereas operations that are related to Editor B are only available
when it is active.
Im thinking that i might need to use multiple contexts to achieve this, where
every view / editor uses the global context but can also specify its own
particular context.
> If I get this going, I'll let you know.
Please do. I'll also post here if i get any further.
thanks,
Martin
|
|
|
Re: global undo [message #444547 is a reply to message #444338] |
Fri, 17 February 2006 11:29 |
Eclipse User |
|
|
|
Originally posted by: daniel.megert.eclipse.org
rick cameron wrote:
>Hi, Martin
>
>I think you're trying to do the same thing I am - see my posting from 12/02.
>
>It looks to me like the undo framework is oriented to each view or editor
>having its own undo stack. Thus, the actions that are put on the menu defer
>to the action handler in the active view/editor. If there is no action
>handler for undo (resp. redo) in the active view/editor (or no operation to
>undo/redo) the action, and therefore the menu item, is disabled.
>
>
You're right, the story is per active part but those parts can all have
the same context (or in other words: undo stack). Important is that each
part registers the Undo/RedoActionHandler with that same context via
setGlobalActionHandler(...). If you only need a global context then
you're best bet is to use IOperationHistory.GLOBAL_UNDO_CONTEXT.
Dani
>If you want to have a single undo stack for the whole app, and have the menu
>items always enabled when there is an operation to be undone or redone, I
>think you'd have to write a different implementation of IAction that doesn't
>defer to the active view/editor, but just queries the operation history
>directly. As I said in my posting, you'd probably combine code from the
>standard undo/redo actions and the standard action handlers.
>
>If I get this going, I'll let you know.
>
>Cheers
>
>- rick
>
>"Martin Wood" <flashdev@relivethefuture.com> wrote in message
>news:dsqvp5$h0t$1@utils.eclipse.org...
>
>
>>Ok, well a minor update.
>>
>>I notice that after I tried adding this in my view's createPartControl :
>>
>>IUndoContext undoContext =
>> PlatformUI.getWorkbench().getOperationSupport().getUndoConte xt();
>>
>> getViewSite().getActionBars().setGlobalActionHandler(ActionF actory.UNDO.getId(),
>>new UndoActionHandler(getSite(), undoContext));
>>
>> getViewSite().getActionBars().setGlobalActionHandler(ActionF actory.REDO.getId(),
>>new RedoActionHandler(getSite(), undoContext));
>>
>>as described in an earlier thread, then the menu items from undo / redo
>>are activated, but only when that view has the focus.
>>
>>Is there any way to make the undo / redo menu items available no matter
>>which window has the focus?
>>
>>I thought that using this 'global undo context' would provide for that but
>>it doesnt appear to..although i think that im really misunderstanding how
>>this system is supposed to work.
>>
>>thanks,
>>
>>Martin
>>
>>
>>Martin Wood wrote:
>>
>>
>>>Hello,
>>>
>>>I've searched the archives and read as much as i can but i still cant
>>>figure out how to get the undo and redo buttons to activate after
>>>performing an undoable operation.
>>>
>>>
>
>
>
>
|
|
|
Goto Forum:
Current Time: Sat Dec 07 14:58:41 GMT 2024
Powered by FUDForum. Page generated in 0.03707 seconds
|