Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Life cycle of a view
Life cycle of a view [message #254303] Mon, 21 June 2004 12:23 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Life cycle of a view [message #254375 is a reply to message #254366] Mon, 21 June 2004 15:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hildegarde_roth.hayoo.de

> There is a failure in your thoughts: Views can have multiple instances.

Misinformation perhaps but no failure in my thoughts: the 2.1.3 manual
quite explicitely says that there can be only one instance of each view
per workbench page. Beside if several instances of the same view could
exist, findView should return a vector and it doesn't.

> Why would one want to do this?

I want to populate the view before showing it. It is good practice to
build your object in the background and show them only when they are
really ready.

> See above.

Ditto.

Hilde
Re: Life cycle of a view [message #254391 is a reply to message #254375] Mon, 21 June 2004 16:07 Go to previous messageGo to next message
Eclipse UserFriend
Hilde Roth wrote:

> I want to populate the view before showing it. It is good practice to
> build your object in the background and show them only when they are
> really ready.

You could fill your view in the "createContent" function, the view will
not appear until you end this function ( but the GUI will freeze ).

Before this call the GUI part of a view doesn't exist at all ( and
cannot exist, because it would lack the link to the parent composite ).

If you want to initialize a datamodel, just put it into another class or
initialize it in the constructor of the view.

Henning Rogge
Re: Life cycle of a view [message #254397 is a reply to message #254391] Mon, 21 June 2004 16:34 Go to previous message
Eclipse UserFriend
Originally posted by: hildegarde_roth.hayoo.de

Thanks. Should I also read about fast views or is it unrelated?

Hilde
Previous Topic:How is Eclipse's swing integration these days?
Next Topic:Problem with classpath after closing Eclipse 3.0RC2
Goto Forum:
  


Current Time: Fri May 09 21:04:37 EDT 2025

Powered by FUDForum. Page generated in 0.03025 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top