Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » How to set the selection in package explorer(How to set the selection in package explorer)
icon4.gif  How to set the selection in package explorer [message #988869] Mon, 03 December 2012 14:01
Flavius Cerna is currently offline 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.
Previous Topic:Contribute to CDT Indexer
Next Topic:Set default start level for p2 enabled product
Goto Forum:
  


Current Time: Sun Oct 26 08:02:08 GMT 2014

Powered by FUDForum. Page generated in 0.01875 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software