Saving Editor Content to non IFile [message #985896] |
Fri, 16 November 2012 15:31 |
|
HI there,
I am opening an editor on a String which works fine. I am able to use the editor to alter that string as I intend. I implemented the IStorageEditorInput Interface which is succesful to display my in-memory content. Still, I have no clue how I can intercept the saving of that editor. I need to bring the altered content from the editor back to the memory (String).
This is the way of how i call the editor:
try {
InputStream inputstream = new StringBufferInputStream(mystring);
IEditorInput edInput = new MemoryEditorInput("MemFile", inputstream);
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
page.openEditor(edInput, "org.eclipse.ui.DefaultTextEditor");
} catch (Exception e) {
...
}
And this is the implementation of IStorageEditorInput:
public class MemoryEditorInput implements IStorageEditorInput {
private InputStream inputStream;
private String dataName;
public MemoryEditorInput(String dataName, InputStream inputStream) {
this.inputStream = inputStream;
this.dataName = dataName;
}
public boolean exists() { return false; }
public ImageDescriptor getImageDescriptor() { return null; }
public String getName() { return dataName; }
public IPersistableElement getPersistable() { return null; }
public String getToolTipText() { return dataName + " - " + inputStream; }
public Object getAdapter(Class adapter) { return null; }
public IStorage getStorage() throws CoreException {
return new IStorage() {
public Object getAdapter(Class adapter) { return null; }
public InputStream getContents() throws CoreException { return inputStream; }
public IPath getFullPath() { return null; }
public String getName() { return null; }
public boolean isReadOnly() { return false; }
};
}
}
There is a lot of articles out there how to open an editor on non file content. But there is no information on how to save that information. Does anyone have a clue how to tackle this issue?
Cheers
Phil
|
|
|
Re: Saving Editor Content to non IFile [message #987336 is a reply to message #985896] |
Mon, 26 November 2012 08:35 |
|
HI all,
Well, i found a way out of it by myself. All I did is overwriting the doSave() method of my Editor. Additionally i store some extra information in my MemoryEditorInput class so that i can ensure the location were i want to save to.
Cheers
Phili
|
|
|
|
Powered by
FUDForum. Page generated in 0.02964 seconds