01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 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.IProgressMonitor;
14: import org.eclipse.core.runtime.OperationCanceledException;
15:
16: import org.eclipse.ltk.core.refactoring.Change;
17: import org.eclipse.ltk.core.refactoring.RefactoringStatus;
18:
19: import org.eclipse.jdt.core.ICompilationUnit;
20: import org.eclipse.jdt.core.IPackageFragment;
21:
22: import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
23: import org.eclipse.jdt.internal.corext.refactoring.reorg.INewNameQuery;
24: import org.eclipse.jdt.internal.corext.util.Messages;
25:
26: public class CopyCompilationUnitChange extends
27: CompilationUnitReorgChange {
28:
29: public CopyCompilationUnitChange(ICompilationUnit cu,
30: IPackageFragment dest, INewNameQuery newNameQuery) {
31: super (cu, dest, newNameQuery);
32: }
33:
34: public RefactoringStatus isValid(IProgressMonitor pm)
35: throws CoreException {
36: // Copy compilation unit change isn't undoable and isn't used
37: // as a redo/undo change right now.
38: return super .isValid(pm, SAVE_IF_DIRTY);
39: }
40:
41: Change doPerformReorg(IProgressMonitor pm) throws CoreException,
42: OperationCanceledException {
43: getCu().copy(getDestinationPackage(), null, getNewName(), true,
44: pm);
45: return null;
46: }
47:
48: public String getName() {
49: return Messages.format(
50: RefactoringCoreMessages.CopyCompilationUnitChange_copy,
51: new String[] { getCu().getElementName(),
52: getPackageName(getDestinationPackage()) });
53: }
54: }
|