use of org.eclipse.wst.dtd.core.internal.event.NodesEvent in project webtools.sourceediting by eclipse.
the class DTDFile method rebuildNodes.
public void rebuildNodes(List nodes) {
// remove the old nodes
removeNodes(nodes);
// now rebuild them
NodesEvent addedDTDNodes = new NodesEvent();
Iterator dtdNodes = nodes.iterator();
while (dtdNodes.hasNext()) {
DTDNode dtdNode = (DTDNode) dtdNodes.next();
// System.out.println("rebuilding " +
// dtdNode.getStructuredDocumentRegion().getText());
DTDNode node = buildNode(dtdNode.getStructuredDTDDocumentRegion());
if (node != null) {
addedDTDNodes.add(node);
}
}
if (addedDTDNodes.getNodes().size() > 0) {
// now tell people about the additions
notifyNodesAdded(addedDTDNodes);
}
}
use of org.eclipse.wst.dtd.core.internal.event.NodesEvent in project webtools.sourceediting by eclipse.
the class DTDFile method newModel.
public void newModel(NewDocumentEvent event) {
creatingNewModel = true;
nodeList.clear();
NodesEvent removeEvent = new NodesEvent();
removeEvent.getNodes().addAll(nodeList);
notifyNodesRemoved(removeEvent);
if (event.getStructuredDocument() != null && event.getStructuredDocument().getRegionList() != null) {
buildNodes(event.getStructuredDocument().getRegionList());
}
creatingNewModel = false;
}
use of org.eclipse.wst.dtd.core.internal.event.NodesEvent in project webtools.sourceediting by eclipse.
the class DTDFile method nodesReplaced.
public void nodesReplaced(StructuredDocumentRegionsReplacedEvent event) {
IStructuredDocumentRegionList oldNodes = event.getOldStructuredDocumentRegions();
NodesEvent removedDTDNodes = new NodesEvent();
for (int i = 0; i < oldNodes.getLength(); i++) {
IStructuredDocumentRegion flatNode = oldNodes.item(i);
for (Iterator iter = getNodes().iterator(); iter.hasNext(); ) {
DTDNode node = (DTDNode) iter.next();
if (node.getStructuredDTDDocumentRegion() == flatNode) {
removedDTDNodes.add(node);
}
}
}
buildNodes(event.getNewStructuredDocumentRegions());
if (removedDTDNodes.getNodes().size() > 0) {
notifyNodesRemoved(removedDTDNodes);
removeNodes(removedDTDNodes.getNodes());
}
}
use of org.eclipse.wst.dtd.core.internal.event.NodesEvent in project webtools.sourceediting by eclipse.
the class DTDFile method buildNodes.
public void buildNodes(IStructuredDocumentRegionList list) {
NodesEvent addedDTDNodes = new NodesEvent();
TopLevelNode previousNode = null;
for (int i = 0; i < list.getLength(); i++) {
IStructuredDocumentRegion flatNode = list.item(i);
TopLevelNode node = (TopLevelNode) buildNode(flatNode);
// node
if (node != null) {
previousNode = node;
addedDTDNodes.add(node);
} else {
if (previousNode != null) {
previousNode.addWhitespaceStructuredDocumentRegion(flatNode);
}
}
}
if (// &&
addedDTDNodes.getNodes().size() > 0) // creatingNewModel == false)
{
// now tell people about the additions
notifyNodesAdded(addedDTDNodes);
}
}
use of org.eclipse.wst.dtd.core.internal.event.NodesEvent in project webtools.sourceediting by eclipse.
the class DTDFile method regionsReplaced.
public void regionsReplaced(RegionsReplacedEvent event) {
List nodesToRebuild = new ArrayList();
IStructuredDocumentRegion flatNode = event.getStructuredDocumentRegion();
DTDNode affectedNode = getNode(flatNode);
if (!isSameTopLevelType(affectedNode)) {
// Bug 111100 - Fire off a node removal event
// to remove the node from the tree viewer
NodesEvent removedDTDNodes = new NodesEvent();
removedDTDNodes.add(affectedNode);
notifyNodesRemoved(removedDTDNodes);
nodesToRebuild.add(affectedNode);
rebuildNodes(nodesToRebuild);
} else {
affectedNode.resolveRegions();
notifyNodeChanged(affectedNode);
// now try and determine which ones were added
NodesEvent addedDTDNodes = new NodesEvent();
ITextRegionList newRegions = event.getNewRegions();
int size = newRegions.size();
for (int i = 0; i < size; i++) {
ITextRegion region = newRegions.get(i);
DTDNode deepestNode = affectedNode.getDeepestNode(flatNode.getStartOffset(region), flatNode.getEndOffset(region));
// the node changed event above
if (deepestNode != affectedNode && !addedDTDNodes.getNodes().contains(deepestNode)) {
addedDTDNodes.add(deepestNode);
}
}
if (addedDTDNodes.getNodes().size() > 0) {
notifyNodesAdded(addedDTDNodes);
}
}
}
Aggregations