1 11 package org.eclipse.debug.internal.ui.sourcelookup; 12 13 import org.eclipse.debug.core.ILaunch; 14 import org.eclipse.debug.core.model.IStackFrame; 15 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; 16 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 17 import org.eclipse.debug.internal.ui.views.launch.LaunchView; 18 import org.eclipse.jface.viewers.ISelection; 19 import org.eclipse.jface.viewers.IStructuredSelection; 20 import org.eclipse.ui.IWorkbenchPage; 21 import org.eclipse.ui.PlatformUI; 22 import org.eclipse.ui.actions.SelectionListenerAction; 23 24 29 public class LookupSourceAction extends SelectionListenerAction { 30 31 private ISourceLookupDirector director = null; 32 private LaunchView fView = null; 33 private IStackFrame frame = null; 34 35 public LookupSourceAction(LaunchView view) { 36 super(SourceLookupUIMessages.LookupSourceAction_0); 37 setEnabled(false); 38 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.LOOKUP_SOURCE_ACTION); 39 fView = view; 40 } 41 42 45 protected boolean updateSelection(IStructuredSelection selection) { 46 director = null; 47 frame = null; 48 if (selection.size() == 1) { 49 Object object = selection.getFirstElement(); 50 if (object instanceof IStackFrame) { 51 frame = (IStackFrame)object; 52 ILaunch launch = frame.getLaunch(); 53 if (launch != null && launch.getLaunchConfiguration() != null && 54 launch.getSourceLocator() instanceof ISourceLookupDirector) { 55 director = (ISourceLookupDirector) launch.getSourceLocator(); 56 } 57 } 58 } 59 return director != null; 60 } 61 64 public void run() { 65 ISelection selection = fView.getViewer().getSelection(); 66 if (selection instanceof IStructuredSelection) { 67 IStructuredSelection ss = (IStructuredSelection) selection; 68 if (ss.size() == 1) { 69 IWorkbenchPage page = fView.getSite().getPage(); 70 SourceLookupManager.getDefault().displaySource(ss.getFirstElement(), page, true); 71 } 72 } 73 } 74 } 75 | Popular Tags |