Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-core-dev] get IProject in a Wizard

-----------------------------------
Sorry for posting this here, but the newsgroup did not deliver the information I need!
-----------------------------------

I got a wizard and want to get the corresponding IProject from StructuredSelection (or from whereever)


public static IProject getProject(IStructuredSelection select){
IProject out = null;
Object o = select.getFirstElement();
IResource resource = null;
if (obj instanceof IResource){
System.out.println("IResource");
resource = (IResource) obj;
}
if (obj instanceof IFile){
System.out.println("IFile");
} 
if (obj instanceof IProject) {
System.out.println("IProject");
} 
}
}
This works for Files + Folders in the resource explorer but not in the Java package explorer. There it only works for the file. I get some Inferfaces from the JDT (org.eclipse.jdt.internal.core.PackageFragment). I do not want to be dependent on what plugin (C++/Java) I develop as my wizard adds some XML functionality. So is there a way to get the IProject out of a wizard even in the Package Explorer?

Thank you very much,
Dennis


Back to the top