KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > languages > javascript > refactoring > WhereUsedQueryUI


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 package org.netbeans.modules.languages.javascript.refactoring;
20
21 import java.text.MessageFormat JavaDoc;
22 import javax.swing.event.ChangeListener JavaDoc;
23 import javax.swing.text.Document JavaDoc;
24 import org.netbeans.api.languages.ASTItem;
25 import org.netbeans.api.languages.ASTNode;
26 import org.netbeans.api.languages.ASTPath;
27 import org.netbeans.api.languages.ASTToken;
28 import org.netbeans.modules.refactoring.api.WhereUsedQuery;
29 import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel;
30 import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
31 import org.openide.filesystems.FileObject;
32 import org.openide.util.HelpCtx;
33 import org.openide.util.NbBundle;
34 import org.openide.util.lookup.Lookups;
35
36 /**
37  *
38  * @author Daniel Prusa
39  */

40 public class WhereUsedQueryUI implements RefactoringUI {
41     
42     private WhereUsedQuery query = null;
43     private WhereUsedPanel panel;
44     private ASTPath path;
45     private String JavaDoc name;
46
47     public WhereUsedQueryUI(ASTPath path, FileObject fileObject, Document JavaDoc doc) {
48         this.query = new WhereUsedQuery(Lookups.fixed(path, fileObject, doc));
49         this.path = path;
50         ASTItem item = path.getLeaf();
51         this.name = item instanceof ASTToken ? ((ASTToken)item).getIdentifier() : ((ASTNode) item).getNT();
52     }
53     
54     public boolean isQuery() {
55         return true;
56     }
57
58     public CustomRefactoringPanel getPanel(ChangeListener JavaDoc parent) {
59         if (panel == null) {
60             panel = new WhereUsedPanel(path, parent);
61         }
62         return panel;
63     }
64
65     public org.netbeans.modules.refactoring.api.Problem setParameters() {
66         return query.checkParameters();
67     }
68
69     public org.netbeans.modules.refactoring.api.Problem checkParameters() {
70         return query.fastCheckParameters();
71     }
72
73     public org.netbeans.modules.refactoring.api.AbstractRefactoring getRefactoring() {
74         return query;
75     }
76
77     public String JavaDoc getDescription() {
78         return new MessageFormat JavaDoc(NbBundle.getMessage(WhereUsedQueryUI.class, "DSC_WhereUsed")).format (
79                     new Object JavaDoc[] {name}
80                 );
81     }
82
83     public String JavaDoc getName() {
84         return NbBundle.getMessage(WhereUsedQueryUI.class, "LBL_WhereUsed");
85     }
86     
87     public boolean hasParameters() {
88         return false;
89     }
90
91     public HelpCtx getHelpCtx() {
92         return new HelpCtx(WhereUsedQueryUI.class);
93     }
94     
95 }
96
Popular Tags