Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » programatically deleting project : i would need some tips
programatically deleting project : i would need some tips [message #335737] Fri, 24 April 2009 15:54 Go to next message
Bozier jerome is currently offline Bozier jeromeFriend
Messages: 2
Registered: July 2009
Junior Member
I face some problems when programatically manipulating projects :

for my application, i let user have the ability to select sub-items of
things he decides to delete (so, container childs, project childs, etc...)

let's take a basic example, an empty java project :
<prj>
<bin>
<src>
<.settings>
<.project>
<.classpath>

at start, i test if prj exists, then delete all its childs, then delete
prj itself when all its childs are deleted.

first problem : when i try to delete prj, prj.exists() return false, so
physical delete on disk is not performed, only logical delete in workspace
is.
i tryed to filter some elements (not deleting .classpath and .project) but
it changes nothing. any hint ?

second problem : in case of closed project, i try to call prj.delete(...)
with flags to force delete contens on disk. project disapear from
workspace but not from disk. is there's a way to do it cleanly ?

third problem : in case of a plugin project, with several .java file
inside, i got an exception when trying to delete "MANIFEST.MF", probably
because of auto-build that have a handle on it. is there is a way to stop
auto-build programatically ?

many thanks in advance,

Jerome Bozier
TPTP project
IBM Rational
Re: programatically deleting project : i would need some tips [message #335741 is a reply to message #335737] Fri, 24 April 2009 18:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Bozier jerome wrote:
> I face some problems when programatically manipulating projects :
>
> for my application, i let user have the ability to select sub-items of
> things he decides to delete (so, container childs, project childs, etc...)
>
> let's take a basic example, an empty java project :
> <prj>
> <bin>
> <src>
> <.settings>
> <.project>
> <.classpath>
> at start, i test if prj exists, then delete all its childs, then
> delete prj itself when all its childs are deleted.

Why not just delete prj from the beginning, instead of deleting children
first? That would seem to solve most, if not all, of the problem you
describe.
[more below]

>
> first problem : when i try to delete prj, prj.exists() return false, so
> physical delete on disk is not performed, only logical delete in
> workspace is.
> i tryed to filter some elements (not deleting .classpath and .project)
> but it changes nothing. any hint ?
>
> second problem : in case of closed project, i try to call
> prj.delete(...) with flags to force delete contens on disk. project
> disapear from workspace but not from disk. is there's a way to do it
> cleanly ?

I would just test for openness and if closed, open it first; then
delete. Actually, the Navigator view (from Resources perspective) allows
you to delete close projects and their disk contents, so I'd look at
what it is doing in the code.

> third problem : in case of a plugin project, with several .java file
> inside, i got an exception when trying to delete "MANIFEST.MF", probably
> because of auto-build that have a handle on it. is there is a way to
> stop auto-build programatically ?

Are you trying the delete during a build? If so, it should probably be
scheduled as a separate Job or perhaps added to the build "work queue."
You can disable/enable auto-build via the IWorkspaceDescription
interface, obtained by ResourcesPlugin.getWorkspace().getDescription().

But I still think deleting the IProject first will be the best option.

Hope this helps,
Eric
Re: programatically deleting project : i would need some tips [message #335751 is a reply to message #335741] Mon, 27 April 2009 09:16 Go to previous message
Bozier jerome is currently offline Bozier jeromeFriend
Messages: 2
Registered: July 2009
Junior Member
many thanks for the help
before, i was first deleting project childs and then, if all childs where
selected, the project
now, in case all childs are selected, i do not delete them but instead, i
delete the whole project and all works fine
Previous Topic:Function to insert oder update @date in javadoc
Next Topic:CVS Deletion of CVS directories created outside of eclipse
Goto Forum:
  


Current Time: Sun Nov 23 05:58:35 GMT 2014

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

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