1 19 20 package org.netbeans.modules.ruby.rubyproject; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.util.ArrayList ; 25 import java.util.Arrays ; 26 import java.util.List ; 27 import java.util.Properties ; 28 import org.netbeans.api.project.Project; 29 import org.netbeans.api.project.ProjectInformation; 30 import org.netbeans.api.project.ProjectManager; 31 import org.netbeans.spi.project.ActionProvider; 32 import org.netbeans.spi.project.CopyOperationImplementation; 33 import org.netbeans.spi.project.DeleteOperationImplementation; 34 import org.netbeans.spi.project.MoveOperationImplementation; 35 import org.netbeans.modules.ruby.spi.project.support.rake.RakeProjectHelper; 36 import org.netbeans.modules.ruby.spi.project.support.rake.EditableProperties; 37 import org.netbeans.modules.ruby.spi.project.support.rake.GeneratedFilesHelper; 38 import org.netbeans.modules.ruby.spi.project.support.rake.PropertyUtils; 39 import org.openide.filesystems.FileObject; 40 import org.openide.util.Lookup; 41 import org.openide.util.NbBundle; 42 43 47 public class RubyProjectOperations implements DeleteOperationImplementation, CopyOperationImplementation, MoveOperationImplementation { 48 49 private RubyProject project; 50 51 public RubyProjectOperations(RubyProject project) { 52 this.project = project; 53 } 54 55 private static void addFile(FileObject projectDirectory, String fileName, List result) { 56 FileObject file = projectDirectory.getFileObject(fileName); 57 58 if (file != null) { 59 result.add(file); 60 } 61 } 62 63 public List <FileObject> getMetadataFiles() { 64 FileObject projectDirectory = project.getProjectDirectory(); 65 List <FileObject> files = new ArrayList <FileObject>(); 66 67 addFile(projectDirectory, "nbproject", files); 72 return files; 73 } 74 75 public List <FileObject> getDataFiles() { 76 List <FileObject> files = new ArrayList <FileObject>(); 77 files.addAll(Arrays.asList(project.getSourceRoots().getRoots())); 78 files.addAll(Arrays.asList(project.getTestSourceRoots().getRoots())); 79 return files; 81 } 82 83 public void notifyDeleting() throws IOException { 84 RubyActionProvider ap = project.getLookup().lookup(RubyActionProvider.class); 85 86 assert ap != null; 87 88 } 98 99 public void notifyDeleted() throws IOException { 100 project.getRakeProjectHelper().notifyDeleted(); 101 } 102 103 public void notifyCopying() { 104 } 106 107 public void notifyCopied(Project original, File originalPath, String nueName) { 108 if (original == null) { 109 return ; 111 } 112 113 fixDistJarProperty (nueName); 114 project.getReferenceHelper().fixReferences(originalPath); 115 116 project.setName(nueName); 117 } 118 119 public void notifyMoving() throws IOException { 120 if (!this.project.getUpdateHelper().requestSave()) { 121 throw new IOException (NbBundle.getMessage(RubyProjectOperations.class, 122 "MSG_OldProjectMetadata")); 123 } 124 notifyDeleting(); 125 } 126 127 public void notifyMoved(Project original, File originalPath, String nueName) { 128 if (original == null) { 129 project.getRakeProjectHelper().notifyDeleted(); 130 return ; 131 } 132 133 fixDistJarProperty (nueName); 134 project.setName(nueName); 135 project.getReferenceHelper().fixReferences(originalPath); 136 } 137 138 private static boolean isParent(File folder, File fo) { 139 if (folder.equals(fo)) 140 return false; 141 142 while (fo != null) { 143 if (fo.equals(folder)) 144 return true; 145 146 fo = fo.getParentFile(); 147 } 148 149 return false; 150 } 151 152 private void fixDistJarProperty (final String newName) { 153 } 166 167 } 168 | Popular Tags |