1 11 package org.eclipse.jdt.internal.debug.ui.monitors; 12 13 14 import org.eclipse.debug.core.model.IDebugElement; 15 import org.eclipse.debug.ui.IDebugUIConstants; 16 import org.eclipse.jdt.debug.core.IJavaDebugTarget; 17 import org.eclipse.jface.action.IAction; 18 import org.eclipse.jface.viewers.ISelection; 19 import org.eclipse.jface.viewers.IStructuredSelection; 20 import org.eclipse.ui.IViewActionDelegate; 21 import org.eclipse.ui.IViewPart; 22 import org.eclipse.ui.texteditor.IUpdate; 23 24 public abstract class MonitorAction implements IViewActionDelegate, IUpdate { 25 26 protected MonitorsView fView; 27 protected IAction fAction; 28 29 35 protected IStructuredSelection getDebugViewSelection() { 36 if (fView != null) { 37 ISelection s =fView.getViewSite().getPage().getSelection(IDebugUIConstants.ID_DEBUG_VIEW); 38 39 if (s instanceof IStructuredSelection) { 40 return (IStructuredSelection)s; 41 } 42 } 43 return null; 44 } 45 46 protected IJavaDebugTarget getDebugTarget() { 47 IStructuredSelection ss= getDebugViewSelection(); 48 if (ss == null || ss.isEmpty() || ss.size() > 1) { 49 return null; 50 } 51 Object element= ss.getFirstElement(); 52 if (element instanceof IDebugElement) { 53 return (IJavaDebugTarget)((IDebugElement)element).getDebugTarget().getAdapter(IJavaDebugTarget.class); 54 } 55 56 return null; 57 } 58 59 62 public void init(IViewPart view) { 63 fView= (MonitorsView)view; 64 fView.add(this); 65 } 66 67 70 public void selectionChanged(IAction action, ISelection selection) { 71 fAction= action; 72 } 73 } | Popular Tags |