Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • Lotus Expeditor wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 6.2.1
  • 6.2.2
  • 6.2.3
  • access services
  • accounts
  • administer
  • application
  • applications
  • broker
  • client
  • client for desktop
  • client management
  • cluster
  • collecting data
  • configuration
  • configure
  • data integrity check tools
  • database
  • db2
  • db2e
  • deleting log entries automatically
  • demo
  • demonstration
  • desktop overview
  • develop
  • device
  • device client
  • diagnosis of problems. See troubleshooting
  • diagnostic data
  • diagnostic tool
  • documentation
  • download
  • environment variables
  • error messages
  • expeditor
  • expeditor server
  • expeditor toolkit
  • files
  • fix pack
  • gettingstarted
  • Help
  • how-to
  • IBM Support
  • install
  • installation
  • integration
  • integrator
  • interaction services
  • Interrogation Windows Tab
  • introduce
  • introduction
  • log files
  • messaging
  • micro
  • mobile databases
  • mobile databases
  • mobile devices
  • mqe
  • nci
  • notes
  • OpenSpan
  • OpenSpan Scripting Container
  • OpenSpan Windows Container
  • overview
  • platform
  • portlet
  • prerequisites
  • presentation
  • problems with synchronization. See troubleshooting.
  • purging log entries automatically
  • Release Notes
  • replication
  • resources on the Web
  • rich client application
  • samples
  • scripts
  • security
  • server
  • software
  • software prerequisites
  • support
  • support troubleshooting
  • Sync Client
  • Sync Server
  • synchronization
  • synchronization problems
  • tool
  • toolkit
  • tools
  • trace files
  • trace level
  • troubleshoot
  • troubleshooting
  • tutorial
  • use
  • was
  • web services
  • What's New
  • xcm
  • xpdt
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > Expeditor Client for Desktop > Sample: Toolbar and Menu Contributions
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Sample: Toolbar and Menu Contributions 

expanded Abstract
collapsed Abstract
Expeditor user interface team best practices on toolbar and menu contributions
ShowTable of Contents
HideTable of Contents
  • 1 Overview
  • 2 Global Toolbar
    • 2.1 Toolbar Action
    • 2.2 Toggle ActionSet Action
    • 2.3 Composite Applications and Activities
  • 3 View Toolbars
    • 3.1 View ToolBar Action and View Menu Action

Overview


The various options available when contributing toolbars and menus can be confusing when developing Expeditor applications. To simplify the process of contributing these items, the Expeditor user interface team recommends the following best practices. Sample code has been provided below to demonstrate the following decorations to the user interface:

Toolbar ActionA rich SWT control added using a controlSet
Toggle Action Set ActionAn action contributed using an actionSet
View ToolBar ActionAn action added to a ViewPart's toolbar
View Menu ActionAn action added to a ViewPart's menu



Global Toolbar

  1. Use org.eclipse.ui.actionSets, if the developer wants to add regular/standard type of toolbar button such as push, radio, toggle, pulldown buttons
  2. Use com.ibm.rcp.ui.controlSets, if the developer wants to add arbitrary SWT control to toolbar, such as Text, Combo, StyledText, Browser controls
  3. The extension point org.eclipse.ui.menus is not supported for the global toolbar in Expeditor

Toolbar Action


The "Toolbar Action" is added using the controlSet extension point detailed in the Expeditor wiki article Contributing custom controls to the main toolbar statically. To add the "Toolbar Action", declare a controlSet, contribute a toolbar, and finally add the control to the toolbar. Valid entries for the path are: BEGIN_GROUP, MIDDLE_GROUP, END_GROUP.

<extension
         point="com.ibm.rcp.ui.controlSets">
      <controlSet
            align="left"
            id="com.ibm.rcp.support.menu.controlset"
            label="Toolbar Samples"
            showInToolBarMenu="true"
            tooltip="Displays toolbar contributions"
            visible="true">
         <toolBar
               id="com.ibm.rcp.support.menu.globaltoolbar"
               path="BEGIN_GROUP">
         </toolBar>
         <control
               class="com.ibm.rcp.support.menu.globaltoolbar.ToolbarAction"
               id="com.ibm.rcp.support.menu.globaltoolbar.control"
               toolbarPath="com.ibm.rcp.support.menu.globaltoolbar">
         </control>
      </controlSet>
   </extension>


The "Toolbar Action" class snippet is below.


public class ToolbarAction extends ContributionItem implements
		ISContributionItem {

	private SToolItem item;

	private final Image icon = Activator.imageDescriptorFromPlugin(
			Activator.PLUGIN_ID, "icons" + File.separator + "notes_icon.gif")
			.createImage();

	public void fill(final SToolBar bar, int index) {
		item = new SToolItem(bar, SWT.PUSH);
		item.setText("Toolbar Action");
		item.setToolTipText("A toolbar contribution");
		item.setImage(icon);

		item.addSelectionListener(new SelectionListener() {

			@Override
			public void widgetDefaultSelected(SelectionEvent event) {
				// no default
			}

			@Override
			public void widgetSelected(SelectionEvent event) {
				Item i = ((Item) event.getSource());
				ActionContributionItem actionContrib = (ActionContributionItem) i
						.getData();

				doSomething(item, actionContrib);
			}
		});
	}

	@Override
	public void fill(SCoolBar parent, int index) {

	}

	public void dispose() {
		icon.dispose();
	}

...


Toggle ActionSet Action


The "Toggle ActionSet Action" is provided as an advanced sample of the Contributing Eclipse-based controls to the toolbar statically wiki article. Depending on the context, some actions may need to be hidden. For example, a composite application may need to show one action while another may need to hide an action and show another. This showing and hiding is accomplished using Eclipse activities. Toolbar actions are associated with an activity, and when required to show, the corresponding activity is enabled.

The following extensions create the "Toggle ActionSet Action" as well as the "ActionSet Action". Initially the "Toggle ActionSet Action" is the only action visible.

<extension
         point="org.eclipse.ui.actionSets">
      <actionSet
            id="com.ibm.rcp.support.menu.actionset"
            label="ActionSet Action"
            visible="true">
         <action
               class="com.ibm.rcp.support.menu.ActionSetAction"
               id="com.ibm.rcp.support.menu.actionset.action"
               label="ActionSet Action"
               style="push"
               toolbarPath="END_GROUP">
         </action>
         <action
               class="com.ibm.rcp.support.menu.ActionSetToggle"
               id="com.ibm.rcp.support.menu.actionset.action.toggle"
               label="Toggle ActionSet Action"
               style="push"
               toolbarPath="END_GROUP">
         </action>
      </actionSet>
   </extension>


Both classes simply implement the org.eclipse.ui.IWorkbenchWindowActionDelegate interface. The "ActionSet Action" is added to an Eclipse activity.

<extension 
	   point="org.eclipse.ui.activities">
  	<activity 
		id="com.ibm.rcp.support.menu.activity" 
		name="Action Set" /> 
  	<activityPatternBinding 
		activityId="com.ibm.rcp.support.menu.activity" 
		isEqualityPattern="false" 
		pattern="com\.ibm\.rcp\.support\.menu/com\.ibm\.rcp\.support\.menu\.actionset\.action" /> 
  </extension>


The pattern is a regular expression; it declares pluginID/actionID. By enabling the activity com.ibm.rcp.support.menu.activity, the Eclipse action defined by the ID com.ibm.rcp.support.menu.actionset.action in the plugin com.ibm.rcp.support.menu is shown. And this is exactly what the "Toggle ActionSet Action" button does, it enables the activity which shows the "ActionSet Action".

// the activity ID from the plugin.xml
// this binds the actionSet contribution to the activity
String id = "com.ibm.rcp.support.menu.activity";

IWorkbenchActivitySupport s = PlatformUI.getWorkbench()
	.getActivitySupport();
IActivityManager m = s.getActivityManager();

IActivity a = m.getActivity(id);

// toggle
if (a != null) {
	Set enabled;
			if (a.isEnabled()) {
		enabled = new HashSet(m.getEnabledActivityIds());
		enabled.remove(id);
	} else {
		enabled = new HashSet(m.getEnabledActivityIds());
		enabled.add(id);
	}
	
	s.setEnabledActivityIds(enabled);
}


Composite Applications and Activities


Expeditor Composite Applications can enable and disable activities. For example when a Composite Application is shown, the activity is enabled, and when the Composite Application is closed or deactivated, the activity is disabled. This gives the show-hide context described earlier. To bind a particular Composite Application to an activity, edit the Composite Application's page properties - activities are defined at the page level not the application level. Add the property com.ibm.rcp.activities=activityId. Multiple activities can be delimited by the token colon colon (::).

View Toolbars

  1. Use org.eclipse.ui.viewActions, if the developer wants to add regular/standard type of toolbar button such as push, radio, toggle, pulldown buttons.
  2. Call IViewSite.getActionBars().getToolbarManager() and add a contribution to the toolbar manager , if the developer wants to add arbitrary SWT control to toolbar, such as Text, Combo, StyledText, Browser controls.
  3. Extension point org.eclipse.ui.menus is not supported for a view's toolbar in Expeditor.

View ToolBar Action and View Menu Action


The "View ToolBar Action" and "View Menu Action" are added programmatically using method two described above. The code for doing this is relatively straightforward and has been provided as part of a ViewPart's creation method.


public void createPartControl(Composite parent) {
	// get menu managers
	org.eclipse.jface.action.IToolBarManager toolBar = super.getViewSite()
			.getActionBars().getToolBarManager();

	org.eclipse.jface.action.IMenuManager menuBar = getViewSite()
			.getActionBars().getMenuManager();

	// create actions
	org.eclipse.jface.action.Action toolAction = new Action() {
		public void run() {
			// do something
		}
	};
	toolAction.setText("View ToolBar Action");

	org.eclipse.jface.action.Action menuAction = new Action() {
		public void run() {
			// do something
		}
	};
	menuAction.setText("View Menu Action");

	// add actions to menu managers
	toolBar.add(toolAction);
	menuBar.add(menuAction);
}





expanded Article information
collapsed Article information
Category:
Expeditor Client for Desktop
Tags:
samples

This Version: Version 4 February 9, 2012 12:15:38 PM by Van Staub  IBMer

expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (4)
collapsed Versions (4)
Version Comparison     
Version Date Changed by               Summary of changes
This version (4) Feb 9, 2012 12:15:38 PM Van Staub  
3 Feb 9, 2012 12:02:33 PM Van Staub  
2 Feb 9, 2012 11:32:19 AM Van Staub  
1 Feb 9, 2012 11:24:36 AM Van Staub  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use