Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Force view to initialize before focus?
Force view to initialize before focus? [message #462289] Thu, 25 January 2007 17:58 Go to next message
Jason is currently offline JasonFriend
Messages: 45
Registered: July 2009
Member
Ok, I'm fairly new to RCP, so this might an obvious question:

I've built my RCP app, which is pretty basic. I have several views that fill the left hand side of the screen that are arranged in a tab folder.

What I have noticed is that a view class is not actually initiated until I click on on the tab that actually gives it focus. That is probably normal lazy instantiation by design, but it actually creates a problem for me. My problem is that when I load that view, I do some initial loading of information that requires classes (via extension points) from other plug-ins that I've developed that feed into the view.

Because the View doesn't init() until I click on it, all of those external plug-ins get loaded when I click on the tab to give that view the focus. The problem with that is that I don't want the user to wait for the plug-ins to load when they click on the tab. Instead, when the app loads (and this view is part of the initial workbench), I want to initialize the view there so that the plug-ins are loaded at startup (perceived performance boost).

Is that possible? I can get into more detail if need be, but I tried to make the question as simplistic as possible...

P.S. Just in case someone else thinks of removing the lazy instantiation of the plug-ins, I can't do that. Not ALL of my plug-ins need to be loaded to contribute to this view. The number of plug-ins I need is variable to which perspective I'm in.
Re: Force view to initialize before focus? [message #462293 is a reply to message #462289] Thu, 25 January 2007 19:04 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Probably the best pattern is to have some kind of extension point
registry ... that can be started by your early startup plugin and
collect whatever information that you need. Then when your view comes
up, the information would already be available in the registry.

But there are some options in IWorkbenchPage#showView(String, String,
int) to instantiate a view without causing it to activate. And you can
also get the IViewReference and do a getPart(true). But both of these
methods are counter to the lazy initialization philosophy of eclipse.

Later,
PW


Re: Force view to initialize before focus? [message #462359 is a reply to message #462289] Sat, 27 January 2007 17:36 Go to previous messageGo to next message
Ilya Shinkarenko is currently offline Ilya ShinkarenkoFriend
Messages: 22
Registered: July 2009
Junior Member
Hi Jason,

in addition to Paul's comments: maybe it is worth looking at extension
point "org.eclipse.ui.startup"

Ilya


Jason wrote:
> Ok, I'm fairly new to RCP, so this might an obvious question:
>
> I've built my RCP app, which is pretty basic. I have several views that fill the left hand side of the screen that are arranged in a tab folder.
>
> What I have noticed is that a view class is not actually initiated until I click on on the tab that actually gives it focus. That is probably normal lazy instantiation by design, but it actually creates a problem for me. My problem is that when I load that view, I do some initial loading of information that requires classes (via extension points) from other plug-ins that I've developed that feed into the view.
>
> Because the View doesn't init() until I click on it, all of those external plug-ins get loaded when I click on the tab to give that view the focus. The problem with that is that I don't want the user to wait for the plug-ins to load when they click on the tab. Instead, when the app loads (and this view is part of the initial workbench), I want to initialize the view there so that the plug-ins are loaded at startup (perceived performance boost).
>
> Is that possible? I can get into more detail if need be, but I tried to make the question as simplistic as possible...
>
> P.S. Just in case someone else thinks of removing the lazy instantiation of the plug-ins, I can't do that. Not ALL of my plug-ins need to be loaded to contribute to this view. The number of plug-ins I need is variable to which perspective I'm in.
Re: Force view to initialize before focus? [message #462436 is a reply to message #462359] Mon, 29 January 2007 15:13 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Ilya Shinkarenko wrote:
> Hi Jason,
>
> in addition to Paul's comments: maybe it is worth looking at extension
> point "org.eclipse.ui.startup"

Just as an aside ... don't use org.eclipse.ui.startup. That's the best
practice :-)

If it is necessary, it should be used for certain kinds of application
re-initialization ... pre-populating your registry with saved data,
potentially starting up a socket connection for some kind of server
plugin, basically datamodel type initialization, etc.

But it is preferable to do that in a plugin with no UI dependencies.

Later,
PW


Re: Force view to initialize before focus? [message #462546 is a reply to message #462289] Tue, 30 January 2007 14:31 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
> Because the View doesn't init() until I click on it, all of those
> external plug-ins get loaded when I click on the tab to give that
> view the focus. The problem with that is that I don't want the
> user to wait for the plug-ins to load when they click on the tab.
> Instead, when the app loads (and this view is part of the initial
> workbench), I want to initialize the view there so that the
> plug-ins are loaded at startup (perceived performance boost).

For me, if I installed a plugin and it made startup slower, I'd say that was a perceived performance slowdown and uninstall the plugin.

The whole point of Eclipse's lazy instantiation is to do the minimum amount of work necessary at each stage. Therefore, the cost of startup is amortized over all the different elements that get brought into play rather than one big hit up front.

If there's a lot of work to be done, you don't have to do it in the UI thread ... you can spin out a separate non-UI job which then updates the results in the view.

Alex.
Re: Force view to initialize before focus? [message #462547 is a reply to message #462289] Tue, 30 January 2007 14:34 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
> Because the View doesn't init() until I click on it, all of those
> external plug-ins get loaded when I click on the tab to give that
> view the focus. The problem with that is that I don't want the
> user to wait for the plug-ins to load when they click on the tab.
> Instead, when the app loads (and this view is part of the initial
> workbench), I want to initialize the view there so that the
> plug-ins are loaded at startup (perceived performance boost).

For me, if I installed a plugin and it made startup slower, I'd say that was a perceived performance slowdown and uninstall the plugin.

The whole point of Eclipse's lazy instantiation is to do the minimum amount of work necessary at each stage. Therefore, the cost of startup is amortized over all the different elements that get brought into play rather than one big hit up front.

If there's a lot of work to be done, you don't have to do it in the UI thread ... you can spin out a separate non-UI job which then updates the results in the view.

Alex.
Re: Force view to initialize before focus? [message #462585 is a reply to message #462289] Tue, 30 January 2007 21:58 Go to previous message
Eclipse UserFriend
Originally posted by: askme.fake.net

On Thu, 25 Jan 2007 12:58:31 -0500, Jason wrote:

> Ok, I'm fairly new to RCP, so this might an obvious question:
>
> I've built my RCP app, which is pretty basic. I have several views that
> fill the left hand side of the screen that are arranged in a tab folder.
>
> What I have noticed is that a view class is not actually initiated until
> I click on on the tab that actually gives it focus. That is probably
> normal lazy instantiation by design, but it actually creates a problem
> for me. My problem is that when I load that view, I do some initial
> loading of information that requires classes (via extension points) from
> other plug-ins that I've developed that feed into the view.
>
> Because the View doesn't init() until I click on it, all of those
> external plug-ins get loaded when I click on the tab to give that view
> the focus. The problem with that is that I don't want the user to wait
> for the plug-ins to load when they click on the tab. Instead, when the
> app loads (and this view is part of the initial workbench), I want to
> initialize the view there so that the plug-ins are loaded at startup
> (perceived performance boost).
>
> Is that possible? I can get into more detail if need be, but I tried to
> make the question as simplistic as possible...
>
> P.S. Just in case someone else thinks of removing the lazy instantiation
> of the plug-ins, I can't do that. Not ALL of my plug-ins need to be
> loaded to contribute to this view. The number of plug-ins I need is
> variable to which perspective I'm in.


Sure many ways. One of my views loads templates before it can show. I
load the data when the plugin is started as opposed to when when the view
is initialized. Your going to take the hit somewhere, you just need to
decide where.

Also you want to try and keep the hit out of the GUI thread so the user
wont have any GUI unresponsivenesss. Plus you can use a job so if your
user wonders WTH is all that disk thrashing, he can look at the progress
bar and see...
Previous Topic:Browser image question
Next Topic:What is rcp plugin?
Goto Forum:
  


Current Time: Wed Jan 15 07:32:04 GMT 2025

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

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

Back to the top