KickJava   Java API By Example, From Geeks To Geeks.

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


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.IJavaExceptionBreakpoint;
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
23
24 /**
25  * Change to update an exception breakpoint when a IType is moved or renamed.
26  */

27 public class JavaExceptionBreakpointTypeChange extends JavaBreakpointTypeChange {
28
29     private boolean fIsCaught;
30     private boolean fIsUncaught;
31     private boolean fIsChecked;
32     
33     public JavaExceptionBreakpointTypeChange(IJavaExceptionBreakpoint classPrepareBreakpoint, Object JavaDoc changedElement, Object JavaDoc argument, int changeType) throws CoreException {
34         super(classPrepareBreakpoint, changedElement, argument, changeType);
35         fIsCaught= classPrepareBreakpoint.isCaught();
36         fIsUncaught= classPrepareBreakpoint.isUncaught();
37         fIsChecked= classPrepareBreakpoint.isChecked();
38     }
39
40     /* (non-Javadoc)
41      * @see org.eclipse.jdt.internal.debug.core.refactoring.JavaBreakpointTypeNameChange#getErrorMessageNoMoreExists()
42      */

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

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

57     public Change performChange(IType newType, Object JavaDoc undoChangedElement, Object JavaDoc undoArgument, int changeType) throws CoreException {
58         Map JavaDoc attributes= getAttributes();
59         BreakpointUtils.addJavaBreakpointAttributes(attributes, newType);
60         // create the new breakpoint
61
IJavaExceptionBreakpoint newExceptionBreakpoint= JDIDebugModel.createExceptionBreakpoint(
62                 BreakpointUtils.getBreakpointResource(newType),
63                 newType.getFullyQualifiedName(),
64                 fIsCaught,
65                 fIsUncaught,
66                 fIsChecked,
67                 true,
68                 attributes);
69         // delete the old one
70
getBreakpoint().delete();
71         return new JavaExceptionBreakpointTypeChange(newExceptionBreakpoint, undoChangedElement, undoArgument, changeType);
72     }
73
74 }
75
Popular Tags