01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.corext.refactoring.structure;
11:
12: import org.eclipse.core.runtime.Assert;
13:
14: import org.eclipse.jdt.core.refactoring.IJavaRefactorings;
15:
16: import org.eclipse.ltk.core.refactoring.RefactoringStatus;
17: import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
18: import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
19: import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
20:
21: import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
22: import org.eclipse.jdt.internal.corext.refactoring.structure.constraints.SuperTypeRefactoringProcessor;
23: import org.eclipse.jdt.internal.corext.refactoring.tagging.IScriptableRefactoring;
24: import org.eclipse.jdt.internal.corext.util.Messages;
25:
26: /**
27: * Refactoring to extract an interface from a type.
28: */
29: public final class ExtractInterfaceRefactoring extends
30: 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(
42: final SuperTypeRefactoringProcessor processor) {
43: super (processor);
44:
45: fProcessor = processor;
46: }
47:
48: /**
49: * Returns the extract interface processor.
50: *
51: * @return the refactoring processor
52: */
53: public final ExtractInterfaceProcessor getExtractInterfaceProcessor() {
54: return (ExtractInterfaceProcessor) getProcessor();
55: }
56:
57: /*
58: * @see org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring#getProcessor()
59: */
60: public final RefactoringProcessor getProcessor() {
61: return fProcessor;
62: }
63:
64: /**
65: * {@inheritDoc}
66: */
67: public final RefactoringStatus initialize(
68: final RefactoringArguments arguments) {
69: Assert.isNotNull(arguments);
70: final RefactoringProcessor processor = getProcessor();
71: if (processor instanceof IScriptableRefactoring) {
72: return ((IScriptableRefactoring) processor)
73: .initialize(arguments);
74: }
75: return RefactoringStatus
76: .createFatalErrorStatus(Messages
77: .format(
78: RefactoringCoreMessages.ProcessorBasedRefactoring_error_unsupported_initialization,
79: IJavaRefactorings.EXTRACT_INTERFACE));
80: }
81: }
|