use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class DTDTreeContentProvider method getChildren.
public Object[] getChildren(Object parentElement) {
// otherwise
if (parentElement instanceof DTDFile) {
if (isShowLogicalOrder()) {
// return the visible node lists
if (logicalNodeLists == null) {
Iterator nodeLists = ((DTDFile) parentElement).getNodeLists().iterator();
List visibleLists = new ArrayList(7);
while (nodeLists.hasNext()) {
NodeList list = (NodeList) nodeLists.next();
if (isVisibleNodeList(list)) {
visibleLists.add(list);
}
}
logicalNodeLists = visibleLists.toArray();
}
return logicalNodeLists;
} else {
// return the visible nodes
List allNodes = ((DTDFile) parentElement).getNodes();
List visibleNodes = new ArrayList(allNodes.size());
for (int i = 0; i < allNodes.size(); i++) {
Object o = allNodes.get(i);
if (isVisibleNode(o)) {
visibleNodes.add(o);
}
}
return visibleNodes.toArray();
}
} else if (parentElement instanceof NodeList) {
return ((NodeList) parentElement).getNodes().toArray();
} else if (parentElement instanceof Element) {
// always group the attributes directly under the element
Object[] children = ((DTDNode) parentElement).getChildren();
List attributes = ((Element) parentElement).getElementAttributes();
Object[] logicalChildren = new Object[children.length + attributes.size()];
int index = 0;
for (index = 0; index < children.length; index++) {
logicalChildren[index] = children[index];
}
for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
logicalChildren[index++] = iter.next();
}
return logicalChildren;
} else if (parentElement instanceof DTDNode) {
return ((DTDNode) parentElement).getChildren();
}
return Collections.EMPTY_LIST.toArray();
}
use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class DTDTreeContentProvider method refreshTree.
/**
* <p>Refreshes the tree from the parents of the given node.</p>
* @param node refresh the tree from the parents of this node
*/
private void refreshTree(Object node) {
List parents = getParents(node);
if (parents.size() > 0) {
for (int p = 0; p < parents.size(); ++p) {
final Object parent = parents.get(p);
// insert the node directly to improve performance
if (parent instanceof DTDFile) {
Object[] objs = getChildren(parent);
for (int i = 0; i < objs.length; i++) {
if (objs[i] == node) {
((AbstractTreeViewer) fViewer).insert(parent, node, i);
break;
}
}
}
this.refreshTreeNode(parent, true);
}
}
}
use of org.eclipse.wst.dtd.core.internal.DTDFile in project webtools.sourceediting by eclipse.
the class AddParameterEntityReferenceAction method run.
public void run() {
DTDFile dtdFile = getModel().getDTDFile();
String extEntity = getFirstExternalParameterEntity(dtdFile);
DTDNode selectedNode = getFirstNodeSelected();
if (extEntity != null) {
dtdFile.createParameterEntityReference(selectedNode, extEntity, true);
} else {
// $NON-NLS-1$
dtdFile.createParameterEntityReference(selectedNode, "%NewEntityReference;", true);
}
}
Aggregations