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.spi;
042:
043: import org.netbeans.modules.refactoring.api.RefactoringElement;
044: import org.openide.filesystems.FileObject;
045: import org.openide.text.PositionBounds;
046: import org.openide.util.Lookup;
047:
048: /** Interface representing a refactoring element (object affected by a refactoring)
049: * returned in a collection from {@link org.netbeans.modules.refactoring.api.AbstractRefactoring#prepare} operation.
050: * <p>
051: *
052: * @author Martin Matula
053: * @author Jan Becicka
054: * @see RefactoringElement
055: * @see SimpleRefactoringElementImpl
056: * @see RefactoringSession
057: * @see RefactoringElementsBag
058: */
059: public interface RefactoringElementImplementation {
060: /** Status corresponding to a normal element */
061: int NORMAL = RefactoringElement.NORMAL;
062: /** Status corresponding to an element that has a warning associated with it */
063: int WARNING = RefactoringElement.WARNING;
064: /** Status flag that indicates that the element cannot be enabled (if a fatal
065: * problem is associated with it) */
066: int GUARDED = RefactoringElement.GUARDED;
067: /** This element is in read-only file */
068: int READ_ONLY = RefactoringElement.READ_ONLY;
069:
070: /** Returns text describing the refactoring element.
071: * @return Text.
072: */
073: String getText();
074:
075: /** Returns text describing the refactoring formatted for display (using HTML tags).
076: * @return Formatted text.
077: */
078: String getDisplayText();
079:
080: /** Indicates whether this refactoring element is enabled.
081: * @return <code>true</code> if this element is enabled, otherwise <code>false</code>.
082: */
083: boolean isEnabled();
084:
085: /** Enables/disables this element.
086: * @param enabled If <code>true</code> the element is enabled, otherwise it is disabled.
087: */
088: void setEnabled(boolean enabled);
089:
090: /**
091: * Performs the change represented by this refactoring element.
092: * Implementation can be impty if the change is done using some high level
093: * transaction model
094: * @see BackupFacility
095: * @see RefactoringElementsBag#registerFileChange
096: * @see RefactoringElementsBag#registerTransaction
097: * @see Transaction
098: * @see RefactoringElementImplementation#performChange
099: * @see RefactoringElementImplementation#undoChange
100: */
101: void performChange();
102:
103: /**
104: * Undo change done by performChange
105: * Implementation can be impty if the change is done using some high level
106: * transaction model
107: * @see BackupFacility
108: * @see RefactoringElementsBag#registerFileChange
109: * @see RefactoringElementsBag#registerTransaction
110: * @see Transaction
111: * @see RefactoringElementImplementation#performChange
112: * @see RefactoringElementImplementation#undoChange
113: */
114: void undoChange();
115:
116: /**
117: * Returns Lookup associated with this element.
118: * Lookup items might be used by TreeElementFactories to build refactoring
119: * preview trees.
120: * @see org.netbeans.modules.refactoring.spi.ui.TreeElement
121: * @see org.netbeans.modules.refactoring.spi.ui.TreeElementFactory
122: * @see org.netbeans.modules.refactoring.spi.ui.TreeElementFactoryImplementation
123: * @return Lookup. Might be empty.
124: */
125: Lookup getLookup();
126:
127: /** Returns file that the element affects (relates to)
128: * @return File
129: */
130: FileObject getParentFile();
131:
132: /** Returns position bounds of the text to be affected by this refactoring element.
133: * @return position bounds
134: */
135: PositionBounds getPosition();
136:
137: /** Returns the status of this refactoring element (whether it is a normal element,
138: * or a warning.
139: * @return Status of this element.
140: */
141: int getStatus();
142:
143: /**
144: * Setter for property status
145: * @param status new value of propery status
146: */
147: void setStatus(int status);
148:
149: /**
150: * opens this RefactoringElement in the editor
151: * @since 1.5.0
152: */
153: void openInEditor();
154:
155: /**
156: * Shows this element in refactoring preview are
157: * @see org.netbeans.modules.refactoring.api.ui.UI#setComponentForRefactoringPreview
158: */
159: void showPreview();
160:
161: }
|