1 11 package org.eclipse.debug.internal.ui.actions.context; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.debug.core.DebugException; 15 import org.eclipse.debug.core.model.IDebugElement; 16 import org.eclipse.debug.core.model.IThread; 17 import org.eclipse.debug.internal.ui.DebugPluginImages; 18 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 19 import org.eclipse.debug.internal.ui.actions.ActionMessages; 20 import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousSuspendResumeAdapter; 21 import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; 22 import org.eclipse.jface.resource.ImageDescriptor; 23 24 public class ResumeAction extends AbstractDebugContextAction { 25 26 30 protected void doAction(Object element) { 31 if (element instanceof IAdaptable) { 32 IAdaptable adaptable = (IAdaptable) element; 33 IAsynchronousSuspendResumeAdapter suspendResumer = (IAsynchronousSuspendResumeAdapter) adaptable.getAdapter(IAsynchronousSuspendResumeAdapter.class); 34 if (suspendResumer != null) 35 suspendResumer.resume(element, new ActionRequestMonitor()); 36 } 37 } 38 39 43 protected void isEnabledFor(Object element, IBooleanRequestMonitor monitor) { 44 if (element instanceof IAdaptable) { 45 IAdaptable adaptable = (IAdaptable) element; 46 IAsynchronousSuspendResumeAdapter suspendResumer = (IAsynchronousSuspendResumeAdapter) adaptable.getAdapter(IAsynchronousSuspendResumeAdapter.class); 47 if (suspendResumer != null) { 48 suspendResumer.canResume(element, monitor); 49 } else { 50 notSupported(monitor); 51 } 52 } 53 } 54 55 56 64 protected void doActionForAllThreads(Object object) throws DebugException { 65 if (isEnabledForAllThreads(object)) { 66 IDebugElement debugElement = (IDebugElement) object; 67 IThread[] threads = debugElement.getDebugTarget().getThreads(); 68 for (int i = 0; i < threads.length; i++) { 69 IThread thread = threads[i]; 70 if (thread.canResume()) { 71 thread.resume(); 72 } 73 } 74 } 75 } 76 77 81 protected boolean isEnabledForAllThreads(Object element) { 82 if (element instanceof IDebugElement) { 83 IDebugElement debugElement = (IDebugElement) element; 84 try { 85 IThread[] threads = debugElement.getDebugTarget().getThreads(); 86 for (int i = 0; i < threads.length; i++) { 87 if (threads[i].canResume()) { 88 return true; 89 } 90 } 91 } catch (DebugException e) { 92 } 93 } 94 return false; 95 } 96 97 101 protected String getStatusMessage() { 102 return ActionMessages.ResumeActionDelegate_Exceptions_occurred_attempting_to_resume__2; 103 } 104 105 109 protected String getErrorDialogMessage() { 110 return ActionMessages.ResumeActionDelegate_Resume_failed__1; 111 } 112 113 117 public String getText() { 118 return ActionMessages.ResumeAction_0; 119 } 120 121 125 public String getHelpContextId() { 126 return "resume_action_context"; } 128 129 133 public String getId() { 134 return "org.eclipse.debug.ui.debugview.toolbar.resume"; } 136 137 141 public String getToolTipText() { 142 return ActionMessages.ResumeAction_3; 143 } 144 145 149 public ImageDescriptor getDisabledImageDescriptor() { 150 return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_RESUME); 151 } 152 153 157 public ImageDescriptor getHoverImageDescriptor() { 158 return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESUME); 159 } 160 161 165 public ImageDescriptor getImageDescriptor() { 166 return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESUME); 167 } 168 } 169 | Popular Tags |