XML Editor [message #143305] |
Wed, 12 October 2005 13:30  |
Eclipse User |
|
|
|
I'm new in plugins development, simple question - how can i run wtp xml
editor with selected file form my plugin, i must extend them?
Robert
|
|
|
|
|
|
Re: XML Editor [message #143879 is a reply to message #143582] |
Fri, 14 October 2005 11:28  |
Eclipse User |
|
|
|
Originally posted by: amywu.us.DELETETHISPART.ibm.com
To programatically open a java.io.File in the xml editor, you could use one
of the IDE.openEditor methods. The problem is you need an IFile as input,
not java.io.File.
If your file is in your eclipse workspace, you can try something like the
following to get the IFile:
IFile file = null;
IFile[] files =
ResourcesPlugin.getWorkspace().getRoot().findFilesForLocatio n(new
Path(javaFile.getSystemPath()));
for (int i = 0; i < files.length && file == null; i++)
if (files[i].exists())
file = files[i];
Once you have the IFile, you can do something like the following:
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
IEditorPart editor = IDE.openEditor(page, file, true);
This will open the editor in the default editor registered for the file's
content type.
If your file is not in your workspace, you should check out
org.eclipse.wst.html.ui.internal.hyperlink.ExternalFileHyper link
That class wraps a file in an IEditorInput and then calls openEditor.
Hope that helps!
"robert w
|
|
|
Powered by
FUDForum. Page generated in 0.02848 seconds