1 11 package org.eclipse.ant.internal.ui.debug.model; 12 13 import com.ibm.icu.text.MessageFormat; 14 import java.util.HashMap ; 15 import java.util.Map ; 16 17 import org.eclipse.ant.internal.ui.debug.IAntDebugConstants; 18 import org.eclipse.core.resources.IMarker; 19 import org.eclipse.core.resources.IResource; 20 import org.eclipse.core.resources.IWorkspaceRunnable; 21 import org.eclipse.core.runtime.CoreException; 22 import org.eclipse.core.runtime.IProgressMonitor; 23 import org.eclipse.debug.core.DebugException; 24 import org.eclipse.debug.core.DebugPlugin; 25 import org.eclipse.debug.core.model.IBreakpoint; 26 import org.eclipse.debug.core.model.LineBreakpoint; 27 28 31 public class AntLineBreakpoint extends LineBreakpoint { 32 33 39 public AntLineBreakpoint() { 40 } 41 42 51 public AntLineBreakpoint(IResource resource, int lineNumber) throws CoreException { 52 this(resource, lineNumber, new HashMap (), true); 53 } 54 55 66 public AntLineBreakpoint(final IResource resource, final int lineNumber, final Map attributes, final boolean register) throws CoreException { 67 IWorkspaceRunnable wr= new IWorkspaceRunnable() { 68 public void run(IProgressMonitor monitor) throws CoreException { 69 IMarker marker = resource.createMarker(IAntDebugConstants.ID_ANT_LINE_BREAKPOINT_MARKER); 70 setMarker(marker); 71 attributes.put(IBreakpoint.ENABLED, Boolean.TRUE); 72 attributes.put(IMarker.LINE_NUMBER, new Integer (lineNumber)); 73 attributes.put(IBreakpoint.ID, IAntDebugConstants.ID_ANT_DEBUG_MODEL); 74 attributes.put(IMarker.MESSAGE, MessageFormat.format(DebugModelMessages.AntLineBreakpoint_0, new String [] {Integer.toString(lineNumber)})); 75 ensureMarker().setAttributes(attributes); 76 77 register(register); 78 } 79 }; 80 run(getMarkerRule(resource), wr); 81 } 82 83 86 public String getModelIdentifier() { 87 return IAntDebugConstants.ID_ANT_DEBUG_MODEL; 88 } 89 90 93 public boolean isRunToLine() { 94 try { 95 return ensureMarker().getAttribute(IAntDebugConstants.ANT_RUN_TO_LINE, false); 96 } catch (DebugException e) { 97 return false; 98 } 99 } 100 101 105 private void register(boolean register) throws CoreException { 106 if (register) { 107 DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this); 108 } else { 109 setRegistered(false); 110 } 111 } 112 } 113 | Popular Tags |