Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Get text from IEditorPart
Get text from IEditorPart [message #269448] Tue, 31 August 2004 04:31
Eclipse UserFriend
Originally posted by: pt00mfr.student.bth.se

Hi, I have a problem with getting text from an IEditorPart object shown in
the workbench. When I use the following code I only get the text that is
shown in the editor from the beginning, not text that have been edited in
the editor after it has been shown. The simple question I have is how to
get text from an IEditorPart?

IWorkbenchWindow window =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();

IEditorReference[] editorReferenceArr = page.getEditorReferences();
for(int i = 0; i < editorReferenceArr.length; i++) {
IEditorPart editor = editorReferenceArr[i].getEditor(true);
if(!editor.isDirty())
continue;
IEditorInput editorInput = editor.getEditorInput();
if(editorInput instanceof IStorageEditorInput) {
IStorageEditorInput iseInput = (IStorageEditorInput) editorInput;
String testCode = ((StringStorage) iseInput.getStorage()).getString();
}
}

StringStorage is a class implements IStorage and getString() only returns
the string object that is stored and viewed in Editor.

/Regards Frasse
Previous Topic:Auto completion 'finish' key?
Next Topic:create ResourceNavigator is not possible?
Goto Forum:
  


Current Time: Wed Nov 05 17:06:39 EST 2025

Powered by FUDForum. Page generated in 0.03071 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top