Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » XML Editor problem
XML Editor problem [message #460574] Fri, 22 December 2006 11:55 Go to next message
Mario Charest is currently offline Mario CharestFriend
Messages: 42
Registered: July 2009
Member
Hi,

I need to implement a XML editor in my RCP Application. That's why I used
the Extension wizard to create a XML Editor.

Two questions:
1. Is there another XML edtior with more features?
2. Does anybody see a problem in the following code? The editor does open,
but instead of showing the file content, there is a horizontal blue line
and a text bellow which contains "ERROR" (nothing else).

The code:

...
File file = new File(thePathAndFile);
IPath location = new Path(file.getAbsolutePath());
PathEditorInput editorInput = new PathEditorInput(location);
IEditorPart editor = page.openEditor(editorInput, editorId);

Thanks in advance!
Re: XML Editor problem [message #460578 is a reply to message #460574] Fri, 22 December 2006 12:05 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Yes the WST project which is part of WTP contains sophisticated editors.
You need the following plugins:

org.eclipse.wst.sse.core,
org.eclipse.wst.sse.ui,
org.eclipse.wst.xml.core,
org.eclipse.wst.xml.ui,
org.eclipse.wst.common.ui,

Afterwards create your own editor the interesting methods look like this:
> public class EXSWTPageEditor extends MultiPageEditorPart implements IResourceChangeListener{
> protected IEditorSite createSite(IEditorPart page) {
> IEditorSite site = null;
> if (page == editor) {
> site = new MultiPageEditorSite(this, page) {
> public String getId() {
> // Sets this ID so nested editor is configured for XML source
> return ContentTypeIdForXML.ContentTypeID_XML + ".source"; //$NON-NLS-1$;
> }
> };
> }
> else {
> site = super.createSite(page);
> }
> return site;
> }
> /**
> * Creates page 0 of the multi-page editor,
> * which contains a text editor.
> */
> void createPage0() {
> try {
> editor = new StructuredTextEditor();
> int index = addPage(editor, getEditorInput());
> setPageText(index, editor.getTitle());
> } catch (PartInitException e) {
> ErrorDialog.openError(
> getSite().getShell(),
> "Error creating nested text editor",
> null,
> e.getStatus());
> }
> }

Tom

Mario schrieb:
> Hi,
> I need to implement a XML editor in my RCP Application. That's why I
> used the Extension wizard to create a XML Editor.
>
> Two questions: 1. Is there another XML edtior with more features?
> 2. Does anybody see a problem in the following code? The editor does
> open, but instead of showing the file content, there is a horizontal
> blue line and a text bellow which contains "ERROR" (nothing else).
>
> The code:
> ..
> File file = new File(thePathAndFile);
> IPath location = new Path(file.getAbsolutePath());
> PathEditorInput editorInput = new PathEditorInput(location);
> IEditorPart editor = page.openEditor(editorInput, editorId);
>
> Thanks in advance!
>
Re: XML Editor problem [message #462033 is a reply to message #460574] Mon, 22 January 2007 17:20 Go to previous message
Mario Charest is currently offline Mario CharestFriend
Messages: 42
Registered: July 2009
Member
Hi,
I got another question. I just don't get it how to use the editor and to open a file. What I need is the editor input and a editor ID, right? As an editor input, I need to have a IFileEditorInput (afaik). But how to get it from a File object?

Thanks for any help!

===

IEditorInput editorInput = createEditorInput(file);
String editorId = EXSWTPageEditor.ID;
IWorkbenchPage page = window.getActivePage();

try {
IEditorPart editor = page.openEditor(editorInput, editorId);
...

---
private IEditorInput createEditorInput(File file) {
IFile iFile = ???
IFileEditorInput editorInput = new FileEditorInput(iFile);
Previous Topic:Classloader problems when bundling CGLIB as plugin
Next Topic:Removing "-k" from default make command
Goto Forum:
  


Current Time: Sat Oct 12 17:02:13 GMT 2024

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

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

Back to the top