1 19 package org.netbeans.modules.languages.javascript.refactoring; 20 21 import java.text.MessageFormat ; 22 import javax.swing.event.ChangeListener ; 23 import javax.swing.text.Document ; 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 40 public class WhereUsedQueryUI implements RefactoringUI { 41 42 private WhereUsedQuery query = null; 43 private WhereUsedPanel panel; 44 private ASTPath path; 45 private String name; 46 47 public WhereUsedQueryUI(ASTPath path, FileObject fileObject, Document 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 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 getDescription() { 78 return new MessageFormat (NbBundle.getMessage(WhereUsedQueryUI.class, "DSC_WhereUsed")).format ( 79 new Object [] {name} 80 ); 81 } 82 83 public String 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 |