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.refactoring.reorg.INewNameQuery;
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 CopyResourceChange extends ResourceReorgChange {
27:
28: public CopyResourceChange(IResource res, IContainer dest,
29: INewNameQuery newNameQuery) {
30: super (res, dest, newNameQuery);
31: }
32:
33: public RefactoringStatus isValid(IProgressMonitor pm)
34: throws CoreException {
35: // Copy resource change isn't undoable and isn't used
36: // as a redo/undo change right now.
37: return super .isValid(pm, SAVE_IF_DIRTY);
38: }
39:
40: protected Change doPerformReorg(IPath path, IProgressMonitor pm)
41: throws CoreException {
42: getResource().copy(path, getReorgFlags(), pm);
43: return null;
44: }
45:
46: public String getName() {
47: return Messages.format(
48: RefactoringCoreMessages.CopyResourceString_copy,
49: new String[] { getResource().getFullPath().toString(),
50: getDestination().getName() });
51: }
52: }
|