001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.ui.views.dependencies;
011:
012: import org.eclipse.jface.action.Action;
013: import org.eclipse.jface.resource.ImageDescriptor;
014: import org.eclipse.osgi.util.NLS;
015: import org.eclipse.pde.internal.ui.IHelpContextIds;
016: import org.eclipse.pde.internal.ui.PDEPluginImages;
017: import org.eclipse.pde.internal.ui.PDEUIMessages;
018: import org.eclipse.swt.graphics.Image;
019: import org.eclipse.swt.graphics.ImageData;
020: import org.eclipse.ui.PlatformUI;
021:
022: /**
023: * Action used for the open historical input again in DependenciesView
024: */
025: public class HistoryAction extends Action {
026: /**
027: * Image descriptor for an image.
028: */
029: public class ImageImageDescriptor extends ImageDescriptor {
030: private Image fImage;
031:
032: /**
033: * Constructor for ImagImageDescriptor.
034: */
035: public ImageImageDescriptor(Image image) {
036: super ();
037: fImage = image;
038: }
039:
040: /*
041: * (non-Javadoc)
042: *
043: * @see Object#equals(Object)
044: */
045: public boolean equals(Object obj) {
046: return (obj != null)
047: && getClass().equals(obj.getClass())
048: && fImage
049: .equals(((ImageImageDescriptor) obj).fImage);
050: }
051:
052: /*
053: * (non-Javadoc)
054: *
055: * @see ImageDescriptor#getImageData()
056: */
057: public ImageData getImageData() {
058: return fImage.getImageData();
059: }
060:
061: /*
062: * (non-Javadoc)
063: *
064: * @see Object#hashCode()
065: */
066: public int hashCode() {
067: return fImage.hashCode();
068: }
069: }
070:
071: private String fElement;
072:
073: private DependenciesView fView;
074:
075: public HistoryAction(DependenciesView view, String element) {
076: super ();
077: fView = view;
078: fElement = element;
079:
080: String elementName = element.toString();
081: setText(elementName);
082: setImageDescriptor(getImageDescriptor(elementName));
083: setDisabledImageDescriptor(PDEPluginImages.DESC_PLUGIN_OBJ);
084:
085: setDescription(NLS.bind(
086: PDEUIMessages.HistoryAction_description, elementName));
087: setToolTipText(NLS.bind(PDEUIMessages.HistoryAction_tooltip,
088: elementName));
089: PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
090: IHelpContextIds.HISTORY_ACTION);
091: }
092:
093: private ImageDescriptor getImageDescriptor(String element) {
094: DependenciesLabelProvider imageProvider = new DependenciesLabelProvider(
095: false);
096: ImageDescriptor desc = new ImageImageDescriptor(imageProvider
097: .getImage(element));
098: imageProvider.dispose();
099:
100: return desc;
101: }
102:
103: /*
104: * @see Action#run()
105: */
106: public void run() {
107: fView.gotoHistoryEntry(fElement);
108: }
109:
110: }
|