|Using custom editor when file is initially loaded from persisted state [message #1707857]
||Wed, 09 September 2015 20:47
| chandrika siva
Registered: September 2015
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.
Powered by FUDForum
. Page generated in 0.02211 seconds