1 19 20 package org.netbeans.modules.java.project; 21 22 import java.net.MalformedURLException ; 23 import java.net.URI ; 24 import java.net.URISyntaxException ; 25 import java.net.URL ; 26 import org.netbeans.api.project.FileOwnerQuery; 27 import org.netbeans.api.project.Project; 28 import org.netbeans.spi.java.queries.UnitTestForSourceQueryImplementation; 29 import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation; 30 import org.openide.ErrorManager; 31 import org.openide.filesystems.FileObject; 32 33 37 @SuppressWarnings ("deprecation") 38 public class UnitTestForSourceQueryImpl implements UnitTestForSourceQueryImplementation, MultipleRootsUnitTestForSourceQueryImplementation { 39 40 41 public UnitTestForSourceQueryImpl() { 42 } 43 44 public URL findUnitTest(FileObject source) { 45 Project project = FileOwnerQuery.getOwner(source); 46 if (project != null) { 47 UnitTestForSourceQueryImplementation query = project.getLookup().lookup(UnitTestForSourceQueryImplementation.class); 48 if (query != null) { 49 return query.findUnitTest(source); 50 } 51 } 52 return null; 53 } 54 55 public URL [] findUnitTests(FileObject source) { 56 Project project = FileOwnerQuery.getOwner(source); 57 if (project != null) { 58 MultipleRootsUnitTestForSourceQueryImplementation query = project.getLookup().lookup(MultipleRootsUnitTestForSourceQueryImplementation.class); 59 if (query != null) { 60 return query.findUnitTests(source); 61 } 62 } 63 return null; 64 } 65 66 public URL findSource(FileObject unitTest) { 67 Project project = FileOwnerQuery.getOwner(unitTest); 68 if (project != null) { 69 UnitTestForSourceQueryImplementation query = project.getLookup().lookup(UnitTestForSourceQueryImplementation.class); 70 if (query != null) { 71 return query.findSource(unitTest); 72 } 73 } 74 return null; 75 } 76 77 public URL [] findSources(FileObject unitTest) { 78 Project project = FileOwnerQuery.getOwner(unitTest); 79 if (project != null) { 80 MultipleRootsUnitTestForSourceQueryImplementation query = project.getLookup().lookup(MultipleRootsUnitTestForSourceQueryImplementation.class); 81 if (query != null) { 82 return query.findSources(unitTest); 83 } 84 } 85 return null; 86 } 87 88 } 89 | Popular Tags |