KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.runtime.Assert;
14
15 import org.eclipse.jface.resource.ImageDescriptor;
16
17 import org.eclipse.ltk.core.refactoring.Refactoring;
18 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
19 import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
20 import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
21
22 import org.eclipse.jdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor;
23 import org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor;
24
25 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
26 import org.eclipse.jdt.internal.ui.JavaPluginImages;
27 import org.eclipse.jdt.internal.ui.refactoring.RefactoringMessages;
28
29 /**
30  * The type renaming wizard.
31  */

32 public class RenameTypeWizard extends RenameRefactoringWizard {
33
34     public RenameTypeWizard(Refactoring refactoring) {
35         this(refactoring, RefactoringMessages.RenameTypeWizard_defaultPageTitle, RefactoringMessages.RenameTypeWizardInputPage_description, JavaPluginImages.DESC_WIZBAN_REFACTOR_TYPE,
36                 IJavaHelpContextIds.RENAME_TYPE_WIZARD_PAGE);
37     }
38
39     public RenameTypeWizard(Refactoring refactoring, String JavaDoc defaultPageTitle, String JavaDoc inputPageDescription, ImageDescriptor inputPageImageDescriptor, String JavaDoc pageContextHelpId) {
40         super(refactoring, defaultPageTitle, inputPageDescription, inputPageImageDescriptor, pageContextHelpId);
41     }
42
43     /*
44      * non java-doc
45      *
46      * @see RefactoringWizard#addUserInputPages
47      */

48     protected void addUserInputPages() {
49         super.addUserInputPages();
50         if (isRenameType())
51             addPage(new RenameTypeWizardSimilarElementsPage());
52
53     }
54
55     public RenameTypeProcessor getRenameTypeProcessor() {
56         RefactoringProcessor proc= ((RenameRefactoring) getRefactoring()).getProcessor();
57         if (proc instanceof RenameTypeProcessor)
58             return (RenameTypeProcessor) proc;
59         else if (proc instanceof RenameCompilationUnitProcessor) {
60             RenameCompilationUnitProcessor rcu= (RenameCompilationUnitProcessor) proc;
61             return rcu.getRenameTypeProcessor();
62         }
63         Assert.isTrue(false); // Should never get here
64
return null;
65     }
66
67     protected boolean isRenameType() {
68         return true;
69     }
70
71     protected RenameInputWizardPage createInputPage(String JavaDoc message, String JavaDoc initialSetting) {
72         return new RenameTypeWizardInputPage(message, IJavaHelpContextIds.RENAME_TYPE_WIZARD_PAGE, true, initialSetting) {
73
74             protected RefactoringStatus validateTextField(String JavaDoc text) {
75                 return validateNewName(text);
76             }
77         };
78     }
79 }
80
Popular Tags