KickJava   Java API By Example, From Geeks To Geeks.

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


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.structure.constraints.SuperTypeRefactoringProcessor;
24 import org.eclipse.jdt.internal.corext.refactoring.tagging.IScriptableRefactoring;
25 import org.eclipse.jdt.internal.corext.util.Messages;
26
27 /**
28  * Refactoring to extract an interface from a type.
29  */

30 public final class ExtractInterfaceRefactoring extends ProcessorBasedRefactoring implements IScriptableRefactoring {
31
32     /** The processor to use */
33     private final SuperTypeRefactoringProcessor fProcessor;
34
35     /**
36      * Creates a new extract interface refactoring.
37      *
38      * @param processor
39      * the processor to use
40      */

41     public ExtractInterfaceRefactoring(final SuperTypeRefactoringProcessor processor) {
42         super(processor);
43
44         fProcessor= processor;
45     }
46
47     /**
48      * Returns the extract interface processor.
49      *
50      * @return the refactoring processor
51      */

52     public final ExtractInterfaceProcessor getExtractInterfaceProcessor() {
53         return (ExtractInterfaceProcessor) getProcessor();
54     }
55
56     /*
57      * @see org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring#getProcessor()
58      */

59     public final RefactoringProcessor getProcessor() {
60         return fProcessor;
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.EXTRACT_INTERFACE));
73     }
74 }
75
Popular Tags