01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.corext.refactoring.changes;
11:
12: import org.eclipse.core.runtime.CoreException;
13: import org.eclipse.core.runtime.IPath;
14: import org.eclipse.core.runtime.IProgressMonitor;
15:
16: import org.eclipse.core.resources.IContainer;
17: import org.eclipse.core.resources.IResource;
18:
19: import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
20: import org.eclipse.jdt.internal.corext.util.Messages;
21:
22: import org.eclipse.ltk.core.refactoring.Change;
23: import org.eclipse.ltk.core.refactoring.RefactoringStatus;
24:
25: public class MoveResourceChange extends ResourceReorgChange {
26:
27: public MoveResourceChange(IResource res, IContainer dest) {
28: super (res, dest, null);
29: }
30:
31: public RefactoringStatus isValid(IProgressMonitor pm)
32: 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)
45: throws CoreException {
46: getResource().move(path, getReorgFlags(), pm);
47: return null;
48: }
49:
50: public String getName() {
51: return Messages.format(
52: RefactoringCoreMessages.MoveResourceChange_move,
53: new String[] { getResource().getFullPath().toString(),
54: getDestination().getName() });
55: }
56: }
|