KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > refactoring > reorg > ReorgCopyWizard


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.ui.refactoring.reorg;
12
13 import org.eclipse.core.resources.IResource;
14
15 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
16 import org.eclipse.ltk.core.refactoring.participants.CopyRefactoring;
17 import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
18
19 import org.eclipse.jdt.core.IJavaElement;
20 import org.eclipse.jdt.core.JavaModelException;
21
22 import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgDestinationValidator;
23 import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaCopyProcessor;
24
25
26 public class ReorgCopyWizard extends RefactoringWizard {
27
28     public ReorgCopyWizard(CopyRefactoring ref) {
29         super(ref, DIALOG_BASED_USER_INTERFACE | NO_PREVIEW_PAGE);
30         setDefaultPageTitle(ReorgMessages.ReorgCopyWizard_1);
31     }
32
33     /* (non-Javadoc)
34      * @see org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard#addUserInputPages()
35      */

36     protected void addUserInputPages() {
37         addPage(new CopyInputPage());
38     }
39     
40     private static class CopyInputPage extends ReorgUserInputPage{
41
42         private static final String JavaDoc PAGE_NAME= "CopyInputPage"; //$NON-NLS-1$
43

44         public CopyInputPage() {
45             super(PAGE_NAME);
46         }
47
48         private JavaCopyProcessor getCopyProcessor(){
49             return (JavaCopyProcessor)((CopyRefactoring)getRefactoring()).getCopyProcessor();
50         }
51
52         protected Object JavaDoc getInitiallySelectedElement() {
53             return getCopyProcessor().getCommonParentForInputElements();
54         }
55
56         protected IJavaElement[] getJavaElements() {
57             return getCopyProcessor().getJavaElements();
58         }
59
60         protected IResource[] getResources() {
61             return getCopyProcessor().getResources();
62         }
63
64         protected IReorgDestinationValidator getDestinationValidator() {
65             return getCopyProcessor();
66         }
67         
68         protected RefactoringStatus verifyDestination(Object JavaDoc selected) throws JavaModelException{
69             if (selected instanceof IJavaElement)
70                 return getCopyProcessor().setDestination((IJavaElement)selected);
71             if (selected instanceof IResource)
72                 return getCopyProcessor().setDestination((IResource)selected);
73             return RefactoringStatus.createFatalErrorStatus(ReorgMessages.ReorgCopyWizard_2);
74         }
75     }
76 }
77
Popular Tags