How to set the selection in package explorer [message #988869] |
Mon, 03 December 2012 09:01 |
Flavius Cerna Messages: 1 Registered: December 2012 |
Junior Member |
|
|
Hi. I also created this post on stackoverflow
stackoverflow.com/questions/13682292/eclipse-package-explorer-set-selection
but without succes and found about this forum and hope I'll have more luck here.
So basicaly I have a file in my workspace; I know it's location and I know it exists.
All I need to do is set it as the current selected(or focused) file in the package explorer.
I tried this
file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(myPath);
if (file != null ) {
//Select the data file
IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
for(IViewReference view:views){
if("org.eclipse.jdt.ui.PackageExplorer".equals(view.getId())){
IViewPart pExplorer = view.getView(true);
pExplorer.getViewSite().getSelectionProvider().setSelection(--);
break;
}
}
But with the information I have on my file, I couldn't manage to create a structuredSelection or something like that which is required as a param for setSelection().
I hope I'm on the right forum. This is really urgent for me so any help is appreciated. Thanks in advance.
|
|
|
Powered by
FUDForum. Page generated in 0.01482 seconds