FileDocCategorySizeDatePackage
SampleAction.javaAPI DocExample2343Fri Dec 05 13:06:24 GMT 2003org.eclipsebook.ch11.Ch1101.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(),
			"Ch11_01 Plug-in",
			"Hello, Eclipse world");
	
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