KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > refactoring > actions > FindUsagesAction


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
20 package org.netbeans.modules.xml.refactoring.actions;
21
22 import javax.swing.JMenuItem JavaDoc;
23 import org.netbeans.modules.refactoring.spi.ui.UI;
24 import org.netbeans.modules.xml.refactoring.ui.j.spi.ui.WhereUsedQueryUI;
25 import org.netbeans.modules.xml.refactoring.ui.j.ui.RefactoringPanel;
26 import org.netbeans.modules.xml.refactoring.ui.util.AnalysisUtilities;
27 import org.netbeans.modules.xml.refactoring.ui.views.WhereUsedView;
28 import org.netbeans.modules.xml.xam.Component;
29 import org.netbeans.modules.xml.xam.Named;
30 import org.netbeans.modules.xml.xam.Referenceable;
31 import org.openide.filesystems.FileObject;
32 import org.openide.nodes.Node;
33 import org.openide.text.CloneableEditorSupport;
34 import org.openide.util.HelpCtx;
35 import org.openide.util.NbBundle;
36 import org.openide.util.actions.CookieAction;
37 import org.openide.windows.TopComponent;
38
39 /**
40  *
41  * @author Jeri Lockhart
42  */

43 public class FindUsagesAction extends CookieAction
44 {
45     static final long serialVersionUID = 1L;
46     
47     private static final Class JavaDoc[] COOKIE_ARRAY =
48             new Class JavaDoc[] { };
49     
50     /**
51      *
52      *
53      */

54     public FindUsagesAction() {
55         super();
56     }
57     
58     
59     /**
60      *
61      *
62      */

63     public String JavaDoc getName() {
64         return NbBundle.getMessage(FindUsagesAction.class,
65                 "LBL_FindUsages"); // NOI18N
66
}
67     
68     
69     /**
70      *
71      *
72      */

73     public HelpCtx getHelpCtx() {
74         return new HelpCtx(getClass());
75     }
76     
77     
78     /**
79      *
80      *
81      */

82     protected boolean asynchronous() {
83         return false;
84     }
85     
86     
87     /**
88      *
89      *
90      */

91     protected boolean enable(Node[] nodes) {
92         if (nodes.length!=1)
93             return false;
94         
95         Referenceable ref = getReferenceable(nodes);
96         return ref instanceof Referenceable;
97     }
98     
99     
100     /**
101      *
102      *
103      */

104     protected void performAction(Node[] nodes) {
105        assert nodes.length==1:
106             "Length of nodes array should be 1";
107         Referenceable ref = getReferenceable(nodes);
108         assert ref != null:"The node's NamedReferenceable should not be null";
109         WhereUsedView wuv = new WhereUsedView(ref);
110         WhereUsedQueryUI ui = new WhereUsedQueryUI(wuv, ref);
111         TopComponent activetc = TopComponent.getRegistry().getActivated();
112         if (activetc instanceof CloneableEditorSupport.Pane) {
113            // new RefactoringPanel(ui, activetc);
114
} else {
115             //new RefactoringPanel(ui);
116
}
117     }
118     
119     protected Referenceable getReferenceable(Node[] nodes) {
120         return AnalysisUtilities.getReferenceable(nodes);
121     }
122
123     protected int mode() {
124         return CookieAction.MODE_EXACTLY_ONE;
125     }
126
127
128
129     protected Class JavaDoc[] cookieClasses() {
130         return COOKIE_ARRAY;
131     }
132     
133  
134     
135     ////////////////////////////////////////////////////////////////////////////
136
// Instance members
137
////////////////////////////////////////////////////////////////////////////
138

139     protected JMenuItem JavaDoc menuItem;
140 }
141
Popular Tags