KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > about > AboutAction


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.ui.internal.about;
12
13 import org.eclipse.core.runtime.IProduct;
14 import org.eclipse.core.runtime.Platform;
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.osgi.util.NLS;
17 import org.eclipse.ui.IWorkbenchWindow;
18 import org.eclipse.ui.actions.ActionFactory;
19 import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
20 import org.eclipse.ui.internal.WorkbenchMessages;
21 import org.eclipse.ui.internal.dialogs.AboutDialog;
22
23 /**
24  * Creates an About dialog and opens it.
25  */

26 public class AboutAction extends Action implements
27         ActionFactory.IWorkbenchAction {
28
29     /**
30      * The workbench window; or <code>null</code> if this action has been
31      * <code>dispose</code>d.
32      */

33     private IWorkbenchWindow workbenchWindow;
34
35     /**
36      * Creates a new <code>AboutAction</code>.
37      *
38      * @param window the window
39      */

40     public AboutAction(IWorkbenchWindow window) {
41         if (window == null) {
42             throw new IllegalArgumentException JavaDoc();
43         }
44
45         this.workbenchWindow = window;
46
47         // use message with no fill-in
48
IProduct product = Platform.getProduct();
49         String JavaDoc productName = null;
50         if (product != null) {
51             productName = product.getName();
52         }
53         if (productName == null) {
54             productName = ""; //$NON-NLS-1$
55
}
56         setText(NLS.bind(WorkbenchMessages.AboutAction_text,productName));
57         setToolTipText(NLS.bind(WorkbenchMessages.AboutAction_toolTip, productName));
58         setId("about"); //$NON-NLS-1$
59
setActionDefinitionId("org.eclipse.ui.help.aboutAction"); //$NON-NLS-1$
60
window.getWorkbench().getHelpSystem().setHelp(this,
61                 IWorkbenchHelpContextIds.ABOUT_ACTION);
62     }
63
64     /*
65      * (non-Javadoc) Method declared on IAction.
66      */

67     public void run() {
68         // make sure action is not disposed
69
if (workbenchWindow != null) {
70             new AboutDialog(workbenchWindow.getShell()).open();
71         }
72     }
73
74     /*
75      * (non-Javadoc) Method declared on ActionFactory.IWorkbenchAction.
76      */

77     public void dispose() {
78         workbenchWindow = null;
79     }
80 }
81
Popular Tags