|
Re: Find if a file is dirty [message #152115 is a reply to message #151915] |
Sun, 02 November 2003 13:08 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: omry.telmap.com
try to wash it, and see if it the water gets dirtyy.
;)
Sudarshan Raghavan wrote:
> Hi,
>
> Is there an easy way to find if the IFile I am dealing with is dirty
> (currently open in an editor and the contents have been modified) ? I have
> to consider the possibility of multiple workbench windows and multiple pages
> within these windows. The IWorkbench.saveAllEditors() method considers all
> the files in the workbench and does not serve my purpose.
>
> Thanks,
> Sudarshan
>
>
|
|
|
|
Re: Find if a file is dirty [message #152574 is a reply to message #151915] |
Mon, 03 November 2003 20:17 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: eclipse.guide.removeMe.andMeToo.earthlink.net
Wouldn't something like this work?
public boolean isFileDirty(IFile f) {
IWorkbenchWindow[] wbWindows =
PlatformUI.getWorkbench().getWorkbenchWindows();
for (each window) {
IWorkbenchPage activePage wbWindow.getActivePage();
IEditorReferences[] editorRefs = activePage.getEditorReferences();
for (each editor reference) {
if (editorRef.isDirty() &&
editorRef instanceof IFileEditorInput &&
editorRef.getFile().equals(f) &&
return true;
}
}
return false;
}
I left out required casts, assignments, etc. I haven't tested this but it's
basically all copied code. BTW, you don't have to consider multiple pages
for each window since there is only one editor reference set for all
perspectives within a given window.
-- Dan
---------------------------------------------------
co-author "The Java Developer's Guide to Eclipse"
http://www.amazon.com/exec/obidos/ASIN/0321159640
"Sudarshan Raghavan" <bali_n@yahoo.com> wrote in message
news:bnu5bh$iqn$1@eclipse.org...
> Hi,
>
> Is there an easy way to find if the IFile I am dealing with is dirty
> (currently open in an editor and the contents have been modified) ? I have
> to consider the possibility of multiple workbench windows and multiple
pages
> within these windows. The IWorkbench.saveAllEditors() method considers all
> the files in the workbench and does not serve my purpose.
>
> Thanks,
> Sudarshan
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03599 seconds