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());
}
Aggregations