Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Saving Editor Content to non IFile(How to save editor content which is not stored in a disk resource)
Saving Editor Content to non IFile [message #985896] Fri, 16 November 2012 15:31 Go to next message
Phil M. Fischer is currently offline Phil M. FischerFriend
Messages: 60
Registered: November 2010
Location: Germany
Member
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 Go to previous messageGo to next message
Phil M. Fischer is currently offline Phil M. FischerFriend
Messages: 60
Registered: November 2010
Location: Germany
Member
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. Wink

Cheers

Phili
Re: Saving Editor Content to non IFile [message #1031864 is a reply to message #987336] Tue, 02 April 2013 09:54 Go to previous message
Binko Binev is currently offline Binko BinevFriend
Messages: 20
Registered: June 2012
Junior Member
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.)
Previous Topic:Cannot find the constants in higher version platform
Next Topic:RCP Obfuscation
Goto Forum:
  


Current Time: Wed Nov 26 11:50:34 GMT 2014

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

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