Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Displaying Attribute Node
Displaying Attribute Node [message #202832] Mon, 22 October 2007 19:50
Eclipse User
Originally posted by: italdesign99.hotmail.com

I have instantiated WST's structured Text Editor.
I'm trying to semi mimick WTP's xml editor.

Here's my content provider:

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMM odel;
import org.w3c.dom.Node;

class DOMContentProvider implements ITreeContentProvider {
public void dispose() {
}

public Object[] getChildren(Object parentElement) {
if (parentElement instanceof INodeNotifier) {
((INodeNotifier)
parentElement).getAdapterFor(RefreshOnNotifyChangedAdapter.c lass);
}

if (parentElement instanceof Node) {
List children = new ArrayList();
Node child = ((Node) parentElement).getFirstChild();
while (child != null) {
if (child instanceof INodeNotifier) {
((INodeNotifier)
child).getAdapterFor(RefreshOnNotifyChangedAdapter.class);
}
children.add(child);
child = child.getNextSibling();
}
return children.toArray();
}
return new Object[0];
}

public Object[] getElements(Object inputElement) {
if (inputElement instanceof IDOMModel) {
if (inputElement instanceof INodeNotifier) {
((INodeNotifier)
inputElement).getAdapterFor(RefreshOnNotifyChangedAdapter.cl ass);
}
return new Object[]{((IDOMModel) inputElement).getDocument()};
}
return new Object[0];
}

public Object getParent(Object element) {
if (element instanceof Node) {
if (element instanceof INodeNotifier) {
((INodeNotifier)
element).getAdapterFor(RefreshOnNotifyChangedAdapter.class);
}
return ((Node) element).getParentNode();
}
return null;
}

public boolean hasChildren(Object element) {
if (element instanceof Node) {
if (element instanceof INodeNotifier) {
((INodeNotifier)
element).getAdapterFor(RefreshOnNotifyChangedAdapter.class);
}

return ((Node) element).getFirstChild() != null;
}
return false;
}

public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
{
}

}

Anyone know a simple way of modifying this in order to get the attribute
node to be returned as well.

Thanks
Previous Topic:WTP Architecture Group -- Request for Information
Next Topic:Get xml node from XML Editor
Goto Forum:
  


Current Time: Mon Oct 20 09:49:31 GMT 2014

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

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