KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > changes > MoveResourceChange


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.corext.refactoring.changes;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IPath;
15 import org.eclipse.core.runtime.IProgressMonitor;
16
17 import org.eclipse.core.resources.IContainer;
18 import org.eclipse.core.resources.IResource;
19
20 import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
21 import org.eclipse.jdt.internal.corext.util.Messages;
22
23 import org.eclipse.ltk.core.refactoring.Change;
24 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
25
26 public class MoveResourceChange extends ResourceReorgChange {
27     
28     public MoveResourceChange(IResource res, IContainer dest){
29         super(res, dest, null);
30     }
31     
32     public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
33         // We already present a dialog to the user if he
34
// moves read-only resources. Since moving a resource
35
// doesn't do a validate edit (it actually doesn't
36
// change the content we can't check for READ only
37
// here.
38
return super.isValid(pm, DIRTY);
39     }
40     
41     /* non java-doc
42      * @see ResourceReorgChange#doPerform(IPath, IProgressMonitor)
43      */

44     protected Change doPerformReorg(IPath path, IProgressMonitor pm) throws CoreException{
45         getResource().move(path, getReorgFlags(), pm);
46         return null;
47     }
48     public String JavaDoc getName() {
49         return Messages.format(RefactoringCoreMessages.MoveResourceChange_move,
50             new String JavaDoc[]{getResource().getFullPath().toString(), getDestination().getName()});
51     }
52 }
53
54
Popular Tags