Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Get TreeSelection path
Get TreeSelection path [message #900102] Sat, 04 August 2012 01:50
rohit chawla is currently offline rohit chawla
Messages: 19
Registered: June 2012
Junior Member
Hi, What is a good way to get the location of current selection in packageExplorer? The selection instance returned is always TreeSelection. But how to get path from the TreeSelection. I am using the following ugly way, which sometimes work & sometimes does not?

I researched a lot on net, but didn't find any good solution.

		IPath path = null;
		try{
			
			Object element = ((TreeSelection) selection). getFirstElement();
			if (element instanceof JavaProject) {
				path = ((JavaProject) element).getPath();

			} else if (element instanceof PackageFragmentRoot) {
				path = ((PackageFragmentRoot) element).getPath();
			} else if (element instanceof PackageFragment) {
				path = ((PackageFragment) element).getPath();
			}
			return path.toString();
		}


Previous Topic:entity expansion limit
Next Topic:Creating JSP, XML got fatal errors please help :(
Goto Forum:
  


Current Time: Tue Sep 16 13:30:51 GMT 2014

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

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