[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform] Re: use of addDocumentListener(..)

Hi vikram,
Can i get more insight..
I must acknowledge here that i am still very much a novice in understanding how eclipse works, but what i intend to do is add a document listener to every type of document (.xml,.doc.txt etc) that can be opened in an eclipse document window. I want to access the document provider of any existing editor in eclipse, get the document and then add a document listener. Below are my codes.


Thanks,
Mgla

public void docListner(){
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow() getActivePage();
IEditorPart part = page.getActiveEditor();
if (!(part instanceof AbstractTextEditor)) return;
ITextEditor editor = (ITextEditor) part;
IDocumentProvider dp = editor.getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
doc.addDocumentListener(this);
}