Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Label/Content Provider for XML Editor's content outline?
Label/Content Provider for XML Editor's content outline? [message #203003] Wed, 24 October 2007 16:32 Go to next message
Eclipse User
Originally posted by: italdesign99.hotmail.com

I am looking for the code for the label and content providers for the xml
editor's content outline.

I found the JFaceNodeLabelProvider and JFaceNodeContentprovider, found in
org.eclipse.wst.xml.ui.internal.contentoutline, but they don't seem to be
parsing out Attribute Nodes from the DOM model when I try to use those
classes with MY editor.

However, the content outline view in WTP's xml editor does show attribute
nodes, and they seem to be displaying correctly.

My treeviewer, uses the JFaceNodeLabelProvider and
JFaceNodeContentprovider, however it doesn't recognize attribute nodes
from the DOM model.

Any ideas?

Thanks!
Re: Label/Content Provider for XML Editor's content outline? [message #203014 is a reply to message #203003] Wed, 24 October 2007 17:00 Go to previous messageGo to next message
Eclipse User
Originally posted by: italdesign99.hotmail.com

Muneer wrote:

> I am looking for the code for the label and content providers for the xml
> editor's content outline.

> I found the JFaceNodeLabelProvider and JFaceNodeContentprovider, found in
> org.eclipse.wst.xml.ui.internal.contentoutline, but they don't seem to be
> parsing out Attribute Nodes from the DOM model when I try to use those
> classes with MY editor.

> However, the content outline view in WTP's xml editor does show attribute
> nodes, and they seem to be displaying correctly.

> My treeviewer, uses the JFaceNodeLabelProvider and
> JFaceNodeContentprovider, however it doesn't recognize attribute nodes
> from the DOM model.

> Any ideas?

> Thanks!


Here's some info on the model:

The following method is found in my editor which generates the model from
the xml input.

IStructuredModel, StructuredModelManager, FactoryRegistry, and
IStructuredDocument are in org.eclipse.wst.sse.core.

private void getModelFromInput(IEditorInput newInput) {

IStructuredModel model = null;
if (newInput != null && editor != null && mainDesignViewer != null) {
IDocument textDocument =
editor.getDocumentProvider().getDocument(newInput);
model =
StructuredModelManager.getModelManager().getModelForRead((IS tructuredDocument)textDocument);

if (model != null) {
/* Register the refresh factory */
FactoryRegistry factoryRegistry = model.getFactoryRegistry();
if (factoryRegistry.getFactoryFor(RefreshOnNotifyChangedAdapter .class)
== null) {
factoryRegistry.addFactory(new
RefreshOnNotifyChangedAdapterFactory(mainDesignViewer));
}
}

mainDesignViewer.setInput(model);
}
mainStructuredModel = model;
}


supplementary methods:


protected void setInput(IEditorInput newInput) {
releaseModel();

super.setInput(newInput);

if (editor != null) {
editor.setInput(newInput);
getModelFromInput(newInput);
}
}


private void releaseModel() {
if (mainStructuredModel != null) {
mainStructuredModel.releaseFromRead();
//mainStructuredModel.
}
}
Re: Label/Content Provider for XML Editor's content outline? [message #203040 is a reply to message #203003] Thu, 25 October 2007 01:22 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2237
Registered: July 2009
Senior Member
Muneer wrote:
> I am looking for the code for the label and content providers for the
> xml editor's content outline.
>
> I found the JFaceNodeLabelProvider and JFaceNodeContentprovider, found
> in org.eclipse.wst.xml.ui.internal.contentoutline, but they don't seem
> to be parsing out Attribute Nodes from the DOM model when I try to use
> those classes with MY editor.
>
> However, the content outline view in WTP's xml editor does show
> attribute nodes, and they seem to be displaying correctly.
> My treeviewer, uses the JFaceNodeLabelProvider and
> JFaceNodeContentprovider, however it doesn't recognize attribute nodes
> from the DOM model.

The outline's not showing attribute nodes in the tree, it is instead
including specific attribute names and values in the *label* for
elements. You're not missing any functionality by the sounds of it,
but if you want Attr Nodes to be their own tree items, you'll have
to extend or reuse the content provider in your own outline
configuration class (subclassing the
XMLContentOutlineConfiguration). Then you can assign that outline
configuration class to be used with your editor part ID or content
type ID as the target:

<extension point="org.eclipse.wst.sse.ui.editorConfiguration">
<contentOutlineConfiguration
class="MuneerContentOutlineConfiguration"
target="muneer" />
</extension>

--
Nitin Dahyabhai
Structured Source Editing


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: Label/Content Provider for XML Editor's content outline? [message #203081 is a reply to message #203040] Thu, 25 October 2007 16:51 Go to previous message
Eclipse User
Originally posted by: italdesign99.hotmail.com

> The outline's not showing attribute nodes in the tree, it is instead
> including specific attribute names and values in the *label* for
> elements. You're not missing any functionality by the sounds of it,
> but if you want Attr Nodes to be their own tree items, you'll have
> to extend or reuse the content provider in your own outline
> configuration class (subclassing the
> XMLContentOutlineConfiguration). Then you can assign that outline
> configuration class to be used with your editor part ID or content
> type ID as the target:

> <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
> <contentOutlineConfiguration
> class="MuneerContentOutlineConfiguration"
> target="muneer" />
> </extension>

> --
> Nitin Dahyabhai
> Structured Source Editing


Thanks so much!

I looked at the AttributeShowingLabelProvider in the XMLConfiguration
class and in my own code, ended up taking the attribute nodes out of each
element node.
Previous Topic:J2EE module dependency on classes
Next Topic:unable to .wtpmodules file
Goto Forum:
  


Current Time: Tue Jul 29 00:55:25 EDT 2014

Powered by FUDForum. Page generated in 0.03141 seconds