KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > structure > UseSuperTypeRefactoring


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.corext.refactoring.structure;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.jdt.core.refactoring.IJavaRefactorings;
16
17 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
18 import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
19 import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
20 import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
21
22 import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
23 import org.eclipse.jdt.internal.corext.refactoring.tagging.IScriptableRefactoring;
24 import org.eclipse.jdt.internal.corext.util.Messages;
25
26 /**
27  * Refactoring to replace type occurrences by a super type where possible.
28  *
29  * @since 3.1
30  */

31 public final class UseSuperTypeRefactoring extends ProcessorBasedRefactoring implements IScriptableRefactoring {
32
33     /** The processor to use */
34     private final UseSuperTypeProcessor fProcessor;
35
36     /**
37      * Creates a new use super type refactoring.
38      *
39      * @param processor
40      * the processor to use
41      */

42     public UseSuperTypeRefactoring(final UseSuperTypeProcessor processor) {
43         super(processor);
44
45         fProcessor= processor;
46     }
47     /*
48      * @see org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring#getProcessor()
49      */

50     public final RefactoringProcessor getProcessor() {
51         return fProcessor;
52     }
53
54     /**
55      * Returns the use super type processor.
56      *
57      * @return the refactoring processor
58      */

59     public final UseSuperTypeProcessor getUseSuperTypeProcessor() {
60         return (UseSuperTypeProcessor) getProcessor();
61     }
62
63     /**
64      * {@inheritDoc}
65      */

66     public final RefactoringStatus initialize(final RefactoringArguments arguments) {
67         Assert.isNotNull(arguments);
68         final RefactoringProcessor processor= getProcessor();
69         if (processor instanceof IScriptableRefactoring) {
70             return ((IScriptableRefactoring) processor).initialize(arguments);
71         }
72         return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.ProcessorBasedRefactoring_error_unsupported_initialization, IJavaRefactorings.USE_SUPER_TYPE));
73     }
74 }
75
Popular Tags