Skip to main content



      Home
Home » Language IDEs » ServerTools (WTP) » Get TreeSelection path
Get TreeSelection path [message #900102] Fri, 03 August 2012 21:50
Eclipse UserFriend
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: Wed Jul 16 23:30:58 EDT 2025

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

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

Back to the top