Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Disable lazy loading of pages
Disable lazy loading of pages [message #900055] Fri, 03 August 2012 13:25 Go to next message
Simon Barnett is currently offline Simon Barnett
Messages: 28
Registered: July 2012
Junior Member
Hi,

I have an Eclipse editor which has several form pages each of whom have their own controls.

When my plugin starts up (ie. when the user opens it) I need to be able to actually create the form content on each form page so that I can use the EMF bindings they create - and this has to be done once which is why I want them done on editor startup, not when a page is opened.

Does anyone know if it's possible to disable the lazy loading aspect of FormPages so that all the controls are created on startup?

Thanks.
Re: Disable lazy loading of pages [message #900169 is a reply to message #900055] Sat, 04 August 2012 19:23 Go to previous messageGo to next message
John Steele is currently offline John Steele
Messages: 49
Registered: January 2010
Member
Hi Simon,

If you already know the index of the page use this:

@Override protected void addPages() {
 try {
	addPage([the page index], new OverviewPage(this, "overview", "Overview"), OverviewEditorInput.INSTANCE);
	...
 } catch (PartInitException e) {
	Logger.INSTANCE.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()));
 }
}


FormEditor calls MultiPageEditorPart, which in tern will call the FormPage's createPartControl(...).

I tested it and it works.

Hope this helps!
Re: Disable lazy loading of pages [message #900282 is a reply to message #900169] Mon, 06 August 2012 07:05 Go to previous messageGo to next message
Simon Barnett is currently offline Simon Barnett
Messages: 28
Registered: July 2012
Junior Member
Hi,

Thanks for this suggestion - but I can't quite get it to work properly.

The problem is that either:-

a) I use getEditorInput() in the main FormEditor class (the one in which I define addPages()) as the IEditorInput parameter - but this causes a StackOverflowError from the fact that FormEditor.java cals getSelection on itself recursively or

b) I use the new page's IEditorInput in the addPages() method but this says it's an illegal value.

So my question is, where do you get your OverviewEditorInput.INSTANCE from? Is this a separate class which you have written yourself? What does it do and how?

Thanks,
Simon
Re: Disable lazy loading of pages [message #900308 is a reply to message #900282] Mon, 06 August 2012 08:55 Go to previous messageGo to next message
John Steele is currently offline John Steele
Messages: 49
Registered: January 2010
Member
Hi Simon,

The editor input that I used in example is a class that I wrote, which implements IEditorInput. I use it as a singleton in this example. It's needed for when the MultiPageEditorPart calls init(site, input) on the IEditorPart (FormPage) that you are adding.

So to answer your question, you need to create a class, which will serve as your editor's input that implements IEditorInput. I have a very simple example listed here: github.com/johnsteele/eclipse-aws/blob/master/com.steelejr.eclipse.aws.dashboard/src/com/steelejr/eclipse/aws/dashboard/model/DashboardEditorInput.java

How you decide to use it is up to you.

John



Re: Disable lazy loading of pages [message #900350 is a reply to message #900308] Mon, 06 August 2012 11:08 Go to previous messageGo to next message
Simon Barnett is currently offline Simon Barnett
Messages: 28
Registered: July 2012
Junior Member
Odd.

I've created my own IEditorInput class as above but I still get the following stack overflow when I click on the particular page that I've done this way:-


java.lang.StackOverflowError
at org.eclipse.ui.part.MultiPageEditorPart.getActiveEditor(MultiPageEditorPart.java:523)
at org.eclipse.ui.forms.editor.FormEditor.getActiveEditor(FormEditor.java:430)
at org.eclipse.ui.forms.editor.FormEditor$FormEditorSelectionProvider.getSelection(FormEditor.java:84)
at org.eclipse.ui.forms.editor.FormEditor$FormEditorSelectionProvider.getSelection(FormEditor.java:89)
at org.eclipse.ui.forms.editor.FormEditor$FormEditorSelectionProvider.getSelection(FormEditor.java:89)
at org.eclipse.ui.forms.editor.FormEditor$FormEditorSelectionProvider.getSelection(FormEditor.java:89)
at org.eclipse.ui.forms.editor.FormEditor$FormEditorSelectionProvider.getSelection(FormEditor.java:89)

Any ideas?
Re: Disable lazy loading of pages [message #900352 is a reply to message #900350] Mon, 06 August 2012 11:15 Go to previous messageGo to next message
Simon Barnett is currently offline Simon Barnett
Messages: 28
Registered: July 2012
Junior Member
I think it might be related to the fact that I'm using addPage() to add a FormPage as this (closed) bug suggests.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=283039

Is this not how it's meant to be used?
Re: Disable lazy loading of pages [message #900356 is a reply to message #900350] Mon, 06 August 2012 11:26 Go to previous message
John Steele is currently offline John Steele
Messages: 49
Registered: January 2010
Member
I had no issues when I added pages to the editor this way. I put a system.out statement in the createFormContent(...) method of the FormPage and it prints out before the tab is selected, which indicates the controls where created before the tab was ever selected.

@Override protected void addPages() {
 try {
        addPage(new WelcomePage (this, "welcome", "Welcome");
	addPage(1, new OverviewPage(this, "overview", "Overview"), OverviewEditorInput.INSTANCE);
	...
 } catch (PartInitException e) {
	Logger.INSTANCE.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()));
 }
}


I then invoke it this way:

FormEditor editor = (FormEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(DashboardEditorInput.INSTANCE, AwsDashboardEditor.ID);
editor.setActivePage(activePageID);


I can fool around with it later when I get home to see if I can replicate the StackOverflowError you're getting.
Previous Topic:Hook into button from Toolbar
Next Topic:Modify indent of tree elements
Goto Forum:
  


Current Time: Thu Jul 24 11:21:29 EDT 2014

Powered by FUDForum. Page generated in 0.02204 seconds