01: /*******************************************************************************
02: * Copyright (c) 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.ltk.core.refactoring.RefactoringStatus;
15: import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
16: import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
17: import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
18:
19: import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
20: import org.eclipse.jdt.internal.corext.refactoring.tagging.IScriptableRefactoring;
21: import org.eclipse.jdt.internal.corext.util.Messages;
22:
23: /**
24: * Refactoring to push down members in a type hierarchy.
25: */
26: public final class PushDownRefactoring extends
27: ProcessorBasedRefactoring implements IScriptableRefactoring {
28:
29: /** The refactoring processor to use */
30: private final PushDownRefactoringProcessor fProcessor;
31:
32: /**
33: * Creates a new push down refactoring.
34: *
35: * @param processor
36: * the push down refactoring processor to use
37: */
38: public PushDownRefactoring(
39: final PushDownRefactoringProcessor processor) {
40: super (processor);
41: fProcessor = processor;
42: }
43:
44: /**
45: * {@inheritDoc}
46: */
47: public RefactoringProcessor getProcessor() {
48: return fProcessor;
49: }
50:
51: /**
52: * Returns the push down processor.
53: *
54: * @return the push down processor
55: */
56: public PushDownRefactoringProcessor getPushDownProcessor() {
57: return (PushDownRefactoringProcessor) getProcessor();
58: }
59:
60: /**
61: * {@inheritDoc}
62: */
63: public final RefactoringStatus initialize(
64: final RefactoringArguments arguments) {
65: Assert.isNotNull(arguments);
66: final RefactoringProcessor processor = getProcessor();
67: if (processor instanceof IScriptableRefactoring) {
68: return ((IScriptableRefactoring) processor)
69: .initialize(arguments);
70: }
71: return RefactoringStatus
72: .createFatalErrorStatus(Messages
73: .format(
74: RefactoringCoreMessages.ProcessorBasedRefactoring_error_unsupported_initialization,
75: getProcessor().getIdentifier()));
76: }
77: }
|