Dynamic View throws error on restart [message #483233] |
Mon, 31 August 2009 12:45  |
Eclipse User |
|
|
|
I have a project of which the user can input data and generate a view.
Then can input different multiples of data generating multiple views. I
also save all this data in a persisted value so that on program restart,
the views can still be presented as if the program never changed.
When the views are created, they create fine. When I restart the program
and the framework tries to reactivate the dynamic views, I receive a
org.eclipse.ui.PartInitException: Could not create view exception because
the getPart() method for the ViewReference returns null.
Is there a proper way to create dynamic views so that this doesn't occur?
How do you persist the part data for a ViewReference?
|
|
|
|
|
|
|
|
|
|
|
Re: Dynamic View throws error on restart [message #490697 is a reply to message #487041] |
Fri, 09 October 2009 14:03  |
Eclipse User |
|
|
|
Sorry for the long delay, I stopped getting notifications from this thread for some reason...
So to create a dynamic view you can do the following:
try
{
PlatformUI.getWorkbench().getActiveWorkbenchWindow().
getActivePage().showView(YourView.VIEW_ID, YourView.getSecondaryID(), IWorkbenchPage.VIEW_VISIBLE);
}
catch (PartInitException e)
{
e.printStackTrace();
}
And this will create the view and (I think) put it in the registry so that you can refer to it from anywhere in the application.
What this will not do is add the view to the view menu so if the dynamic view is ever closed, you are unable to reopen it. I fixed this issue by giving the dynamic views their own menu on the main menu bar. Not a very good fix but it worked for my situation. If you are looking to get the view into the View menu, I can only wish you luck!
Post if you have any other questions, I'm now listening on this thread again.
|
|
|
Powered by
FUDForum. Page generated in 0.06370 seconds