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.IProgressMonitor; 19 20 import org.eclipse.jdt.core.ICompilationUnit; 21 import org.eclipse.jdt.core.IJavaElement; 22 import org.eclipse.jdt.core.IJavaProject; 23 import org.eclipse.jdt.core.JavaModelException; 24 25 import org.eclipse.jdt.internal.corext.util.Messages; 26 27 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; 28 import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.DialogPackageExplorerActionGroup; 29 30 31 37 public class ExcludeOperation extends ClasspathModifierOperation { 38 39 50 public ExcludeOperation(IClasspathModifierListener listener, IClasspathInformationProvider informationProvider) { 51 super(listener, informationProvider, NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_tooltip, IClasspathInformationProvider.EXCLUDE); 52 } 53 54 61 public void run(IProgressMonitor monitor) throws InvocationTargetException { 62 List result= null; 63 fException= null; 64 try { 65 List javaElements= getSelectedElements(); 66 IJavaProject project= fInformationProvider.getJavaProject(); 67 result= exclude(javaElements, project, monitor); 68 } catch (CoreException e) { 69 fException= e; 70 result= null; 71 } 72 super.handleResult(result, monitor); 73 } 74 75 89 public boolean isValid(List elements, int[] types) throws JavaModelException { 90 if (elements.size() == 0) 91 return false; 92 for(int i= 0; i < elements.size(); i++) { 93 Object element= elements.get(i); 94 int type= types[i]; 95 if (!(type == DialogPackageExplorerActionGroup.PACKAGE_FRAGMENT || 96 type == DialogPackageExplorerActionGroup.INCLUDED_FOLDER || 97 element instanceof ICompilationUnit)) 98 return false; 99 } 100 return true; 101 } 102 103 115 public String getDescription(int type) { 116 IJavaElement elem= (IJavaElement) getSelectedElements().get(0); 117 String name= escapeSpecialChars(elem.getElementName()); 118 if (type == DialogPackageExplorerActionGroup.PACKAGE_FRAGMENT) 119 return Messages.format(NewWizardMessages.PackageExplorerActionGroup_FormText_ExcludePackage, name); 120 if (type == DialogPackageExplorerActionGroup.INCLUDED_FOLDER) 121 return Messages.format(NewWizardMessages.PackageExplorerActionGroup_FormText_ExcludePackage, name); 122 if (type == DialogPackageExplorerActionGroup.COMPILATION_UNIT) 123 return Messages.format(NewWizardMessages.PackageExplorerActionGroup_FormText_ExcludeFile, name); 124 if (type == DialogPackageExplorerActionGroup.INCLUDED_FILE) 125 return Messages.format(NewWizardMessages.PackageExplorerActionGroup_FormText_ExcludeFile, name); 126 return NewWizardMessages.PackageExplorerActionGroup_FormText_Default_Exclude; 127 } 128 } 129 | Popular Tags |