KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 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.ltk.core.refactoring.RefactoringStatus;
16 import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
17 import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
18 import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
19
20 import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
21 import org.eclipse.jdt.internal.corext.refactoring.tagging.IScriptableRefactoring;
22 import org.eclipse.jdt.internal.corext.util.Messages;
23
24 /**
25  * Refactoring to pull up members in a type hierarchy.
26  */

27 public class PullUpRefactoring extends ProcessorBasedRefactoring 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(final RefactoringArguments arguments) {
63         Assert.isNotNull(arguments);
64         final RefactoringProcessor processor= getProcessor();
65         if (processor instanceof IScriptableRefactoring) {
66             return ((IScriptableRefactoring) processor).initialize(arguments);
67         }
68         return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.ProcessorBasedRefactoring_error_unsupported_initialization, getProcessor().getIdentifier()));
69     }
70 }
Popular Tags