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) {
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.TTCN3_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.
@Override
public void setup(final IDocument document) {
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.TTCNPP_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 ch.hsr.ifs.cdttesting by IFS-HSR.
the class Editor method createSourceViewer.
@Override
protected ISourceViewer createSourceViewer(final Composite parent, final IVerticalRuler ruler, final int styles) {
final ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
getSourceViewerDecorationSupport(viewer);
final IEditorInput input = getEditorInput();
final IDocument document = getDocumentProvider().getDocument(input);
file = new TestFile((FileEditorInput) input, getDocumentProvider());
file.parse();
document.addDocumentListener(new IDocumentListener() {
@Override
public void documentChanged(final DocumentEvent event) {
file.parse();
}
@Override
public void documentAboutToBeChanged(final DocumentEvent event) {
}
});
return viewer;
}
use of org.eclipse.jface.text.IDocumentListener in project watchdog by TestRoots.
the class EditorListener method listenToDocumentChanges.
/**
* Adds a document change listener to the supplied editor. Fires a
* {@link StartEditingEditorEvent} when a change to a document is made.
*
* @param partEditor
* @throws IllegalArgumentException
*/
private void listenToDocumentChanges() throws IllegalArgumentException {
IDocumentProvider documentProvider = editor.getDocumentProvider();
document = documentProvider.getDocument(editor.getEditorInput());
documentListener = new IDocumentListener() {
@Override
public void documentChanged(DocumentEvent event) {
/*
* Three events exist that can influence the Levenshtein
* distance:
* 1. Addition. In this case length=0 and text>0, therefore max(length,text)=text=Levenshtein distance.
* 2. Removal. In this case length>0 and text=0, therefore max(length,text)=length=Levenshtein distance.
* 3. Modification. In this case length>0 and text>0, therefore max(length,text)>=Levenshtein distance.
*
* So, in general it holds that modCount >= Levenshtein
* distance.
*/
int textLength = 0;
if (event.getText() != null) {
textLength = event.getText().length();
}
int modCount = Math.max(event.getLength(), textLength);
WatchDogEventType.SUBSEQUENT_EDIT.process(new WatchDogEventType.EditorWithModCount(editor, modCount));
}
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
WatchDogEventType.START_EDIT.process(editor);
}
};
document.addDocumentListener(documentListener);
}
use of org.eclipse.jface.text.IDocumentListener in project xtext-eclipse by eclipse.
the class DocumentTokenSourceTest method setUp.
@Before
public void setUp() throws Exception {
tokenSource = new DocumentTokenSource();
tokenSource.setLexer(new Provider<Lexer>() {
@Override
public Lexer get() {
return new org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer();
}
});
document = new Document("");
document.addDocumentListener(new IDocumentListener() {
@Override
public void documentChanged(DocumentEvent event) {
tokenSource.updateStructure(event);
}
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
}
});
}
Aggregations