1 11 package org.eclipse.pde.internal.ui.view; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.jface.resource.ImageDescriptor; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.pde.internal.ui.IHelpContextIds; 17 import org.eclipse.pde.internal.ui.PDEPluginImages; 18 import org.eclipse.pde.internal.ui.PDEUIMessages; 19 import org.eclipse.swt.graphics.Image; 20 import org.eclipse.swt.graphics.ImageData; 21 import org.eclipse.ui.PlatformUI; 22 23 26 public class HistoryAction extends Action { 27 30 public class ImageImageDescriptor extends ImageDescriptor { 31 private Image fImage; 32 33 36 public ImageImageDescriptor(Image image) { 37 super(); 38 fImage = image; 39 } 40 41 46 public boolean equals(Object obj) { 47 return (obj != null) && getClass().equals(obj.getClass()) 48 && fImage.equals(((ImageImageDescriptor) obj).fImage); 49 } 50 51 56 public ImageData getImageData() { 57 return fImage.getImageData(); 58 } 59 60 65 public int hashCode() { 66 return fImage.hashCode(); 67 } 68 } 69 70 private String fElement; 71 72 private DependenciesView fView; 73 74 public HistoryAction(DependenciesView view, String element) { 75 super(); 76 fView = view; 77 fElement = element; 78 79 String elementName = element.toString(); 80 setText(elementName); 81 setImageDescriptor(getImageDescriptor(elementName)); 82 setDisabledImageDescriptor(PDEPluginImages.DESC_PLUGIN_OBJ); 83 84 setDescription(NLS.bind(PDEUIMessages.HistoryAction_description, elementName)); 85 setToolTipText(NLS.bind(PDEUIMessages.HistoryAction_tooltip, elementName)); 86 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IHelpContextIds.HISTORY_ACTION); 87 } 88 89 private ImageDescriptor getImageDescriptor(String element) { 90 DependenciesLabelProvider imageProvider = new DependenciesLabelProvider( 91 false); 92 ImageDescriptor desc = new ImageImageDescriptor(imageProvider 93 .getImage(element)); 94 imageProvider.dispose(); 95 96 return desc; 97 } 98 99 102 public void run() { 103 fView.gotoHistoryEntry(fElement); 104 } 105 106 } 107 | Popular Tags |