Search in sources :

Example 1 with DocumentRangeNode

use of org.eclipse.compare.structuremergeviewer.DocumentRangeNode in project linuxtools by eclipse.

the class SpecStructureCreator method createStructureComparator.

@Override
protected IStructureComparator createStructureComparator(Object input, IDocument document, ISharedDocumentAdapter adapter, IProgressMonitor monitor) {
    final boolean isEditable;
    if (input instanceof IEditableContent) {
        isEditable = ((IEditableContent) input).isEditable();
    } else {
        isEditable = false;
    }
    // get the resource being compared, but treat compare with history as
    // null resource
    IFile file = null;
    if (input instanceof IResourceProvider) {
        IResource res = ((IResourceProvider) input).getResource();
        file = res.getAdapter(IFile.class);
    }
    DocumentRangeNode rootNode = new StructureRootNode(document, input, this, adapter) {

        @Override
        public boolean isEditable() {
            return isEditable;
        }
    };
    try {
        monitor = beginWork(monitor);
        // Section Root
        SpecNode specfileSectionRoot = new SpecNode(rootNode, 0, SPECFILE_ROOT_NODE, document, 0, document.getLength());
        parseSpecfile(specfileSectionRoot, document, file);
    } finally {
        if (monitor != null) {
            monitor.done();
        }
    }
    return rootNode;
}
Also used : IResourceProvider(org.eclipse.compare.IResourceProvider) DocumentRangeNode(org.eclipse.compare.structuremergeviewer.DocumentRangeNode) IFile(org.eclipse.core.resources.IFile) IEditableContent(org.eclipse.compare.IEditableContent) IResource(org.eclipse.core.resources.IResource) StructureRootNode(org.eclipse.compare.structuremergeviewer.StructureRootNode)

Aggregations

IEditableContent (org.eclipse.compare.IEditableContent)1 IResourceProvider (org.eclipse.compare.IResourceProvider)1 DocumentRangeNode (org.eclipse.compare.structuremergeviewer.DocumentRangeNode)1 StructureRootNode (org.eclipse.compare.structuremergeviewer.StructureRootNode)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1