KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > core > refactoring > MethodBreakpointMethodChange


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.core.refactoring;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
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.IMethod;
20 import org.eclipse.jdt.debug.core.IJavaMethodBreakpoint;
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 /**
28  * @since 3.2
29  *
30  */

31 public class MethodBreakpointMethodChange extends MethodBreakpointChange {
32
33     private IMethod fDestMethod;
34     
35     public MethodBreakpointMethodChange(IJavaMethodBreakpoint breakpoint, IMethod destMethod) throws CoreException {
36         super(breakpoint);
37         fDestMethod = destMethod;
38     }
39     /* (non-Javadoc)
40      * @see org.eclipse.ltk.core.refactoring.Change#getName()
41      */

42     public String JavaDoc getName() {
43         return MessageFormat.format(RefactoringMessages.MethodBreakpointMethodChange_0,
44                 new String JavaDoc[] {getBreakpointLabel(getOriginalBreakpoint()), fDestMethod.getElementName()});
45     }
46
47     /* (non-Javadoc)
48      * @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
49      */

50     public Change perform(IProgressMonitor pm) throws CoreException {
51         Map JavaDoc map = new HashMap JavaDoc();
52         BreakpointUtils.addJavaBreakpointAttributes(map, fDestMethod);
53         IResource resource = BreakpointUtils.getBreakpointResource(fDestMethod);
54         int range[] = getNewLineNumberAndRange(fDestMethod);
55         IJavaMethodBreakpoint breakpoint = JDIDebugModel.createMethodBreakpoint(
56                 resource,
57                 fDestMethod.getDeclaringType().getFullyQualifiedName(),
58                 fDestMethod.getElementName(),
59                 fDestMethod.getSignature(),
60                 isEntry(),
61                 isExit(),
62                 isNativeOnly(),
63                 range[0],
64                 range[1],
65                 range[2],
66                 getHitCount(),
67                 true,
68                 map);
69         apply(breakpoint);
70         getOriginalBreakpoint().delete();
71         return new DeleteBreakpointChange(breakpoint);
72     }
73
74 }
75
Popular Tags