1 11 12 package org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage; 13 14 import java.lang.reflect.InvocationTargetException ; 15 import java.util.List ; 16 17 import org.eclipse.jface.action.Action; 18 import org.eclipse.jface.resource.ImageDescriptor; 19 20 import org.eclipse.jdt.core.JavaModelException; 21 22 import org.eclipse.jdt.internal.corext.buildpath.ClasspathModifierOperation; 23 24 import org.eclipse.jdt.internal.ui.JavaPlugin; 25 26 30 public class ClasspathModifierAction extends Action { 31 private ClasspathModifierOperation fOperation; 32 33 44 public ClasspathModifierAction(ClasspathModifierOperation operation, ImageDescriptor imageDescriptor, ImageDescriptor disabledImageDescriptor, String text, String tooltip, int style) { 45 super(text, style); 46 setImageDescriptor(imageDescriptor); 47 setDisabledImageDescriptor(disabledImageDescriptor); 48 setText(text); 49 setToolTipText(tooltip); 50 fOperation= operation; 51 } 52 53 56 public void run() { 57 try { 58 fOperation.run(null); 59 setEnabled(fOperation.isValid()); 60 } catch (InvocationTargetException e) { 61 } catch (InterruptedException e) { 63 } catch (JavaModelException e) { 65 JavaPlugin.log(e); 66 } 67 } 71 72 87 public boolean isValid(List selectedElements, int[] types) throws JavaModelException { 88 return fOperation.isValid(selectedElements, types); 89 } 90 91 98 public ClasspathModifierOperation getOperation() { 99 return fOperation; 100 } 101 102 112 public String getDescription(int type) { 113 return fOperation.getDescription(type); 114 } 115 116 119 public String getId() { 120 return fOperation.getId(); 121 } 122 123 128 public String getName() { 129 return fOperation.getName(); 130 } 131 } 132 | Popular Tags |