Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » From plugin to RCP: Save/Load functionality
From plugin to RCP: Save/Load functionality [message #246886] Thu, 15 January 2009 07:14 Go to next message
Eclipse UserFriend
Originally posted by:


I have writing an eclipse plugin using GEF. Now I am migrating it to a
standalone RCP application. It went fairly smoothly, but I am a bit
confused with how files are loaded and saved in an RCP application.

In the plugin (class MyGraphicalEditor), there were the methods doSave(), doSaveAs() and setInput(), like this
(and like in the Shapes example):

public class MyGraphicalEditor extends EditorPart{
public void doSave(IProgressMonitor monitor) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
IFile file = ((IFileEditorInput) getEditorInput()).getFile();
file.setContents (new ByteArrayInputStream(out.toByteArray()), true, false, monitor);
} catch (CoreException ce) {
} catch (IOException ioe) {

protected void setInput(IEditorInput input) {
try {
IFile file = ((IFileEditorInput) input).getFile();
InputStream is = file.getContents();
if (is.available() == 0) root = new RootNode();
else {
ObjectInputStream in = new ObjectInputStream(is);
root = (RootNode) in.readObject();
catch (IOException e) {
} catch (CoreException e) {
} catch (ClassNotFoundException e) {


When moving to RCP, at first I get null pointer if I leave setInput() as it is.
I saw in an example a new class like this:

public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
public void postStartup() {

try {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
page.openEditor(new MyEditorInput("editor"), MyGraphicalEditor.ID, false);
} catch (Exception e) {

From now on I am not at all sure what I have to do. I did create MyEditorInput and I modified setInput() in the editor like this:

protected void setInput(IEditorInput input) {
MyEditorInput myeditorInput = ((MyEditorInput) input);
model = myeditorInput.getModel();

When running the application the model is loaded and I can edit it, but then doSave() and doSaveAs() have problems.

I don't know what interface MyEditorInput should implement. I guess something like IEditorInput/IFileEditorInput/IPathEditorInput.
I have not found clear documentation about this, and unfortunately the RCP Shapes example does not implement doSave(), doSaveAs().

I am not even sure that MyEditorInput has to exist? Maybe there is another way or small tweak that can be done in doSave() without it.

I would like to simply have the minimal functionality: When opening the editor, the user is editing an Untitled file and then he can
use save as to set the file name and location. Or maybe there is no file open at startup: the user creates a new file and then he can
use save. Either way is good.

What direction should I take? Is there a working example with source code?
Re: From plugin to RCP: Save/Load functionality [message #532106 is a reply to message #246886] Fri, 07 May 2010 08:26 Go to previous messageGo to next message
Rima Mising name is currently offline Rima Mising nameFriend
Messages: 6
Registered: April 2010
Junior Member
i also have same problem.... if u find the solution tell me also
Re: From plugin to RCP: Save/Load functionality [message #1624257 is a reply to message #246886] Thu, 19 February 2015 17:16 Go to previous message
Vítor Moscon is currently offline Vítor MosconFriend
Messages: 4
Registered: January 2013
Junior Member
I have the same problem too!
Previous Topic:[Announce] GEF 3.5.0 I200901141304 is available
Next Topic:[Zest] center View on a node
Goto Forum:

Current Time: Sat Jun 23 06:52:14 GMT 2018

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

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

Back to the top