1 11 package org.eclipse.debug.internal.ui.sourcelookup; 12 13 import org.eclipse.debug.core.ILaunch; 14 import org.eclipse.debug.core.model.IDebugElement; 15 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; 16 import org.eclipse.debug.internal.ui.DebugUIPlugin; 17 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 18 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 19 import org.eclipse.debug.internal.ui.views.launch.LaunchView; 20 import org.eclipse.debug.ui.DebugUITools; 21 import org.eclipse.debug.ui.sourcelookup.SourceLookupDialog; 22 import org.eclipse.jface.viewers.ISelection; 23 import org.eclipse.jface.viewers.IStructuredSelection; 24 import org.eclipse.jface.window.Window; 25 import org.eclipse.swt.widgets.Shell; 26 import org.eclipse.ui.IWorkbenchPage; 27 import org.eclipse.ui.PlatformUI; 28 import org.eclipse.ui.actions.SelectionListenerAction; 29 30 36 public class EditSourceLookupPathAction extends SelectionListenerAction { 37 38 private ISourceLookupDirector director = null; 39 private LaunchView fView = null; 40 41 public EditSourceLookupPathAction(LaunchView view) { 42 super(SourceLookupUIMessages.EditSourceLookupPathAction_0); 43 setEnabled(false); 44 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.EDIT_SOURCELOOKUP_ACTION); 45 setImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_SRC_LOOKUP_MENU)); 46 fView = view; 47 } 48 49 52 protected boolean updateSelection(IStructuredSelection selection) { 53 director = null; 54 if (selection.size() == 1) { 55 Object object = selection.getFirstElement(); 56 ILaunch launch = null; 57 if (object instanceof IDebugElement) { 58 launch = ((IDebugElement)object).getLaunch(); 59 } else if (object instanceof ILaunch) { 60 launch = (ILaunch)object; 61 } 62 if (launch != null && launch.getLaunchConfiguration() != null && 63 launch.getSourceLocator() instanceof ISourceLookupDirector) { 64 director = (ISourceLookupDirector) launch.getSourceLocator(); 65 } 66 } 67 return director != null; 68 } 69 72 public void run() { 73 Shell shell = DebugUIPlugin.getShell(); 74 SourceLookupDialog dialog = new SourceLookupDialog(shell, director); 75 if (dialog.open() == Window.OK) { 76 ISelection selection = fView.getViewer().getSelection(); 77 if (selection instanceof IStructuredSelection) { 78 IStructuredSelection ss = (IStructuredSelection) selection; 79 if (ss.size() == 1) { 80 IWorkbenchPage page = fView.getSite().getPage(); 81 SourceLookupManager.getDefault().displaySource(ss.getFirstElement(), page, true); 82 } 83 } 84 } 85 } 86 } 87 | Popular Tags |