現在、Eclipse プラグインを開発しています。したがって、プロジェクトで現在選択されているファイルを知る必要があります(ランタイム環境ではありません)。今までEclipseから選択を取得しており、選択が(デバッガーからの)ファイルであることを知っています。しかし、それが本当にファイルであるかどうかを確認すると、機能しません。
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("");
}
}
コードをデバッグすると、instanceof
ブロックをステップオーバーします。私は何を間違っていますか?ブロックに入りたい。