| When is it save to access a view instance? [message #301314] |
Tue, 28 March 2006 02:33  |
Eclipse User |
|
|
|
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at
Hi,
I want to access the instance of a view. The view is part of my default
perspective and will thus be loaded on startup. When is it save query
it, i.e. in what method of the plug-in lifecycle can I assume that all
view instances have been created? [I'd query it with
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().findView]
BTW, my target view is the PropertyView (IPageLayout.ID_PROP_SHEET). I
plan to update it with its #refresh method when the properties of object
it displays are changed in another view. I know that's a hack, so if
there is a nicer way to do that, I'd be happy to learn about it :)
Thanks,
M
|
|
|
| Re: When is it save to access a view instance? [message #301352 is a reply to message #301314] |
Wed, 29 March 2006 07:57   |
Eclipse User |
|
|
|
martin wrote:
> Hi,
>
> I want to access the instance of a view. The view is part of my default
> perspective and will thus be loaded on startup. When is it save query
> it, i.e. in what method of the plug-in lifecycle can I assume that all
> view instances have been created? [I'd query it with
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().findView]
From within a view, you would probably use
getSite().getPage().findView(*) or findViewReference(*).
The problem is when you're view is recreated on startup, there are 2
cases. 1) your view is visible, and it's part is actually created. 2)
it's not visible (behind tabs) and so only it's IViewReference is created.
The other view has the same constraint.
Even in the #1 case, there's no guarranteed order ... your view could be
created before the second view.
If you really need to act on the second view, I'd ...
1) do your getSite().getPage().findView(*) ... if you get it, do what
you want.
2) if you don't attach an IPartListener2 to the page. When the second
view is created, then you can notify your view to do something with it.
Later,
PW
|
|
|
| Re: When is it save to access a view instance? [message #301355 is a reply to message #301352] |
Wed, 29 March 2006 08:58  |
Eclipse User |
|
|
|
Originally posted by: address.starts.after.hyphen-martin.umgeher.joanneum.at
Paul Webster wrote:
> martin wrote:
>> Hi,
>>
>> I want to access the instance of a view. The view is part of my
>> default perspective and will thus be loaded on startup. When is it
>> save query it, i.e. in what method of the plug-in lifecycle can I
>> assume that all view instances have been created? [I'd query it with
>> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().findView]
>
>
> From within a view, you would probably use
> getSite().getPage().findView(*) or findViewReference(*).
>
> The problem is when you're view is recreated on startup, there are 2
> cases. 1) your view is visible, and it's part is actually created. 2)
> it's not visible (behind tabs) and so only it's IViewReference is created.
>
> The other view has the same constraint.
>
> Even in the #1 case, there's no guarranteed order ... your view could be
> created before the second view.
>
> If you really need to act on the second view, I'd ...
>
> 1) do your getSite().getPage().findView(*) ... if you get it, do what
> you want.
>
> 2) if you don't attach an IPartListener2 to the page. When the second
> view is created, then you can notify your view to do something with it.
>
> Later,
> PW
Thanks for your input. What seems to work for me is to access the view
in my WorkbenchWindowAdvisor implementation's postWindowOpen method. Of
course, I still have to assume that the view is not hidden, but for my
special case I can assume so because I define the initial perspective.
It still is a hack though.. but without this, using the property sheet
view seems quite useless to me.
Thanks,
M
|
|
|
Powered by
FUDForum. Page generated in 0.03454 seconds