Skip to main content



      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 15:58 Go to next message
Eclipse UserFriend
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 09:29 Go to previous messageGo to next message
Eclipse UserFriend
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 11:39 Go to previous messageGo to next message
Eclipse UserFriend
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 11:54 Go to previous messageGo to next message
Eclipse UserFriend
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 12:01 Go to previous messageGo to next message
Eclipse UserFriend
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 13:35 Go to previous messageGo to next message
Eclipse UserFriend
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 15:38 Go to previous messageGo to next message
Eclipse UserFriend
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 05:09 Go to previous messageGo to next message
Eclipse UserFriend
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 18:32 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 13:26:26 EDT 2025

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

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

Back to the top