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.core.resources.IFile; 21 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 import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.ClasspathModifierQueries.OutputFolderQuery; 30 31 32 39 public class AddSelectedLibraryOperation extends ClasspathModifierOperation { 40 41 52 public AddSelectedLibraryOperation(IClasspathModifierListener listener, IClasspathInformationProvider informationProvider) { 53 super(listener, informationProvider, NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelLibToCP_tooltip, IClasspathInformationProvider.ADD_SEL_LIB_TO_BP); 54 } 55 56 64 public void run(IProgressMonitor monitor) throws InvocationTargetException { 65 List result= null; 66 fException= null; 67 try { 68 List elements= getSelectedElements(); 69 IJavaProject project= fInformationProvider.getJavaProject(); 70 result= addLibraryEntries(elements, project, monitor); 71 } catch (CoreException e) { 72 fException= e; 73 result= null; 74 } 75 super.handleResult(result, monitor); 76 } 77 78 92 public boolean isValid(List elements, int[] types) throws JavaModelException { 93 if (elements.size() == 0) 94 return false; 95 for (int i= 0; i < elements.size(); i++) { 96 if (types[i] != DialogPackageExplorerActionGroup.ARCHIVE) { 97 return false; 98 } 99 } 100 return true; 101 } 102 103 115 public String getDescription(int type) { 116 Object obj= getSelectedElements().get(0); 117 String name= escapeSpecialChars(((IFile) obj).getName()); 118 119 if (type == DialogPackageExplorerActionGroup.ARCHIVE) 120 return Messages.format(NewWizardMessages.PackageExplorerActionGroup_FormText_ArchiveToBuildpath, name); 121 return NewWizardMessages.PackageExplorerActionGroup_FormText_Default_toBuildpath; 122 } 123 } 124 | Popular Tags |