1 19 package org.netbeans.modules.retouche.navigation; 20 21 import java.util.ArrayList ; 22 import java.util.Collections ; 23 import java.util.List ; 24 import org.netbeans.api.gsf.CancellableTask; 25 import org.netbeans.api.retouche.source.CompilationInfo; 26 import org.netbeans.api.retouche.source.Source.Priority; 27 import org.netbeans.modules.gsf.LanguageRegistry; 28 import org.openide.filesystems.FileObject; 29 import org.openide.filesystems.FileUtil; 30 import org.openide.util.Lookup; 31 import org.netbeans.api.retouche.source.Phase; 32 import org.netbeans.api.retouche.source.support.LookupBasedSourceTaskFactory; 33 34 43 public final class ClassMemberNavigatorSourceFactory extends LookupBasedSourceTaskFactory { 44 45 private ClassMemberPanelUI ui; 46 private static final CancellableTask<CompilationInfo> EMPTY_TASK = new CancellableTask<CompilationInfo>() { 47 48 public void cancel() {} 49 50 public void run(CompilationInfo parameter) throws Exception {} 51 }; 52 53 static ClassMemberNavigatorSourceFactory getInstance() { 54 return Lookup.getDefault().lookup(ClassMemberNavigatorSourceFactory.class); 55 } 56 57 public ClassMemberNavigatorSourceFactory() { 58 super(Phase.ELEMENTS_RESOLVED, Priority.NORMAL); 59 } 60 61 public synchronized CancellableTask<CompilationInfo> createTask(FileObject file) { 62 if ( ui == null) { 64 return EMPTY_TASK; 65 } 66 else { 67 return ui.getTask(); 68 } 69 } 70 71 public List <FileObject> getFileObjects() { 72 List <FileObject> result = new ArrayList <FileObject>(); 73 74 LanguageRegistry registry = LanguageRegistry.getInstance(); 76 for( FileObject fileObject : super.getFileObjects() ) { 77 if (!registry.isSupported(FileUtil.getMIMEType(fileObject))) { 78 continue; 79 } 80 result.add(fileObject); 81 } 82 83 if (result.size() == 1) 84 return result; 85 86 return Collections.emptyList(); 87 } 88 89 public synchronized void setLookup(Lookup l, ClassMemberPanelUI ui) { 90 this.ui = ui; 91 super.setLookup(l); 92 } 93 94 @Override 95 protected void lookupContentChanged() { 96 if ( ui != null ) { 98 ui.showWaitNode(); } 100 } 101 102 } 103 | Popular Tags |