KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > refactoring > moveclass > AbstractMoveClassRefactoringElement


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.refactoring.moveclass;
21
22 import org.netbeans.jmi.javamodel.Element;
23 import org.netbeans.modules.j2ee.refactoring.DefaultPositionBoundsResolver;
24 import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
25 import org.netbeans.modules.refactoring.spi.SimpleRefactoringElementImpl;
26 import org.openide.ErrorManager;
27 import org.openide.filesystems.FileObject;
28 import org.openide.loaders.DataObject;
29 import org.openide.loaders.DataObjectNotFoundException;
30 import org.openide.text.PositionBounds;
31
32 /**
33  *
34  * @author mg116726
35  */

36 public abstract class AbstractMoveClassRefactoringElement extends SimpleRefactoringElementImpl implements RefactoringElementImplementation {
37     
38     private int status = RefactoringElementImplementation.NORMAL;
39     
40     protected boolean enabled = true;
41     protected String JavaDoc oldName;
42     protected String JavaDoc newName;
43     protected FileObject parentFile;
44     
45     /** Indicates whether this refactoring element is enabled.
46      * @return <code>true</code> if this element is enabled, otherwise <code>false</code>.
47      */

48     public boolean isEnabled() {
49         return enabled;
50     }
51     
52     /** Enables/disables this element.
53      * @param enabled If <code>true</code> the element is enabled, otherwise it is disabled.
54      */

55     public void setEnabled(boolean enabled) {
56         this.enabled = enabled;
57     }
58     
59     /** Returns text describing the refactoring element.
60      * @return Text.
61      */

62     public String JavaDoc getText() {
63         return getDisplayText();
64     }
65     
66     /** Returns Java element associated with this refactoring element.
67      * @return MDR Java element.
68      */

69     public Element getJavaElement() {
70         return null;
71     }
72     
73     /** Returns file that the element affects (relates to)
74      * @return File
75      */

76     public FileObject getParentFile() {
77         return parentFile;
78     }
79     
80     /** Returns position bounds of the text to be affected by this refactoring element.
81      */

82     public PositionBounds getPosition() {
83         try {
84             return new DefaultPositionBoundsResolver(DataObject.find(getParentFile()), oldName).getPositionBounds();
85         } catch (DataObjectNotFoundException ex) {
86             ErrorManager.getDefault().notify(ex);
87         }
88         return null;
89     }
90     
91     /** Returns the status of this refactoring element (whether it is a normal element,
92      * or a warning.
93      * @return Status of this element.
94      */

95     public int getStatus() {
96         return status;
97     }
98     
99     public void setStatus(int status) {
100         this.status = status;
101     }
102     
103 }
Popular Tags