Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Get TreeSelection path
Get TreeSelection path [message #900102] Sat, 04 August 2012 01:50
rohit chawla is currently offline rohit chawlaFriend
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: Wed Apr 24 19:34:31 GMT 2024

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

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

Back to the top