01: /*******************************************************************************
02: * Copyright (c) 2004, 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.handlers;
11:
12: import org.eclipse.core.commands.ExecutionEvent;
13: import org.eclipse.core.commands.ExecutionException;
14: import org.eclipse.jface.action.IAction;
15: import org.eclipse.jface.viewers.ISelection;
16: import org.eclipse.ui.IWorkbenchWindow;
17:
18: /**
19: * A handler that can be used to imitate a IWorkbenchWindowActionDelegate.
20: *
21: * @since 3.1
22: */
23: public abstract class WorkbenchWindowHandlerDelegate extends
24: ExecutableExtensionHandler implements
25: IWorkbenchWindowHandlerDelegate {
26:
27: /**
28: * By default, this will do nothing. Subclasses may override.
29: *
30: * @param window
31: * the window that provides the context for this delegate
32: * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
33: */
34: public void init(final IWorkbenchWindow window) {
35: // Do nothing by default.
36: }
37:
38: /**
39: * This simply calls execute with a <code>null</code> map of parameter
40: * values. If an <code>ExecutionException</code> occurs, then this should
41: * be handle somehow. It's not clear what we'll do yet.
42: *
43: * @param action
44: * The action proxy that handles the presentation portion of the
45: * action
46: * @see org.eclipse.ui.IActionDelegate#run(IAction)
47: */
48: public void run(final IAction action) {
49: try {
50: execute(new ExecutionEvent());
51: } catch (final ExecutionException e) {
52: // TODO Do something meaningful and poignant.
53: }
54: }
55:
56: /**
57: * By default, this will do nothing. Subclasses may override.
58: *
59: * @param action
60: * The action proxy that handles presentation portion of the
61: * action
62: * @param selection
63: * The current selection, or <code>null</code> if there is no
64: * selection.
65: *
66: * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
67: */
68: public void selectionChanged(IAction action, ISelection selection) {
69: // Do nothing be default.
70: }
71: }
|