Search in sources :

Example 46 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project linuxtools by eclipse.

the class DockerDocumentProvider method createDocument.

@Override
protected IDocument createDocument(Object element) throws CoreException {
    IDocument document = super.createDocument(element);
    if (document != null) {
        DockerPartitionScanner scanner = new DockerPartitionScanner();
        IDocumentPartitioner partitioner = new FastPartitioner(scanner, DockerPartitionScanner.ALLOWED_CONTENT_TYPES);
        partitioner.connect(document);
        document.setDocumentPartitioner(partitioner);
    }
    return document;
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) DockerPartitionScanner(org.eclipse.linuxtools.internal.docker.editor.scanner.DockerPartitionScanner) IDocument(org.eclipse.jface.text.IDocument)

Example 47 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project linuxtools by eclipse.

the class STPFormattingTest method setupDocumentPartitioner.

/**
 * Sets up the document partitioner for the given document for the given partitioning.
 *
 * @param document
 * @param partitioning
 * @param owner may be null
 */
private static void setupDocumentPartitioner(IDocument document, String partitioning) {
    IDocumentPartitioner partitioner = new FastPartitioner(new STPPartitionScanner(), STPPartitionScanner.STP_PARTITION_TYPES);
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3 = (IDocumentExtension3) document;
        extension3.setDocumentPartitioner(partitioning, partitioner);
    } else {
        document.setDocumentPartitioner(partitioner);
    }
    partitioner.connect(document);
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) STPPartitionScanner(org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPPartitionScanner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner)

Example 48 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project tmdm-studio-se by Talend.

the class XMLDocumentProvider method createDocument.

// XMLEditor editor;
// public XMLDocumentProvider(XMLEditor editor){
// this.editor=editor;
// }
protected IDocument createDocument(Object element) throws CoreException {
    if (element instanceof XMLEditorInput) {
        // IDocument document = super.createDocument(element);
        IDocument document = ((XMLEditorInput) element).getDocument();
        if (document != null) {
            IDocumentPartitioner partitioner = new FastPartitioner(new XMLPartitionScanner(), new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT });
            partitioner.connect(document);
            document.setDocumentPartitioner(partitioner);
        }
        return document;
    }
    return null;
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IDocument(org.eclipse.jface.text.IDocument)

Example 49 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner in project tmdm-studio-se by Talend.

the class ElementFKInfoFormatViewer method intallDocument.

private void intallDocument(IDocument doc) {
    IDocumentPartitioner partitioner = new FastPartitioner(new ElementFKInfotPartitionScanner(), new String[] { ElementFKInfotPartitionScanner.COMMON_STRING });
    partitioner.connect(doc);
    doc.setDocumentPartitioner(partitioner);
    setDocument(doc, annotationModel);
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner)

Example 50 with IDocumentPartitioner

use of org.eclipse.jface.text.IDocumentPartitioner 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

IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)72 IDocument (org.eclipse.jface.text.IDocument)27 IDocumentExtension3 (org.eclipse.jface.text.IDocumentExtension3)27 FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)25 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)12 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)9 IFile (org.eclipse.core.resources.IFile)7 IModelManager (org.eclipse.wst.sse.core.internal.provisional.IModelManager)7 IStructuredTextPartitioner (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredTextPartitioner)6 BadLocationException (org.eclipse.jface.text.BadLocationException)5 ITypedRegion (org.eclipse.jface.text.ITypedRegion)5 DocumentEvent (org.eclipse.jface.text.DocumentEvent)4 IDocumentListener (org.eclipse.jface.text.IDocumentListener)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)3 IPath (org.eclipse.core.runtime.IPath)3 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)3 SQLDocument (com.cubrid.common.ui.query.editor.SQLDocument)2 SQLPartitionScanner (com.cubrid.common.ui.query.editor.SQLPartitionScanner)2