I currently develop a Eclipse Plug-in. Therefore I need to know the currently selected File in the Project (not in runtime Environment). Till now I get the selection from Eclipse and I know that the selection is a File (from debugger). But when I check if it is really a File it doesn't work.
ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().getSelection();
if (selection instanceof ITreeSelection) {
ITreeSelection treeSelection = (ITreeSelection) selection;
Object firstElement = treeSelection.getFirstElement(); //This Object is a File
if (firstElement instanceof File) {
File file = (File) firstElement;
String absolutePath = file.getAbsolutePath();
String path = file.getPath();
System.out.println("");
}
}
When I debug the code it steps over the instanceof
block. What am I doing wrong? I want to step into the Block.