How can an Eclipse plugin access the project directory?

By : Milhous
Source: Stackoverflow.com
Question!

Is there a way to get the directory of a project in Eclipse? We are writing a plugin that will allow the user to select files, and then run some processes on those files. I would ideally like to be able to get all the files with a certain extension, but that is not necessary.

By : Milhous


Answers

If you want to enable your users to select files inside eclipse workspace with a certain extension, you can look at the class org.eclipse.ui.dialogs.ElementTreeSelectionDialog (org.eclipse.ui.dialogs plugin)as a start.

Then, to have an example on how to make it filter extensions, you can look at the class org.eclipse.jdt.internal.ui.viewsupport.FilteredElementTreeSelectionDialog (org.eclipse.jdt.ui plugin) to see how they do it and then reimplement the stuff.

This should give you a higher level of action than going threw files inside projects by hand and reimplement dialogs.

By : Denis R.


Since you can't use lambda you can just replace it with an anonymous delegate.

myCar = carList.Find(delegate(Car car) { return car.Year == i; });
By : Ajaxx


I don't use pydev, but to drop to python's interactive REPL from code:

import code
code.interact(local=locals())

To drop to python's debugger from code:

import pdb
pdb.set_trace()

Finally, to run a interactive REPL after running some code, you can use python's -i switch:

python -i script.py

That will give you a python prompt after the code, even if it throws an exception.

You may be able to hook some of those solutions into pydev, I think.

By : nosklo


This video can help you solving your question :)
By: admin