Search in sources :

Example 1 with DocumentProvider

use of com.cubrid.tool.editor.DocumentProvider in project cubrid-manager by CUBRID.

the class PropDocumentProvider method getDocument.

/**
	 * Retrieves the document to be edited.
	 * 
	 * @param element Object
	 * @return IDocument
	 */
public IDocument getDocument(Object element) {
    IDocument document = null;
    if (element instanceof IEditorInput) {
        IEditorInput ei = ((IEditorInput) element);
        DocumentProvider dp = (DocumentProvider) ei.getAdapter(DocumentProvider.class);
        if (dp != null) {
            document = dp.getDocument(element);
        }
    }
    if (document == null) {
        document = new Document();
    }
    IDocumentPartitioner partitioner = new FastPartitioner(new PropPartitionScanner(), PropPartitionScanner.LEGAL_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) DocumentProvider(com.cubrid.tool.editor.DocumentProvider) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) IDocument(org.eclipse.jface.text.IDocument) IEditorInput(org.eclipse.ui.IEditorInput)

Example 2 with DocumentProvider

use of com.cubrid.tool.editor.DocumentProvider in project cubrid-manager by CUBRID.

the class XMLDocumentProvider method getDocument.

/**
	 * Retrieves the document to be edited.
	 * 
	 * @param element Object
	 * @return IDocument
	 */
public IDocument getDocument(Object element) {
    IDocument document = null;
    if (element instanceof IEditorInput) {
        IEditorInput ei = ((IEditorInput) element);
        DocumentProvider dp = (DocumentProvider) ei.getAdapter(DocumentProvider.class);
        if (dp != null) {
            document = dp.getDocument(element);
        }
    }
    if (document == null) {
        document = new Document();
    }
    IDocumentPartitioner partitioner = new FastPartitioner(new XMLPartitionScanner(), new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT });
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
    return document;
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) DocumentProvider(com.cubrid.tool.editor.DocumentProvider) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) XMLPartitionScanner(com.cubrid.tool.editor.xml.scanner.XMLPartitionScanner) IDocument(org.eclipse.jface.text.IDocument) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

DocumentProvider (com.cubrid.tool.editor.DocumentProvider)2 Document (org.eclipse.jface.text.Document)2 IDocument (org.eclipse.jface.text.IDocument)2 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)2 FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)2 IEditorInput (org.eclipse.ui.IEditorInput)2 XMLPartitionScanner (com.cubrid.tool.editor.xml.scanner.XMLPartitionScanner)1