]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/RenameTypeWizard.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui refactoring / org / eclipse / jdt / internal / ui / refactoring / reorg / RenameTypeWizard.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.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 defaultPageTitle, String inputPageDescription, ImageDescriptor inputPageImageDescriptor, String pageContextHelpId) {
40                 super(refactoring, defaultPageTitle, inputPageDescription, inputPageImageDescriptor, pageContextHelpId);
41         }
42
43         /*
44          * non java-doc
45          *
46          * @see RefactoringWizard#addUserInputPages
47          */
48         @Override
49         protected void addUserInputPages() {
50                 super.addUserInputPages();
51                 if (isRenameType())
52                         addPage(new RenameTypeWizardSimilarElementsPage());
53
54         }
55
56         public RenameTypeProcessor getRenameTypeProcessor() {
57                 RefactoringProcessor proc= ((RenameRefactoring) getRefactoring()).getProcessor();
58                 if (proc instanceof RenameTypeProcessor)
59                         return (RenameTypeProcessor) proc;
60                 else if (proc instanceof RenameCompilationUnitProcessor) {
61                         RenameCompilationUnitProcessor rcu= (RenameCompilationUnitProcessor) proc;
62                         return rcu.getRenameTypeProcessor();
63                 }
64                 Assert.isTrue(false); // Should never get here
65                 return null;
66         }
67
68         protected boolean isRenameType() {
69                 return true;
70         }
71
72         @Override
73         protected RenameInputWizardPage createInputPage(String message, String initialSetting) {
74                 return new RenameTypeWizardInputPage(message, IJavaHelpContextIds.RENAME_TYPE_WIZARD_PAGE, true, initialSetting) {
75
76                         @Override
77                         protected RefactoringStatus validateTextField(String text) {
78                                 return validateNewName(text);
79                         }
80                 };
81         }
82 }