01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.about;
11:
12: import org.eclipse.core.runtime.IProduct;
13: import org.eclipse.core.runtime.Platform;
14: import org.eclipse.jface.action.Action;
15: import org.eclipse.osgi.util.NLS;
16: import org.eclipse.ui.IWorkbenchWindow;
17: import org.eclipse.ui.actions.ActionFactory;
18: import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
19: import org.eclipse.ui.internal.WorkbenchMessages;
20: import org.eclipse.ui.internal.dialogs.AboutDialog;
21:
22: /**
23: * Creates an About dialog and opens it.
24: */
25: public class AboutAction extends Action implements
26: ActionFactory.IWorkbenchAction {
27:
28: /**
29: * The workbench window; or <code>null</code> if this action has been
30: * <code>dispose</code>d.
31: */
32: private IWorkbenchWindow workbenchWindow;
33:
34: /**
35: * Creates a new <code>AboutAction</code>.
36: *
37: * @param window the window
38: */
39: public AboutAction(IWorkbenchWindow window) {
40: if (window == null) {
41: throw new IllegalArgumentException();
42: }
43:
44: this .workbenchWindow = window;
45:
46: // use message with no fill-in
47: IProduct product = Platform.getProduct();
48: String productName = null;
49: if (product != null) {
50: productName = product.getName();
51: }
52: if (productName == null) {
53: productName = ""; //$NON-NLS-1$
54: }
55: setText(NLS.bind(WorkbenchMessages.AboutAction_text,
56: productName));
57: setToolTipText(NLS.bind(WorkbenchMessages.AboutAction_toolTip,
58: productName));
59: setId("about"); //$NON-NLS-1$
60: setActionDefinitionId("org.eclipse.ui.help.aboutAction"); //$NON-NLS-1$
61: window.getWorkbench().getHelpSystem().setHelp(this ,
62: IWorkbenchHelpContextIds.ABOUT_ACTION);
63: }
64:
65: /*
66: * (non-Javadoc) Method declared on IAction.
67: */
68: public void run() {
69: // make sure action is not disposed
70: if (workbenchWindow != null) {
71: new AboutDialog(workbenchWindow.getShell()).open();
72: }
73: }
74:
75: /*
76: * (non-Javadoc) Method declared on ActionFactory.IWorkbenchAction.
77: */
78: public void dispose() {
79: workbenchWindow = null;
80: }
81: }
|