Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » how (and when) are view constructed?(what are constraints on view constructor?)
how (and when) are view constructed? [message #512762] Sun, 07 February 2010 10:37 Go to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
I'm curious to know when are view instantiated during the application lifecycle, since the layout factory simply refers to their ID I believe the view is created when first used in a perspective. And what are the constraints on view constructors? For instace, is it possible to use a factory method to create a view?
Re: how (and when) are view constructed? [message #512822 is a reply to message #512762] Mon, 08 February 2010 05:51 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 07/02/10 4:07 PM, Luca Ferrari wrote:
> I'm curious to know when are view instantiated during the application
> lifecycle, since the layout factory simply refers to their ID I believe
> the view is created when first used in a perspective. And what are the
> constraints on view constructors? For instace, is it possible to use a
> factory method to create a view?
>

You are right. A viewpart is instantiated only when it is required.
Even if its added to a perspective, it won't be instantiated if its not
visible initially (some other view is active and visible in the same folder)

--
- Prakash
Platform UI Team, IBM

Blog <http://blog.eclipse-tips.com>
Twitter <http://www.twitter.com/Eclipse_Tips>
Re: how (and when) are view constructed? [message #512910 is a reply to message #512822] Mon, 08 February 2010 10:48 Go to previous messageGo to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
But is there a way to instrument eclipse to use afactory method (something like getInstance()) instead of the default constructor?
Moreover, can I assume a view is always a singleton in the rcp platform?
Re: how (and when) are view constructed? [message #513009 is a reply to message #512910] Mon, 08 February 2010 15:02 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Luca Ferrari wrote:
> But is there a way to instrument eclipse to use afactory method
> (something like getInstance()) instead of the default constructor?
> Moreover, can I assume a view is always a singleton in the rcp platform?

It's never that simple :-)

A view is constructed when it is show for the first time in a
perspective (either because it's part of the perspective or because of a
user showView).

Lifecycle:
no-arg constructor
init(*)
createPartControl(*)
....
dispose()

Within one window, there will only be one instance of a view with that
exact ID (one outline view, for example). But if you open 2 windows,
you can have 2 outline view instances. Closing a view (so it is
disposed) and then opening the view again causes a new instances to be
created (the other already being disposed).

You *could* use org.eclipse.core.runtime.IExecutableExtensionFactory
instead of the view class to allow more control over instantiating the
view itself ... except when create() is called it still has to be
unique, as there's no way to tell what the framework will use it for.

Later,
PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:What's the id of the copy entry in the non-text editor popup menu?
Next Topic:Plug-in stop() be terminated before completion.
Goto Forum:
  


Current Time: Thu Nov 27 17:31:13 GMT 2014

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

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