Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to switch off lazy loading of views in perspective folder
How to switch off lazy loading of views in perspective folder [message #734134] Thu, 06 October 2011 19:58 Go to next message
Arjan Huijzer is currently offline Arjan HuijzerFriend
Messages: 9
Registered: October 2011
Junior Member
Hi all,

I have a perspective containing a top view and a folder with four stacked views:

layout.addView(WorkitemView.ID, IPageLayout.LEFT, 1.0f, IPageLayout.ID_EDITOR_AREA);
		
IFolderLayout folder = layout.createFolder("folder", IPageLayout.BOTTOM, 0.7f, WorkitemView.ID);
folder.addView(VariablesView.ID);
folder.addView(PackagesView.ID);
folder.addView(AttachmentsView.ID);
folder.addView(ErrorView.ID);


The views in the folder all need to update when a selection is made in the top view. This is accomplished by adding a selection listener. However, only the view that is actually shown reacts on the selection. When I select another view, it is still empty.

The code that adds the selection listener is placed in the view's init() method and apparently this is only called for the first view in the folder when the perspective is loaded.

Is there a way to switch off this "lazy loading" so that all views are created (and their init() method called) when the perspective is created?

Thanks in advance for any help,

Arjan
Re: How to switch off lazy loading of views in perspective folder [message #734940 is a reply to message #734134] Mon, 10 October 2011 13:29 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3801
Registered: July 2009
Senior Member
On 06.10.2011 21:58, huijzer wrote:
> Hi all,
>
> I have a perspective containing a top view and a folder with four
> stacked views:
>
> layout.addView(WorkitemView.ID, IPageLayout.LEFT, 1.0f,
> IPageLayout.ID_EDITOR_AREA);
>
> IFolderLayout folder = layout.createFolder("folder",
> IPageLayout.BOTTOM, 0.7f, WorkitemView.ID);
> folder.addView(VariablesView.ID);
> folder.addView(PackagesView.ID);
> folder.addView(AttachmentsView.ID);
> folder.addView(ErrorView.ID);
>
> The views in the folder all need to update when a selection is made in
> the top view. This is accomplished by adding a selection listener.
> However, only the view that is actually shown reacts on the selection.
> When I select another view, it is still empty.
> The code that adds the selection listener is placed in the view's
> init() method and apparently this is only called for the first view in
> the folder when the perspective is loaded.
> Is there a way to switch off this "lazy loading" so that all views are
> created (and their init() method called) when the perspective is created?
No.

Dani
>
> Thanks in advance for any help,
>
> Arjan
>
Re: How to switch off lazy loading of views in perspective folder [message #734998 is a reply to message #734940] Mon, 10 October 2011 15:39 Go to previous messageGo to next message
Daniel iCanHasLastName is currently offline Daniel iCanHasLastNameFriend
Messages: 6
Registered: May 2011
Junior Member
huijzer wrote on Thu, 06 October 2011 21:58
Hi all,

I have a perspective containing a top view and a folder with four stacked views: [...]

The views in the folder all need to update when a selection is made in the top view. [...]

Is there a way to switch off this "lazy loading" so that all views are created (and their init() method called) when the perspective is created?
[...]


Dani Megert wrote on Mon, 10 October 2011 15:29

No.

Dani
>


May i humbly ask if someone could loosely describe how to handle this kind of behaviour adequately?

I am not the OP but i try to tackle a similar problem. Would i need to use some kind of osgi-magic or do i maybe need to define some extension-point?

If you maybe do not happen to find the time to describe something, then it would be very nice if you could point out some URL's with content helping to tackle the problem.

Thank you very much in advance for all effort!
Daniel
Re: How to switch off lazy loading of views in perspective folder [message #735005 is a reply to message #734134] Mon, 10 October 2011 15:54 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
Why don't you simply fetch the current selection once the other view is
initialized?

Tom

Am 06.10.11 21:58, schrieb huijzer:
> Hi all,
>
> I have a perspective containing a top view and a folder with four
> stacked views:
>
> layout.addView(WorkitemView.ID, IPageLayout.LEFT, 1.0f,
> IPageLayout.ID_EDITOR_AREA);
>
> IFolderLayout folder = layout.createFolder("folder", IPageLayout.BOTTOM,
> 0.7f, WorkitemView.ID);
> folder.addView(VariablesView.ID);
> folder.addView(PackagesView.ID);
> folder.addView(AttachmentsView.ID);
> folder.addView(ErrorView.ID);
>
> The views in the folder all need to update when a selection is made in
> the top view. This is accomplished by adding a selection listener.
> However, only the view that is actually shown reacts on the selection.
> When I select another view, it is still empty.
> The code that adds the selection listener is placed in the view's init()
> method and apparently this is only called for the first view in the
> folder when the perspective is loaded.
> Is there a way to switch off this "lazy loading" so that all views are
> created (and their init() method called) when the perspective is created?
>
> Thanks in advance for any help,
>
> Arjan
>
Re: How to switch off lazy loading of views in perspective folder [message #735015 is a reply to message #734998] Mon, 10 October 2011 16:01 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
The only solution I could think of is to
a) Install a IPerspectiveListener
b) Interate through all Views/Editors using

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences()|getEditorReferences()

and calling
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView()|showEditor

Tom

Am 10.10.11 17:39, schrieb Daniel:
> huijzer wrote on Thu, 06 October 2011 21:58
>> Hi all,
>>
>> I have a perspective containing a top view and a folder with four
>> stacked views: [...]
>>
>> The views in the folder all need to update when a selection is made in
>> the top view. [...]
>>
>> Is there a way to switch off this "lazy loading" so that all views are
>> created (and their init() method called) when the perspective is created?
>> [...]
>
>
> Dani Megert wrote on Mon, 10 October 2011 15:29
>> No.
>>
>> Dani
>> >
>
>
> May i humbly ask if someone could loosely describe how to handle this
> kind of behaviour adequately?
> I am not the OP but i try to tackle a similar problem. Would i need to
> use some kind of osgi-magic or do i maybe need to define some
> extension-point?
>
> If you maybe do not happen to find the time to describe something, then
> it would be very nice if you could point out some URL's with content
> helping to tackle the problem.
>
> Thank you very much in advance for all effort!
> Daniel
Re: How to switch off lazy loading of views in perspective folder [message #735035 is a reply to message #735015] Mon, 10 October 2011 17:35 Go to previous messageGo to next message
Arjan Huijzer is currently offline Arjan HuijzerFriend
Messages: 9
Registered: October 2011
Junior Member
Hi Tom,

Thanks for your replies. I will try the solution using the IPerspectiveListener. If verything works as expected, I'll post again.
Once again, thanks!

Arjan
Re: How to switch off lazy loading of views in perspective folder [message #735055 is a reply to message #735035] Mon, 10 October 2011 19:38 Go to previous messageGo to next message
Arjan Huijzer is currently offline Arjan HuijzerFriend
Messages: 9
Registered: October 2011
Junior Member
Just a quick follow-up:

I have succeeded in getting the behavior I wanted. To accomplish this, I first had to add a perspective listener. This was done in the actual PerspectiveFactory class.

public class WorkflowPerspective implements IPerspectiveFactory {

	public static final String ID = "lime.workflow.perspective";
	
	@Override
	public void createInitialLayout(IPageLayout layout) {

		layout.setEditorAreaVisible(false);
		layout.setFixed(false);
		
		layout.addView(WorkitemView.ID, IPageLayout.LEFT, 1.0f, IPageLayout.ID_EDITOR_AREA);
		
		IFolderLayout folder = layout.createFolder("folder", IPageLayout.BOTTOM, 0.7f, WorkitemView.ID);
		folder.addView(VariablesView.ID);
		folder.addView(PackagesView.ID);
		folder.addView(AttachmentsView.ID);
		folder.addView(ErrorView.ID);
		
		IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		workbenchWindow.addPerspectiveListener(new MyPerspectiveAdapter());
	}

}


Next I implemented the listener by subclassing PerspectiveAdapter.

public class MyPerspectiveAdapter extends PerspectiveAdapter {

	@Override
	public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
		IViewReference[] references = page.getViewReferences();
		for (IViewReference reference : references) {
			try {
				page.showView(reference.getId(), null, IWorkbenchPage.VIEW_CREATE);
			} catch (PartInitException e) {
				throw new LimeException(e);
			}
		}
	}
	
}


Thanks for all the help!

Arjan
Re: How to switch off lazy loading of views in perspective folder [message #735214 is a reply to message #735055] Tue, 11 October 2011 09:09 Go to previous messageGo to next message
Daniel iCanHasLastName is currently offline Daniel iCanHasLastNameFriend
Messages: 6
Registered: May 2011
Junior Member
Wow, this was both helpful as i / we now know about solutions for two scenarios: the "lazy initialized" Views and the "pre-initialized" Views.

Thank you both for your continued effort to give feedback concerning this stuff!
Re: How to switch off lazy loading of views in perspective folder [message #750756 is a reply to message #735214] Tue, 25 October 2011 22:32 Go to previous message
Mahdi Yusuf is currently offline Mahdi YusufFriend
Messages: 8
Registered: January 2011
Junior Member
This would require you to reset the perspective every time the tool started in order for it to work? How can I make this run every time launch as opposed to only when I change perspectives, because my application only has one perspective?

Thanks!
Previous Topic:Discouraged access for the use of WorkbenchWindow
Next Topic:Swing + RCP problem
Goto Forum:
  


Current Time: Thu Dec 18 07:22:56 GMT 2014

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

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