FileDocCategorySizeDatePackage
SampleAction.javaAPI DocExample1812Thu Mar 18 10:01:48 GMT 2004org.cookbook.ch12.MenuPlugIn.actions

SampleAction

public class SampleAction extends Object implements org.eclipse.ui.IWorkbenchWindowActionDelegate
Our sample action implements workbench action delegate. The action proxy will be created by the workbench and shown in the UI. When the user tries to use the action, this delegate will be created and execution will be delegated to it.
see
IWorkbenchWindowActionDelegate

Fields Summary
private org.eclipse.ui.IWorkbenchWindow
window
Constructors Summary
public SampleAction()
The constructor.

	
Methods Summary
public voiddispose()
We can use this method to dispose of any system resources we previously allocated.

see
IWorkbenchWindowActionDelegate#dispose

	
public voidinit(org.eclipse.ui.IWorkbenchWindow window)
We will cache window object in order to be able to provide parent shell for the message dialog.

see
IWorkbenchWindowActionDelegate#init

		this.window = window;
	
public voidrun(org.eclipse.jface.action.IAction action)
The action has been activated. The argument of the method represents the 'real' action sitting in the workbench UI.

see
IWorkbenchWindowActionDelegate#run

		MessageDialog.openInformation(
			window.getShell(),
			"MenuPlugIn Plug-in",
			"This plug-in is functional.");
	
public voidselectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection)
Selection in the workbench has been changed. We can change the state of the 'real' action here if we want, but this can only happen after the delegate has been created.

see
IWorkbenchWindowActionDelegate#selectionChanged