Search in sources :

Example 1 with RelateElementsCommand

use of com.amalto.workbench.widgets.xmlviewer.model.commands.RelateElementsCommand in project tmdm-studio-se by Talend.

the class XMLTreeModel method createTree.

public void createTree(IDocument document) {
    this.fireDocumentAboutToBeChanged(this.getTree());
    IDocumentPartitioner partitioner = document.getDocumentPartitioner();
    String[] categories = ((IDocumentPartitionerExtension2) partitioner).getManagingPositionCategories();
    this.sourceViewer.getCodeTagContainersRegistry().clear();
    for (int iCat = 0; iCat < categories.length; iCat++) {
        String category = categories[iCat];
        Position[] positions = null;
        try {
            positions = document.getPositions(category);
            this.rootNode = new XMLRootNode(0, 0, IXMLPartitions.XML_TAG, document, sourceViewer);
            ElementsToRelate.currentNode = this.rootNode;
            ElementsToRelate.parentNode = null;
            for (int j = 0; j < positions.length; j++) {
                Position pos = positions[j];
                ElementsToRelate.node = (XMLNode) pos;
                ElementsToRelate.node.getChildren().clear();
                ElementsToRelate.node.setCorrespondingNode(null);
                ElementsToRelate.node.setSourceViewer(this.sourceViewer);
                if (ElementsToRelate.currentNode != null && ElementsToRelate.currentNode.isTag()) {
                    String nodeType = ElementsToRelate.node.getType();
                    RelateElementsCommand command = this.commands.get(nodeType);
                    if (command != null) {
                        command.excecute(this.rootNode, this.sourceViewer.getCodeTagContainersRegistry());
                    }
                }
            }
        } catch (BadPositionCategoryException e) {
            e.printStackTrace();
        }
    }
    this.fireDocumentChanged(this.getTree());
}
Also used : IDocumentPartitionerExtension2(org.eclipse.jface.text.IDocumentPartitionerExtension2) RelateElementsCommand(com.amalto.workbench.widgets.xmlviewer.model.commands.RelateElementsCommand) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) Position(org.eclipse.jface.text.Position) BadPositionCategoryException(org.eclipse.jface.text.BadPositionCategoryException)

Aggregations

RelateElementsCommand (com.amalto.workbench.widgets.xmlviewer.model.commands.RelateElementsCommand)1 BadPositionCategoryException (org.eclipse.jface.text.BadPositionCategoryException)1 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)1 IDocumentPartitionerExtension2 (org.eclipse.jface.text.IDocumentPartitionerExtension2)1 Position (org.eclipse.jface.text.Position)1