1 19 24 25 package org.netbeans.modules.piagetproject; 26 import java.beans.PropertyChangeListener ; 27 import java.io.File ; 28 import java.io.IOException ; 29 import java.util.Properties ; 30 import javax.swing.Icon ; 31 import javax.swing.ImageIcon ; 32 import org.netbeans.api.project.Project; 33 import org.netbeans.api.project.ProjectInformation; 34 import org.netbeans.spi.project.ProjectState; 35 import org.openide.ErrorManager; 36 import org.openide.filesystems.FileObject; 37 import org.openide.filesystems.FileUtil; 38 import org.openide.loaders.DataFolder; 39 import org.openide.util.Lookup; 40 import org.openide.util.Utilities; 41 import org.openide.util.lookup.Lookups; 42 import org.openide.nodes.Node; 43 44 45 46 public final class PiagetProject implements Project { 47 48 49 private final FileObject projectFileObject; 50 private final Node projectNode; 51 public static String workPath; 52 private final ProjectState state; 53 54 public PiagetProject(FileObject projectDir, ProjectState state) { 55 this.projectFileObject = projectDir; 56 DataFolder data = DataFolder.findFolder(projectDir); 57 this.projectNode = data.getNodeDelegate(); 58 this.state = state; 59 structure(); 60 } 61 62 public FileObject getProjectDirectory() { 63 return projectFileObject; 64 } 65 66 67 68 69 70 public Lookup getLookup() { 71 return Lookups.fixed(new Object [] { 72 this, state, 74 new Info(), new PiagetLogicalView(this), }); 77 } 78 79 82 void structure() { 83 84 95 96 String [] dirNames = new String []{PiagetProjectFactory.ORIGINALS_DIR, PiagetProjectFactory.PARSED_DIR}; 97 FileObject repository = projectFileObject.getFileObject(PiagetProjectFactory.PROJECT_DIR); 98 for(int i=0;i<dirNames.length;i++){ 99 FileObject dir = repository.getFileObject(dirNames[i]); 100 if (dir == null) { 101 try { 102 repository.createFolder(dirNames[i]); 103 } catch (IOException ioe) { 104 ErrorManager.getDefault().notify(ioe); 105 } 106 } 107 } 108 109 FileObject workDir = repository.getFileObject(PiagetProjectFactory.PARSED_DIR); 110 File f = FileUtil.toFile(workDir); 111 this.workPath = f.getAbsolutePath(); 112 113 123 } 124 125 126 127 private final class Info implements ProjectInformation { 128 public Icon getIcon() { 129 return new ImageIcon (Utilities.loadImage( 130 "org/netbeans/modules/piagetproject/resources/project.png")); 131 } 132 133 public String getName() { 134 return getProjectDirectory().getName(); 135 } 136 137 public String getDisplayName() { 138 return getName(); 139 } 140 141 public void addPropertyChangeListener(PropertyChangeListener pcl) { 142 } 144 145 public void removePropertyChangeListener(PropertyChangeListener pcl) { 146 } 148 149 public Project getProject() { 150 return PiagetProject.this; 151 } 152 } 153 154 } 155 | Popular Tags |