Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to create a second IEditorInput
How to create a second IEditorInput [message #214317] Fri, 14 April 2006 22:02 Go to next message
Eclipse UserFriend
Originally posted by: micha.m2visio.de

Hi All,

I have a MultiPageEditor with one page as Gef editor and another as
TextEditor.
While saving the gef diagram I store the gef information in one file and at
the same time I create a new file with a specific XML like structure. When
opening the gef file I need to create a second IEditorInput for the file
with XML and add it to the text editor. To get the name of XML file
dynamically is not a problem but I still have no idea how to create a second
IEditorInput. Especially as I can't set the path or name for it.

Any suggestions are welcome.

Thanks Michael
Re: How to create a second IEditorInput [message #214349 is a reply to message #214317] Sun, 16 April 2006 15:34 Go to previous message
Eclipse UserFriend
Originally posted by: micha.m2visio.de

I found the solution.
I'll atach the source code for the case that anybody need it:

// MulitPageEditor
public void init(IEditorSite site, IEditorInput input) throws
PartInitException {
EditorUtils editorUtils = new EditorUtils();
IEditorInput visualInput;

try {
IFile file = ((IFileEditorInput) input).getFile();
IFile visualFile = editorUtils.getVisualFile(file.getLocation());
visualInput = new FileEditorInput(visualFile);

if (!visualFile.exists()) {
visualFile.create(file.getContents(),true,null);
}
}
....
super.init(site, visualInput);
...
}

// EdtiorUtils
public class EditorUtils {

IPath path;

public IFile getVisualFile(IPath iPath) {
path = iPath;
path = path.removeFileExtension();
path = path.addFileExtension("xy");
IWorkspaceRoot myWorkspaceRoot =
ResourcesPlugin.getWorkspace().getRoot();
IFile visualFile = myWorkspaceRoot.getFileForLocation(path);

return visualFile;
}
}

Michael


"Michael" <micha@m2visio.de> schrieb im Newsbeitrag
news:e1p65e$jtr$1@utils.eclipse.org...
> Hi All,
>
> I have a MultiPageEditor with one page as Gef editor and another as
> TextEditor.
> While saving the gef diagram I store the gef information in one file and
> at the same time I create a new file with a specific XML like structure.
> When opening the gef file I need to create a second IEditorInput for the
> file with XML and add it to the text editor. To get the name of XML file
> dynamically is not a problem but I still have no idea how to create a
> second IEditorInput. Especially as I can't set the path or name for it.
>
> Any suggestions are welcome.
>
> Thanks Michael
>
Previous Topic:Double clicking on the model object to display children on two sides of splitter
Next Topic:Performance Problem
Goto Forum:
  


Current Time: Mon Jan 20 07:24:39 GMT 2025

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

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

Back to the top