Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Using custom editor when file is initially loaded from persisted state
Using custom editor when file is initially loaded from persisted state [message #1707857] Wed, 09 September 2015 20:47 Go to next message
Eclipse UserFriend
Hi,

Please bear with me when I set the initial context of the problem.

I have a custom editor class that extends SapphireEditorForXml and I also have a custom EditorInput for it - ResourceFileStoreEditorInput. I use this to display a file that is actually on the server instead of local file system.
I have custom Action classes that listens to users action such as double clicking on a file. When a file is opened by a explicit user action everything works fine in my code as the action goes through the action handler which explicitly creates the custom editorInput object (ResourceFileStoreEditorInput). For example, my custom action handler has the following line of code

((WorkbenchPage) window.getActivePage()).openEditorFromDescriptor(new ResourceFileStoreEditorInput(fileStore, file), editorDescriptor, true, null);

where "file" object is created based on the path of the current selection.

But I am have trouble when the RCP is opened not by user event but on launch based on earlier persisted state. i.e. I open a file using double click, it went through my action handler, opened the file using my custom editor. Then I close the RCP client and restart it. Now the file that was opened earlier is opened again based on the persisted state and this uses the FileStoreEditorInputFactory and FileStoreEditorInput instead of my custom ResourceFileStoreEditorInput. I get a class cast exception on the view. How do I fix this issue?

I am not able to override setInput as this method is marked final in SapphireEditor. When I tried debugging this, I see that the code that opens the file on client startup goes through org.eclipse.ui.internal.EditorReference.getEditorInput() that create the EditorInput object based memento string (got using getModel().getPersistedState().get(MEMENTO_KEY)) which points to default FileStoreEditorInputFactory. Is this something that I have to overwrite too? Any pointers or suggestions would be greatly appreciated.

Thank you,
Chandrika

Re: Using custom editor when file is initially loaded from persisted state [message #1708470 is a reply to message #1707857] Wed, 16 September 2015 20:07 Go to previous message
Eclipse UserFriend
I found the solution for this. Realized that I didn't have to override the setInput( ) method at all. I created a custom EditorInputFactory similar to FileStoreEditorInputFactory and registered that it my plugin.xml. In my custom EditorInput class I overwrote the methods getFactoryId and saveState and when I persist state - 1. I set the factory id to my custom factory class and 2. save additional information needed to create an instance of my custom editorInput class on restore state. This fixed the issue.
Previous Topic:updating browse button image for a custom browse action handler
Next Topic:Announcing Sapphire 8.2.1 Release
Goto Forum:
  


Current Time: Tue Mar 19 06:15:40 GMT 2024

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

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

Back to the top