1 11 package org.eclipse.jdt.internal.debug.core.refactoring; 12 13 import java.util.HashMap ; 14 import java.util.Map ; 15 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IProgressMonitor; 19 import org.eclipse.jdt.core.IField; 20 import org.eclipse.jdt.debug.core.IJavaWatchpoint; 21 import org.eclipse.jdt.debug.core.JDIDebugModel; 22 import org.eclipse.jdt.internal.debug.ui.BreakpointUtils; 23 import org.eclipse.ltk.core.refactoring.Change; 24 25 import com.ibm.icu.text.MessageFormat; 26 27 31 public class WatchpointFieldChange extends WatchpointChange { 32 33 private IField fDestField; 34 35 public WatchpointFieldChange(IJavaWatchpoint watchpoint, IField destField) throws CoreException { 36 super(watchpoint); 37 fDestField = destField; 38 } 39 40 43 public String getName() { 44 return MessageFormat.format(RefactoringMessages.WatchpointFieldChange_0, 45 new String [] {getBreakpointLabel(getOriginalBreakpoint()), fDestField.getElementName()}); 46 } 47 48 51 public Change perform(IProgressMonitor pm) throws CoreException { 52 Map map = new HashMap (); 53 BreakpointUtils.addJavaBreakpointAttributes(map, fDestField); 54 IResource resource = BreakpointUtils.getBreakpointResource(fDestField); 55 int[] range = getNewLineNumberAndRange(fDestField); 56 IJavaWatchpoint breakpoint = JDIDebugModel.createWatchpoint( 57 resource, 58 fDestField.getDeclaringType().getFullyQualifiedName(), 59 fDestField.getElementName(), 60 range[0], 61 range[1], 62 range[2], 63 getHitCount(), 64 true, 65 map); 66 apply(breakpoint); 67 getOriginalBreakpoint().delete(); 68 return new DeleteBreakpointChange(breakpoint); 69 } 70 71 } 72 | Popular Tags |