Search in sources :

Example 1 with NodesEvent

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);
    }
}
Also used : NodesEvent(org.eclipse.wst.dtd.core.internal.event.NodesEvent) Iterator(java.util.Iterator)

Example 2 with NodesEvent

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;
}
Also used : NodesEvent(org.eclipse.wst.dtd.core.internal.event.NodesEvent)

Example 3 with NodesEvent

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());
    }
}
Also used : NodesEvent(org.eclipse.wst.dtd.core.internal.event.NodesEvent) IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) Iterator(java.util.Iterator)

Example 4 with NodesEvent

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);
    }
}
Also used : NodesEvent(org.eclipse.wst.dtd.core.internal.event.NodesEvent) IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)

Example 5 with NodesEvent

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);
        }
    }
}
Also used : NodesEvent(org.eclipse.wst.dtd.core.internal.event.NodesEvent) ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ArrayList(java.util.ArrayList) ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

NodesEvent (org.eclipse.wst.dtd.core.internal.event.NodesEvent)5 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)3 Iterator (java.util.Iterator)2 IStructuredDocumentRegionList (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)1 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)1