KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > view > HistoryAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
24  * Action used for the open historical input again in DependenciesView
25  */

26 public class HistoryAction extends Action {
27     /**
28      * Image descriptor for an image.
29      */

30     public class ImageImageDescriptor extends ImageDescriptor {
31         private Image fImage;
32
33         /**
34          * Constructor for ImagImageDescriptor.
35          */

36         public ImageImageDescriptor(Image image) {
37             super();
38             fImage = image;
39         }
40
41         /*
42          * (non-Javadoc)
43          *
44          * @see Object#equals(Object)
45          */

46         public boolean equals(Object JavaDoc obj) {
47             return (obj != null) && getClass().equals(obj.getClass())
48                     && fImage.equals(((ImageImageDescriptor) obj).fImage);
49         }
50
51         /*
52          * (non-Javadoc)
53          *
54          * @see ImageDescriptor#getImageData()
55          */

56         public ImageData getImageData() {
57             return fImage.getImageData();
58         }
59
60         /*
61          * (non-Javadoc)
62          *
63          * @see Object#hashCode()
64          */

65         public int hashCode() {
66             return fImage.hashCode();
67         }
68     }
69
70     private String JavaDoc fElement;
71
72     private DependenciesView fView;
73
74     public HistoryAction(DependenciesView view, String JavaDoc element) {
75         super();
76         fView = view;
77         fElement = element;
78
79         String JavaDoc 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 JavaDoc 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     /*
100      * @see Action#run()
101      */

102     public void run() {
103         fView.gotoHistoryEntry(fElement);
104     }
105
106 }
107
Popular Tags