Life cycle of a view [message #254303] |
Mon, 21 June 2004 12:23  |
Eclipse User |
|
|
|
Originally posted by: hildegarde_roth.hayoo.de
Even after reading the help and searching this forum, I am still
in the dark as to the life cycle of a view. How do you check that
the unique view instance you want to show exists and if it doesn't
create one programmatically? Whose responsibility is it?
IWorkbenchPage.showView looks like a good fit but since it can
return a null and the javadoc does not say in _which_ circumstances
a null is returned (only if the id is not recognized or in other
scenarios as well?) this is not clear. Furthermore I may want to
instantiate the view without showing it rigth away. There is a
companion findView method but from looking at the source it does
not look like it will instantiate anything.
So, what is the proper way to go about this?
Hilde
PS: Since views are singletons I am surprised that the same pattern
as in plugin classes, i.e., of a static getInstance method, is not
used with view classes, too.
|
|
|
Re: Life cycle of a view [message #254366 is a reply to message #254303] |
Mon, 21 June 2004 15:15   |
Eclipse User |
|
|
|
Hilde Roth schrieb:
> Even after reading the help and searching this forum, I am still
> in the dark as to the life cycle of a view. How do you check that
> the unique view instance you want to show exists and if it doesn't
> create one programmatically? Whose responsibility is it?
There is a failure in your thoughts: Views can have multiple instances.
> IWorkbenchPage.showView looks like a good fit
Yep. It will return an instance of the view, so it is not your
responsibility.
but since it can
> return a null and the javadoc does not say in _which_ circumstances
> a null is returned (only if the id is not recognized or in other
> scenarios as well?) this is not clear.
That's completely irrelevant. If it can't be created, it can't be
created. You cannot change anything of this fact and it should not even
bother you, who/where/when/why it could not be created.
Furthermore I may want to
> instantiate the view without showing it rigth away. There is a
> companion findView method but from looking at the source it does
> not look like it will instantiate anything.
Why would one want to do this? A view is for interaction with the user.
If I create a view then I want to show it. If you want to execute code
without showing the view then this code should belong to something else
but definitely not to the view.
(BTW: There are methods which get called before your view is shown)
> So, what is the proper way to go about this?
Rethinking your design...
> PS: Since views are singletons I am surprised that the same pattern
> as in plugin classes, i.e., of a static getInstance method, is not
> used with view classes, too.
See above.
Ciao, Michael.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03025 seconds