1 19 20 package org.netbeans.modules.apisupport.project.queries; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.net.URI ; 25 import org.netbeans.api.project.ProjectManager; 26 import org.netbeans.api.project.ant.AntArtifact; 27 import org.netbeans.api.project.libraries.Library; 28 import org.netbeans.modules.apisupport.project.NbModuleProject; 29 import org.netbeans.modules.apisupport.project.Util; 30 import org.netbeans.modules.apisupport.project.universe.ModuleEntry; 31 import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender; 32 import org.openide.filesystems.FileObject; 33 import org.openide.filesystems.FileUtil; 34 import org.openide.util.NbBundle; 35 36 41 public final class ModuleProjectClassPathExtender implements ProjectClassPathExtender { 42 43 private static final String LIBRARY_NAME = "swing-layout"; private static final String MODULE_NAME = "org.jdesktop.layout"; 46 private final NbModuleProject project; 47 48 public ModuleProjectClassPathExtender(NbModuleProject project) { 49 this.project = project; 50 } 51 52 public boolean addLibrary(Library library) throws IOException { 53 boolean cpChanged = false; 54 if (library.getName().equals(LIBRARY_NAME)) { 55 ModuleEntry entry = project.getModuleList().getEntry(MODULE_NAME); 56 if (entry != null) { 57 cpChanged = Util.addDependency(project, MODULE_NAME); 58 } else { 59 IOException e = new IOException ("no module " + MODULE_NAME); Util.err.annotate(e, NbBundle.getMessage(ModuleProjectClassPathExtender.class, "ERR_could_not_find_module", MODULE_NAME)); 61 throw e; 62 } 63 } else { 64 IOException e = new IOException ("unknown lib " + library.getName()); Util.err.annotate(e, NbBundle.getMessage(ModuleProjectClassPathExtender.class, "ERR_unsupported_library", library.getDisplayName())); 66 throw e; 67 } 68 if (cpChanged) { 69 ProjectManager.getDefault().saveProject(project); 70 } 71 return cpChanged; 72 } 73 74 public boolean addArchiveFile(FileObject archiveFile) throws IOException { 75 IOException e = new IOException ("not implemented: " + archiveFile); Util.err.annotate(e, NbBundle.getMessage(ModuleProjectClassPathExtender.class, "ERR_jar", FileUtil.getFileDisplayName(archiveFile))); 77 throw e; 78 } 79 80 public boolean addAntArtifact(AntArtifact artifact, URI artifactElement) throws IOException { 81 IOException e = new IOException ("not implemented: " + artifactElement); String displayName; 84 if ("file".equals(artifactElement.getScheme())) { displayName = new File (artifactElement).getAbsolutePath(); 86 } else { 87 displayName = artifactElement.toString(); 88 } 89 Util.err.annotate(e, NbBundle.getMessage(ModuleProjectClassPathExtender.class, "ERR_jar", displayName)); 90 throw e; 91 } 92 93 } 94 | Popular Tags |