1 11 package org.eclipse.ui.views.navigator; 12 13 import org.eclipse.core.resources.IContainer; 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.jface.viewers.StructuredSelection; 16 import org.eclipse.ui.PlatformUI; 17 18 23 public class GotoResourceAction extends ResourceNavigatorAction { 24 31 public GotoResourceAction(IResourceNavigator navigator, String label) { 32 super(navigator, label); 33 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, 34 INavigatorHelpContextIds.GOTO_RESOURCE_ACTION); 35 } 36 37 42 public void run() { 43 IContainer container = (IContainer) getViewer().getInput(); 44 GotoResourceDialog dialog = new GotoResourceDialog(getShell(), 45 container, IResource.FILE | IResource.FOLDER 46 | IResource.PROJECT); 47 dialog.open(); 48 Object [] result = dialog.getResult(); 49 if (result == null || result.length == 0 50 || result[0] instanceof IResource == false) { 51 return; 52 } 53 54 IResource selection = (IResource) result[0]; 55 getViewer().setSelection(new StructuredSelection(selection), true); 56 } 57 } 58 | Popular Tags |