Undo in properties view [message #297658] |
Wed, 18 January 2006 05:46  |
Eclipse User |
|
|
|
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at
Hi,
I use the undo system in my views by registering them to the global
action handler of UNDO/REDO actions, which works fine: When an undo
operation is executed by the operation history, it can be undone by
pressing an undo toolbar button.
I also want to use undo in my IPropertySources that are used by the
platform's properties view (IPageLayout.ID_PROP_SHEET). How can I
register this view to the undo system in order to enable the undoability
of operations executed inside of it?
[As a short scenario description why I want to use this: I have a view
showing a list of Foos which can be renamed in this view; and the
currerntly selected Foo's properties are displayed in the properties
view where I can edit the name as well. In the first case, I can undo
the renaming; in the second, I can't.]
Thanks,
Martin
|
|
|
Re: Undo in properties view [message #297660 is a reply to message #297658] |
Wed, 18 January 2006 05:59   |
Eclipse User |
|
|
|
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at
martin wrote:
> Hi,
>
> I use the undo system in my views by registering them to the global
> action handler of UNDO/REDO actions, which works fine: When an undo
> operation is executed by the operation history, it can be undone by
> pressing an undo toolbar button.
>
> I also want to use undo in my IPropertySources that are used by the
> platform's properties view (IPageLayout.ID_PROP_SHEET). How can I
> register this view to the undo system in order to enable the undoability
> of operations executed inside of it?
>
> [As a short scenario description why I want to use this: I have a view
> showing a list of Foos which can be renamed in this view; and the
> currerntly selected Foo's properties are displayed in the properties
> view where I can edit the name as well. In the first case, I can undo
> the renaming; in the second, I can't.]
Ok, found a (the?) solution:
First, I get the view site of the properties view:
IViewSite site =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().findView(IPageLayout.ID_PROP_SHEET).getViewSite();
Then, I use this site to register at the global action handler:
site.getActionBars().setGlobalActionHandler(
ActionFactory.UNDO.getId(),
new UndoActionHandler(site, context));
Is this the right way?
|
|
|
Re: Undo in properties view [message #297719 is a reply to message #297660] |
Wed, 18 January 2006 14:40   |
Eclipse User |
|
|
|
Originally posted by: nick_edgar._no.spam.please_.ca.ibm.com
Martin,
That is the correct way to hook a handler for undo/redo. However, this
is normally done by the view itself. You'll likely run into lifecycle
issues if you do this from outside the view (e.g. from the property source).
You may need to provide your own property sheet implementation to the
Properties view. You can do this by having your source view or editor
override getAdapter(Class), check for IPropertySheetPage.class, and
return your own subclass of PropertySheetPage. Or you can implement
IPropertySheetPage from scratch if you want to present your properties
differently than the default page.
You can then override createControl as follows:
public void createControl(Composite parent) {
super.createControl(parent);
getSite().getActionBars().setGlobalActionHandler(...);
}
This is a general problem though. The Properties view should probably
be changed to redirect undo/redo to its current source part.
For a related issue around the Save action, see:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=112225#c11
Providing your own subclass may also be required to address your other
question about updates. See my reply to your "How to update the
properties view?" post.
Nick
martin wrote:
> martin wrote:
>
>> Hi,
>>
>> I use the undo system in my views by registering them to the global
>> action handler of UNDO/REDO actions, which works fine: When an undo
>> operation is executed by the operation history, it can be undone by
>> pressing an undo toolbar button.
>>
>> I also want to use undo in my IPropertySources that are used by the
>> platform's properties view (IPageLayout.ID_PROP_SHEET). How can I
>> register this view to the undo system in order to enable the
>> undoability of operations executed inside of it?
>>
>> [As a short scenario description why I want to use this: I have a view
>> showing a list of Foos which can be renamed in this view; and the
>> currerntly selected Foo's properties are displayed in the properties
>> view where I can edit the name as well. In the first case, I can undo
>> the renaming; in the second, I can't.]
>
>
> Ok, found a (the?) solution:
>
> First, I get the view site of the properties view:
> IViewSite site =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().findView(IPageLayout.ID_PROP_SHEET).getViewSite();
>
>
> Then, I use this site to register at the global action handler:
> site.getActionBars().setGlobalActionHandler(
> ActionFactory.UNDO.getId(),
> new UndoActionHandler(site, context));
>
> Is this the right way?
|
|
|
|
Re: Undo in properties view [message #297778 is a reply to message #297741] |
Thu, 19 January 2006 11:09  |
Eclipse User |
|
|
|
Originally posted by: nick_edgar._no.spam.please_.ca.ibm.com
Sigh. I've filed a bug for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=124495
You could try the approach used by EMF-generated editors, which is to
delegate back to the source part and use its actions directly in the
property sheet page's action bars.
See the bug report above for more details.
Nick
martin wrote:
>> You can then override createControl as follows:
>> public void createControl(Composite parent) {
>> super.createControl(parent);
>> getSite().getActionBars().setGlobalActionHandler(...);
>> }
>
>
> I have troubles with this approach: PropertySheetPage.getSite returns a
> PageSite which is an IWorkbenchSite, but the action handlers
> (RedoActionHandler and UndoActionHandler; org.eclipse.ui.operations)
> require an IWorkbenchPartSite, so I cannot perform the action handler
> registration from the PropertySheetPage... Any ideas how to work around
> this problem?
|
|
|
Powered by
FUDForum. Page generated in 0.06850 seconds