views:

257

answers:

2

I am attempting to get full path of a selected node in the package explorer which is a folder or package not a file in my Eclipse Ganymede plug-in. I tried the way that is mentioned at http://stackoverflow.com/questions/585802/how-to-get-the-selected-node-in-the-package-explorer-from-an-eclipse-plugin page, but whenever i use the following line in my code,

IFile file = (IFile) structured.getFirstElement(); (This one) IPath path = file.getLocation();

plugin does not work and does not respond also it gives no exception warning. When i changed IFile declaration to Object declaration it is fine. But i need to get file or folder to get full path for my operations.

Any help will be appreciated...

A: 

May be you should debug your code and check what is the actual type of the selection's first element.

You should also launch your second eclipse instance when testing with the -consolelog option in order to have error log redirected to the console. (for information about error log, if your are running your app from an SDK eclipse using Eclipse launch configuration, you have to check the error log of the second instance to see errors and not the one of the first eclipse instance ... I am used to see people confusing this )

Manuel Selva
A: 

I figured out this issue. I used IJavaElement instead of using IFile. I get IJavaElement with using IPackageFragmentRoot a=(IPackageFragmentRoot) b.getParent(); IJavaElement[] c=a.getChildren();

. Before these, I added imported packages of org.eclipse.jdt.core.dom to dependecies of plugin. Now I can take full path of each IJavaElement whether it is a file or folder.

Erhan