KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 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 org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.jdt.core.IJavaElement;
16 import org.eclipse.jdt.core.IPackageFragment;
17 import org.eclipse.jdt.core.IType;
18 import org.eclipse.jdt.core.JavaModelException;
19 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
20 import org.eclipse.ltk.core.refactoring.Change;
21 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
22 import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
23 import org.eclipse.ltk.core.refactoring.participants.MoveParticipant;
24
25
26 /**
27  */

28 public class LaunchConfigurationITypeMoveParticipant extends MoveParticipant {
29     
30     private IType fType;
31     private IJavaElement fDestination;
32
33     /* (non-Javadoc)
34      * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object)
35      */

36     protected boolean initialize(Object JavaDoc element) {
37         fType= (IType)element;
38         try {
39             // check that the type is no a local, and is no declared in a local type
40
IType declaringType= fType;
41             while (declaringType != null) {
42                 if (fType.isLocal()) {
43                     return false;
44                 }
45                 declaringType= declaringType.getDeclaringType();
46             }
47         } catch (JavaModelException e) {
48             JDIDebugUIPlugin.log(e);
49         }
50         Object JavaDoc destination= getArguments().getDestination();
51         if (destination instanceof IPackageFragment || destination instanceof IType) {
52             fDestination= (IJavaElement) destination;
53             return true;
54         }
55         return false;
56     }
57
58     /* (non-Javadoc)
59      * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
60      */

61     public String JavaDoc getName() {
62         return RefactoringMessages.LaunchConfigurationParticipant_0;
63     }
64
65     /* (non-Javadoc)
66      * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
67      */

68     public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) {
69         return new RefactoringStatus();
70     }
71
72     /* (non-Javadoc)
73      * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
74      */

75     public Change createChange(IProgressMonitor pm) throws CoreException {
76         return JDTDebugRefactoringUtil.createChangesForTypeMove(fType, fDestination);
77     }
78
79 }
80
Popular Tags