001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.refactoring.java.api;
042:
043: import org.netbeans.api.java.source.TreePathHandle;
044: import org.netbeans.modules.refactoring.api.AbstractRefactoring;
045: import org.openide.util.lookup.Lookups;
046:
047: /**
048: * Convert Inner to Top-Level refactoring implementation class. This refactoring
049: * is capable of converting an inner class into a top-level class.
050: *
051: * @see org.netbeans.modules.refactoring.spi.RefactoringPlugin
052: * @see org.netbeans.modules.refactoring.spi.RefactoringPluginFactory
053: * @see org.netbeans.modules.refactoring.api.AbstractRefactoring
054: * @see org.netbeans.modules.refactoring.api.RefactoringSession
055: *
056: * @author Martin Matula
057: * @author Jan Becicka
058: */
059: public final class InnerToOuterRefactoring extends AbstractRefactoring {
060:
061: // parameters of the refactoring
062: private String className;
063: private String referenceName;
064:
065: /**
066: * Creates a new instance of InnerToOuterRefactoring.
067: *
068: * @param sourceType An inner class that should be converted to a top-level class.
069: */
070: public InnerToOuterRefactoring(TreePathHandle sourceType) {
071: super (Lookups.singleton(sourceType));
072: }
073:
074: /** Returns the type the members of which should be pulled up
075: * by this refactoring.
076: * @return Source of the members to be pulled up.
077: */
078: public TreePathHandle getSourceType() {
079: return getRefactoringSource().lookup(TreePathHandle.class);
080: }
081:
082: // --- PARAMETERS ----------------------------------------------------------
083:
084: /** Returns the name for the top-level class to be created.
085: * @return Class name.
086: */
087: public String getClassName() {
088: return className;
089: }
090:
091: /** Sets name for the top-level class to be created.
092: * @param className Class name.
093: */
094: public void setClassName(String className) {
095: this .className = className;
096: }
097:
098: /** Returns name of the field that should be generated as a reference to the original
099: * outer class. If null, no field will be generated.
100: * @return Name of the field to be generated or null if no field will be generated.
101: */
102: public String getReferenceName() {
103: return referenceName;
104: }
105:
106: /** Sets name of the field that should be generated as a reference to the original
107: * outer class. Can be set to null which indicates that no field should be generated.
108: * @param referenceName Name of the field or null if no field should be generated.
109: */
110: public void setReferenceName(String referenceName) {
111: this.referenceName = referenceName;
112: }
113: }
|