1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.debug.core.DebugException; 15 import org.eclipse.jdt.debug.core.IJavaStackFrame; 16 import org.eclipse.jdt.internal.debug.ui.ExceptionHandler; 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.swt.widgets.Event; 21 import org.eclipse.ui.IActionDelegate2; 22 import org.eclipse.ui.IViewActionDelegate; 23 import org.eclipse.ui.IViewPart; 24 25 28 public class DropToFrameButton implements IViewActionDelegate, IActionDelegate2 { 29 30 private IJavaStackFrame fFrame = null; 31 32 35 public void init(IViewPart view) { 36 } 37 38 41 public void run(IAction action) { 42 try { 43 fFrame.dropToFrame(); 44 } catch (DebugException e) { 45 String title= ActionMessages.getString("DropToFrameAction.Drop_to_Frame_1"); String message= ActionMessages.getString("DropToFrameAction.Exceptions_occurred_attempting_to_drop_to_frame._2"); ExceptionHandler.handle(e, title, message); 48 } 49 } 50 51 54 public void selectionChanged(IAction action, ISelection selection) { 55 fFrame = null; 56 if (selection instanceof IStructuredSelection) { 57 IStructuredSelection ss = (IStructuredSelection) selection; 58 if (ss.size() == 1) { 59 Object object = ss.getFirstElement(); 60 if (object instanceof IAdaptable) { 61 IJavaStackFrame frame = (IJavaStackFrame) ((IAdaptable)object).getAdapter(IJavaStackFrame.class); 62 if (frame != null && frame.supportsDropToFrame()) { 63 action.setEnabled(true); 64 fFrame = frame; 65 return; 66 } 67 } 68 } 69 } 70 action.setEnabled(false); 71 } 72 73 76 public void init(IAction action) { 77 } 78 79 82 public void dispose() { 83 fFrame = null; 84 } 85 86 89 public void runWithEvent(IAction action, Event event) { 90 run(action); 91 } 92 93 } 94 | Popular Tags |