1 19 20 package org.netbeans.spi.project.support; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.util.ArrayList ; 25 import java.util.List ; 26 import org.netbeans.api.project.Project; 27 import org.netbeans.spi.project.CopyOperationImplementation; 28 import org.netbeans.spi.project.DataFilesProviderImplementation; 29 import org.netbeans.spi.project.DeleteOperationImplementation; 30 import org.netbeans.spi.project.MoveOperationImplementation; 31 import org.openide.filesystems.FileObject; 32 33 39 public final class ProjectOperations { 40 41 private ProjectOperations() { 42 } 43 44 51 public static List <FileObject> getMetadataFiles(Project prj) { 52 List <FileObject> result = new ArrayList <FileObject>(); 53 54 for (DataFilesProviderImplementation i : prj.getLookup().lookupAll(DataFilesProviderImplementation.class)) { 55 result.addAll(i.getMetadataFiles()); 56 assert !result.contains(null) : "Nulls in " + result + " from " + i; 57 } 58 59 return result; 60 } 61 62 69 public static List <FileObject> getDataFiles(Project prj) { 70 List <FileObject> result = new ArrayList <FileObject>(); 71 72 for (DataFilesProviderImplementation i : prj.getLookup().lookupAll(DataFilesProviderImplementation.class)) { 73 result.addAll(i.getDataFiles()); 74 assert !result.contains(null) : "Nulls in " + result + " from " + i; 75 } 76 77 return result; 78 } 79 80 86 public static boolean isDeleteOperationSupported(Project prj) { 87 return prj.getLookup().lookup(DeleteOperationImplementation.class) != null; 88 } 89 90 98 public static void notifyDeleting(Project prj) throws IOException { 99 for (DeleteOperationImplementation i : prj.getLookup().lookupAll(DeleteOperationImplementation.class)) { 100 i.notifyDeleting(); 101 } 102 } 103 104 110 public static void notifyDeleted(Project prj) throws IOException { 111 for (DeleteOperationImplementation i : prj.getLookup().lookupAll(DeleteOperationImplementation.class)) { 112 i.notifyDeleted(); 113 } 114 } 115 116 122 public static boolean isCopyOperationSupported(Project prj) { 123 return prj.getLookup().lookup(CopyOperationImplementation.class) != null; 124 } 125 126 134 public static void notifyCopying(Project prj) throws IOException { 135 for (CopyOperationImplementation i : prj.getLookup().lookupAll(CopyOperationImplementation.class)) { 136 i.notifyCopying(); 137 } 138 } 139 140 154 public static void notifyCopied(Project original, Project nue, File originalPath, String name) throws IOException { 155 for (CopyOperationImplementation i : original.getLookup().lookupAll(CopyOperationImplementation.class)) { 156 i.notifyCopied(null, originalPath, name); 157 } 158 for (CopyOperationImplementation i : nue.getLookup().lookupAll(CopyOperationImplementation.class)) { 159 i.notifyCopied(original, originalPath, name); 160 } 161 } 162 163 171 public static void notifyMoving(Project prj) throws IOException { 172 for (MoveOperationImplementation i : prj.getLookup().lookupAll(MoveOperationImplementation.class)) { 173 i.notifyMoving(); 174 } 175 } 176 177 191 public static void notifyMoved(Project original, Project nue, File originalPath, String name) throws IOException { 192 for (MoveOperationImplementation i : original.getLookup().lookupAll(MoveOperationImplementation.class)) { 193 i.notifyMoved(null, originalPath, name); 194 } 195 for (MoveOperationImplementation i : nue.getLookup().lookupAll(MoveOperationImplementation.class)) { 196 i.notifyMoved(original, originalPath, name); 197 } 198 } 199 200 207 public static boolean isMoveOperationSupported(Project prj) { 208 return true; } 210 211 } 212 | Popular Tags |