Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Dynamic View throws error on restart
Dynamic View throws error on restart [message #483233] Mon, 31 August 2009 16:45 Go to next message
Ricky Patel is currently offline Ricky PatelFriend
Messages: 33
Registered: July 2009
Member
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 #483248 is a reply to message #483233] Mon, 31 August 2009 18:08 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Where are you storing the data that can be used to re-create the views? How is it accessed? The secondary view ID?

PW


Re: Dynamic View throws error on restart [message #483315 is a reply to message #483248] Tue, 01 September 2009 03:39 Go to previous messageGo to next message
Ricky Patel is currently offline Ricky PatelFriend
Messages: 33
Registered: July 2009
Member
Where are you storing the data that can be used to re-create the views?
That data is stored in a persisted value on the preference store

How is it accessed?
I access it personally when I create and recreate the views

The secondary view ID?
The secondary view id is based upon the data provided by the user, the
data provided can be assumed to be unique
Re: Dynamic View throws error on restart [message #483417 is a reply to message #483315] Tue, 01 September 2009 14:51 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

I'm asking how it is accessed. i.e. how does the view know which information to retrieve from the preference store?

When the view is re-instantiated on startup it only has access to 3 things. Its ID, its secondaryId, and an IMemento if one was saved.

Which of those three things gives you the information you need to access your preference store? Is the problem you are generating a different key on startup or that when you ask the preference store for that key, it doesn't return the correct information?

PW


Re: Dynamic View throws error on restart [message #483778 is a reply to message #483417] Wed, 02 September 2009 22:39 Go to previous messageGo to next message
Ricky Patel is currently offline Ricky PatelFriend
Messages: 33
Registered: July 2009
Member
Ahh sorry, there is no IMemento object. It uses the secondary id to look
the data up in the preference store
Re: Dynamic View throws error on restart [message #483968 is a reply to message #483778] Thu, 03 September 2009 18:51 Go to previous messageGo to next message
Ricky Patel is currently offline Ricky PatelFriend
Messages: 33
Registered: July 2009
Member
It has to deal with the actual Part not being set in the ViewReference.
When is this value set on shutdown? If i can get that information I can
maybe work backwards to see why the part information isn't being set.
Re: Dynamic View throws error on restart [message #484031 is a reply to message #483778] Fri, 04 September 2009 00:13 Go to previous messageGo to next message
Ricky Patel is currently offline Ricky PatelFriend
Messages: 33
Registered: July 2009
Member
I figured out the issue... I wasn't under the impression that Eclipse will
handle dynamically generated views for you, I was attempting to create
them from scratch every time. Since I didn't supply enough data on init,
the framework had issues on restart. Thanks for your help and clearing
this up with me!
Re: Dynamic View throws error on restart [message #487041 is a reply to message #484031] Mon, 21 September 2009 15:59 Go to previous messageGo to next message
Jon  is currently offline Jon Friend
Messages: 6
Registered: July 2009
Junior Member
I'm looking to create views dynamically. How did you do this and insert the dynamic view to the view registry?

It looks like the only way to accomplish this is by creating a shell view up front and changing the contents.

Thanks in advance
Re: Dynamic View throws error on restart [message #490693 is a reply to message #483233] Fri, 09 October 2009 17:48 Go to previous messageGo to next message
Ricky Patel is currently offline Ricky PatelFriend
Messages: 33
Registered: July 2009
Member
Thanks for your help Smile

[Updated on: Fri, 09 October 2009 17:49]

Report message to a moderator

Re: Dynamic View throws error on restart [message #490697 is a reply to message #487041] Fri, 09 October 2009 18:03 Go to previous message
Ricky Patel is currently offline Ricky PatelFriend
Messages: 33
Registered: July 2009
Member
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.
Previous Topic:Flashing Window Title Text using Display.async
Next Topic:Mistake by externilization of string from the plugin.xml
Goto Forum:
  


Current Time: Thu Mar 28 15:10:11 GMT 2024

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

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

Back to the top