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