KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.text.MessageFormat JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.jdt.core.IType;
18 import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
19 import org.eclipse.jdt.debug.core.JDIDebugModel;
20 import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
21 import org.eclipse.ltk.core.refactoring.Change;
22 import org.eclipse.ltk.core.refactoring.NullChange;
23
24
25 /**
26  * Change to update a line breakpoint when a IType is moved or renamed.
27  */

28 public class JavaLineBreakpointTypeChange extends JavaBreakpointTypeChange {
29     
30     private int fLineNumber;
31     private int fCharStart;
32     private int fCharEnd;
33     
34     public JavaLineBreakpointTypeChange(IJavaLineBreakpoint lineBreakpoint, Object JavaDoc changedElement, Object JavaDoc argument, int changeType) throws CoreException {
35         super(lineBreakpoint, changedElement, argument, changeType);
36         fLineNumber= lineBreakpoint.getLineNumber();
37         fCharStart= lineBreakpoint.getCharStart();
38         fCharEnd= lineBreakpoint.getCharEnd();
39     }
40
41     /* (non-Javadoc)
42      * @see org.eclipse.jdt.internal.debug.core.refactoring.JavaBreakpointTypeNameChange#getErrorMessageNoMoreExists()
43      */

44     public String JavaDoc getErrorMessageNoMoreExists() {
45         return MessageFormat.format(RefactoringMessages.JavaLineBreakpointTypeChange_0, new String JavaDoc[] {getDeclaringType().getElementName(), Integer.toString(fLineNumber)}); //$NON-NLS-1$
46
}
47
48     /* (non-Javadoc)
49      * @see org.eclipse.ltk.core.refactoring.Change#getName()
50      */

51     public String JavaDoc getName() {
52         return MessageFormat.format(RefactoringMessages.JavaLineBreakpointTypeChange_1, new String JavaDoc[] {getDeclaringType().getElementName(), Integer.toString(fLineNumber)}); //$NON-NLS-1$
53
}
54
55     /* (non-Javadoc)
56      * @see org.eclipse.jdt.internal.debug.core.refactoring.JavaBreakpointTypeNameChange#performChange(org.eclipse.jdt.core.IType, java.lang.String)
57      */

58     public Change performChange(IType newType, Object JavaDoc undoChangedElement, Object JavaDoc undoArgument, int changeType) throws CoreException {
59         if (newType == null) {
60             return new NullChange();
61         }
62         Map JavaDoc attributes= getAttributes();
63         BreakpointUtils.addJavaBreakpointAttributes(attributes, newType);
64         // create the new breakpoint
65
IJavaLineBreakpoint newLineBreakpoint= JDIDebugModel.createLineBreakpoint(
66                 BreakpointUtils.getBreakpointResource(newType),
67                 newType.getFullyQualifiedName(),
68                 fLineNumber,
69                 fCharStart,
70                 fCharEnd,
71                 getHitCount(),
72                 true,
73                 attributes
74                 );
75         // delete the old one
76
getBreakpoint().delete();
77         return new JavaLineBreakpointTypeChange(newLineBreakpoint, undoChangedElement, undoArgument, changeType);
78     }
79
80     public int getCharEnd() {
81         return fCharEnd;
82     }
83     
84     public int getCharStart() {
85         return fCharStart;
86     }
87     
88     /**
89      * Return the number of the line where the breakpoint is set
90      */

91     public int getLineNumber() {
92         return fLineNumber;
93     }
94
95 }
96
Popular Tags