1 11 12 package org.eclipse.jdt.internal.corext.buildpath; 13 14 import java.lang.reflect.InvocationTargetException ; 15 import java.util.ArrayList ; 16 import java.util.List ; 17 18 import org.eclipse.core.runtime.IProgressMonitor; 19 20 import org.eclipse.jface.viewers.IStructuredSelection; 21 22 import org.eclipse.jdt.core.IJavaElement; 23 import org.eclipse.jdt.core.IJavaProject; 24 import org.eclipse.jdt.core.IPackageFragmentRoot; 25 import org.eclipse.jdt.core.JavaModelException; 26 27 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; 28 import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.DialogPackageExplorerActionGroup; 29 import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.ClasspathModifierQueries.IInclusionExclusionQuery; 30 import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.GenerateBuildPathActionGroup.EditFilterAction; 31 32 38 public class EditFiltersOperation extends ClasspathModifierOperation { 39 40 private final IClasspathInformationProvider fCPInformationProvider; 41 private final IClasspathModifierListener fListener; 42 43 54 public EditFiltersOperation(IClasspathModifierListener listener, IClasspathInformationProvider informationProvider) { 55 super(listener, informationProvider, NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_tooltip, IClasspathInformationProvider.EDIT_FILTERS); 56 fListener= listener; 57 fCPInformationProvider= informationProvider; 58 59 } 60 61 69 public void run(IProgressMonitor monitor) throws InvocationTargetException { 70 EditFilterAction action= new EditFilterAction(); 71 IStructuredSelection selection= fCPInformationProvider.getSelection(); 72 Object firstElement= selection.getFirstElement(); 73 action.selectionChanged(selection); 74 action.run(); 75 List l= new ArrayList (); 76 l.add(firstElement); 77 if (fListener != null) { 78 List entries= action.getCPListElements(); 79 fListener.classpathEntryChanged(entries); 80 } 81 fCPInformationProvider.handleResult(l, null, IClasspathInformationProvider.EDIT_FILTERS); 82 } 83 84 98 public boolean isValid(List elements, int[] types) throws JavaModelException { 99 if (elements.size() != 1) 100 return false; 101 IJavaProject project= fInformationProvider.getJavaProject(); 102 Object element= elements.get(0); 103 104 if (element instanceof IJavaProject) { 105 if (isSourceFolder(project)) 106 return true; 107 } else if (element instanceof IPackageFragmentRoot) { 108 return ((IPackageFragmentRoot) element).getKind() == IPackageFragmentRoot.K_SOURCE; 109 } 110 return false; 111 } 112 113 125 public String getDescription(int type) { 126 if (type == DialogPackageExplorerActionGroup.JAVA_PROJECT) 127 return NewWizardMessages.PackageExplorerActionGroup_FormText_Edit; 128 if (type == DialogPackageExplorerActionGroup.PACKAGE_FRAGMENT_ROOT) 129 return NewWizardMessages.PackageExplorerActionGroup_FormText_Edit; 130 if (type == DialogPackageExplorerActionGroup.MODIFIED_FRAGMENT_ROOT) 131 return NewWizardMessages.PackageExplorerActionGroup_FormText_Edit; 132 return NewWizardMessages.PackageExplorerActionGroup_FormText_Default_Edit; 133 } 134 } 135 | Popular Tags |