1 11 package org.eclipse.pde.internal.core; 12 13 import org.eclipse.core.resources.*; 14 import org.eclipse.core.runtime.*; 15 16 17 public class CoreUtility { 18 19 public static void addNatureToProject(IProject proj, String natureId, 20 IProgressMonitor monitor) throws CoreException { 21 IProjectDescription description = proj.getDescription(); 22 String [] prevNatures = description.getNatureIds(); 23 String [] newNatures = new String [prevNatures.length + 1]; 24 System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); 25 newNatures[prevNatures.length] = natureId; 26 description.setNatureIds(newNatures); 27 proj.setDescription(description, monitor); 28 } 29 30 public static void createFolder(IFolder folder, boolean force, 31 boolean local, IProgressMonitor monitor) throws CoreException { 32 if (!folder.exists()) { 33 IContainer parent = folder.getParent(); 34 if (parent instanceof IFolder) { 35 createFolder((IFolder) parent, force, local, monitor); 36 } 37 folder.create(force, local, monitor); 38 } 39 } 40 41 public static void createProject(IProject project, IPath location, 42 IProgressMonitor monitor) throws CoreException { 43 if (!Platform.getLocation().equals(location)) { 44 IProjectDescription desc = project.getWorkspace() 45 .newProjectDescription(project.getName()); 46 desc.setLocation(location); 47 project.create(desc, monitor); 48 } else 49 project.create(monitor); 50 } 51 } 52
| Popular Tags
|