use of org.eclipse.jface.text.IDocumentListener 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.IDocumentListener 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.IDocumentListener in project egit by eclipse.
the class CommitMessageComponent method addListeners.
private void addListeners() {
authorHandler = UIUtils.addPreviousValuesContentProposalToText(authorText, AUTHOR_VALUES_PREF);
authorText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (!listenersEnabled || !authorText.isEnabled())
return;
listener.statusUpdated();
}
});
committerText.addModifyListener(new ModifyListener() {
String oldCommitter = committerText.getText();
@Override
public void modifyText(ModifyEvent e) {
if (!listenersEnabled || !committerText.isEnabled())
return;
if (signedOff) {
// the commit message is signed
// the signature must be updated
String newCommitter = committerText.getText();
String oldSignOff = getSignedOff(oldCommitter);
String newSignOff = getSignedOff(newCommitter);
commitText.setText(replaceSignOff(commitText.getText(), oldSignOff, newSignOff));
oldCommitter = newCommitter;
}
listener.statusUpdated();
}
});
committerHandler = UIUtils.addPreviousValuesContentProposalToText(committerText, COMMITTER_VALUES_PREF);
commitText.getDocument().addDocumentListener(new IDocumentListener() {
@Override
public void documentChanged(DocumentEvent event) {
if (!listenersEnabled || !commitText.isEnabled())
return;
updateSignedOffButton();
updateChangeIdButton();
listener.statusUpdated();
}
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
// nothing to do
}
});
}
use of org.eclipse.jface.text.IDocumentListener in project titan.EclipsePlug-ins by eclipse.
the class DocumentSetupParticipant method setup.
@Override
public void setup(final IDocument document) {
IDocumentPartitioner partitioner = new FastPartitioner(new PartitionScanner(), PartitionScanner.PARTITION_TYPES);
if (document instanceof IDocumentExtension3) {
IDocumentExtension3 extension3 = (IDocumentExtension3) document;
extension3.setDocumentPartitioner(PartitionScanner.CONFIG_PARTITIONING, partitioner);
} else {
document.setDocumentPartitioner(partitioner);
}
partitioner.connect(document);
document.addDocumentListener(new IDocumentListener() {
@Override
public void documentAboutToBeChanged(final DocumentEvent event) {
GlobalIntervalHandler.putInterval(event.getDocument(), null);
}
@Override
public void documentChanged(final DocumentEvent event) {
// Do nothing
}
});
}
use of org.eclipse.jface.text.IDocumentListener in project titan.EclipsePlug-ins by eclipse.
the class DocumentSetupParticipant method setup.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.
* eclipse.jface.text.IDocument)
*/
@Override
public void setup(final IDocument document) {
EditorTracker.remove(editor);
EditorTracker.put((IFile) editor.getEditorInput().getAdapter(IFile.class), editor);
DocumentTracker.put((IFile) editor.getEditorInput().getAdapter(IFile.class), document);
IDocumentPartitioner partitioner = new FastPartitioner(new PartitionScanner(), PartitionScanner.PARTITION_TYPES);
if (document instanceof IDocumentExtension3) {
IDocumentExtension3 extension3 = (IDocumentExtension3) document;
extension3.setDocumentPartitioner(PartitionScanner.ASN1_PARTITIONING, partitioner);
} else {
document.setDocumentPartitioner(partitioner);
}
partitioner.connect(document);
document.addDocumentListener(new IDocumentListener() {
@Override
public void documentAboutToBeChanged(final DocumentEvent event) {
GlobalIntervalHandler.putInterval(event.getDocument(), null);
}
@Override
public void documentChanged(final DocumentEvent event) {
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
analyze(document, false);
}
}
});
analyze(document, true);
}
Aggregations