Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Handling deletion of project folder and .project file.
Handling deletion of project folder and .project file. [message #325230] Tue, 12 February 2008 14:32 Go to next message
Eclipse UserFriend
Originally posted by: marcio.debarros.gmail.com

Hi,

In my plug-in a single project will be created automatically behind the
scenes in the current workspace, so the user will not be able to name
it. If I delete the project folder and its contents, it seems that the
workbench still keeps a reference to it and gives me a ResourceException
next time I startup with the error "The project descriptor file .project
is missing..."

How can I check if the project is still valid and if necessary force it
to be recreated ?

I added the following checks but it still throws the exception:


IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject project = workspace.getRoot().getProject("MyProject");
try {
project.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
if (!project.exists()) {
project.create(new NullProgressMonitor());
}
if (!project.isOpen()) {
project.open(new NullProgressMonitor());
}


Thanks for any suggestion

--MD.
Re: Handling deletion of project folder and .project file. [message #325240 is a reply to message #325230] Tue, 12 February 2008 22:49 Go to previous messageGo to next message
Eclipse UserFriend
How are you deleting the project?

- Prakash

Eclipse Tips: http://blog.cypal-solutions.com
Eclipse Search: http://www.cypal.in/eclipsesearch

Marcio DeBarros wrote:
> Hi,
>
> In my plug-in a single project will be created automatically behind the
> scenes in the current workspace, so the user will not be able to name
> it. If I delete the project folder and its contents, it seems that the
> workbench still keeps a reference to it and gives me a ResourceException
> next time I startup with the error "The project descriptor file .project
> is missing..."
>
> How can I check if the project is still valid and if necessary force it
> to be recreated ?
>
> I added the following checks but it still throws the exception:
>
>
> IWorkspace workspace = ResourcesPlugin.getWorkspace();
> IProject project = workspace.getRoot().getProject("MyProject");
> try {
> project.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
> if (!project.exists()) {
> project.create(new NullProgressMonitor());
> }
> if (!project.isOpen()) {
> project.open(new NullProgressMonitor());
> }
>
>
> Thanks for any suggestion
>
> --MD.
Re: Handling deletion of project folder and .project file. [message #325253 is a reply to message #325240] Wed, 13 February 2008 09:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marcio.debarros.gmail.com

Prakash G.R. wrote:
> How are you deleting the project?
>
> - Prakash
>
> Eclipse Tips: http://blog.cypal-solutions.com
> Eclipse Search: http://www.cypal.in/eclipsesearch
>
> Marcio DeBarros wrote:
>> Hi,
>>
>> In my plug-in a single project will be created automatically behind
>> the scenes in the current workspace, so the user will not be able to
>> name it. If I delete the project folder and its contents, it seems
>> that the workbench still keeps a reference to it and gives me a
>> ResourceException next time I startup with the error "The project
>> descriptor file .project is missing..."
>>
>> How can I check if the project is still valid and if necessary force
>> it to be recreated ?
>>
>> I added the following checks but it still throws the exception:
>>
>>
>> IWorkspace workspace = ResourcesPlugin.getWorkspace();
>> IProject project = workspace.getRoot().getProject("MyProject");
>> try {
>> project.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
>> if (!project.exists()) {
>> project.create(new NullProgressMonitor());
>> }
>> if (!project.isOpen()) {
>> project.open(new NullProgressMonitor());
>> }
>>
>>
>> Thanks for any suggestion
>>
>> --MD.
Hi Prakash,

In this case I deleted it directly from the file system, which is always
a possibility for a user to do. Since my last post I came up with a
workaround by checking during the bundle activation:

if (!project folder exists)
create folder
if (!project description exists)
create a new one from a copy saved in the plug-in.

So that takes care of the initial problem, but I would like to know if
there is a proper way provided by the Eclipse.

Thanks,
Re: Handling deletion of project folder and .project file. [message #325274 is a reply to message #325253] Wed, 13 February 2008 11:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Hi,

It would be better to NOT delete it through the filesystem. It thinks
that project is still there but closed so that if the folder reappears
it has a project again.

Instead use the Eclipse workbench functions to delete it. There is a
IProject.delete() method that I think should be able to do it. That way
it will be physically delete plus Eclipse will remove the project from
its internal tables too.


--
Thanks,
Rich Kulp
Re: Handling deletion of project folder and .project file. [message #325281 is a reply to message #325274] Wed, 13 February 2008 14:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marcio.debarros.gmail.com

Rich Kulp wrote:
> Hi,
>
> It would be better to NOT delete it through the filesystem. It thinks
> that project is still there but closed so that if the folder reappears
> it has a project again.
>
> Instead use the Eclipse workbench functions to delete it. There is a
> IProject.delete() method that I think should be able to do it. That way
> it will be physically delete plus Eclipse will remove the project from
> its internal tables too.
>
>
Hi Rich,

Thanks for you input. I agree with you 100%, however what I am trying to
do is to make my plug-in foolproof in a way that if the user does that,
the workbench will not throw a fit.


--MD.
Re: Handling deletion of project folder and .project file. [message #325289 is a reply to message #325281] Wed, 13 February 2008 15:12 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

If a user did that then they could do that for any project and every
application would have a problem. But nobody else worries about that.
Users typically never walk into the actual workspace and delete projects
through the filesystem.


>
> Thanks for you input. I agree with you 100%, however what I am trying to
> do is to make my plug-in foolproof in a way that if the user does that,
> the workbench will not throw a fit.
>
>
> --MD.

--
Thanks,
Rich Kulp
Previous Topic:tableviewer scrolling problem
Next Topic:Wrapping source code
Goto Forum:
  


Current Time: Thu Jul 17 19:11:30 EDT 2025

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

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

Back to the top