Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Reuse the save, new, print toolbar set
Reuse the save, new, print toolbar set [message #532224] Fri, 07 May 2010 11:30 Go to next message
Geejay is currently offline Geejay
Messages: 160
Registered: February 2010
Senior Member
Hello there,

I wanted to reuse the toolbar that has the New Project drop-down, the save icon and the print icon in the standard Eclipse install (I am working with 3,5).

Plug-in spy says that it is contributed by org.eclipse.ui.workbench (
org.eclipse.ui.workbench (3.5.1.M20090826-0800a).

How do I go about adding this functionality?

Thanks

Greg



Re: Reuse the save, new, print toolbar set [message #532280 is a reply to message #532224] Fri, 07 May 2010 14:54 Go to previous messageGo to next message
Christophe Fondacci is currently offline Christophe Fondacci
Messages: 95
Registered: July 2009
Location: Paris
Member
Hello Greg,

You'll have to extend the method fillCoolBar in your ActionBarAdvisor to initialize this toolbar with the actions.

At some point you'll have to define the following thing :
protected void fillCoolBar(ICoolBarManager cbManager) {
	IToolBarManager fileToolBar = new ToolBarManager(cbManager.getStyle());
	fileToolBar.add(getAction(ActionFactory.NEW_WIZARD_DROP_DOWN.getId()));
	fileToolBar.add(getAction(ActionFactory.SAVE.getId()));
	fileToolBar.add(getAction(ActionFactory.PRINT.getId()));
	cbManager.add(new ToolBarContributionItem(fileToolBar,IWorkbenchActionConstants.TOOLBAR_FILE));	
}


And that should make the controls you need to appear. Have a look at the ActionFactory to know more and discover other actions you may be interested in.

Note that this is sample code, you may need to initialize the appropriate group markers as well for proper interaction with contributions from other components...

Hope this helps,
Christophe
http://www.nextep-softwares.com

Re: Reuse the save, new, print toolbar set [message #532549 is a reply to message #532224] Mon, 10 May 2010 08:49 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

In addition to the help Chris gave, you can find where the IDE defines
its menus/toolbars in org.eclipse.ui.internal.ide.WorkbenchActionBuilder

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Reuse the save, new, print toolbar set [message #532751 is a reply to message #532549] Tue, 11 May 2010 03:01 Go to previous message
Geejay is currently offline Geejay
Messages: 160
Registered: February 2010
Senior Member
Thanks guys. I was wondering if I could actually define these actions (and the toolbar) as extensions (in the XML)?

FYI I actually used something like this:

protected void makeActions(final IWorkbenchWindow window) {
newWizard = ActionFactory.NEW_WIZARD_DROP_DOWN.create(window);
save = ActionFactory.SAVE.create(window);
print = ActionFactory.PRINT.create(window);

register(newWizard);
register(save);
register(print);
}

protected void fillCoolBar(ICoolBarManager cbManager) {
IToolBarManager fileToolBar = new ToolBarManager(cbManager.getStyle());
fileToolBar.add(newWizard);
fileToolBar.add(save);
fileToolBar.add(print);
cbManager.add(new ToolBarContributionItem(fileToolBar,IWorkbenchActionConstant s.TOOLBAR_FILE));
}

Previous Topic:Newbe question on refresh things.
Next Topic:Standalone help / user assistance
Goto Forum:
  


Current Time: Thu Aug 21 06:20:07 EDT 2014

Powered by FUDForum. Page generated in 0.08497 seconds