KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > refactoring > changeparam > AbstractChangeParamsRefactoringElement


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.changeparam;
21
22 import org.netbeans.jmi.javamodel.Element;
23 import org.netbeans.modules.j2ee.refactoring.DefaultPositionBoundsResolver;
24 import org.netbeans.modules.refactoring.api.ChangeParametersRefactoring.ParameterInfo;
25 import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
26 import org.netbeans.modules.refactoring.spi.SimpleRefactoringElementImpl;
27 import org.openide.ErrorManager;
28 import org.openide.filesystems.FileObject;
29 import org.openide.loaders.DataObject;
30 import org.openide.loaders.DataObjectNotFoundException;
31 import org.openide.text.PositionBounds;
32
33 /**
34  *
35  * @author Martin Grebac
36  */

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

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

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

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

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

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

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

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