Search in sources :

Example 1 with IDocumentPartitioningListener

use of org.eclipse.jface.text.IDocumentPartitioningListener in project mylyn.docs by eclipse.

the class MarkupEditor method updateDocument.

private void updateDocument() {
    if (getSourceViewer() != null) {
        IDocument previousDocument = document;
        document = getSourceViewer().getDocument();
        if (previousDocument == document) {
            return;
        }
        if (previousDocument != null && documentListener != null) {
            previousDocument.removeDocumentListener(documentListener);
        }
        if (previousDocument != null && documentPartitioningListener != null) {
            previousDocument.removeDocumentPartitioningListener(documentPartitioningListener);
        }
        if (document != null) {
            if (documentListener == null) {
                documentListener = new IDocumentListener() {

                    public void documentAboutToBeChanged(DocumentEvent event) {
                    }

                    public void documentChanged(DocumentEvent event) {
                        previewDirty = true;
                        outlineDirty = true;
                        synchronized (MarkupEditor.this) {
                            ++documentGeneration;
                        }
                        scheduleOutlineUpdate();
                        if (isShowingPreview()) {
                            updatePreview();
                        }
                    }
                };
            }
            document.addDocumentListener(documentListener);
            if (documentPartitioningListener == null) {
                documentPartitioningListener = new IDocumentPartitioningListener() {

                    public void documentPartitioningChanged(IDocument document) {
                        // async update
                        scheduleOutlineUpdate();
                    }
                };
            }
            document.addDocumentPartitioningListener(documentPartitioningListener);
        }
        previewDirty = true;
        outlineDirty = true;
        updateOutline();
    }
}
Also used : IDocumentListener(org.eclipse.jface.text.IDocumentListener) DocumentEvent(org.eclipse.jface.text.DocumentEvent) IDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener) IDocument(org.eclipse.jface.text.IDocument)

Example 2 with IDocumentPartitioningListener

use of org.eclipse.jface.text.IDocumentPartitioningListener in project mylyn.docs by eclipse.

the class WikiTextSourceEditor method updateDocument.

private void updateDocument() {
    if (getSourceViewer() != null) {
        IDocument previousDocument = document;
        document = getSourceViewer().getDocument();
        if (previousDocument == document) {
            return;
        }
        if (previousDocument != null && documentListener != null) {
            previousDocument.removeDocumentListener(documentListener);
        }
        if (previousDocument != null && documentPartitioningListener != null) {
            previousDocument.removeDocumentPartitioningListener(documentPartitioningListener);
        }
        if (document != null) {
            if (documentListener == null) {
                documentListener = new IDocumentListener() {

                    public void documentAboutToBeChanged(DocumentEvent event) {
                    }

                    public void documentChanged(DocumentEvent event) {
                        outlineDirty = true;
                        synchronized (WikiTextSourceEditor.this) {
                            ++documentGeneration;
                        }
                        scheduleOutlineUpdate();
                    }
                };
            }
            document.addDocumentListener(documentListener);
            if (documentPartitioningListener == null) {
                documentPartitioningListener = new IDocumentPartitioningListener() {

                    public void documentPartitioningChanged(IDocument document) {
                        // async update
                        scheduleOutlineUpdate();
                    }
                };
            }
            document.addDocumentPartitioningListener(documentPartitioningListener);
        }
        synchronized (WikiTextSourceEditor.this) {
            outlineDirty = true;
        }
        updateOutline();
    }
}
Also used : IDocumentListener(org.eclipse.jface.text.IDocumentListener) DocumentEvent(org.eclipse.jface.text.DocumentEvent) IDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener) IDocument(org.eclipse.jface.text.IDocument)

Example 3 with IDocumentPartitioningListener

use of org.eclipse.jface.text.IDocumentPartitioningListener in project webtools.sourceediting by eclipse.

the class BasicStructuredDocument method fireDocumentPartitioningChanged.

/**
 * Fires the document partitioning changed notification to all registered
 * document partitioning listeners. Uses a robust iterator.
 *
 * @param event
 *            the document partitioning changed event
 *
 * @see IDocumentPartitioningListenerExtension2
 */
protected void fireDocumentPartitioningChanged(DocumentPartitioningChangedEvent event) {
    if (fDocumentPartitioningListeners == null || fDocumentPartitioningListeners.size() == 0)
        return;
    List list = new ArrayList(fDocumentPartitioningListeners);
    Iterator e = list.iterator();
    while (e.hasNext()) {
        IDocumentPartitioningListener l = (IDocumentPartitioningListener) e.next();
        if (l instanceof IDocumentPartitioningListenerExtension2) {
            IDocumentPartitioningListenerExtension2 extension2 = (IDocumentPartitioningListenerExtension2) l;
            extension2.documentPartitioningChanged(event);
        } else if (l instanceof IDocumentPartitioningListenerExtension) {
            IDocumentPartitioningListenerExtension extension = (IDocumentPartitioningListenerExtension) l;
            extension.documentPartitioningChanged(this, event.getCoverage());
        } else {
            l.documentPartitioningChanged(this);
        }
    }
}
Also used : IDocumentPartitioningListenerExtension(org.eclipse.jface.text.IDocumentPartitioningListenerExtension) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) ArrayList(java.util.ArrayList) IDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener) IDocumentPartitioningListenerExtension2(org.eclipse.jface.text.IDocumentPartitioningListenerExtension2)

Aggregations

IDocumentPartitioningListener (org.eclipse.jface.text.IDocumentPartitioningListener)3 DocumentEvent (org.eclipse.jface.text.DocumentEvent)2 IDocument (org.eclipse.jface.text.IDocument)2 IDocumentListener (org.eclipse.jface.text.IDocumentListener)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IDocumentPartitioningListenerExtension (org.eclipse.jface.text.IDocumentPartitioningListenerExtension)1 IDocumentPartitioningListenerExtension2 (org.eclipse.jface.text.IDocumentPartitioningListenerExtension2)1 IStructuredDocumentRegionList (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)1