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 pull up members in a type hierarchy.
25: */
26: public class PullUpRefactoring extends ProcessorBasedRefactoring
27: implements IScriptableRefactoring {
28:
29: /** The refactoring processor to use */
30: private final HierarchyProcessor fProcessor;
31:
32: /**
33: * Creates a new pull up refactoring.
34: *
35: * @param processor
36: * the pull up refactoring processor to use
37: */
38: public PullUpRefactoring(final HierarchyProcessor processor) {
39: super (processor);
40: fProcessor = processor;
41: }
42:
43: /**
44: * {@inheritDoc}
45: */
46: public RefactoringProcessor getProcessor() {
47: return fProcessor;
48: }
49:
50: /**
51: * Returns the pull up processor.
52: *
53: * @return the pull up processor
54: */
55: public PullUpRefactoringProcessor getPullUpProcessor() {
56: return (PullUpRefactoringProcessor) getProcessor();
57: }
58:
59: /**
60: * {@inheritDoc}
61: */
62: public final RefactoringStatus initialize(
63: final RefactoringArguments arguments) {
64: Assert.isNotNull(arguments);
65: final RefactoringProcessor processor = getProcessor();
66: if (processor instanceof IScriptableRefactoring) {
67: return ((IScriptableRefactoring) processor)
68: .initialize(arguments);
69: }
70: return RefactoringStatus
71: .createFatalErrorStatus(Messages
72: .format(
73: RefactoringCoreMessages.ProcessorBasedRefactoring_error_unsupported_initialization,
74: getProcessor().getIdentifier()));
75: }
76: }
|