How to create a second IEditorInput [message #214317] |
Fri, 14 April 2006 22:02 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
>
|
|
|
Powered by
FUDForum. Page generated in 0.03328 seconds