1 19 20 package org.netbeans.modules.projectimport.eclipse; 21 22 import java.io.File ; 23 import java.util.Iterator ; 24 import java.util.logging.Logger ; 25 import org.netbeans.modules.projectimport.LoggerFactory; 26 import org.netbeans.modules.projectimport.ProjectImporterException; 27 28 35 public final class ProjectFactory { 36 37 38 private static final Logger logger = 39 LoggerFactory.getDefault().createLogger(ProjectFactory.class); 40 41 42 private static ProjectFactory instance = new ProjectFactory(); 43 44 private ProjectFactory() {} 45 46 47 public static ProjectFactory getInstance() { 48 return instance; 49 } 50 51 59 public EclipseProject load(File projectDir) throws 60 ProjectImporterException { 61 Workspace workspace = Workspace.createWorkspace(projectDir.getParentFile()); 62 if (workspace != null) { 63 WorkspaceParser parser = new WorkspaceParser(workspace); 64 parser.parse(); 65 } 66 return load(projectDir, workspace); 67 } 68 69 75 EclipseProject load(File projectDir, Workspace workspace) throws 76 ProjectImporterException { 77 78 EclipseProject project = EclipseProject.createProject(projectDir); 79 if (project != null) { 80 project.setWorkspace(workspace); 81 load(project); 82 } 83 return project; 84 } 85 86 92 void load(EclipseProject project) throws ProjectImporterException { 93 logger.finest("Loading project: " + project.getDirectory().getAbsolutePath()); ProjectParser.parse(project); 95 File cpFile = project.getClassPathFile(); 96 if (cpFile != null && cpFile.exists()) { 98 project.setClassPath(ClassPathParser.parse(cpFile)); 99 for (Iterator it = project.getClassPath().getEntries().iterator(); it.hasNext(); ) { 100 project.setAbsolutePathForEntry((ClassPathEntry) it.next()); 101 } 102 } else { 103 logger.finer("Project " + project.getName() + " doesn't have java nature."); project.setJavaNature(false); 106 } 107 } 108 } 109 110 111 | Popular Tags |