Saving Editor Content to non IFile [message #985896] |
Fri, 16 November 2012 10:31  |
Eclipse User |
|
|
|
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 #1031864 is a reply to message #987336] |
Tue, 02 April 2013 05:54  |
Eclipse User |
|
|
|
Hi,
Sorry for disturbing. I have a question regaridng OLE SWT.
I use it extensively to build a Word document report - insertion iof images, building blocks, graphs, tables, coloring of cells, hyperlinks, merging cells etc.
It works. But not always. Errors come when invoking a COm method, getting or setting a property. So I can limit it to Othe class OleAutomation.
But there are direct calls to the native methods and I cannot debug further.
Do you have any idea how I can make this communication reliable?
I also send my version of an editor ( if you are still interested in saving etc.)
|
|
|
Powered by
FUDForum. Page generated in 0.03609 seconds