If you use an online repo like e.g. bitbucket, which is free for public and private repos by the way, you will have little chance of this ever happening again. Using a SVN or other version control plugin in Eclipse makes this not too difficult. Using an online repo means that your code is both on your computer and on an online location. Losing both is extremely unlikely.
Also, hurray for local history in Eclipse!