KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > refactoring > FauxRefactoringElement


1 /*
2  * WhereUsedElement.java
3  *
4  * Created on December 30, 2006, 4:41 PM
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
10 package org.netbeans.modules.xml.refactoring;
11
12 import java.awt.event.ActionEvent JavaDoc;
13 import javax.swing.Action JavaDoc;
14 import org.netbeans.modules.refactoring.spi.SimpleRefactoringElementImpl;
15 import org.netbeans.modules.refactoring.spi.ui.UI;
16 import org.netbeans.modules.xml.refactoring.spi.UIHelper;
17 import org.netbeans.modules.xml.refactoring.ui.util.AnalysisUtilities;
18 import org.netbeans.modules.xml.xam.Component;
19 import org.netbeans.modules.xml.xam.Referenceable;
20 import org.netbeans.modules.xml.xam.dom.DocumentModel;
21 import org.openide.filesystems.FileObject;
22 import org.openide.nodes.Node;
23 import org.openide.text.PositionBounds;
24
25 /**
26  *
27  * @author Sonali
28  */

29 public class FauxRefactoringElement extends SimpleRefactoringElementImpl {
30     
31     Usage usage;
32     Node node;
33     FileObject targetFobj;
34     Referenceable ref;
35     String JavaDoc name, label;
36     
37     /** Creates a new instance of WhereUsedElement */
38     public FauxRefactoringElement(Referenceable ref) {
39         this.ref = ref;
40         Component targetComponent = ref instanceof Component ? (Component) ref : ref instanceof DocumentModel ? ((DocumentModel) ref).getRootComponent() :null;
41             assert targetComponent != null : "target is not Component or DocumentModel";
42             targetFobj = AnalysisUtilities.getFileObject(targetComponent);
43                       
44             UIHelper helper = RefactoringManager.getInstance().getTargetComponentUIHelper(ref);
45             if (helper == null){
46                 helper = new UIHelper();
47             }
48             node = AnalysisUtilities.getDisplayNode(ref);
49             name = AnalysisUtilities.getName(ref);
50             label = " <b>" + name + "</b>";
51     }
52
53     public String JavaDoc getText() {
54         return name;
55     }
56
57     public String JavaDoc getDisplayText() {
58        return label;
59       
60        
61     }
62
63     public void performChange() {
64     }
65
66     public Object JavaDoc getComposite() {
67         return ref;
68         //return null;
69
}
70
71     public FileObject getParentFile() {
72         return targetFobj;
73     }
74     
75     
76
77     public PositionBounds getPosition() {
78         return null;
79     }
80     
81      public void showPreview() {
82          //UI.setComponentForRefactoringPreview(null);
83
}
84      
85      public void openInEditor(){
86          //System.out.println("openInEditor::called");
87
}
88      
89      public void setEnabled(boolean enabled){
90          usage.setIncludedInRefactoring(enabled);
91          //System.out.println("setEnabled called with " + enabled);
92
}
93          
94      
95     
96 }
97
Popular Tags