プロジェクトのポップアップメニューにオプションを追加するためのEclipse用プラグインを開発しました。このオプションはクラスを名前で検索し、パッケージ エクスプローラーでクラスを強調表示します。ハイライト部分に問題があります。フォルダー内のクラスを検索したので、クラスパスはありますが、強調表示する方法がわかりません。
これを試しましたが、結果が得られませんでした:
String path = "D:\\Programs\\eclipse\\runtime-EclipseApplication\\tessssst\\src\\testClass.java";
IPath iPath = new Path(path);
IFile file = project.getFile(iPath);
file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(iPath);
ISelection selection = new StructuredSelection(file);
IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().resetPerspective();
for(IViewReference view:views){
if("org.eclipse.jdt.ui.PackageExplorer".equals(view.getId())){
IViewPart pExplorer = view.getView(true);
pExplorer.getViewSite().getSelectionProvider().setSelection(selection);
break;
}
}
前もって感謝します