1 11 package org.eclipse.jdt.internal.ui.wizards.buildpaths; 12 13 import java.util.ArrayList ; 14 import java.util.Arrays ; 15 import java.util.List ; 16 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IPath; 19 import org.eclipse.core.runtime.IProgressMonitor; 20 21 import org.eclipse.core.resources.IProject; 22 import org.eclipse.core.resources.IResource; 23 24 import org.eclipse.jface.resource.ImageDescriptor; 25 26 import org.eclipse.jdt.core.IJavaElement; 27 import org.eclipse.jdt.core.IJavaProject; 28 import org.eclipse.jdt.core.IPackageFragmentRoot; 29 30 import org.eclipse.jdt.internal.ui.JavaPlugin; 31 import org.eclipse.jdt.internal.ui.wizards.NewElementWizard; 32 33 public abstract class BuildPathWizard extends NewElementWizard { 34 35 private boolean fDoFlushChange; 36 private final CPListElement fEntryToEdit; 37 private IPackageFragmentRoot fPackageFragmentRoot; 38 private IPath fOutputLocation; 39 private final ArrayList fExistingEntries; 40 41 public BuildPathWizard(CPListElement[] existingEntries, CPListElement newEntry, IPath outputLocation, String titel, ImageDescriptor image) { 42 fOutputLocation= outputLocation; 43 if (image != null) 44 setDefaultPageImageDescriptor(image); 45 46 setDialogSettings(JavaPlugin.getDefault().getDialogSettings()); 47 setWindowTitle(titel); 48 49 fEntryToEdit= newEntry; 50 fExistingEntries= new ArrayList (Arrays.asList(existingEntries)); 51 fDoFlushChange= true; 52 } 53 54 57 protected void finishPage(IProgressMonitor monitor) throws InterruptedException , CoreException { 58 if (fDoFlushChange) { 59 IJavaProject javaProject= getEntryToEdit().getJavaProject(); 60 61 BuildPathsBlock.flush(getExistingEntries(), getOutputLocation(), javaProject, monitor); 62 63 IProject project= javaProject.getProject(); 64 IPath path= getEntryToEdit().getPath(); 65 66 IResource folder= project.getWorkspace().getRoot().findMember(path); 67 fPackageFragmentRoot= javaProject.getPackageFragmentRoot(folder); 68 } 69 } 70 71 74 public IJavaElement getCreatedElement() { 75 return fPackageFragmentRoot; 76 } 77 78 public void setDoFlushChange(boolean b) { 79 fDoFlushChange= b; 80 } 81 82 public ArrayList getExistingEntries() { 83 return fExistingEntries; 84 } 85 86 public IPath getOutputLocation() { 87 return fOutputLocation; 88 } 89 90 protected void setOutputLocation(IPath outputLocation) { 91 fOutputLocation= outputLocation; 92 } 93 94 protected CPListElement getEntryToEdit() { 95 return fEntryToEdit; 96 } 97 98 public List getInsertedElements() { 99 return new ArrayList (); 100 } 101 102 public List getRemovedElements() { 103 return new ArrayList (); 104 } 105 106 public List getModifiedElements() { 107 ArrayList result= new ArrayList (1); 108 result.add(fEntryToEdit); 109 return result; 110 } 111 112 public abstract void cancel(); 113 114 } 115 | Popular Tags |