Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Plug-in Developer Guide
Previous Page Home Next Page

Defining the actions

The primary customization provided by the BrowserAdvisor in the browser example is the designation of the action bar content for the workbench window:

	public void fillActionBars(IWorkbenchWindow window, IActionBarConfigurer configurer, int flags) {
		...
		BrowserActionBuilder builder = new BrowserActionBuilder(window);
		getWorkbenchConfigurer().getWindowConfigurer(window).setData(BUILDER_KEY, builder); 
		builder.fillActionBars(configurer, flags);
	}

Let's take a closer look at how these actions are defined in the BrowserActionBuilder. In particular, let's look at the actions that are handled by the browser view.

private void makeActions() {
		...				
		backAction = new RetargetAction("back", "&Back");  
		backAction.setToolTipText("Back");
		backAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_BACK));
		window.getPartService().addPartListener(backAction);
		
		forwardAction = new RetargetAction("forward", "&Forward");  
		forwardAction.setToolTipText("Forward");
		forwardAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD));
		window.getPartService().addPartListener(forwardAction);
		
		stopAction = new RetargetAction("stop", "Sto&p"); 
		stopAction.setToolTipText("Stop");
		window.getPartService().addPartListener(stopAction);
		
		refreshAction = new RetargetAction("refresh", "&Refresh");  
		refreshAction.setToolTipText("Refresh");
		window.getPartService().addPartListener(refreshAction);
		...
	}

The actions are defined as retargetable actions so that individual views can implement the handler actions. The BrowserView associates its handler actions with the window's retargetable actions when it creates the controls for the view:

	private Browser createBrowser(Composite parent, final IActionBars actionBars) {
		
		...
		actionBars.setGlobalActionHandler("back", backAction); 
		actionBars.setGlobalActionHandler("forward", forwardAction); 
		actionBars.setGlobalActionHandler("stop", stopAction); 
		actionBars.setGlobalActionHandler("refresh", refreshAction); 
		...
	}

These actions are created when the view is first created.

	private Action backAction = new Action("Back") {
		public void run() {
			browser.back();
		}
	};

See Retargetable actions for a complete discussion of retargetable actions and how they are defined and implemented.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire