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.tagging.IScriptableRefactoring;
23: import org.eclipse.jdt.internal.corext.util.Messages;
24:
25: /**
26: * Refactoring to replace type occurrences by a super type where possible.
27: *
28: * @since 3.1
29: */
30: public final class UseSuperTypeRefactoring extends
31: 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: /*
49: * @see org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring#getProcessor()
50: */
51: public final RefactoringProcessor getProcessor() {
52: return fProcessor;
53: }
54:
55: /**
56: * Returns the use super type processor.
57: *
58: * @return the refactoring processor
59: */
60: public final UseSuperTypeProcessor getUseSuperTypeProcessor() {
61: return (UseSuperTypeProcessor) getProcessor();
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.USE_SUPER_TYPE));
80: }
81: }
|