]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/CopyCompilationUnitChange.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / core refactoring / org / eclipse / jdt / internal / corext / refactoring / changes / CopyCompilationUnitChange.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 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.IProgressMonitor;
15 import org.eclipse.core.runtime.OperationCanceledException;
16
17 import org.eclipse.ltk.core.refactoring.Change;
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 import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
27
28 public class CopyCompilationUnitChange extends CompilationUnitReorgChange {
29
30         public CopyCompilationUnitChange(ICompilationUnit cu, IPackageFragment dest, INewNameQuery newNameQuery){
31                 super(cu, dest, newNameQuery);
32
33                 // Copy compilation unit change isn't undoable and isn't used
34                 // as a redo/undo change right now.
35                 setValidationMethod(SAVE_IF_DIRTY);
36         }
37
38         @Override
39         Change doPerformReorg(IProgressMonitor pm) throws CoreException, OperationCanceledException {
40                 getCu().copy(getDestinationPackage(), null, getNewName(), true, pm);
41                 return null;
42         }
43
44         @Override
45         public String getName() {
46                 return Messages.format(RefactoringCoreMessages.CopyCompilationUnitChange_copy,
47                         new String[]{ BasicElementLabels.getFileName(getCu()), getPackageName(getDestinationPackage())});
48         }
49 }