1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.Status; 17 import org.eclipse.core.runtime.jobs.Job; 18 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 19 import org.eclipse.jface.dialogs.ErrorDialog; 20 import org.eclipse.jface.text.source.IVerticalRulerInfo; 21 import org.eclipse.swt.widgets.Display; 22 import org.eclipse.ui.texteditor.ITextEditor; 23 24 public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerAction { 25 26 29 public EnableDisableBreakpointRulerAction(ITextEditor editor, IVerticalRulerInfo info) { 30 setInfo(info); 31 setTextEditor(editor); 32 setText(ActionMessages.EnableDisableBreakpointRulerAction__Enable_Breakpoint_1); } 34 35 38 public void run() { 39 if (getBreakpoint() != null) { 40 new Job(ActionMessages.EnableDisableBreakpointRulerAction_0) { protected IStatus run(IProgressMonitor monitor) { 42 try { 43 getBreakpoint().setEnabled(!getBreakpoint().isEnabled()); 44 return Status.OK_STATUS; 45 } catch (final CoreException e) { 46 Display.getDefault().asyncExec(new Runnable (){ 47 public void run() { 48 ErrorDialog.openError(getTextEditor().getEditorSite().getShell(), ActionMessages.EnableDisableBreakpointRulerAction_Enabling_disabling_breakpoints_2, ActionMessages.EnableDisableBreakpointRulerAction_Exceptions_occurred_enabling_disabling_the_breakpoint_3, e.getStatus()); } 50 }); 51 } 52 return Status.CANCEL_STATUS; 53 } 54 }.schedule(); 55 } 56 } 57 58 61 public void update() { 62 setBreakpoint(determineBreakpoint()); 63 if (getBreakpoint() == null) { 64 setEnabled(false); 65 return; 66 } 67 setEnabled(true); 68 try { 69 boolean enabled = getBreakpoint().isEnabled(); 70 setText(enabled ? ActionMessages.EnableDisableBreakpointRulerAction__Disable_Breakpoint_4 : ActionMessages.EnableDisableBreakpointRulerAction__Enable_Breakpoint_5); } catch (CoreException ce) { 72 JDIDebugUIPlugin.log(ce); 73 } 74 } 75 } 76 | Popular Tags |