01: /*******************************************************************************
02: * Copyright (c) 2007 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.examples.contributions.handlers;
11:
12: import org.eclipse.core.commands.AbstractHandler;
13: import org.eclipse.core.commands.ExecutionEvent;
14: import org.eclipse.core.commands.ExecutionException;
15: import org.eclipse.ui.IWorkbenchWindow;
16: import org.eclipse.ui.examples.contributions.ContributionMessages;
17: import org.eclipse.ui.handlers.HandlerUtil;
18: import org.eclipse.jface.dialogs.MessageDialog;
19:
20: /**
21: * Our sample handler extends AbstractHandler, an IHandler base class.
22: *
23: * @see org.eclipse.core.commands.IHandler
24: * @see org.eclipse.core.commands.AbstractHandler
25: * @since 3.3
26: */
27: public class GlobalMenuHandler extends AbstractHandler {
28: /**
29: * The constructor.
30: */
31: public GlobalMenuHandler() {
32: }
33:
34: /**
35: * the command has been executed, so extract extract the needed information
36: * from the application context.
37: */
38: public Object execute(ExecutionEvent event)
39: throws ExecutionException {
40: IWorkbenchWindow window = HandlerUtil
41: .getActiveWorkbenchWindowChecked(event);
42: MessageDialog.openInformation(window.getShell(),
43: ContributionMessages.SampleHandler_plugin_name,
44: ContributionMessages.SampleHandler_hello_msg);
45: return null;
46: }
47: }
|