KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 /**
28  * @since 3.2
29  *
30  */

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     /* (non-Javadoc)
41      * @see org.eclipse.ltk.core.refactoring.Change#getName()
42      */

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

51     public Change perform(IProgressMonitor pm) throws CoreException {
52         Map JavaDoc map = new HashMap JavaDoc();
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