KickJava   Java API By Example, From Geeks To Geeks.

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


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.openide.filesystems.FileObject;
21 import org.openide.nodes.Node;
22 import org.openide.text.PositionBounds;
23
24 /**
25  *
26  * @author Sonali
27  */

28 public class FileRenameElement extends SimpleRefactoringElementImpl {
29     
30     Usage usage;
31     Node node;
32     FileObject fobj;
33     
34     /** Creates a new instance of WhereUsedElement */
35     public FileRenameElement(Usage u) {
36         this.usage=u;
37         Component comp = usage.getComponent();
38         node = usage.getContainer().getEngine().getUIHelper().getDisplayNode(comp);
39     }
40
41     public String JavaDoc getText() {
42         return node.getName();
43     }
44
45     public String JavaDoc getDisplayText() {
46        return node.getHtmlDisplayName();
47       
48        
49     }
50
51     public void performChange() {
52         System.out.println("Perform change called");
53         
54     }
55
56     public Object JavaDoc getComposite() {
57         return usage;
58         //return null;
59
}
60
61     public FileObject getParentFile() {
62         return usage.getContainer().getFileObject();
63    }
64     
65     public PositionBounds getPosition() {
66         return null;
67     }
68     
69      public void showPreview() {
70          //UI.setComponentForRefactoringPreview(null);
71
}
72      
73      public void openInEditor(){
74          System.out.println("openInEditor::called");
75          /*ViewComponentCookie vc = (ViewComponentCookie)node.getCookie(ViewComponentCookie.class);
76          if(vc != null){
77              System.out.println("NOT NULL");
78              vc.view(ViewComponentCookie.View.SOURCE, usage.getComponent());
79          }*/

80          
81          Action JavaDoc preferredAction = node.getPreferredAction();
82         if (preferredAction != null) {
83         String JavaDoc command = (String JavaDoc)preferredAction.getValue(Action.ACTION_COMMAND_KEY);
84         ActionEvent JavaDoc ae = new ActionEvent JavaDoc(node, 0, command);
85         preferredAction.actionPerformed(ae);
86         }
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