1 11 12 package org.eclipse.jdt.internal.corext.buildpath; 13 14 import java.lang.reflect.InvocationTargetException ; 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.jdt.core.IClasspathEntry; 22 import org.eclipse.jdt.core.IJavaProject; 23 import org.eclipse.jdt.core.JavaModelException; 24 25 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; 26 27 30 public class ResetAllOperation extends ClasspathModifierOperation { 31 private IClasspathEntry[] fEntries; 32 private IPath fOutputLocation; 33 44 public ResetAllOperation(IClasspathModifierListener listener, IClasspathInformationProvider informationProvider) { 45 super(listener, informationProvider, NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip, IClasspathInformationProvider.RESET_ALL); 46 } 47 48 56 public void run(IProgressMonitor monitor) throws InvocationTargetException { 57 fException= null; 58 try { 59 fInformationProvider.getJavaProject().setRawClasspath(fEntries, fOutputLocation, monitor); 60 fInformationProvider.deleteCreatedResources(); 61 fEntries= null; 62 fOutputLocation= null; 63 } catch (CoreException e) { 64 fException= e; 65 } 66 67 super.handleResult(null, monitor); 68 } 69 70 84 public boolean isValid(List elements, int[] types) throws JavaModelException { 85 IJavaProject project= fInformationProvider.getJavaProject(); 86 if (project == null) 87 return false; 88 if (fEntries == null) { 89 fEntries= project.getRawClasspath(); 90 fOutputLocation= project.getOutputLocation(); 91 } 92 if (!project.getOutputLocation().equals(fOutputLocation)) 93 return true; 94 IClasspathEntry[] currentEntries= project.getRawClasspath(); 95 if (currentEntries.length != fEntries.length) 96 return true; 97 for(int i= 0; i < fEntries.length; i++) { 98 if (!fEntries[i].equals(currentEntries[i])) 99 return true; 100 } 101 return false; 102 } 103 104 113 public String getDescription(int type) { 114 return NewWizardMessages.PackageExplorerActionGroup_FormText_Default_ResetAll; 115 } 116 } 117 | Popular Tags |