Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Find if a file is dirty
Find if a file is dirty [message #151915] Fri, 31 October 2003 17:16 Go to next message
Sudarshan Raghavan is currently offline Sudarshan RaghavanFriend
Messages: 15
Registered: July 2009
Junior Member
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 #152115 is a reply to message #151915] Sun, 02 November 2003 13:08 Go to previous messageGo to next message
Eclipse UserFriend
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 #152390 is a reply to message #152115] Mon, 03 November 2003 14:32 Go to previous messageGo to next message
Sudarshan Raghavan is currently offline Sudarshan RaghavanFriend
Messages: 15
Registered: July 2009
Junior Member
Omry,

Smart way of proving your ignorance ;-)

--

"Omry Yadan" <omry@telmap.com> wrote in message
news:bo2vbo$t10$1@eclipse.org...
> 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 messageGo to next message
Eclipse UserFriend
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
>
>
Re: Find if a file is dirty [message #152597 is a reply to message #152574] Mon, 03 November 2003 22:02 Go to previous message
Sudarshan Raghavan is currently offline Sudarshan RaghavanFriend
Messages: 15
Registered: July 2009
Junior Member
Dan,
Thats what I finally did. I was looking for a simple method like
saveDirtyEditor(IFile) which will save a file if it is dirty. Since there
was no such method., I implemented it in my plugin using a logic similar to
yours.

Thanks,
Sudarshan

"Dan Kehn" <eclipse.guide@removeMe.andMeToo.earthlink.net> wrote in message
news:bo6d1v$5du$1@eclipse.org...
> 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
> >
> >
>
>
Previous Topic:getting an IFile from the java editor
Next Topic:CVS Repository
Goto Forum:
  


Current Time: Wed Feb 05 14:11:23 GMT 2025

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

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

Back to the top