KickJava   Java API By Example, From Geeks To Geeks.

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


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.refactoring.reorg.INewNameQuery;
22 import org.eclipse.jdt.internal.corext.util.Messages;
23
24 import org.eclipse.ltk.core.refactoring.Change;
25 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
26
27 public class CopyResourceChange extends ResourceReorgChange {
28     
29     public CopyResourceChange(IResource res, IContainer dest, INewNameQuery newNameQuery){
30         super(res, dest, newNameQuery);
31     }
32     
33     public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
34         // Copy resource change isn't undoable and isn't used
35
// as a redo/undo change right now. Furthermore the current
36
// implementation allows copying dirty files. In this case only
37
// the content on disk is copied.
38
return super.isValid(pm, NONE);
39     }
40     
41     protected Change doPerformReorg(IPath path, IProgressMonitor pm) throws CoreException{
42         getResource().copy(path, getReorgFlags(), pm);
43         return null;
44     }
45     
46     public String JavaDoc getName() {
47         return Messages.format(RefactoringCoreMessages.CopyResourceString_copy,
48             new String JavaDoc[]{getResource().getFullPath().toString(), getDestination().getName()});
49     }
50 }
51
Popular Tags