KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 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.List JavaDoc;
14
15 import org.eclipse.core.resources.IMarker;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.OperationCanceledException;
18 import org.eclipse.debug.core.model.IBreakpoint;
19 import org.eclipse.jdt.core.ICompilationUnit;
20 import org.eclipse.jdt.core.IJavaElement;
21 import org.eclipse.jdt.core.IPackageFragment;
22 import org.eclipse.jdt.core.IType;
23 import org.eclipse.jdt.debug.core.IJavaBreakpoint;
24 import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
25
26 /**
27  * Breakpoint participant for type move.
28  *
29  * @since 3.2
30  */

31 public class BreakpointMoveTypeParticipant extends BreakpointMoveParticipant {
32
33     /* (non-Javadoc)
34      * @see org.eclipse.jdt.internal.debug.core.refactoring.BreakpointRenameParticipant#accepts(org.eclipse.jdt.core.IJavaElement)
35      */

36     protected boolean accepts(IJavaElement element) {
37         return element instanceof IType && getArguments().getDestination() instanceof IPackageFragment;
38     }
39     
40     /* (non-Javadoc)
41      * @see org.eclipse.jdt.internal.debug.core.refactoring.BreakpointMoveParticipant#gatherChanges(org.eclipse.core.resources.IMarker[], java.util.List)
42      */

43     protected void gatherChanges(IMarker[] markers, List JavaDoc changes) throws CoreException, OperationCanceledException {
44         IType originalType = (IType) getOriginalElement();
45         IPackageFragment destPackage = (IPackageFragment) getDestination();
46         for (int i = 0; i < markers.length; i++) {
47             IMarker marker = markers[i];
48             IBreakpoint breakpoint = getBreakpoint(marker);
49             if (breakpoint instanceof IJavaBreakpoint) {
50                 IJavaBreakpoint javaBreakpoint = (IJavaBreakpoint) breakpoint;
51                 IType breakpointType = BreakpointUtils.getType(javaBreakpoint);
52                 if (breakpointType != null && isContained(originalType, breakpointType)) {
53                     ICompilationUnit cu = destPackage.getCompilationUnit(breakpointType.getCompilationUnit().getElementName());
54                     IJavaElement element = BreakpointChange.findElement(cu, breakpointType);
55                     if (element != null) {
56                         if (element instanceof IType) {
57                             IType destType = (IType) element;
58                             changes.add(createTypeChange(javaBreakpoint, destType, breakpointType));
59                         }
60                     }
61                 }
62             }
63         }
64     }
65     
66 }
67
Popular Tags