01: /*******************************************************************************
02: * Copyright (c) 2006, 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.fieldassist.actions;
11:
12: import org.eclipse.jface.action.IAction;
13: import org.eclipse.jface.viewers.ISelection;
14: import org.eclipse.ui.IWorkbenchWindow;
15: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
16: import org.eclipse.ui.examples.fieldassist.FieldAssistTestDialog;
17:
18: /**
19: * Our sample action implements workbench action delegate. The action proxy will
20: * be created by the workbench and shown in the UI. When the user tries to use
21: * the action, this delegate will be created and execution will be delegated to
22: * it.
23: *
24: * @see IWorkbenchWindowActionDelegate
25: */
26: public class TestDialogAction implements IWorkbenchWindowActionDelegate {
27: private IWorkbenchWindow window;
28:
29: /**
30: * The constructor.
31: */
32: public TestDialogAction() {
33: }
34:
35: /**
36: * The action has been activated. The argument of the method represents the
37: * 'real' action sitting in the workbench UI.
38: *
39: * @see IWorkbenchWindowActionDelegate#run
40: */
41: public void run(IAction action) {
42: new FieldAssistTestDialog(window.getShell(), "tom").open();
43: }
44:
45: /**
46: * Selection in the workbench has been changed. We can change the state of
47: * the 'real' action here if we want, but this can only happen after the
48: * delegate has been created.
49: *
50: * @see IWorkbenchWindowActionDelegate#selectionChanged
51: */
52: public void selectionChanged(IAction action, ISelection selection) {
53: }
54:
55: /**
56: * We can use this method to dispose of any system resources we previously
57: * allocated.
58: *
59: * @see IWorkbenchWindowActionDelegate#dispose
60: */
61: public void dispose() {
62: }
63:
64: /**
65: * We will cache window object in order to be able to provide parent shell
66: * for the dialog.
67: *
68: * @see IWorkbenchWindowActionDelegate#init
69: */
70: public void init(IWorkbenchWindow window) {
71: this.window = window;
72: }
73: }
|