KickJava   Java API By Example, From Geeks To Geeks.

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


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
12 package org.eclipse.jdt.internal.debug.core.refactoring;
13
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.core.runtime.IProgressMonitor;
16 import org.eclipse.core.runtime.OperationCanceledException;
17 import org.eclipse.jdt.core.IPackageFragment;
18 import org.eclipse.jdt.core.IPackageFragmentRoot;
19 import org.eclipse.ltk.core.refactoring.Change;
20 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
21 import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
22 import org.eclipse.ltk.core.refactoring.participants.MoveParticipant;
23
24
25 /**
26  * Participant for IPackageFragment move.
27  */

28 public class LaunchConfigurationIPackageFragmentMoveParticipant extends MoveParticipant {
29
30     private IPackageFragment fPackageFragment;
31     private IPackageFragmentRoot 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         fPackageFragment= (IPackageFragment)element;
38         Object JavaDoc destination= getArguments().getDestination();
39         if (destination instanceof IPackageFragmentRoot) {
40             fDestination= (IPackageFragmentRoot) destination;
41             // nothing to do if the project doesn't change
42
if (fDestination.getJavaProject().equals(fPackageFragment.getJavaProject())) {
43                 return false;
44             }
45             return true;
46         }
47         return false;
48     }
49
50     /* (non-Javadoc)
51      * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName()
52      */

53     public String JavaDoc getName() {
54         return RefactoringMessages.LaunchConfigurationParticipant_0;
55     }
56
57     /* (non-Javadoc)
58      * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
59      */

60     public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException {
61         return new RefactoringStatus();
62     }
63
64     /* (non-Javadoc)
65      * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
66      */

67     public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
68         return JDTDebugRefactoringUtil.createChangesForPackageMove(fPackageFragment, fDestination);
69     }
70
71 }
72
Popular Tags