KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > refactoring > ui > j > api > RefactoringElement


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.refactoring.ui.j.api;
20
21 //import org.netbeans.jmi.javamodel.Element;
22
//import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
23
import org.netbeans.modules.xml.refactoring.ui.j.spi.RefactoringElementImplementation;
24 import org.openide.filesystems.FileObject;
25 import org.openide.text.PositionBounds;
26
27 /** Interface representing a refactoring element (object affected by a refactoring)
28  * returned in a collection from {@link org.netbeans.modules.refactoring.api.AbstractRefactoring#prepare} operation.
29  * <p>
30  *
31  * @see RefactoringElementImplementation
32  * @author Martin Matula
33  */

34 public final class RefactoringElement {
35     /** Status corresponding to a normal element */
36     public static final int NORMAL = 0;
37     /** Status corresponding to an element that has a warning associated with it */
38     public static final int WARNING = 1;
39     /** Status flag that indicates that the element cannot be enabled (if a fatal
40      * problem is associated with it) */

41     public static final int GUARDED = 2;
42     /** This element is in read-only file */
43     public static final int READ_ONLY = 3;
44     
45     // delegate
46
private final RefactoringElementImplementation impl;
47     
48     RefactoringElement(RefactoringElementImplementation impl) {
49         assert impl != null;
50         this.impl = impl;
51     }
52     
53     /** Returns text describing the refactoring element.
54      * @return Text.
55      */

56     public String JavaDoc getText() {
57         return impl.getText();
58     }
59     
60     /** Returns text describing the refactoring formatted for display (using HTML tags).
61      * @return Formatted text.
62      */

63     public String JavaDoc getDisplayText() {
64         return impl.getDisplayText();
65     }
66     
67     /** Indicates whether this refactoring element is enabled.
68      * @return <code>true</code> if this element is enabled, otherwise <code>false</code>.
69      */

70     public boolean isEnabled() {
71         return impl.isEnabled();
72     }
73     
74     /** Enables/disables this element.
75      * @param enabled If <code>true</code> the element is enabled, otherwise it is disabled.
76      */

77     public void setEnabled(boolean enabled) {
78         impl.setEnabled(enabled);
79     }
80     
81     /** Returns Java element associated with this refactoring element.
82      * @return MDR Java element.
83      */

84 // public Element getJavaElement() {
85
// return impl.getJavaElement();
86
// }
87

88     /** Returns file that the element affects (relates to)
89      * @return File
90      */

91     public FileObject getParentFile() {
92         return impl.getParentFile();
93     }
94     
95     /** Returns position bounds of the text to be affected by this refactoring element.
96      */

97     public PositionBounds getPosition() {
98         return impl.getPosition();
99     }
100     
101     /** Returns the status of this refactoring element (whether it is a normal element,
102      * or a warning.
103      * @return Status of this element.
104      */

105     public int getStatus() {
106         return impl.getStatus();
107     }
108
109     /**
110      * opens this RefactoringElement in the editor
111      * @since 1.5.0
112      */

113     public void openInEditor() {
114         impl.openInEditor();
115     }
116     
117 }
118
Popular Tags