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 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…
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.