<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;A0QDRH0-cCp7ImA9WxJVF0w.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241</id><updated>2009-07-04T20:26:15.358+05:30</updated><title>Eclipse Tips</title><subtitle type="html">Tips and Tricks for Eclipse Plug-in Development</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.eclipse-tips.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>93</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><thespringbox:skin xmlns:thespringbox="http://www.thespringbox.com/dtds/thespringbox-1.0.dtd">http://feeds.feedburner.com/cypal?format=skin</thespringbox:skin><link rel="self" href="http://feeds.feedburner.com/cypal" type="application/atom+xml" /><feedburner:emailServiceId>cypal</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry gd:etag="W/&quot;CEcAQH88cCp7ImA9WxJVEE0.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-7989849880617545097</id><published>2009-06-26T13:10:00.000+05:30</published><updated>2009-06-26T13:10:41.178+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-26T13:10:41.178+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="RCP" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="Commands" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Keyboard accessibility thru Command Framework</title><content type="html">Keyboard shortcuts is usually much speedier than reaching out your mouse, moving it, pointing it to something and clicking. But there are some things which cannot be done that easily by keyboard shortcuts. For me, one of them is finding out a closed project and open it. Unfortunately, I've quite a large set of projects in my workspace and try to keep most them closed, when not used. In addition to that in the Package Explorer, I've the 'Closed Projects' filter on. So if I need to open a project, I've use the pull down menu, uncheck 'Closed Projects' navigate thru the working sets to find the right project and double click it. To enable keyboard access to this regular task, I decided to make use of &lt;a href="http://wiki.eclipse.org/Platform_Command_Framework"&gt;Commands Framework&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The solution is to add a &lt;a href="http://blog.eclipse-tips.com/2008/12/commands-part-3-parameters-for-commands.html"&gt;parameterized command&lt;/a&gt;, and in the values, I compute the projects which are closed. So when I press the awesome shortcut (Ctrl+3) it would display me the list of closed projects. With few keys, I can navigate to the project I want and open it. Lets see how to do it. First step is the command with the parameter:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;extension point="org.eclipse.ui.commands"&amp;gt;
   &amp;lt;command
            defaultHandler="com.eclipse_tips.handlers.OpenProjectHandler"
            id="com.eclipse-tips.openProject.command"
            name="Open Project"&amp;gt;
      &amp;lt;commandParameter
               id="com.eclipse-tips.openProject.projectNameParameter"
               name="Name"
               optional="false"
               values="com.eclipse_tips.handlers.ProjectNameParameterValues"&amp;gt;
      &amp;lt;/commandParameter&amp;gt;
   &amp;lt;/command&amp;gt;
&amp;lt;/extension&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
And the handler:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java;"&gt;public Object execute(ExecutionEvent event) throws ExecutionException {
 String projectName = event.getParameter("com.eclipse-tips.openProject.projectNameParameter");
 IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
 IProject project = root.getProject(projectName);
 try {
  project.open(null);
 } catch (CoreException e) {
  throw new ExecutionException("Error occured while open project", e);
 }
 return null;
}
&lt;/pre&gt;&lt;br /&gt;
For the parameter values, I look for closed projects and return them:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java;"&gt;public Map&amp;lt;String, String&amp;gt; getParameterValues() {

 IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
 IProject[] projects = root.getProjects();
 Map&amp;lt;String, String&amp;gt; paramValues = new HashMap&amp;lt;String, String&amp;gt;();
 for (IProject project : projects) {
  if (project.exists() &amp;amp;&amp;amp; !project.isOpen()) {
   paramValues.put(project.getName(), project.getName());
  }

 }
 return paramValues;
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
So finally, When I press Ctrl+3 and type OPN, I get the list:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_hsp14iFkRLs/SkR2yIhfxzI/AAAAAAAAECA/D0u-kCTiq-Q/s1600-h/KeyboardCommands.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_hsp14iFkRLs/SkR2yIhfxzI/AAAAAAAAECA/D0u-kCTiq-Q/s400/KeyboardCommands.png" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;
This idea can be extended to provide keyboard accessibility to many functionalities. Say in an RCP mail application, you can add a command like 'Go To Mail' with parameter as the Subject/Sender:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_hsp14iFkRLs/SkR539zueKI/AAAAAAAAECI/REDeNO2mVnQ/s1600-h/KeyboardCommands1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_hsp14iFkRLs/SkR539zueKI/AAAAAAAAECI/REDeNO2mVnQ/s400/KeyboardCommands1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Hmmm, if only the 'Built On Eclipse' mail app that I *have* to use, knows the existence of threads other than the UI thread :-(&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-7989849880617545097?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/jzeEc1ip9Z4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/7989849880617545097/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=7989849880617545097&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/7989849880617545097?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/7989849880617545097?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/jzeEc1ip9Z4/keyboard-accessibility-thru-command.html" title="Keyboard accessibility thru Command Framework" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_hsp14iFkRLs/SkR2yIhfxzI/AAAAAAAAECA/D0u-kCTiq-Q/s72-c/KeyboardCommands.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/06/keyboard-accessibility-thru-command.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUMEQ3o7eyp7ImA9WxJXEEw.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-2386978422358746936</id><published>2009-06-03T13:51:00.003+05:30</published><updated>2009-06-03T13:53:22.403+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T13:53:22.403+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jface" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="guidelines" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Subtask in ProgressMonitors</title><content type="html">Here is a trivial tip. When inspecting a bug, I found a interesting thing on Progress Monitors. We know monitor.worked() increments the progress bar, but how do we change the text to update the current subtask? The initial text is set by the beginTask() method and it should be called only once. I digged into the IProgressMonitor and found the subtask() method:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java;"&gt;IRunnableWithProgress operation = new IRunnableWithProgress() {

 public void run(IProgressMonitor monitor) {

  monitor.beginTask("Main task running ...", 5);
  for (int i = 0; i &amp;lt; 5; i++) {
   monitor.subTask("Subtask # " + i + " running.");
   runSubTask(new SubProgressMonitor(monitor, 1), i);
  }
 }

};
&lt;/pre&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_hsp14iFkRLs/SiYv6gq_xPI/AAAAAAAADpY/vDP9JM1hYzU/s1600-h/ProgressWithSubTask1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_hsp14iFkRLs/SiYv6gq_xPI/AAAAAAAADpY/vDP9JM1hYzU/s400/ProgressWithSubTask1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Now the question is what happens when the runSubTask() method sets another subTask on the SubProgressMonitor?&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java;"&gt;private void runSubTask(IProgressMonitor monitor, int subTaskId) {

 monitor.beginTask("Sub task running", 10);
  for (int i = 0; i &amp;lt; 10; i++) {
   monitor.subTask("Inside subtask, " + i + " out of 10");
   // do something here ...
   monitor.worked(1);
   if (monitor.isCanceled())
    throw new OperationCanceledException();
 }
  monitor.done();
 }

}
&lt;/pre&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_hsp14iFkRLs/SiYwUsf-8SI/AAAAAAAADpg/9hmZYQi9ufY/s1600-h/ProgressWithSubTask2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_hsp14iFkRLs/SiYwUsf-8SI/AAAAAAAADpg/9hmZYQi9ufY/s400/ProgressWithSubTask2.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Basically the SubProgressMonitor's subTask() overwrites the parent's subTask(). Thats the default behaviour. You can customize it with the style bits provided in the SubProgressMonitor:&lt;br /&gt;
&lt;br /&gt;
If you want to append the SubProgressMonitor's subTask info, use the style PREPEND_MAIN_LABEL_TO_SUBTASK:&lt;br /&gt;
&lt;pre class="brush: java;"&gt;new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK), i);&lt;/pre&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_hsp14iFkRLs/SiYxQ54EfzI/AAAAAAAADpo/TsxDbbnNb5M/s1600-h/ProgressWithSubTask3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_hsp14iFkRLs/SiYxQ54EfzI/AAAAAAAADpo/TsxDbbnNb5M/s400/ProgressWithSubTask3.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Else if you want to ignore it altogher then use the SUPPRESS_SUBTASK_LABEL style:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java;"&gt;new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL), i);&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-2386978422358746936?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/T2meNyoULUU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/2386978422358746936/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=2386978422358746936&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/2386978422358746936?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/2386978422358746936?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/T2meNyoULUU/subtask-in-progressmonitors.html" title="Subtask in ProgressMonitors" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_hsp14iFkRLs/SiYv6gq_xPI/AAAAAAAADpY/vDP9JM1hYzU/s72-c/ProgressWithSubTask1.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/06/subtask-in-progressmonitors.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE4CRn85cSp7ImA9WxJQFUQ.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-838666877859722878</id><published>2009-05-29T15:10:00.004+05:30</published><updated>2009-05-29T17:06:07.129+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-29T17:06:07.129+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="RCP" /><category scheme="http://www.blogger.com/atom/ns#" term="Mac" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="guidelines" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><category scheme="http://www.blogger.com/atom/ns#" term="swt" /><title>Search menu in Mac - the implementation</title><content type="html">In the previous entry I mentioned about the &lt;a href="http://blog.eclipse-tips.com/2009/05/search-menu-in-mac.html" linkindex="207"&gt;Search Menu in Mac&lt;/a&gt;. Lets see what that search menu contains:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_hsp14iFkRLs/Sh-mTAhPuqI/AAAAAAAADoA/bFIxmmj8I2k/s1600-h/Tweetie_Mac_Search_Menu1.png" imageanchor="1" linkindex="208" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;br /&gt;
&lt;/a&gt;&amp;nbsp;&lt;a href="http://3.bp.blogspot.com/_hsp14iFkRLs/Sh-s6fxoaXI/AAAAAAAADoI/Q0n2b1lKuec/s1600-h/Tweetie_Mac_Search_Menu1.png" imageanchor="1" linkindex="209" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_hsp14iFkRLs/Sh-s6fxoaXI/AAAAAAAADoI/Q0n2b1lKuec/s400/Tweetie_Mac_Search_Menu1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
The first item is the "Clear" menu. It clears the recent search history. Next comes the recent searches. If you want to call it as "Search History", you can do it in the title field menu item. The title field &amp;amp; clear menu item are visible only when there is at least one entry in the recent searches. The menu can also have custom items, where you can include you own action items. Lets see how to add all these in an SWT app:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;Text searchText = new Text(shell, SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH);
  SearchFieldSupport searchFieldSupport = new SearchFieldSupport(searchText);
  Menu menu = new Menu(searchText);
  
  MenuItem customItem = new MenuItem(menu, SWT.NONE);
  customItem.setText("Custom Action");
  customItem.addSelectionListener(new SelectionAdapter() {
   public void widgetSelected(SelectionEvent e) {
    MessageDialog.openInformation(shell, "Search Field", "Custom action is done here");
   };
  });
  
  MenuItem sep1 = new MenuItem(menu, SWT.SEPARATOR);
  
  MenuItem recentMenuItem = new MenuItem(menu, SWT.NONE);
  recentMenuItem.setText("Search History");
  SearchFieldSupport.setRecentSearchesTitle(recentMenuItem);
  
  // for the search history
  MenuItem recentsMenuItem = new MenuItem(menu, SWT.PUSH);
  SearchFieldSupport.setRecentSearches(recentsMenuItem);
  
  MenuItem sep2 = new MenuItem(menu, SWT.SEPARATOR);

  MenuItem clearMenuItem = new MenuItem(menu, SWT.PUSH);
  clearMenuItem.setText("Clear History");
  SearchFieldSupport.setClearRecents(clearMenuItem);

  searchFieldSupport.setMenu(menu);
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Here is the result:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_hsp14iFkRLs/Sh-s8Km0cBI/AAAAAAAADoQ/jyU6iBgQK7Q/s1600-h/Mac_SWT_Search.png" imageanchor="1" linkindex="210" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_hsp14iFkRLs/Sh-s8Km0cBI/AAAAAAAADoQ/jyU6iBgQK7Q/s320/Mac_SWT_Search.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Its almost perfect except that when we clear the search history and see the menu, it looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_hsp14iFkRLs/Sh-s_dGEh7I/AAAAAAAADoY/WyYEhsjoduA/s1600-h/Search_Separator.png" imageanchor="1" linkindex="211" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_hsp14iFkRLs/Sh-s_dGEh7I/AAAAAAAADoY/WyYEhsjoduA/s320/Search_Separator.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Its because the separators are still shown even when there is no recent menu items. The hack is to set the separator as a resentSearches menu item:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;MenuItem sep2 = new MenuItem(menu, SWT.SEPARATOR);
  SearchFieldSupport.setRecentSearchesTitle(sep2);
&lt;/pre&gt;&lt;br /&gt;
The Search Field also supports a custom menu item which tells that there is no recent search items. This menu item is automatically hidden when there search history is not empty. We can add that also before the second separator:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;MenuItem recentsMenuItem = new MenuItem(menu, SWT.PUSH);
  SearchFieldSupport.setRecentSearches(recentsMenuItem);
  
  MenuItem noRecentMenuItem = new MenuItem(menu, SWT.NONE);
  noRecentMenuItem.setText("No Search History");
  SearchFieldSupport.setNoRecentSearches(noRecentMenuItem);
  
  MenuItem sep2 = new MenuItem(menu, SWT.SEPARATOR);
  SearchFieldSupport.setRecentSearchesTitle(sep2);
&lt;/pre&gt;&lt;br /&gt;
Now we are all set:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_hsp14iFkRLs/Sh-tBBrSgUI/AAAAAAAADog/RASrf0OvunY/s1600-h/Search_Empty.png" imageanchor="1" linkindex="212" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_hsp14iFkRLs/Sh-tBBrSgUI/AAAAAAAADog/RASrf0OvunY/s320/Search_Empty.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
The last missing piece of the puzzle, the SearchFieldSupport class:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java; collapse: true"&gt;package org.eclipse.ui.cocoa.ext;

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.cocoa.ext.internal.NSSearchField;

/**
 * 
 * @author Prakash G.R.
 * 
 */
public class SearchFieldSupport implements KeyListener, DisposeListener {
 
 private final NSSearchField nsSearchField;
 private final Text text;

 public SearchFieldSupport(Text text) {
  this.text = text;
  text.addKeyListener(this);
  text.addDisposeListener(this);
  nsSearchField = new NSSearchField(text);
 }

 public Text getText() {
  return text;
 }

 public String[] getRecentSearchStrings() {
  return nsSearchField.getRecentSearches();
 }
 
 public void setRecentSearchStrings(String[] recentSearches) {
  nsSearchField.setRecentSearches(recentSearches);
 }

 public void setMenu(Menu menu) {
  nsSearchField.setMenu(menu);
 }

 public static void setNoRecentSearches(MenuItem menuItem) {
  NSSearchField.setTag(menuItem, NSSearchField.NSSearchFieldNoRecentsMenuItemTag);
 }

 public static void setClearRecents(MenuItem menuItem) {
  NSSearchField.setTag(menuItem, NSSearchField.NSSearchFieldClearRecentsMenuItemTag);
 }

 public static void setRecentSearchesTitle(MenuItem menuItem) {
  NSSearchField.setTag(menuItem, NSSearchField.NSSearchFieldRecentsTitleMenuItemTag);
 }

 public static void setRecentSearches(MenuItem menuItem) {
  NSSearchField.setTag(menuItem, NSSearchField.NSSearchFieldRecentsMenuItemTag);
 }

 public void widgetDisposed(DisposeEvent e) {
  text.removeKeyListener(this);
 }

 public void keyPressed(KeyEvent e) {
  // do nothing
 }

 public void keyReleased(KeyEvent e) {
  if (e.keyCode == '\r') {
   String[] recentSearchStrings = getRecentSearchStrings();
   int oldSize = recentSearchStrings.length;
   String[] newSearchStrings = new String[recentSearchStrings.length + 1];
   System.arraycopy(recentSearchStrings, 0, newSearchStrings, 0, recentSearchStrings.length);
   newSearchStrings[oldSize] = text.getText();
   setRecentSearchStrings(newSearchStrings);
   text.setSelection(0, text.getText().length());
  }
 }

}
&lt;/pre&gt;&lt;br /&gt;
and the custom NSSearchField class:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java; collapse: true"&gt;package org.eclipse.ui.cocoa.ext.internal;

import java.lang.reflect.Field;

import org.eclipse.swt.internal.cocoa.NSArray;
import org.eclipse.swt.internal.cocoa.NSMenu;
import org.eclipse.swt.internal.cocoa.NSMenuItem;
import org.eclipse.swt.internal.cocoa.NSMutableArray;
import org.eclipse.swt.internal.cocoa.NSString;
import org.eclipse.swt.internal.cocoa.OS;
import org.eclipse.swt.internal.cocoa.id;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Text;

/**
 * @author Prakash G.R.
 * 
 */
@SuppressWarnings("restriction")
public class NSSearchField extends org.eclipse.swt.internal.cocoa.NSSearchField {

 public static final int NSSearchFieldRecentsTitleMenuItemTag = 1000;
 public static final int NSSearchFieldRecentsMenuItemTag = 1001;
 public static final int NSSearchFieldClearRecentsMenuItemTag = 1002;
 public static final int NSSearchFieldNoRecentsMenuItemTag = 1003;

 private static final int /* long */sel_setSearchMenuTemplate = OS.sel_registerName("setSearchMenuTemplate:");
 private static final int /* long */sel_setTag = OS.sel_registerName("setTag:");
 private static final int /* long */sel_setRecentSearches = OS.sel_registerName("setRecentSearches:");

 public NSSearchField(id id) {
  super(id);
 }

 public NSSearchField(Text text) {
  super(text.view);
 }

 public void setMenu(Menu menu) {
  try {
   Field field = Menu.class.getDeclaredField("nsMenu");
   field.setAccessible(true);

   NSMenu nsMenu = (NSMenu) field.get(menu);

   OS.objc_msgSend(this.id, sel_setSearchMenuTemplate, nsMenu.id);
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 public static boolean setTag(MenuItem menuItem, int tag) {
  try {
   Field field = MenuItem.class.getDeclaredField("nsItem");
   field.setAccessible(true);

   NSMenuItem nsMenuItem = (NSMenuItem) field.get(menuItem);
   OS.objc_msgSend(nsMenuItem.id, sel_setTag, tag);

   // no action for titles
   if (tag == NSSearchFieldRecentsTitleMenuItemTag || tag == NSSearchFieldNoRecentsMenuItemTag) {
    nsMenuItem.setAction(0);
   }
   return true;
  } catch (Exception e) {
   return false;
  }
 }

 public String[] getRecentSearches() {
  NSArray recentSearches = super.recentSearches();
  String[] recentSearchStrings = new String[recentSearches.count()];
  for (int i = 0; i &amp;lt; recentSearchStrings.length; i++) {
   recentSearchStrings[i] = (new NSString(recentSearches.objectAtIndex(i))).getString();
  }
  return recentSearchStrings;
 }

 public void setRecentSearches(String[] recentSearchStrings) {
  
  NSMutableArray recentSearches = NSMutableArray.arrayWithCapacity(recentSearchStrings.length);
  for (String aRecentSearcb : recentSearchStrings) {
   NSString nsString = NSString.stringWith(aRecentSearcb);
   recentSearches.addObject(nsString);
  }
  OS.objc_msgSend(this.id, sel_setRecentSearches, recentSearches.id);
  
 }
}
&lt;/pre&gt;&lt;br /&gt;
Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-838666877859722878?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/_1WqCtWp3MY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/838666877859722878/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=838666877859722878&amp;isPopup=true" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/838666877859722878?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/838666877859722878?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/_1WqCtWp3MY/search-menu-in-mac-implementation.html" title="Search menu in Mac - the implementation" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_hsp14iFkRLs/Sh-s6fxoaXI/AAAAAAAADoI/Q0n2b1lKuec/s72-c/Tweetie_Mac_Search_Menu1.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/05/search-menu-in-mac-implementation.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkUESH4zeyp7ImA9WxJQFUQ.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-5683512156685396104</id><published>2009-05-26T17:24:00.001+05:30</published><updated>2009-05-29T15:13:29.083+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-29T15:13:29.083+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Mac" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><category scheme="http://www.blogger.com/atom/ns#" term="swt" /><title>Search menu in Mac</title><content type="html">In Mac applications, the little search box can have a pull down menu (similar to a View's pull down menu). It can have recent searches, user contributed menu entries, a menu item for clearing the recent searches etc. Here is the search box of Tweetie (the twitter app that I use):&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_hsp14iFkRLs/ShvX5ccsbkI/AAAAAAAADns/vuhs0Z4n25o/s1600-h/Tweetie_Mac_Search_Menu.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_hsp14iFkRLs/ShvX5ccsbkI/AAAAAAAADns/vuhs0Z4n25o/s400/Tweetie_Mac_Search_Menu.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Eclipse by default offers the SWT.SEARCH style which will bring this search box instead of the default text box. But there is no option to add the menu. For today's SWT-Cocoa hack, I tried to enhance the Search box with the search menu and here is the result:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_hsp14iFkRLs/ShvX6NZwCPI/AAAAAAAADn0/o-4tfxj8BNw/s1600-h/SWT_Mac_Search.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_hsp14iFkRLs/ShvX6NZwCPI/AAAAAAAADn0/o-4tfxj8BNw/s400/SWT_Mac_Search.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
The code is so ugly that I can't post it in public yet. Will post it with refinements tomorrow.&lt;br /&gt;
&lt;br /&gt;
Update: The implementation is &lt;a href="http://blog.eclipse-tips.com/2009/05/search-menu-in-mac-implementation.html"&gt;available here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-5683512156685396104?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/4NrSzbxY5QQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/5683512156685396104/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=5683512156685396104&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/5683512156685396104?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/5683512156685396104?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/4NrSzbxY5QQ/search-menu-in-mac.html" title="Search menu in Mac" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_hsp14iFkRLs/ShvX5ccsbkI/AAAAAAAADns/vuhs0Z4n25o/s72-c/Tweetie_Mac_Search_Menu.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/05/search-menu-in-mac.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04ESXs8fyp7ImA9WxJQEE8.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-4762226622898038483</id><published>2009-05-23T01:17:00.002+05:30</published><updated>2009-05-23T01:21:48.577+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-23T01:21:48.577+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jface" /><category scheme="http://www.blogger.com/atom/ns#" term="Mac" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><category scheme="http://www.blogger.com/atom/ns#" term="swt" /><title>Badge label on Mac Dock icon</title><content type="html">I'm passionate on both Mac and Eclipse. Although Eclipse runs well on a Mac, its not a marriage made in heaven. Its really hard to get the complete Mac experience with a portable UI tool kit. If you think of features like &lt;a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=246165" linkindex="68"&gt;this one&lt;/a&gt;, its actually endless list. One such thing is the badge on the Dock Icon. In Mac, the Dock icon can have a badge - like the number of unread mails in your inbox. How much effort does it takes to add a badge to our RCP mail sample? Not much. Since SWT doesn't have a NSDockTile, we need a NSDockTile class with two methods, one to get the DockTile for the application and the other to set the badge on it (there is an easier way by using the Mac Generator tool, but that will be a patch to SWT itself, which I wanted to avoid):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java; collapse: true"&gt;/**
 * @author Prakash G.R. (grprakash@gmail.com) 
 * 
 */
@SuppressWarnings("restriction")
public class NSDockTile extends NSResponder {

 private static final int sel_setBadgeLabel_ = OS.sel_registerName("setBadgeLabel:");
 private static final int sel_dockTile_ = OS.sel_registerName("dockTile");
 private static final int sel_display_ = OS.sel_registerName("display");

 public NSDockTile(int id) {
  super(id);
 }

 public static NSDockTile getApplicationDockTile() {
  NSApplication sharedApplication = NSApplication.sharedApplication();
  int id = OS.objc_msgSend(sharedApplication.id, sel_dockTile_);
  NSDockTile dockTile = new NSDockTile(id);
  return dockTile;
 }

 public void setBadgeLabel(String badgeLabel) {
   NSString nsBadgeLabel = NSString.stringWith(badgeLabel);
   OS.objc_msgSend(this.id, sel_setBadgeLabel_, nsBadgeLabel.id);
   OS.objc_msgSend(this.id, sel_display_);
 }
}
&lt;/pre&gt;&lt;br /&gt;
And a two line code to set the badge:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java;"&gt;NSDockTile nsDockTile = NSDockTile.getApplicationDockTile();
nsDockTile.setBadgeLabel("6");
&lt;/pre&gt;&lt;br /&gt;
There you go in the dock icon and in the minimized window:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_hsp14iFkRLs/Shb96m7JMzI/AAAAAAAADnE/h7fEqJoOjTo/s1600-h/RCPMailDock.png" imageanchor="1" linkindex="69" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_hsp14iFkRLs/Shb96m7JMzI/AAAAAAAADnE/h7fEqJoOjTo/s400/RCPMailDock.png" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_hsp14iFkRLs/Shb97sot5fI/AAAAAAAADnM/h14qB8Ocvg8/s1600-h/RCPMailWindow.png" imageanchor="1" linkindex="70" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_hsp14iFkRLs/Shb97sot5fI/AAAAAAAADnM/h14qB8Ocvg8/s400/RCPMailWindow.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
In case you were wondering how the GMail icon for the application is set, here is the code for that:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java;"&gt;ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(iconUrl);
Image image = imageDescriptor.createImage();
NSApplication app = NSApplication.sharedApplication();
app.setApplicationIconImage(image.handle);
&lt;/pre&gt;&lt;br /&gt;
Oh, BTW, I've just started learning Objective C, Cocoa &amp;amp; related things. So stay tuned, you will see more Mac related posts here. Also what is your favourite Mac feature that you are missing in Eclipse?&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-4762226622898038483?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/K3GxaV-btwU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/4762226622898038483/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=4762226622898038483&amp;isPopup=true" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/4762226622898038483?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/4762226622898038483?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/K3GxaV-btwU/badge-label-on-mac-dock-icon.html" title="Badge label on Mac Dock icon" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_hsp14iFkRLs/Shb96m7JMzI/AAAAAAAADnE/h7fEqJoOjTo/s72-c/RCPMailDock.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/05/badge-label-on-mac-dock-icon.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkICRnk5eip7ImA9WxJRFEw.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-9040372474361125777</id><published>2009-05-16T00:37:00.001+05:30</published><updated>2009-05-16T00:39:27.722+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-16T00:39:27.722+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="RCP" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="3.5" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Creating a custom Property View</title><content type="html">In an RCP application, you might need a Properties View, which shows only the properties of a specific view or a set of views. But the generic Properties View will show from all the other views that support it. Armed up with the knowledge of &lt;a href="http://blog.eclipse-tips.com/2009/05/how-to-create-pagebookview.html"&gt;how a PageBookView works&lt;/a&gt;, lets see how to hack the Properties View to listen only to a specific view.&lt;br /&gt;
&lt;br /&gt;
The isImportant() method is the one which decides whether to create an IPage for the specific IWorkbenchPart or not. The idea is to override that method and return false for all the workbenchPart that we are not interested in. Lets create the view first:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;view
            class="com.eclipse_tips.views.CustomPropertiesView"
            icon="icons/sample.gif"
            id="com.eclipse-tips.views.customePropertiesView"
            name="My Properties View"&amp;gt;
&amp;lt;/view&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
The CustomPropertiesView should extend PropertySheet and override the isImportant():&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;public class CustomPropertiesView extends PropertySheet {

 @Override
 protected boolean isImportant(IWorkbenchPart part) {
  if (part.getSite().getId().equals(IPageLayout.ID_PROJECT_EXPLORER))
   return true;
  return false;
 }
}&lt;/pre&gt;&lt;br /&gt;
In this case, I'm making the view only to respond to Project Explorer and ignore other views. Here is the CustomPropertyView in action:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_hsp14iFkRLs/Sg28Nwe3QSI/AAAAAAAADko/DqnVd7obB1Y/s1600-h/CustomPropertiesProjectExplore.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_hsp14iFkRLs/Sg28Nwe3QSI/AAAAAAAADko/DqnVd7obB1Y/s320/CustomPropertiesProjectExplore.png" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&amp;nbsp;&lt;a href="http://4.bp.blogspot.com/_hsp14iFkRLs/Sg28VbUXjHI/AAAAAAAADkw/J6Bv2_uIkwU/s1600-h/CustomPropertiesNavigator.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_hsp14iFkRLs/Sg28VbUXjHI/AAAAAAAADkw/J6Bv2_uIkwU/s320/CustomPropertiesNavigator.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
If you are on 3.5 or above, you would see the Pin Action in your Custom Properties View. If you don't want the Pin action in your properties view, there is no way to prevent the PropertySheet to adding the action. The action is added to both tool bar and menu in the createControl() method. Only way to get rid of the action is to remove it after the PropertySheet adds it:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;@Override
 public void createPartControl(Composite parent) {
  
  super.createPartControl(parent);
  IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
  IContributionItem[] items = menuManager.getItems();
  for (IContributionItem iContributionItem : items) {
   if(iContributionItem instanceof ActionContributionItem) {
    if(((ActionContributionItem) iContributionItem).getAction() instanceof PinPropertySheetAction) {
     menuManager.remove(iContributionItem);
     break;
    }
   }
  }

  IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
  items = toolBarManager.getItems();
  for (IContributionItem iContributionItem : items) {
   if(iContributionItem instanceof ActionContributionItem) {
    if(((ActionContributionItem) iContributionItem).getAction() instanceof PinPropertySheetAction)) {
     toolBarManager.remove(iContributionItem);
     break;
    }
   }
  }
 }
&lt;/pre&gt;&lt;br /&gt;
And don't forget to override the isPinned() method:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;@Override
 public boolean isPinned() {
  return false;
 }
&lt;/pre&gt;&lt;br /&gt;
There you go:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_hsp14iFkRLs/Sg28gW12WnI/AAAAAAAADk4/Y_bxy5lHIvI/s1600-h/PinActionRemoved.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_hsp14iFkRLs/Sg28gW12WnI/AAAAAAAADk4/Y_bxy5lHIvI/s320/PinActionRemoved.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-9040372474361125777?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/dWaTq8NDkaM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/9040372474361125777/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=9040372474361125777&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/9040372474361125777?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/9040372474361125777?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/dWaTq8NDkaM/creating-custom-property-view.html" title="Creating a custom Property View" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_hsp14iFkRLs/Sg28Nwe3QSI/AAAAAAAADko/DqnVd7obB1Y/s72-c/CustomPropertiesProjectExplore.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/05/creating-custom-property-view.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak4GRnk5fyp7ImA9WxJRE08.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-5571902850791056235</id><published>2009-05-14T15:22:00.166+05:30</published><updated>2009-05-15T00:52:07.727+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-15T00:52:07.727+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>How to create a PageBookView</title><content type="html">Think of Properties View. It displays the properties of the selected element in the active part. Whenever the selection changes or the active part changes, it tracks them and displays the properties (unless you used the &lt;a href="http://blog.eclipse-tips.com/2008/10/multi-instance-property-view-first-look.html" linkindex="218"&gt;'Pin to selection' feature available from 3.5&lt;/a&gt;) There are many views like this, which update themselves when the active part changes. Outline view, Templates view, GEF Palette view, etc. If you want to create such view, its not a tough job - Eclipse provides you all the basic features in the class PageBookView. All you need is to extend this class and fill the void by implementing the abstract methods. Thats what we are going to see in this tip. The use case is to create a ActivePartTrackerView, which will display the name of the current active workbench part.&lt;br /&gt;
&lt;br /&gt;
First lets create a View:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;extension
         point="org.eclipse.ui.views"&amp;gt;
      &amp;lt;view
            class="com.eclipse_tips.views.SelectionView"
            icon="icons/sample.gif"
            id="com.eclipse-tips.views.pagebookview"
            name="Selection Provider View"&amp;gt;
      &amp;lt;/view&amp;gt;
   &amp;lt;/extension&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The contents of the PageBookView is arranged in pages (IPage). There can be multiple pages, each of them is associated with a corresponding IWorkbenchPart. When the associated part becomes active, the PageBookView automatically switches to the respective page. When a PageBookView is created, it asks for a bootstrap part by calling getBootstrapPart() method. When no bootstrap part is found, it uses a default page. That default page is also shown when there are no pages for the currently active part. Lets start by creating this default page. To do that we need to implement the createDefaultPage() method, which returns the default page. Lets use the MessagePage which simply displays a string.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;@Override
 protected IPage createDefaultPage(PageBook book) {
  MessagePage messagePage = new MessagePage();
  initPage(messagePage);
  messagePage.setMessage("No interested in this part");
  messagePage.createControl(book);
  return messagePage;
 }&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_hsp14iFkRLs/Sgxt208UPZI/AAAAAAAADkE/SR-LI-i_N3Y/s1600-h/PageBookView-defaultPage.png" imageanchor="1" linkindex="219" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_hsp14iFkRLs/Sgxt208UPZI/AAAAAAAADkE/SR-LI-i_N3Y/s320/PageBookView-defaultPage.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Now our SelectionView is up and running, except that its showing a static content not creating any IPages for the active parts. Before we create an IPage, how to determine whether to create an IPage for a given IWorkbenchPart or ignore it? Its by the isImportant() method. Lets say, we want to respond only to the parts that are contributed by the Platform UI.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;@Override
 protected boolean isImportant(IWorkbenchPart part) {
  return part.getSite().getPluginId().startsWith("org.eclipse.ui");
 }
&lt;/pre&gt;&lt;br /&gt;
So if a Package Explorer(contributed by JDT) or the Manifest Editor(contributed by PDE) is the active part, then our SelectionView will not create any page and use the default page. If its a TextEditor or Project Explorer, then it will create the page and show it.&lt;br /&gt;
&lt;br /&gt;
To create an IPage for a given part, we need to override the doCreatePage() method. Unlike the createDefaultPage() method this doesn't return a IPage, rather a PageRec. Why? This Page Record stores additional information - the associated workbench part and action bars:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;@Override
 protected PageRec doCreatePage(IWorkbenchPart part) {
  MessagePage messagePage = new MessagePage();
  initPage(messagePage);
  messagePage.setMessage("Page for "+part.getTitle());
  messagePage.createControl(getPageBook());
  return new PageRec(part, messagePage);
 }
&lt;/pre&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_hsp14iFkRLs/SgxuQqhOp7I/AAAAAAAADkM/JtgxVLQy4WI/s1600-h/PageBookView+ProjectExplorer.png" imageanchor="1" linkindex="220" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_hsp14iFkRLs/SgxuQqhOp7I/AAAAAAAADkM/JtgxVLQy4WI/s320/PageBookView+ProjectExplorer.png" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&amp;nbsp;&lt;a href="http://2.bp.blogspot.com/_hsp14iFkRLs/Sgxuh324AYI/AAAAAAAADkc/j5LUqVwMlPM/s1600-h/PageBookView+TextEditor.png" imageanchor="1" linkindex="221" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_hsp14iFkRLs/Sgxuh324AYI/AAAAAAAADkc/j5LUqVwMlPM/s320/PageBookView+TextEditor.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
When you are switching between the TextEditor and the ProjectExplore view, the PageBookView will track and find the page for the active part and automatically show it. When the page is no longer needed (the associated part is closed), it would call the doDestroyPage(). This is where you would ideally remove any listeners and dispose of the resources.&lt;br /&gt;
&lt;br /&gt;
So the whole class goes here:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java; collapse: true"&gt;package com.eclipse_tips.views;

import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.IPage;
import org.eclipse.ui.part.MessagePage;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.PageBookView;

/**
 * @author Prakash G.R.
 *
 */
public class ActivePartTrackerView extends PageBookView {

 @Override
 protected IPage createDefaultPage(PageBook book) {
  MessagePage messagePage = new MessagePage();
  initPage(messagePage);
  messagePage.setMessage("No interested in this part");
  messagePage.createControl(book);
  return messagePage;
 }

 @Override
 protected PageRec doCreatePage(IWorkbenchPart part) {
  MessagePage messagePage = new MessagePage();
  initPage(messagePage);
  messagePage.setMessage("Page for "+part.getTitle());
  messagePage.createControl(getPageBook());
  return new PageRec(part, messagePage);
 }

 @Override
 protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
  pageRecord.page.dispose();
 }

 @Override
 protected IWorkbenchPart getBootstrapPart() {
  IWorkbenchPage page = getSite().getPage();
  if(page != null) {
   // check whether the active part is important to us
   IWorkbenchPart activePart = page.getActivePart();
   return isImportant(activePart)?activePart:null;
  }
  return null;
 }

 @Override
 protected boolean isImportant(IWorkbenchPart part) {
  return part.getSite().getPluginId().startsWith("org.eclipse.ui");
 }

}
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-5571902850791056235?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/dXsIBkgNz3w" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/5571902850791056235/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=5571902850791056235&amp;isPopup=true" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/5571902850791056235?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/5571902850791056235?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/dXsIBkgNz3w/how-to-create-pagebookview.html" title="How to create a PageBookView" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_hsp14iFkRLs/Sgxt208UPZI/AAAAAAAADkE/SR-LI-i_N3Y/s72-c/PageBookView-defaultPage.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/05/how-to-create-pagebookview.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEEHQH4-fyp7ImA9WxJREU8.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-3867721587101245330</id><published>2009-05-12T16:29:00.002+05:30</published><updated>2009-05-12T16:40:31.057+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-12T16:40:31.057+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="wizards" /><category scheme="http://www.blogger.com/atom/ns#" term="dialogs" /><category scheme="http://www.blogger.com/atom/ns#" term="Mac" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="guidelines" /><category scheme="http://www.blogger.com/atom/ns#" term="3.5" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><category scheme="http://www.blogger.com/atom/ns#" term="swt" /><title>Sheet support in SWT</title><content type="html">For those who have downloaded 3.5 M7 would have seen Sheets support has been added to SWT and Platform UI has used the API wherever applicable. For those who are wondering what a Sheet means, its an eye-candy in Mac. Here is a sample of a MessageDialog shown with and without Sheet style:&lt;br /&gt;
&lt;br /&gt;
&lt;object height="395" width="714"&gt; &lt;param name="movie" value="http://content.screencast.com/users/grprakash/folders/Jing/media/42a0726e-f51c-44d3-9237-95624768131d/jingswfplayer.swf"&gt;&lt;/param&gt;&lt;param name="quality" value="high"&gt;&lt;/param&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;/param&gt;&lt;param name="flashVars" value="thumb=http://content.screencast.com/users/grprakash/folders/Jing/media/42a0726e-f51c-44d3-9237-95624768131d/FirstFrame.jpg&amp;containerwidth=714&amp;containerheight=395&amp;loaderstyle=jing&amp;content=http://content.screencast.com/users/grprakash/folders/Jing/media/42a0726e-f51c-44d3-9237-95624768131d/00000003.swf"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="scale" value="showall"&gt;&lt;/param&gt;&lt;param name="allowScriptAccess" value="always"&gt;&lt;/param&gt;&lt;param name="base" value="http://content.screencast.com/users/grprakash/folders/Jing/media/42a0726e-f51c-44d3-9237-95624768131d/"&gt;&lt;/param&gt;&lt;embed src="http://content.screencast.com/users/grprakash/folders/Jing/media/42a0726e-f51c-44d3-9237-95624768131d/jingswfplayer.swf" quality="high" bgcolor="#FFFFFF" width="714" height="395" type="application/x-shockwave-flash" allowScriptAccess="always" flashVars="thumb=http://content.screencast.com/users/grprakash/folders/Jing/media/42a0726e-f51c-44d3-9237-95624768131d/FirstFrame.jpg&amp;containerwidth=714&amp;containerheight=395&amp;loaderstyle=jing&amp;content=http://content.screencast.com/users/grprakash/folders/Jing/media/42a0726e-f51c-44d3-9237-95624768131d/00000003.swf" allowFullScreen="true" base="http://content.screencast.com/users/grprakash/folders/Jing/media/42a0726e-f51c-44d3-9237-95624768131d/" scale="showall"&gt;&lt;/embed&gt; &lt;/object&gt;&lt;br /&gt;
&lt;br /&gt;
(in case you didn't notice the obvious, I'm back on a Mac :-P)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;So what is a Sheet?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
A Sheet is essentially a Dialog, which is tied to a parent window. It acts as a Modal Dialog, so the user cannot perform any operations on a window until the Dialog is dismissed. (He is free to work on other windows) The dialog is&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;always attached with the window until dismissed&lt;/li&gt;
&lt;li&gt;placed in the center of the window&lt;/li&gt;
&lt;li&gt;moves along when the window is moved&lt;/li&gt;
&lt;/ul&gt;&lt;b&gt; To Sheet or not to Sheet?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Use Sheets when the interaction is very short like the question "Is Eclipse a cool product?&amp;nbsp; &lt;yes&gt; &lt;no&gt;". Opening a 15 step Wizard to choose your life partner is not right place to use Sheet.&lt;/no&gt;&lt;/yes&gt;&lt;/li&gt;
&lt;li&gt;&lt;yes&gt;&lt;no&gt;Do not use Sheets where the user might still need to interact with the Window (like copy something from window and paste it in the Sheet). Since Sheets are Window Modal, it doesn't allow the user to interact with the associated Window &lt;br /&gt;
&lt;/no&gt;&lt;/yes&gt;&lt;/li&gt;
&lt;li&gt;Sheets are not Application Modal. So if you want a dialog to be Application Modal, don' use Sheets&lt;/li&gt;
&lt;li&gt;Unlike normal Dialogs, Sheets do not have title. Avoid Sheets where title provides valuable information.&lt;/li&gt;
&lt;li&gt; Do not use nested Sheets (says Apple's UI guidelines)&lt;/li&gt;
&lt;/ul&gt;&lt;b&gt;How do I use Sheet?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Simple. Set the SWT.Sheet style to the Shell of the dialog. In case you are using the MessageDialog, pass on the style bit as the last argument to the MessageDialog.open() method&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-3867721587101245330?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/HcKntuxxQKg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/3867721587101245330/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=3867721587101245330&amp;isPopup=true" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/3867721587101245330?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/3867721587101245330?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/HcKntuxxQKg/sheet-support-in-swt.html" title="Sheet support in SWT" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/05/sheet-support-in-swt.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkAEQnozfSp7ImA9WxJREU8.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-3809991569368288397</id><published>2009-05-12T14:57:00.002+05:30</published><updated>2009-05-12T15:01:43.485+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-12T15:01:43.485+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="3.5" /><category scheme="http://www.blogger.com/atom/ns#" term="Commands" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Commands Part 7: Adding standard commands</title><content type="html">&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;In the earlier installments, we have seen adding our commands to menus and toolbars. But what about the standard menu items like Cut, Copy, Paste etc? We'll see how to add these to a context menu of the Sample View.&lt;br /&gt;
&lt;br /&gt;
Create the Sample View through the PDE's Extension Point Wizard. In the SampleView class, notice these lines:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3333ff; font-family: monospace;"&gt;private void hookContextMenu() {&lt;br /&gt;
&lt;br /&gt;
// rest of the code...&lt;br /&gt;
getSite().registerContextMenu(menuMgr, viewer);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
private void fillContextMenu(IMenuManager manager) {&lt;br /&gt;
&lt;br /&gt;
//rest of the code&lt;br /&gt;
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The first one registers this context menu, so that other plugins can contribute their commands to it. The second one adds a separator, which serves as a place holder/location where the contribution goes. So the SampleView is ready to accept the contributions, lets now contribute:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3333ff; font-family: monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;lt;extension&lt;br /&gt;
point="org.eclipse.ui.menus"&amp;gt;&lt;br /&gt;
&amp;lt;menuContribution&lt;br /&gt;
locationURI="popup:com.eclipse_tips.commands.part7.views.SampleView?after=additions"&amp;gt;&lt;br /&gt;
&amp;lt;command commandId="org.eclipse.ui.edit.cut"/&amp;gt;&lt;br /&gt;
&amp;lt;command commandId="org.eclipse.ui.edit.copy"/&amp;gt;&lt;br /&gt;
&amp;lt;command commandId="org.eclipse.ui.edit.paste"/&amp;gt;&lt;br /&gt;
&amp;lt;/menuContribution&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The id for the context menu, is by default the View's id, and we add our contribution after the separator. We can add any command, either the Platform defined or our own. Result:&lt;br /&gt;
&lt;br /&gt;
&lt;div align="center"&gt;&lt;img alt="" src="http://lh6.ggpht.com/_hsp14iFkRLs/SglA2CzYkuI/AAAAAAAADj8/lf20NWfFSvY/%5BUNSET%5D.png?imgmax=800" /&gt;&lt;/div&gt;&lt;br /&gt;
Now we have the menu items, images, shortcut keys everything in place (you ought to love the command framework :-)), except that the items are not enabled. Its because there is no handler for these commands for the given context. There are multiple ways to contribute the handler, since we are adding this to our view, lets use the activePartId variable:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3333ff; font-family: monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;lt;extension&lt;br /&gt;
point="org.eclipse.ui.handlers"&amp;gt;&lt;br /&gt;
&amp;lt;handler&lt;br /&gt;
class="com.eclipse_tips.commands.part7.handlers.CutHandler"&lt;br /&gt;
commandId="org.eclipse.ui.edit.cut"&amp;gt;&lt;br /&gt;
&amp;lt;activeWhen&amp;gt;&lt;br /&gt;
&amp;lt;with&lt;br /&gt;
variable="activePartId"&amp;gt;&lt;br /&gt;
&amp;lt;equals&lt;br /&gt;
value="com.eclipse_tips.commands.part7.views.SampleView"&amp;gt;&lt;br /&gt;
&amp;lt;/equals&amp;gt;&lt;br /&gt;
&amp;lt;/with&amp;gt;&lt;br /&gt;
&amp;lt;/activeWhen&amp;gt;&lt;br /&gt;
&amp;lt;/handler&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Other commands also have similar handlers. Now:&lt;br /&gt;
&lt;br /&gt;
&lt;div align="center"&gt;&lt;img alt="" src="http://lh4.ggpht.com/_hsp14iFkRLs/SglA3iQguMI/AAAAAAAADkA/qFQNOd4ytOI/%5BUNSET%5D.png?imgmax=800" /&gt;&lt;/div&gt;&lt;br /&gt;
There you go. In the similar way you can add all the standard commands to any menu/context menu you prefer. Just make sure that you have the handler for the commands with the right activeWhen &amp;amp; enabledWhen expression.&lt;br /&gt;
&lt;br /&gt;
The standard command Ids can be found in the IWorkbenchCommandConstants class (available in 3.5)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="zemanta-pixie"&gt;&lt;img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=eade1cdf-7873-8044-85b6-ccda04833046" /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-3809991569368288397?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/9e9sY9JShLY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/3809991569368288397/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=3809991569368288397&amp;isPopup=true" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/3809991569368288397?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/3809991569368288397?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/9e9sY9JShLY/commands-part-7-adding-standard.html" title="Commands Part 7: Adding standard commands" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/05/commands-part-7-adding-standard.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4DSHkzeSp7ImA9WxVaEEU.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-648909486460899790</id><published>2009-04-07T11:20:00.001+05:30</published><updated>2009-04-07T11:29:39.781+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-07T11:29:39.781+05:30</app:edited><title>[Off Topic] Thank you!</title><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;When Google Web Tookit was released to the public, I played with it and realized that an Eclipse plug-in could simply few things. Since I didn't find any, I started learning Eclipse plug-in development to create &lt;a href="http://code.google.com/p/cypal-studio" target="_blank"&gt;one&lt;/a&gt;. I've fallen in love with Eclipse and its been a wonderful journey since then. I created this blog to publish the tips I've learnt. Shifted myself from server-side-runtime to IDE. I was the first guy to offer Eclipse Plug-in development training in India. With few like-minded-friends, we even started &lt;a href="http://www.cypal.in" target="_blank"&gt;a company&lt;/a&gt; to do this training. The clientele includes several small companies and big companies as well. When IBM extended the Eclipse team in Asia, I was the first hire and moved to Eclipse Platform UI team. Last week my &lt;a href="http://dev.eclipse.org/mhonarc/lists/platform-ui-dev/msg04150.html" target="_blank"&gt;committer election&lt;/a&gt; successfully concluded and I've become a &lt;a href="http://dev.eclipse.org/mhonarc/lists/platform-ui-dev/msg04168.html" target="_blank"&gt;committer now&lt;/a&gt;! Its one of my happiest moments and this blog has been partially responsible for all of this. I've learnt so many &lt;a href="http://blog.eclipse-tips.com/2008/08/adding-color-and-font-preferences.html" target="_blank"&gt;things&lt;/a&gt; &lt;a href="http://blog.eclipse-tips.com/2008/07/selection-dialogs-in-eclipse.html" target="_blank"&gt;just&lt;/a&gt; &lt;a href="http://blog.eclipse-tips.com/2008/05/single-column-tableviewer-and.html" target="_blank"&gt;for&lt;/a&gt; &lt;a href="http://blog.eclipse-tips.com/2008/01/how-to-add-trayitem-in-eclipse-rcp.html" target="_blank"&gt;the&lt;/a&gt; &lt;a href="http://blog.eclipse-tips.com/2008/10/extending-filtereditemsselectiondialog.html" target="_blank"&gt;sake&lt;/a&gt;&amp;#160;&lt;a href="http://blog.eclipse-tips.com/2008/05/how-to-add-new-resource-to-working-sets.html" target="_blank"&gt;of&lt;/a&gt; &lt;a href="http://blog.eclipse-tips.com/2008/10/multi-instance-property-view-first-look.html" target="_blank"&gt;publishing&lt;/a&gt; &lt;a href="http://blog.eclipse-tips.com/2008/11/creating-custom-marker-view.html" target="_blank"&gt;tips&lt;/a&gt;.&lt;/p&gt;    &lt;p&gt;I really thank all of the readers of this blog. Your comments, emails, queries kept me going. Thanks!&lt;/p&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-648909486460899790?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/4ET4MSHqJBI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/648909486460899790/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=648909486460899790&amp;isPopup=true" title="10 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/648909486460899790?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/648909486460899790?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/4ET4MSHqJBI/off-topic-thank-you.html" title="[Off Topic] Thank you!" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">10</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/04/off-topic-thank-you.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cCQXgyeSp7ImA9WxVUE0g.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-7478856046198898152</id><published>2009-03-18T12:21:00.001+05:30</published><updated>2009-03-18T12:21:00.691+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-18T12:21:00.691+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Reviews" /><category scheme="http://www.blogger.com/atom/ns#" term="tools" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="search" /><category scheme="http://www.blogger.com/atom/ns#" term="Bugs" /><title>Searching Eclipse Bugzilla</title><content type="html">&lt;p&gt;There are many times you would want to search for a bug, say with a class name / stack trace. Using Bugzilla for this kind of searches is really painful. First the UI that it presents is not an elegant one (esp. if you are used to one single text box of Google) and then its very slow. It would have been much better if our Bugzilla allows Search Engines to index, but its still a &lt;a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=214067" target="_blank"&gt;work in progress&lt;/a&gt;. Meanwhile, &lt;a href="http://wagenknecht.org" target="_blank"&gt;Gunnar Wagenknecht&lt;/a&gt; has come up with &lt;a href="http://eclipsebugsearch.labs.ageto.net" target="_blank"&gt;an incubation project that allows searching the bugzilla&lt;/a&gt;. It just features one text box as opposed to the Bugzilla:&lt;/p&gt;  &lt;p&gt;&lt;img height="133" alt="Eclipse Bug Search" src="http://lh6.ggpht.com/_hsp14iFkRLs/ScCZlGaFxdI/AAAAAAAADf0/iMhX1CM4g6Y/image%5B12%5D.png?imgmax=800" width="721" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;and you can type in the Bug Number or key words (like 'About Dialog') or a class name and search. Results are usually within a second. Whats even more nice is the right side bar, which has a tag-clouds-style attributes of the bug:&lt;/p&gt;  &lt;p&gt;&lt;img height="484" alt="Eclipse Bug Search Tags" src="http://lh3.ggpht.com/_hsp14iFkRLs/ScCZr6J_R0I/AAAAAAAADf4/I9W-kDqPVuE/image%5B17%5D.png?imgmax=800" width="223" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;Click on the items and it will filter your results accordingly:&lt;/p&gt;  &lt;p&gt;&lt;img height="375" alt="Eclipse Bug Search Filters" src="http://lh4.ggpht.com/_hsp14iFkRLs/ScCZzkHJFjI/AAAAAAAADf8/6enIBnjwxtE/image%5B27%5D.png?imgmax=800" width="723" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;If you use Bugzilla frequently, this is very effective tool and I strongly recommend you to try it. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-7478856046198898152?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/dEhmsgcfmrs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/7478856046198898152/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=7478856046198898152&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/7478856046198898152?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/7478856046198898152?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/dEhmsgcfmrs/searching-eclipse-bugzilla.html" title="Searching Eclipse Bugzilla" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/03/searching-eclipse-bugzilla.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MCQnYzeSp7ImA9WxVUEE4.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-6790319963395593191</id><published>2009-03-14T17:10:00.003+05:30</published><updated>2009-03-14T17:21:03.881+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-14T17:21:03.881+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="PDE" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="3.5" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Do you need PDE custom attribute?</title><content type="html">&lt;p&gt;One of the features that I was very eagerly expecting in 3.5 M6 is PDE's Custom Attribute. As of now, the Manifest editor has very limited ways of editing an attribute in the plug-in. It could be either String/boolean/Java/Resource/Id. What if PDE provides an extension point and you could plug in your own controls in the editor? Well thats exactly the Custom Attribute feature that I'm talking about. I've been playing it with for a while, and its awesome. The possibilities are really endless and here are some samples:&lt;/p&gt;&lt;p&gt;Pick your favourite color:&lt;/p&gt;&lt;p&gt;&lt;img height="190" alt="Color Picker" src="http://lh4.ggpht.com/_hsp14iFkRLs/SbuW4Qw7cXI/AAAAAAAADfY/LCNlP2g5gFo/image47.png?imgmax=800" width="331" border="0" /&gt;&amp;#160; &lt;/p&gt;&lt;p&gt;Select the SWT Platforms you support:&lt;/p&gt;&lt;p&gt;&lt;img height="189" alt="SWT Platform" src="http://lh3.ggpht.com/_hsp14iFkRLs/SbuXFccyIXI/AAAAAAAADfc/Fx0fI7pztEw/image28.png?imgmax=800" width="390" border="0" /&gt; &lt;/p&gt;&lt;p&gt;Choose an icon from your plug-in or shared images:&lt;/p&gt;&lt;p&gt;&lt;img height="542" alt="Image Chooser" src="http://lh6.ggpht.com/_hsp14iFkRLs/SbuXQZcBNQI/AAAAAAAADfg/YPnuEzC6ZiU/image25.png?imgmax=800" width="536" border="0" /&gt; &lt;/p&gt;&lt;p&gt;Or the best I've seen - define the location URI for a menu/toolbar contribution:&lt;/p&gt;&lt;p&gt;&lt;img height="219" alt="Location URI" src="http://lh6.ggpht.com/_hsp14iFkRLs/SbuXcPuuB1I/AAAAAAAADfk/9a3Yj9pxS4w/image22.png?imgmax=800" width="538" border="0" /&gt; &lt;/p&gt;&lt;p&gt;You can even provide auto complete in the text editor tab:&lt;/p&gt;&lt;p&gt;&lt;img height="311" alt="" src="http://lh6.ggpht.com/_hsp14iFkRLs/SbuXm887wDI/AAAAAAAADfo/l_V7E2MIWns/image39.png?imgmax=800" width="556" border="0" /&gt; &lt;/p&gt;&lt;p&gt;This feature is not just cool one, but also a useful one and will boost productivity. Its very unfortunate that it slipped this milestone (M6) due to work load. Its even unfortunate that beyond M6 no API/extension point can be added. What this means, we have to wait till 3.6 (released in 2010) to get this feature. Or somehow convince *everyone* that its should be pushed into 3.5 itself. &lt;a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=227055#c44" target="_blank"&gt;Martin says&lt;/a&gt; &amp;quot;that is not impossible&amp;quot;,&amp;#160; and &lt;a href="http://wiki.eclipse.org/Eclipse/PMC" target="_blank"&gt;the way is&lt;/a&gt;: &amp;quot;to go through the process (e-mail and public discussion on eclipse-pmc list)&amp;quot;. As everyone is busy with EclipseCon, I think that this process would start after EclipseCon.&lt;/p&gt;&lt;p&gt;Meanwhile, if you like this feature and want it in 3.5 itself, why don't you &lt;a href="https://bugs.eclipse.org/bugs/votes.cgi?action=show_user&amp;bug_id=227055#vote_227055" target="_blank"&gt;vote for this bug&lt;/a&gt;? I'm sure community's voice will be heard. If this gets into next milestone, I'll promise that I'll write a tip on how to use this extension point :-)&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-6790319963395593191?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/wUxUgE4jpKk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/6790319963395593191/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=6790319963395593191&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/6790319963395593191?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/6790319963395593191?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/wUxUgE4jpKk/do-you-need-pde-custom-attribute.html" title="Do you need PDE custom attribute?" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/03/do-you-need-pde-custom-attribute.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMBQn05eip7ImA9WxVVF0U.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-2799990864235728024</id><published>2009-03-11T20:27:00.001+05:30</published><updated>2009-03-11T20:27:33.322+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-11T20:27:33.322+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="search" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Eclipse Search - now with an Eclipse Plugin!</title><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Searching for Eclipse related material in Google is a painful task. It shows up lots of irrelevant results. With &lt;a href="http://blog.eclipse-tips.com/2008/02/eclipse-search.html" target="_blank"&gt;Eclipse Search&lt;/a&gt;, this was pretty much eliminated. It searches only our Eclipse related sites and provides relevant results. The results are even categorized into Blogs, Source, etc. To make things simple, I added a &lt;a href="http://blog.eclipse-tips.com/2008/07/eclipse-search-now-with-firefox-plugin.html" target="_blank"&gt;search plugin for the browsers&lt;/a&gt;. This helps to search help right from your search box of your browser. Still this has one problem - you need a browser to search. You need to copy &amp;amp; paste the class/method name from your Eclipse to Browser and start searching. Switch back to Eclipse and resume the work. Now this can be simplified by a search plugin for Eclipse.&lt;/p&gt;  &lt;p&gt;&lt;img height="454" alt="Eclipse Search" src="http://lh5.ggpht.com/_hsp14iFkRLs/SbfRA84aMCI/AAAAAAAADfE/_3iJ6Xt388U/image17.png?imgmax=800" width="527" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;When you open Search Page, you can see an Eclipse Search tab there. You don't even need to copy a text for searching - just a selection would do. The plug-in takes the current selection as the initial input. You can select the labels you want to search for and hit Enter. You get the results right there inside Eclipse itself:&lt;/p&gt;  &lt;p&gt;&lt;img height="521" alt="Eclipse Search - Results" src="http://lh6.ggpht.com/_hsp14iFkRLs/SbfRJArWVdI/AAAAAAAADfI/PPt3c2RfANs/image21.png?imgmax=800" width="835" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The recent searches are available in the History Menu:&lt;/p&gt;  &lt;p&gt;&lt;img height="160" alt="Eclipse Search - History" src="http://lh3.ggpht.com/_hsp14iFkRLs/SbfRPvHN20I/AAAAAAAADfM/9vAuUrnsqv0/image24.png?imgmax=800" width="272" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;And in case want to switch to a browser from the current results:&lt;/p&gt;  &lt;p&gt;&lt;img height="101" alt="Eclipse Search - New Browser" src="http://lh4.ggpht.com/_hsp14iFkRLs/SbfRWAP4WEI/AAAAAAAADfQ/vXTjutFnyaQ/image27.png?imgmax=800" width="288" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Me and few of my team mates are using it regularly and find it very handy. &lt;a href="http://cypal-eclipse-utils.googlecode.com/files/in.cypal.eclipse.tools.search_1.0.0.200902281330.jar" target="_blank"&gt;Download&lt;/a&gt; and try it yourself.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-2799990864235728024?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/GoGkTO27luk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/2799990864235728024/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=2799990864235728024&amp;isPopup=true" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/2799990864235728024?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/2799990864235728024?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/GoGkTO27luk/eclipse-search-now-with-eclipse-plugin.html" title="Eclipse Search - now with an Eclipse Plugin!" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">8</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/03/eclipse-search-now-with-eclipse-plugin.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak4AQn09eyp7ImA9WxVVFUw.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-5440090601938186194</id><published>2009-03-08T18:56:00.001+05:30</published><updated>2009-03-08T18:59:03.363+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-08T18:59:03.363+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jface" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="guidelines" /><category scheme="http://www.blogger.com/atom/ns#" term="3.5" /><category scheme="http://www.blogger.com/atom/ns#" term="Commands" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Commands Part 6: Toggle &amp; Radio menu contributions</title><content type="html">&lt;p&gt;In the previous parts of the series, we saw how Commands contribute to push style menu items. But commands allow you to contribute menu items with 'toggle' and 'radio' style as well. Let us see how to contribute the familiar &amp;quot;Format&amp;quot; menu thru Commands:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_hsp14iFkRLs/SbPHVVU91pI/AAAAAAAADe8/6m6nEl85xV4/image5.png?imgmax=800"&gt;&lt;img height="149" alt="image" src="http://lh5.ggpht.com/_hsp14iFkRLs/SbPHgbSogyI/AAAAAAAADfA/aV1vuAGQOqg/image_thumb1.png?imgmax=800" width="137" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;First we will look at the toggle style menu contribution. Commands can have states associated with it. A state id known by its id and it can have any value, which is stored in a subclass of org.eclipse.core.commands.State. To know whether a command is checked or not, the Command Framework looks for a state with the id 'org.eclipse.ui.commands.toggleState'. Lets specify the default checked state of Bold to true and Italic to false:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#000080" size="2"&gt;&amp;lt;command      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; defaultHandler=&amp;quot;com.eclipse_tips.commandstate.BoldHandler&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id=&amp;quot;com.eclipse-tips.commandState.boldCommand&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;Bold&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;state       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; class=&amp;quot;org.eclipse.ui.handlers.RegistryToggleState:true&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id=&amp;quot;org.eclipse.ui.commands.toggleState&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;/state&amp;gt;       &lt;br /&gt;&amp;lt;/command&amp;gt;       &lt;br /&gt;&amp;lt;command       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; defaultHandler=&amp;quot;com.eclipse_tips.commandstate.ItalicHandler&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id=&amp;quot;com.eclipse-tips.commandState.italicCommand&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;Italic&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;state       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; class=&amp;quot;org.eclipse.ui.handlers.RegistryToggleState:false&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id=&amp;quot;org.eclipse.ui.commands.toggleState&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;/state&amp;gt;       &lt;br /&gt;&amp;lt;/command&amp;gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The Framework expects a Boolean value from the state. It doesn't care about which class that holds the state. So why should we use the RegistryToggleState instead of our own state class? Two reasons:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;It implements IExecutableExtension. So you can specify the default values in the plugin.xml as I've done above. &lt;/li&gt;    &lt;li&gt;It extends PersistentState, so it can remember the value between Eclipse sessions. So if the user had checked/unchecked the menu, restarts Eclipse, he will get the same state as he left before - all this, you get without even your plugin being loaded. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;So how should the handler work for this command?&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#000080" size="2"&gt;public Object execute(ExecutionEvent event) throws ExecutionException {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Command command = event.getCommand();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; boolean oldValue = HandlerUtil.toggleCommandState(command);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // use the old value and perform the operation &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#000080" size="2"&gt;&amp;#160;&amp;#160;&amp;#160; return null;      &lt;br /&gt;}&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;Basically, its the Handler's responsibility to update the Command's state. The HandlerUtil has a convenient method which toggles the state and gives you the old value of the state. You can use the value to perform the operation.&lt;/p&gt;  &lt;p&gt;The radio state is also similar, which expects the state with a predefined id. Since the same command is contributed for various option, its should be a parameterized command. The id of the parameter which denotes the radio state is also predefined:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#000080" size="2"&gt;&amp;lt;command      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; defaultHandler=&amp;quot;com.eclipse_tips.commandstate.AlignHandler&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id=&amp;quot;com.eclipse-tips.commandState.alignCommand&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;Align Command&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;commandParameter       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id=&amp;quot;org.eclipse.ui.commands.radioStateParameter&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;State&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; optional=&amp;quot;false&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;/commandParameter&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;state       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; class=&amp;quot;org.eclipse.ui.handlers.RadioState:left&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id=&amp;quot;org.eclipse.ui.commands.radioState&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;/state&amp;gt;       &lt;br /&gt;&amp;lt;/command&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Just like toggle state, the state must have the id and the class could be anything that stores the value as String. The RadioState class provides initializing from plugin.xml and also persists the value across sessions.&lt;/p&gt;  &lt;p&gt;The menu contribution would specify the parameter value:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#000080" size="2"&gt;&amp;lt;menuContribution      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; locationURI=&amp;quot;menu:org.eclipse.ui.main.menu?after=additions&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;menu       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; label=&amp;quot;Format&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ... other contributions here       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;command       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; commandId=&amp;quot;com.eclipse-tips.commandState.alignCommand&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; label=&amp;quot;Align Left&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; style=&amp;quot;radio&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;parameter       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;org.eclipse.ui.commands.radioStateParameter&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; value=&amp;quot;left&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/parameter&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/command&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;command       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; commandId=&amp;quot;com.eclipse-tips.commandState.alignCommand&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; label=&amp;quot;Align Center&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; style=&amp;quot;radio&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;parameter       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;org.eclipse.ui.commands.radioStateParameter&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; value=&amp;quot;center&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/parameter&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/command&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;command       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; commandId=&amp;quot;com.eclipse-tips.commandState.alignCommand&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; label=&amp;quot;Align Right&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; style=&amp;quot;radio&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;parameter       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;org.eclipse.ui.commands.radioStateParameter&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; value=&amp;quot;right&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/parameter&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/command&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;/menu&amp;gt;       &lt;br /&gt;&amp;lt;/menuContribution&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The Command Framework understands this parameter and sets the UI contributions according to this value. Again its the handler's job to set the correct state from the command's parameter during execution. You have helper methods in the HandlerUtil to perform this:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#000080" size="2"&gt;public Object execute(ExecutionEvent event) throws ExecutionException {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if(HandlerUtil.matchesRadioState(event))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return null; // we are already in the updated state - do nothing       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; String currentState = event.getParameter(RadioState.PARAMETER_ID);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // perform task for current state       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; if(currentState.equals(&amp;quot;left&amp;quot;))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // perform left alignment       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; else if(currentState.equals(&amp;quot;center&amp;quot;))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // perform center alignment       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // and so on ...       &lt;br /&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // and finally update the current state       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; HandlerUtil.updateRadioState(event.getCommand(), currentState);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#000080" size="2"&gt;&amp;#160;&amp;#160;&amp;#160; return null;      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;strong&gt;Bonus:&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Q: I want the initial value always loaded from the plugin.xml, the state should not be remembered between sessions. Should I write my own State class?&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;A: Not necessary. You can specify both the default value of the state and whether to persist or not in the plugin.xml itself:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" color="#000080" size="2"&gt;&amp;lt;command      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; defaultHandler=&amp;quot;com.eclipse_tips.commandstate.AlignHandler&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id=&amp;quot;com.eclipse-tips.commandState.alignCommand&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;Align Command&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;commandParameter       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id=&amp;quot;org.eclipse.ui.commands.radioStateParameter&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;State&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; optional=&amp;quot;false&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;/commandParameter&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;state       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id=&amp;quot;org.eclipse.ui.commands.radioState&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;class       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; class=&amp;quot;org.eclipse.ui.handlers.RadioState&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;parameter       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;default&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; value=&amp;quot;left&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/parameter&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;parameter       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;persisted&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; value=&amp;quot;false&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/parameter&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/class&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160; &amp;lt;/state&amp;gt;       &lt;br /&gt;&amp;lt;/command&amp;gt;&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;This applies for toggle state as well.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Q: I want to know the state of the command elsewhere in the code. How do I get it?&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;A: Just use Command.getState(&amp;lt;state id&amp;gt;).getValue(). The state ids are available as constants at RegistryToggleState.STATE_ID and RadioState.STATE_ID&lt;/p&gt;  &lt;p&gt;My patch for this feature has just been checked in and should be available from 3.5 M6 onwards. If you are curious, pick up a recent Nightly build and play with this.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-5440090601938186194?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/yunJAX8qIFU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/5440090601938186194/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=5440090601938186194&amp;isPopup=true" title="16 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/5440090601938186194?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/5440090601938186194?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/yunJAX8qIFU/commands-part-6-toggle-radio-menu.html" title="Commands Part 6: Toggle &amp;amp; Radio menu contributions" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">16</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MGR3s9eCp7ImA9WxVWFUs.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-7464270251242389085</id><published>2009-02-25T16:30:00.003+05:30</published><updated>2009-02-25T17:00:26.560+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-25T17:00:26.560+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Reviews" /><category scheme="http://www.blogger.com/atom/ns#" term="plugins" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><title>WireframeSketcher - Review and free licenses</title><content type="html">A picture is worth of 1000 words. That is why I have a habit of creating mockups/prototypes of UI before creating the real ones. There are umpteen number of tools available in the market, but I'm comfortable with plain old paper &amp;amp; pencil. Mostly because I don't need complex tools and partly because if I convert the price from Dollars to Rupees it would leave a bug hole in my wallet. Add to that I use Mac (my personal laptop), Windows (my official laptop) and Linux (my spare desktop). It is hard for me to find a simple tool that would work on all OS and still available for a cheaper price. To end my worries, here is &lt;a href="http://wireframesketcher.com/" target="_blank"&gt;WireframeSketcher&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Its an Eclipse plugin, so it works perfectly on all the platforms. Lets talk about simplicity.&lt;br /&gt;
The tool is as simple as it gets. The editor works on a .screen file, which can be kept under any project. In the editor, you have a drawing canvas and a palette with the most commonly used UI widgets. Drag and drop the elements you need from the palette to the canvas. You can group elements, adjust the Z-Order, move or resize them. Sounds like a perfect fit for me. Here is a screen shot of the product in action:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lh4.ggpht.com/_hsp14iFkRLs/SaUkS8p76xI/AAAAAAAADd0/RG38h9FqfRw/image6.png?imgmax=800"&gt;&lt;img alt="WireframeSketcher" border="0" height="361" src="http://lh4.ggpht.com/_hsp14iFkRLs/SaUkaDtKhuI/AAAAAAAADd4/wRRgLVGqFlU/image_thumb6.png?imgmax=800" width="600" /&gt;&lt;/a&gt;&lt;br /&gt;
I usually create the mockup and then create the actual UI. For a change, I tried creating a mockup of the existing UI. The mimicked picture:&lt;br /&gt;
&lt;a href="http://lh4.ggpht.com/_hsp14iFkRLs/SaUkis-MVWI/AAAAAAAADd8/l8wL3JSgPm4/image33.png?imgmax=800"&gt;&lt;img alt="WireframeSketcher" border="0" height="347" src="http://lh5.ggpht.com/_hsp14iFkRLs/SaUktG63vZI/AAAAAAAADeA/A-pbvsteTrI/image3_thumb2.png?imgmax=800" width="600" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Thats a pretty rough sketch. But creating the above took me less than 5 mins! I can spend a little more time and make it look more like the original picture, but I think this conveys the message. I wish it supports more options like generating SWT/Swing code from the mock up. How cool that would be? Awesome, but that would would deviate from its mail goal - creating mockups. I think it will compromise on the simplicity as well.&lt;br /&gt;
&lt;br /&gt;
I wish I could write more about this tool, but honestly there is nothing like you working on this. You don't have to go thru a a big manual. Just create a new .screen file and start using it. Period.&lt;br /&gt;
&lt;br /&gt;
Overall, its a neat and simple tool that helps you to create mockups. If you are looking for a such a tool to prototype the UI and explain it to the customer/boss and willing to live with minor nuances, then this tool is for you. If you are looking for more advanced one with complete control over the UI, you have to look elsewhere.&lt;br /&gt;
&lt;br /&gt;
Now lets come to the last part - cost of it. Right now there is no commercial version available. Evaluation licenses are available to play around with the tool. If you want a full free license, here is a chance exclusively for the readers of this blog.&lt;br /&gt;
&lt;br /&gt;
All you have to do is to post a comment answering this simple question: "What are the pros of UI prototyping?". Remember to enter your comment on or before March 3rd, 2009 and your comment should have your name and email id. &lt;a href="http://wireframesketcher.com/about.html" target="_blank"&gt;Peter&lt;/a&gt; will be selecting 5 random answers and will be giving out licenses to them.&lt;br /&gt;
&lt;br /&gt;
(In case you don't want to expose your email id in public, just leave the comment and send your name &amp;amp; email id to my email id: &lt;a href="mailto:grprakash@gmail.com"&gt;grprakash@gmail.com&lt;/a&gt;)&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-7464270251242389085?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/9FefdcUq8dE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/7464270251242389085/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=7464270251242389085&amp;isPopup=true" title="15 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/7464270251242389085?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/7464270251242389085?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/9FefdcUq8dE/wireframesketcher-review-and-free.html" title="WireframeSketcher - Review and free licenses" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">15</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/02/wireframesketcher-review-and-free.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8MQ3o6fCp7ImA9WxVVFUU.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-7022191035441814296</id><published>2009-02-23T13:49:00.003+05:30</published><updated>2009-03-09T13:18:02.414+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-09T13:18:02.414+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="RCP" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="guidelines" /><category scheme="http://www.blogger.com/atom/ns#" term="Commands" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Commands Part 5: Authentication in RCP applications</title><content type="html">One of the frequently asked questions on Command Framework is 'how to dynamically update a command?' I thought I'll couple the answer with implementing ISourceProvider and explain it with a usecase: Authentication in RCP applications. Most of the RCP applications I've seen, needs authentication. Obviously it would need a Login/Logout menu items and other user related options. This can be accomplished in many ways, and I'm going to show you how to do it with Command Framework.&lt;br /&gt;
Lets do it in step by step.&lt;br /&gt;
&lt;h2&gt;Defining the session state thru ISourceProvider:&lt;/h2&gt;First, we need to store the session state in a variable. When we say variable in Command Framework, its not a public final static String. It is something that you can use it in the visibleWhen, activeWhen and enabledWhen expressions. The variable has to be provided thru a ISourceProvider:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;extension      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point="org.eclipse.ui.services"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;sourceProvider       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; provider="com.eclipse_tips.rcp.app.SessionSourceProvider"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;variable       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="com.eclipse-tips.rcp.app.sessionState"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; priorityLevel="workbench"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/variable&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/sourceProvider&amp;gt;       &lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;/span&gt;&lt;br /&gt;
A ISourceProvider can provide the state of multiple variables. However, our source provider will give the value of only one variable - 'com.eclipse-tips.rcp.app.sessionState'. The values of this variable would be either 'loggedIn' or 'loggedOut'. The list of values cannot be defined thru the extension, so this is up to you to define it, publish it and use it.&lt;br /&gt;
In the extension, you can see the priorityLevel attribute. This is used by the IHandlerService to determine which handler is active for a given command and its defined in the org.eclipse.ui.ISources interface. See my earlier tip on Command Framework for more explanation on this priority attribute.&lt;br /&gt;
The class should either implement ISourceProvider or extend AbstractSourceProvider. The preferred way is extending, so we'll do it that way:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;public class SessionSourceProvider extends AbstractSourceProvider { &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public final static String SESSION_STATE = "com.eclipse-tips.rcp.app.sessionState";      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; private final static String LOGGED_IN = "loggedIn";       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; private final static String LOGGED_OUT = "loggedOut";       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; boolean loggedIn;       &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public String[] getProvidedSourceNames() {       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new String[] {SESSION_STATE};       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public Map&amp;lt;String, String&amp;gt; getCurrentState() {       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map&amp;lt;String, String&amp;gt; currentState = new HashMap&amp;lt;String, String&amp;gt;(1);       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String currentState =&amp;nbsp; loggedIn?LOGGED_IN:LOGGED_OUT;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; currentState.put(SESSION_STATE, currentState);       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return currentState;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void dispose() {} &lt;/span&gt;  &lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void setLoggedIn(boolean loggedIn) { &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(this.loggedIn == loggedIn)      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return; // no change &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.loggedIn = loggedIn;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String currentState =&amp;nbsp; loggedIn?LOGGED_IN:LOGGED_OUT;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fireSourceChanged(ISources.WORKBENCH, SESSION_STATE, currentState);       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }       &lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
The first method is simple. As I mentioned earlier, a source provider can provider the state of multiple variables. The list of the variables (source names) is returned in the call. The second method is called to get the current state. The variable:value pairs are put in a map and returned back to the caller. The third method dispose is a no-op method for us. These three methods completes the API contract, but we have added one more method, where the value is updated to the source provider itself. So whenever a Login/Logout happens we need to call this method. This method fires the sourceChanged event, so that all the listeners can update accordingly. &lt;br /&gt;
When the sourceChanged event is fired, the status of the Command Handlers which has activeWhen or enabledWhen expressions with this variable re-evaluated with the new value of the variable. This holds good for visibleWhen expressions of the Commands as well. So if you want to show/enable a contribution item only when the user has logged in, you can use this variable like:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;extension      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point="org.eclipse.ui.menus"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;menuContribution       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; locationURI="menu:file?after=additions"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;command       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="org.eclipse.ui.window.preferences"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;visibleWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable="com.eclipse-tips.rcp.app.sessionState"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;equals       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="loggedIn"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/equals&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/with&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/visibleWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/command&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/menuContribution&amp;gt;       &lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;/span&gt; &lt;br /&gt;
Now the File-&amp;gt;Preferences will be visible only when the user has logged in. &lt;br /&gt;
&lt;h2&gt;Updating the state:&lt;/h2&gt;Now that we have the source provider and the menu items that are dynamically enabled/disabled or shown/hidden according to the sessionState, the problem is how to we update the state?&lt;br /&gt;
Elsewhere, when a command is executed for Login/Logout, we have to make a call to SessionSourceProvider.setLoggedIn() method. But how do we get hold of the instance of the SessionSourceProvider? This is where the ISourceProviderService comes into picture. This service has a getSourceProvider() method, where if you give the variable name, it will give the corresponding source provider. The next obvious question would be where to get the implementation of this service? Not this service, for any service, you can use IServiceLocator to get the implementation and fortunately the IWorkbenchWindow implements this service. So when we execute the Login/Logout command:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;// get the window (which is a IServiceLocator)      &lt;br /&gt;
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);       &lt;br /&gt;
// get the service       &lt;br /&gt;
ISourceProviderService service = (ISourceProviderService) window.getService(ISourceProviderService.class);       &lt;br /&gt;
// get our source provider by querying by the variable name       &lt;br /&gt;
SessionSourceProvider sessionSourceProvider = (SessionSourceProvider) service.getSourceProvider(SessionSourceProvider.SESSION_STATE);       &lt;br /&gt;
// set the value       &lt;br /&gt;
sessionSourceProvider.setLoggedIn(isSessionActive);&lt;/span&gt; &lt;br /&gt;
&lt;h2&gt;Dynamically updating the Login/Logout command:&lt;/h2&gt;The Login and Logout commands are mutually exclusive. When one appears the other won't. So you can have two different commands and use the visibleWhen with our sessionState variable to show/hide them. The other way is to have one command and update the text of the command according to the state. The first way is very similar to the Preference command that is explained above, so let me explain the second way here:&lt;br /&gt;
The idea is to define a single command and two handlers:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;extension      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point="org.eclipse.ui.commands"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;command       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse-tips.rcp.app.sessionCommand"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="Session Command"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/command&amp;gt;       &lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;extension      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point="org.eclipse.ui.handlers"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;handler       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="com.eclipse_tips.rcp.app.handlers.LoginHandler"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.rcp.app.sessionCommand"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;activeWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable="com.eclipse-tips.rcp.app.sessionState"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;equals       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="loggedOut"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/equals&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/with&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/activeWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/handler&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;handler       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="com.eclipse_tips.rcp.app.handlers.LogoutHandler"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.rcp.app.sessionCommand"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;activeWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable="com.eclipse-tips.rcp.app.sessionState"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;equals       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="loggedIn"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/equals&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/with&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/activeWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/handler&amp;gt;       &lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;extension      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point="org.eclipse.ui.menus"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;menuContribution       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; locationURI="menu:file?before=quit"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;command       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.rcp.app.sessionCommand"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; style="push"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/command&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/menuContribution&amp;gt;       &lt;br /&gt;
&amp;lt;/extension&amp;gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
So the first handler, LoginHandler will be active when the user is logged out and the LogoutHandler will be active when the user is logged in. Both the handlers after performing their respective actions will notify the SessionSourceProvider, but how do we change the menu text? This happens thru IElementUpdater. When a handler implements this interface, it can update the associated contributions. When I say update, it means the text, tooltip, image etc. So the LoginHandler would look like:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;public class LoginHandler extends AbstractHandler implements IElementUpdater { &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public Object execute(ExecutionEvent event) throws ExecutionException {       &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // perform login here ...       &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISourceProviderService service = (ISourceProviderService) window.getService(ISourceProviderService.class);       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SessionSourceProvider sessionSourceProvider = (SessionSourceProvider) service.getSourceProvider(SessionSourceProvider.SESSION_STATE);       &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // update the source provider       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sessionSourceProvider.setLoggedIn(true); &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void updateElement(UIElement element, Map parameters) {       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; element.setText("Login");       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;}&lt;/span&gt;&lt;br /&gt;
The LogoutHandler also will have a similar code. Remember its not a mandatory thing to have multiple handlers to update the command dynamically. You can do it even with single handler as well.&lt;br /&gt;
One last piece, the Command Framework will call the updateElement() method only when the value of the variables in the *when expression is changed. So in other places where you want to update a command when no variable change has occurred, you need to use the ICommandService:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;ICommandService commandService = (ICommandService.class)serviceLocator.getService(ICommandService.class);      &lt;br /&gt;
commandService.refreshElements(commandId, null);&lt;/span&gt;&lt;br /&gt;
&lt;p&gt;See also:&lt;/p&gt;&lt;p&gt;Part 1: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-1-actions-vs-commands.html" target="_blank"&gt;Actions Vs Commands&lt;/a&gt;     &lt;br /&gt;
Part 2: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-2-selection-and.html" target="_blank"&gt;Selection and Enablement of Handlers&lt;/a&gt;     &lt;br /&gt;
Part 3: &lt;a href="http://blog.eclipse-tips.com/2008/12/commands-part-3-parameters-for-commands.html" target="_blank"&gt;Parameters for Commands&lt;/a&gt;&lt;br /&gt;
Part 4: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-4-misc-items.html"&gt;Misc items ...&lt;/a&gt;&lt;br /&gt;
Part 6: &lt;a href="http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html"&gt;'toggle' &amp; 'radio' style menu contribution&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-7022191035441814296?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/vzXy9vRa_-4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/7022191035441814296/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=7022191035441814296&amp;isPopup=true" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/7022191035441814296?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/7022191035441814296?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/vzXy9vRa_-4/commands-part-5-authentication-in-rcp.html" title="Commands Part 5: Authentication in RCP applications" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/02/commands-part-5-authentication-in-rcp.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUQCSHc-cSp7ImA9WxVWFEg.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-5358957113667531250</id><published>2009-02-18T22:40:00.001+05:30</published><updated>2009-02-24T12:06:09.959+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-24T12:06:09.959+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="RCP" /><category scheme="http://www.blogger.com/atom/ns#" term="dialogs" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="3.5" /><category scheme="http://www.blogger.com/atom/ns#" term="Commands" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Customizing the About Dialog</title><content type="html">In the About Dialog, the image, text etc, can be customized by the extension point org.eclipse.core.runtime.products (or PDE's product editor). But with few changes into the nightly build of 3.5, the About Dialog sports a new look and is much more customizable. In this tip, lets see how to extend it.&lt;br /&gt;
&lt;br /&gt;
The new Eclipse About Dialog (for the RCP mail sample) looks like this:&lt;br /&gt;
&lt;img alt="image" border="0" height="307" src="http://lh5.ggpht.com/_hsp14iFkRLs/SZvME4HiNzI/AAAAAAAADdM/vecByMxotIc/image%5B38%5D.png?imgmax=800" width="569" /&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you click the "Installation Details" button, you will get this Dialog:&lt;br /&gt;
&lt;img alt="image" border="0" height="453" src="http://lh6.ggpht.com/_hsp14iFkRLs/SZvMU6J3iJI/AAAAAAAADdQ/b3Q3VAOkTzA/image%5B42%5D.png?imgmax=800" width="626" /&gt;&lt;br /&gt;
&lt;br /&gt;
How about adding our own tab here? You need to extend the new org.eclipse.ui.installationPages extension point. &lt;br /&gt;
&amp;lt;extension    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point="org.eclipse.ui.installationPages"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;page     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="com.eclipse_tips.rcp.mail.MailInstallationpage"     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse-tips.rcp.mail.Installationpage"     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="RCP Mail"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/page&amp;gt;     &lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class should extend org.eclipse.ui.about.InstallationPage, which has the createControl() method. Create all the UI you want there:&lt;br /&gt;
&lt;img alt="image" border="0" height="353" src="http://lh3.ggpht.com/_hsp14iFkRLs/SZvMoXwSubI/AAAAAAAADdU/8USVXKOBGkY/image%5B46%5D.png?imgmax=800" width="554" /&gt; &lt;br /&gt;
If you see the Plug-ins tab or Configuration tab, there are few buttons. How to add a new button in our RCP Mail Tab? I was looking for a createButtons() method to override, but its not that way. The buttons are contributed thru Command Framework:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;extension    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point="org.eclipse.ui.commands"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;command     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; defaultHandler="com.eclipse_tips.rcp.mail.ShowRegistrationHandler"     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse-tips.rcp.mail.showRegistrationCommand"     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="Registration Details"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/command&amp;gt;     &lt;br /&gt;
&amp;lt;/extension&amp;gt;     &lt;br /&gt;
&amp;lt;extension     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point="org.eclipse.ui.menus"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;menuContribution     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; locationURI="toolbar:org.eclipse.ui.installationDialog.buttonbar"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;command     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.rcp.mail.showRegistrationCommand"     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; style="push"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;visibleWhen&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable="org.eclipse.ui.installationPage.activePage.id"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;equals     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="com.eclipse-tips.rcp.mail.InstallationPage"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/equals&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/with&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/visibleWhen&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/command&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/menuContribution&amp;gt;     &lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
If you don't understand the above extension, you need to refer to my earlier tips on Command Framework :-P&lt;br /&gt;
Result:&lt;br /&gt;
&lt;img alt="image" border="0" height="356" src="http://lh4.ggpht.com/_hsp14iFkRLs/SZvM5icOwHI/AAAAAAAADdY/vZyGd51zf2s/image%5B50%5D.png?imgmax=800" width="559" /&gt; &lt;br /&gt;
&lt;br /&gt;
Why can't it be as simple as extending a createButtons() method? Well, flexibility for other plugins to extend. Say if we want to add a button to the existing Plug-ins tab, all we have to do is add a menuContribution:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;extension    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point="org.eclipse.ui.menus"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;menuContribution     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; locationURI="toolbar:org.eclipse.ui.installationDialog.buttonbar"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;command     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.rcp.mail.showRegistrationCommand"     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; style="push"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;visibleWhen&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable="org.eclipse.ui.installationPage.activePage.id"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;equals     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="30.PluginPage"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/equals&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/with&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/visibleWhen&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/command&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/menuContribution&amp;gt;     &lt;br /&gt;
&amp;lt;/extension&amp;gt; &lt;br /&gt;
&lt;br /&gt;
See. Extending it is now simple!&lt;br /&gt;
&lt;img alt="image" border="0" height="357" src="http://lh3.ggpht.com/_hsp14iFkRLs/SZvUDQuaeiI/AAAAAAAADdc/mpRs9M7pHbw/image%5B55%5D.png?imgmax=800" width="559" /&gt; &lt;br /&gt;
&lt;br /&gt;
The id of the Plug-ins tab is "30.PluginPage" and the id of the Configuration tab is "31.SystemPage". Did you notice something odd there? The ids are prefixed with some numbers. These numbers decide the order of the tabs appearing in the dialog. This is not a documented behaviour, so don't expect to work the same in future versions, but for now it works. So if we prefix our ids with a lower number like "10.com.eclipse-tips.rcp.mail.InstallationPage", our tab will be shown first:&lt;br /&gt;
&lt;img alt="image" border="0" height="354" src="http://lh5.ggpht.com/_hsp14iFkRLs/SZvUljtjRNI/AAAAAAAADdg/gVX1lLO6pTs/image%5B59%5D.png?imgmax=800" width="557" /&gt;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
The Configuration lists out all the configuration details, so if you want to add your own configuration to it, you need to extend org.eclipse.ui.systemSummarySections:&lt;br /&gt;
&amp;lt;extension    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point="org.eclipse.ui.systemSummarySections"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;section     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="com.eclipse_tips.rcp.mail.MailSummarySection"     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse_tips.rcp.mail.mailSummarySection"     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sectionTitle="RCP Mail Details"&amp;gt;     &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/section&amp;gt;     &lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class should implement org.eclipse.ui.about.ISystemSummarySection, which has a single method write(PrintWriter writer). You can add all the configuration details to the writer:&lt;br /&gt;
public class MailSummarySection implements ISystemSummarySection { &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void write(PrintWriter writer) {     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.println("User Name=Prakash G.R.");     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.println("Mail Server=GMail");     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; writer.println("Protocol=POP3");     &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
}&lt;br /&gt;
&lt;img alt="image" border="0" height="357" src="http://lh3.ggpht.com/_hsp14iFkRLs/SZvaIsKp9sI/AAAAAAAADdk/UGMj1WVHEGU/image%5B63%5D.png?imgmax=800" width="558" /&gt; &lt;br /&gt;
This has been there for a while, thought I'll add it for completeness :-)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update [24-Feb-2009]: In the recent nightly, the Command Contribution story has been completely removed and createButtons() method have been added. Now the framework is not flexible enough, so you can't contribute to existing pages, but the code gets much simpler now. Trade offs :-)&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-5358957113667531250?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/V1XC8EYlKWc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/5358957113667531250/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=5358957113667531250&amp;isPopup=true" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/5358957113667531250?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/5358957113667531250?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/V1XC8EYlKWc/customizing-about-dialog.html" title="Customizing the About Dialog" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/02/customizing-about-dialog.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0AGQX05eyp7ImA9WxVXFEs.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-3247335524702999200</id><published>2009-02-12T23:32:00.000+05:30</published><updated>2009-02-12T23:32:00.323+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-12T23:32:00.323+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Progress" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="guidelines" /><title>Using progress bars ...</title><content type="html">In the last tip, I said the &lt;a href="http://blog.eclipse-tips.com/2009/01/top-10-mistakes-in-eclipse-plug-in.html" target="_blank"&gt;top most mistake done by Eclipse plug-in developers&lt;/a&gt; is running long running operations in the UI thread. Assuming that you are running it in a non-UI thread, how to show the progress of the execution? Obviously thru progress monitors. But how many different ways are there to show a progress monitor? Lets see them in this tip.&lt;br /&gt;
The first option is ProgressMonitorDialog. You have to create a IRunnableWithProgress and use the run method:&lt;br /&gt;
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);   &lt;br /&gt;
dialog.run(true, true, new IRunnableWithProgress(){ &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void run(IProgressMonitor monitor) {   &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; monitor.beginTask("Some nice progress message here ...", 100);    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // execute the task ...    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; monitor.done();    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }    &lt;br /&gt;
});&lt;br /&gt;
Result:&lt;br /&gt;
&amp;nbsp;&lt;img alt="ProgressMonitorDialog" border="0" height="210" src="http://lh6.ggpht.com/_hsp14iFkRLs/SZRdw4ZmoFI/AAAAAAAADbw/8uIFqMaxzCc/image%5B6%5D.png?imgmax=800" width="479" /&gt; &lt;br /&gt;
As you can see, the dialog is kind-of blocking the user. This dialog is advisable only in the rare cases where the user have to wait till the operation is completed. In most other cases, you should prefer running a Job. A Job is not blocking to the user and can still show the progress. The progress is available in the Progress View.&lt;br /&gt;
&lt;br /&gt;
Job job = new Job("My new job") { &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override   &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; protected IStatus run(IProgressMonitor monitor) {    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; monitor.beginTask("Some nice progress message here ...", 100);    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // execute the task ...    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; monitor.done();    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Status.OK_STATUS;    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }    &lt;br /&gt;
};    &lt;br /&gt;
job.schedule();&lt;br /&gt;
&lt;br /&gt;
Result:&lt;br /&gt;
&amp;nbsp;&lt;img alt="Job in Progress View" border="0" height="239" src="http://lh6.ggpht.com/_hsp14iFkRLs/SZReDypu6WI/AAAAAAAADb0/u8HqU_XDAts/image%5B15%5D.png?imgmax=800" width="543" /&gt;&lt;br /&gt;
&lt;br /&gt;
If you make the job as a user job by calling setUser(true), the progress dialog will be opened, where the user can chose to run the job as a background job. If the user doesn't want to see this dialog again, he can select to 'Always run in background':&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the job is initiated by the user interacting with a workbench part (like clicking a button in a view), a better way to schedule the job is thru the site's IWorkbencSiteProgressService.schedule. When the job begins to execute, the workbench part can show it visually. The default behaviour is to italize the part name:&lt;br /&gt;
&lt;img alt="WorkbenchPart.showBusy" border="0" height="268" src="http://lh4.ggpht.com/_hsp14iFkRLs/SZReUxp8x_I/AAAAAAAADb4/M8xnmH9qUl0/image%5B23%5D.png?imgmax=800" width="756" /&gt;   &lt;br /&gt;
But you can customize it by overriding the showBusy() method in your WorkbenchPart:&lt;br /&gt;
public void showBusy(boolean busy) {   &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; super.showBusy(busy);    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(busy)    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setPartName("I'm doing a job right now...");    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else    &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setPartName("Sample View");    &lt;br /&gt;
}&lt;br /&gt;
Result:&lt;br /&gt;
&lt;img alt="WorkbenchPart.showBusy" border="0" height="268" src="http://lh6.ggpht.com/_hsp14iFkRLs/SZRf8eSYxhI/AAAAAAAADb8/5pfaLKkw2Is/image%5B32%5D.png?imgmax=800" width="758" /&gt; &lt;br /&gt;
&lt;br /&gt;
In case your action doesn't have any WorkbenchPart associated with it, you can use the IWorkbenchWindow.run(...) to show the progress:&lt;br /&gt;
&lt;br /&gt;
&lt;img alt="IWorkbenchWindow.run" border="0" height="238" src="http://lh6.ggpht.com/_hsp14iFkRLs/SZRgTccM-oI/AAAAAAAADcA/AchxvBw1qkw/image%5B40%5D.png?imgmax=800" width="811" /&gt; &lt;br /&gt;
&lt;br /&gt;
If you are running a long running operation in a wizard/wizardPage you should consider running it thru getContainer().run(). This will show the progressBar right there in the wizard dialog itself:&lt;br /&gt;
&lt;br /&gt;
&lt;img alt="progressbar in wizard" border="0" height="133" src="http://lh4.ggpht.com/_hsp14iFkRLs/SZRgnzWYf8I/AAAAAAAADcE/ZZ1JJyksghs/image%5B48%5D.png?imgmax=800" width="533" /&gt; &lt;br /&gt;
&lt;br /&gt;
If you are updating the UI elements in the wizardPage during the execution, you have to note that if you do a setEnabled() on any widget, it won't reflect. Its because the container registers the enabled state of the widgets before execution; disables the widgets; executes the task and restores the widget's enabled state to the saved value. So if you have changed the state during the operation, it will be overwritten by the container.&lt;br /&gt;
&lt;br /&gt;
In case, you can't display a progressbar, you should at least use BusyIndicator.showWhile() and display the busy cursor to show that some operation is being executed. Else the user might be wondering why the UI is frozen.&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-3247335524702999200?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/uilznkra1cA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/3247335524702999200/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=3247335524702999200&amp;isPopup=true" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/3247335524702999200?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/3247335524702999200?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/uilznkra1cA/using-progress-bars.html" title="Using progress bars ..." /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">8</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/02/using-progress-bars.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8MRnwzeCp7ImA9WxVWFU4.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-1165728340942375293</id><published>2009-01-28T23:35:00.003+05:30</published><updated>2009-02-25T08:31:27.280+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-25T08:31:27.280+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="guidelines" /><title>Top 10 mistakes in Eclipse Plug-in Development</title><content type="html">Having trained a lot of new comers to the Eclipse plug-in development, I've seen certain common mistakes repeated all the time. I've tried to compile a top 10 list of such common mistakes, so next time you hit them, you will know that you are not alone :-)&lt;br /&gt;
&lt;br /&gt;
Update: Thanks to &lt;a href="http://www.blogger.com/profile/10730042929073818285" target="_blank"&gt;Hiroki Kondo(kompiro)&lt;/a&gt; a Japanese version of this entry is available &lt;a href="http://d.hatena.ne.jp/kompiro/20090214/1234631568" target="blank"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
(&lt;b&gt;&lt;u&gt;10) Not reading the JavaDoc&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;blockquote&gt;This is nothing specific about Eclipse Plug-in development. Its more common among the Java programmers, or probably a common thing among all the programmers - not reading the documentation. How many of you know that there are classes that shouldn't be inherited or the interfaces that are not supposed to be implemented by you? Well API tooling will help you, but there are lot of other corner cases which you won't find unless you read the JavaDoc. I myself do this mistake all the time. Honestly for a long while I didn't know that a command's handler is supposed to return only null (which is the result of the execution)- When did you know this? &lt;br /&gt;
In case you didn't know, JDT provides you a JavaDoc view which shows up the Java doc with the formatting.&lt;br /&gt;
&lt;img alt="JavaDoc view" border="0" height="261" src="http://lh3.ggpht.com/_hsp14iFkRLs/SYASQos8ChI/AAAAAAAADak/KvVQU0UnFqg/image32.png?imgmax=800" width="640" /&gt; &lt;/blockquote&gt;&lt;b&gt;&lt;u&gt;(9) Forgetting to add a default constructor&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;blockquote&gt;You had that nice wizard class which works fine when you create it yourself and put it in a WizardDialog. But you can't make it work with the INewWizard. After a "little" debugging you realize that you didn't have a default constructor for the Wizard class! Yes, its not just the Wizard class, but most of the other classes that you specify in your plugin.xml for that "class" attribute, should have a default constructor, as it will instantiated thru reflection.&lt;/blockquote&gt;&lt;b&gt;&lt;u&gt;(8) Not decomposing into different plugins&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;blockquote&gt;Another common thing among the newbies. They have a tendency to put everything into a single plug-in. Splitting your code base across different plug-in improves the modularity and maintainability. You should at least consider splitting the core and ui part, so that testing the core part becomes easy. &lt;/blockquote&gt;&lt;b&gt;&lt;u&gt;(7) Using "internal" code&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;blockquote&gt;I've seen this as an unavoidable thing in many cases. You see some functionality in the internal code that you would require, so make use of those internal classes. There are thousands of internal classes, but believe me, the one that used will be refactored and changed in the next release, so you will have a hard time upgrading to a newer release. It has happened to me more than once. Why *that* class of all the classes? sigh! &lt;br /&gt;
If you find any internal code generic and useful, raise a bug to make it a part of API. Instead of using the internal classes, you can copy the code into your code base and make use of it. &lt;/blockquote&gt;&lt;b&gt;&lt;u&gt;(6) Directly setting the classpath&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;blockquote&gt;Every plugin project is a Java Project, but that doesn't mean that you can simply update the Java classpath with the jar files that you require. Because your plug-in's classpath at runtime will be different. If you had to add a jar to the classpath, you should consider adding it thru the 'Add' button in Classpath section of the Runtime tab.&lt;br /&gt;
&lt;img alt="updating plugin classpath" border="0" height="388" src="http://lh6.ggpht.com/_hsp14iFkRLs/SYASbenYPAI/AAAAAAAADao/qS_6zK9jb4o/image9.png?imgmax=800" width="585" /&gt;&amp;nbsp; &lt;/blockquote&gt;&lt;b&gt;&lt;u&gt;(5) Ignoring build.properties&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;blockquote&gt;Most common mistake among the newbies. Add an icon/resource under a new folder; test the plug-in, which works fine; export it and deploy it elsewhere; it stops working. Reason? The build.properties didn't have an entry for the folder/file that you added, so the exported plug-in doesn't have that resource. So, remember, whenever you add a folder/individual resource, make sure you update the build.properties file as well.&lt;br /&gt;
&lt;a href="http://lh6.ggpht.com/_hsp14iFkRLs/SYAS3Fvxb_I/AAAAAAAADas/B6NjPL0g9nw/image16.png?imgmax=800"&gt;&lt;img alt="build.properties" border="0" height="365" src="http://lh6.ggpht.com/_hsp14iFkRLs/SYAdP9_-wRI/AAAAAAAADaw/irZPhwHoEi8/image_thumb5.png?imgmax=800" width="441" /&gt;&lt;/a&gt; &lt;/blockquote&gt;&lt;u&gt;&lt;b&gt;(4) Empty dispose method&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;blockquote&gt;Remember the the golden rule, "When you create, you dispose". SWT resources like images and fonts should be always disposed of when you are done with them. I've seen many people not doing this at all. Another important issue is when you are overriding the dispose method, you should always call the super.dispose() to ensure the resources created by the super class are properly disposed. Also, if you have attached any listeners like IPartListener or IResourceChangeListener, during the life cycle of your class, you should consider removing those listeners in the dispose method.&lt;/blockquote&gt;&lt;b&gt;&lt;u&gt;(3) Not honoring monitor.isCanceled()&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;blockquote&gt;Your Job does a lengthy operation and the user might want to cancel it. It can be done by pressing cancel in the ProgressMonitor dialog or in the Wizard or thru the Progress View. What ever way he does, the IProgressMonitor supplied to you will have the cancel flag set to true. Its your responsibility to periodically check the isCancelled() and abort the operation. When the user presses 'Cancel' and if nothing happens, believe me, its a very bad user experience.&lt;br /&gt;
&lt;img alt="Cancelling a job" border="0" height="210" src="http://lh5.ggpht.com/_hsp14iFkRLs/SYAdi9sFKlI/AAAAAAAADa0/MhpiEsAn2Vo/image23.png?imgmax=800" width="481" /&gt; &lt;/blockquote&gt;&lt;u&gt;&lt;b&gt;(2) Blindly contributing to everywhere&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;blockquote&gt;People tend to add their contribution virtually everywhere thinking their plug-in is the important one to the user. But hard fact is it will be annoying for the user. So: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Stop adding your view to every perspective that you know &lt;/li&gt;
&lt;li&gt;Do not extend org.eclipse.ui.startup unless its really, really, necessary &lt;/li&gt;
&lt;li&gt;Do not make your action set to be visible in all the perspectives &lt;/li&gt;
&lt;li&gt;Try not to create a modal dialog &lt;/li&gt;
&lt;li&gt;When you adding menu items thru objectContributions, try to add it to the specific class, rather than simply Object &lt;/li&gt;
&lt;/ul&gt;&lt;/blockquote&gt;&lt;b&gt;&lt;u&gt;(1) Executing a long running operation in Display thread&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;blockquote&gt;Do I need to tell about this? Not just newbies, even experienced ones tend to do this mistake. In my present job, I have to use an internal RCP application on a regular basis, does this mistake for almost all the operations. The end result is a non-responding UI and a very frustrated user :-(&amp;nbsp; Once I pointed out a piece of code and asked a developer why he was doing such a big calculation on a Display thread, he was very surprised. He said that he is neither doing a Display.asyncExec() nor a UIJob, so the code will not run in the display thread. Here is a thumb rule. The operation that you do inside the SWT listener methods will be run in the display thread. There are more than few people who don't realize this and think that only the that gets executed in Display.asyncExec or Display.syncExec are the ones that run in the UI thread. So don't do long calculations or contact a server across the network in those listeners. If you have to run such a lengthy operation, spawn off a separate job and return quickly, so the UI remains responsive.&lt;/blockquote&gt;What are the other mistakes that you frequently come across?&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-1165728340942375293?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/iQXPbwDwTHU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/1165728340942375293/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=1165728340942375293&amp;isPopup=true" title="9 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/1165728340942375293?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/1165728340942375293?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/iQXPbwDwTHU/top-10-mistakes-in-eclipse-plug-in.html" title="Top 10 mistakes in Eclipse Plug-in Development" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">9</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/01/top-10-mistakes-in-eclipse-plug-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYBRHk5eSp7ImA9WxVREUQ.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-8102373741912115957</id><published>2009-01-17T17:48:00.001+05:30</published><updated>2009-01-17T18:12:35.721+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-17T18:12:35.721+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><title>[Off Topic] Moving to Google's Feedburner</title><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This blogs RSS feed is available through FeedBurner. Now that its acquired by Google, they are moving their services to Google platform. The good news for me in that is I've one less password to remember :-) Today I've migrated this blogs feed to the Google services and it went fine and hope works for everyone. I've not seen the stats in the recent while, but looks like the subscribers count is steadily increasing. From a humble 20, its now gone above 500 ! &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;img height="195" alt="image" src="http://lh3.ggpht.com/_hsp14iFkRLs/SXHMLmG_vdI/AAAAAAAADZ4/oEs7HKZa6nM/image%5B15%5D.png?imgmax=800" width="538" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;Google Analytics says that planeteclipse.org and eclipsezone.com are the top referrers. So few posts make their way into these sites, are the major source of my subscribers. The more interesting part comes about the way people subscribe to this blog.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_hsp14iFkRLs/SXHMSG1MUoI/AAAAAAAADZ8/NUJoV2Qtk9A/image%5B17%5D.png?imgmax=800"&gt;&lt;img height="387" alt="image" src="http://lh5.ggpht.com/_hsp14iFkRLs/SXHMl2ZQ_5I/AAAAAAAADaA/Tj2o29ZPpWA/image_thumb%5B4%5D.png?imgmax=800" width="473" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Looks like Google Reader+iGoogle takes a lions share and the next is email subscribers. When I added the email subscription option, I thought at most 10 people would sign up thru that service. The count stands above 60!&lt;/p&gt;  &lt;p&gt;I started this blog with the intention of delivering tips and tricks of Eclipse Plugin development that I've learnt, and will continue doing that. Meanwhile excuse me for the occasional, pointless posts like this one :-)&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-8102373741912115957?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/_AzKQ5Xlz4Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/8102373741912115957/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=8102373741912115957&amp;isPopup=true" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/8102373741912115957?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/8102373741912115957?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/_AzKQ5Xlz4Q/off-topic-moving-to-google-feedburner.html" title="[Off Topic] Moving to Google&amp;#39;s Feedburner" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/01/off-topic-moving-to-google-feedburner.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkAEQno5cSp7ImA9WxVVFUU.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-4683890223289512521</id><published>2009-01-11T00:22:00.003+05:30</published><updated>2009-03-09T13:15:03.429+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-09T13:15:03.429+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jface" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="Commands" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Commands Part 4: Misc items ...</title><content type="html">&lt;p&gt;&lt;strong&gt;How do I know about execution of a command?&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;You can use the IExecutionListener:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;ICommandService service = (ICommandService) serviceLocator.getService(ICommandService.class);        &lt;br /&gt;
service.addExecutionListener(new IExecutionListener() { &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;&amp;#160;&amp;#160;&amp;#160; public void notHandled(String commandId, NotHandledException exception) {        &lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;&amp;#160;&amp;#160;&amp;#160; public void postExecuteFailure(String commandId, ExecutionException exception) {        &lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;&amp;#160;&amp;#160;&amp;#160; public void postExecuteSuccess(String commandId, Object returnValue) {        &lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;&amp;#160;&amp;#160;&amp;#160; public void preExecute(String commandId, ExecutionEvent event) {        &lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; }         &lt;br /&gt;
});&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;The IExecutionListener is merely an observer of the command execution so it can neither veto on it nor make any changes to the event. &lt;/p&gt;&lt;h3&gt;&lt;strong&gt;How do I get the active Window/Shell in my handler code?&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Use HandlerUtil. Its a handy class which gives you access to most common variables like active window, active shell, context ids, active part, current selection,&amp;#160; etc.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;Shell shell = HandlerUtil.getActiveShell(event);        &lt;br /&gt;
ISelection selection = HandlerUtil.getCurrentSelection(event); &lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;All of the get* methods will have a get*Checked variants. The first ones will return you null if the variable is not available. The checked ones will throw you an exception if the variable is null. If you have your own variable, you can use the getVariable() method to get it.&lt;/p&gt;&lt;h3&gt;&lt;strong&gt;Can I programmatically execute a Command?&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Yes. But don't simple call command.execute(), use the IHandlerService to execute a command:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class);        &lt;br /&gt;
handlerService.executeCommand(commandId, null);&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;h3&gt;&lt;strong&gt;Can I programmatically create and manipulate a Command?&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;Yes! You can use ICommandService to create a new command and then associate a handler thru IHandlerService:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class);        &lt;br /&gt;
Command command = commandService.getCommand(&amp;quot;my.new.undefined.command&amp;quot;);         &lt;br /&gt;
command.define(&amp;quot;New Command&amp;quot;, &amp;quot;This is created Programatically!&amp;quot;,&amp;#160; &lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; commandService.getCategory(&amp;quot;org.eclipse.ui.category.window&amp;quot;)); &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;IHandlerService handlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class);        &lt;br /&gt;
handlerService.activateHandler(command.getId(), new AbstractHandler() { &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;&amp;#160;&amp;#160;&amp;#160; public Object execute(ExecutionEvent event) throws ExecutionException {        &lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.out.println(&amp;quot;Command executed !&amp;quot;);         &lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return null;         &lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; }         &lt;br /&gt;
});&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;See also:&lt;/p&gt;&lt;p&gt;Part 1: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-1-actions-vs-commands.html" target="_blank"&gt;Actions Vs Commands&lt;/a&gt;     &lt;br /&gt;
Part 2: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-2-selection-and.html" target="_blank"&gt;Selection and Enablement of Handlers&lt;/a&gt;     &lt;br /&gt;
Part 3: &lt;a href="http://blog.eclipse-tips.com/2008/12/commands-part-3-parameters-for-commands.html" target="_blank"&gt;Parameters for Commands&lt;/a&gt;&lt;br /&gt;
Part 5: &lt;a href="http://blog.eclipse-tips.com/2009/02/commands-part-5-authentication-in-rcp.html"&gt;ISourceProvider &amp; dynamically updating Commands&lt;/a&gt;&lt;br /&gt;
Part 6: &lt;a href="http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html"&gt;'toggle' &amp; 'radio' style menu contribution&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-4683890223289512521?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/QnRNfv0h9pg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/4683890223289512521/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=4683890223289512521&amp;isPopup=true" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/4683890223289512521?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/4683890223289512521?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/QnRNfv0h9pg/commands-part-4-misc-items.html" title="Commands Part 4: Misc items ..." /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/01/commands-part-4-misc-items.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUIBQXc-eSp7ImA9WxVSFU0.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-2289708938645812555</id><published>2009-01-09T17:41:00.001+05:30</published><updated>2009-01-09T17:49:10.951+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-09T17:49:10.951+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="swt" /><title>Adding an input prompt to SWT Text</title><content type="html">&lt;p&gt;Adding an &lt;a href="http://ui-patterns.com/pattern/InputPrompt" target="_blank"&gt;Input Prompt&lt;/a&gt; to a text control is most common in web applications. Today I happened to see a &lt;a href="http://github.com/madrobby/prototype_helpers/tree/master/defaultValueActsAsHint/defaultvalueactsashint.js" target="_blank"&gt;JavaScript&lt;/a&gt; that handles this elegantly. The script itself is just 18 lines and using it requires just &lt;a href="http://mir.aculo.us/2009/1/7/using-input-values-as-hints-the-easy-way" target="_blank"&gt;1 line of code&lt;/a&gt;. What would be the effort required to create something in SWT? hmmm not very different:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;public static void addPrompt(final Text text, final String defaultText) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; text.addFocusListener(new FocusListener() { &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void focusGained(FocusEvent e) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if(text.getText().equals(defaultText)) {         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; text.setText(&amp;quot;&amp;quot;);         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; text.setForeground(null);         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void focusLost(FocusEvent e) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if(text.getText().equals(&amp;quot;&amp;quot;)) {         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; text.setText(defaultText);         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; text.setForeground(text.getDisplay().getSystemColor(SWT.COLOR_GRAY));         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; });         &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;To use:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New" color="#000080" size="3"&gt;InputPrompter.addPrompt(text, &amp;quot;Click Me!&amp;quot;);&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The result&lt;/p&gt;  &lt;p&gt;&lt;img height="106" alt="Input Prompt SWT" src="http://lh5.ggpht.com/_hsp14iFkRLs/SWc-7tpTJdI/AAAAAAAADWc/HF-7TtBNUnc/image%5B14%5D.png?imgmax=800" width="205" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;&lt;img height="104" alt="Input Prompt SWT" src="http://lh4.ggpht.com/_hsp14iFkRLs/SWc-_JCU0bI/AAAAAAAADWg/iKiXcZu01yg/image%5B12%5D.png?imgmax=800" width="207" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;The same trick can be applied to Combo boxes as well.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-2289708938645812555?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/hCC-egJsXq8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/2289708938645812555/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=2289708938645812555&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/2289708938645812555?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/2289708938645812555?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/hCC-egJsXq8/adding-input-prompt-to-swt-text.html" title="Adding an input prompt to SWT Text" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/01/adding-input-prompt-to-swt-text.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMHRH09cCp7ImA9WxVVFUU.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-2383263858817820854</id><published>2009-01-07T23:55:00.004+05:30</published><updated>2009-03-09T13:10:35.368+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-09T13:10:35.368+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jface" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="Commands" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Commands Part 3: Parameters for Commands</title><content type="html">Think of a command which opens a file in an editor. You can't possibly create an extensive list of "Open File - somefile.txt", "Open File - someotherfile.txt", etc. Rather you want a generic command like "Open File" with the actual file as a parameter. In this tip, lets see how to create such a command.&lt;br /&gt;
The extension point for the command and the parameter:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;command name="Open File"      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; defaultHandler="com.eclipse_tips.commads.OpenFileHandler"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse-tips.commands.openFileCommand"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;commandParameter       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse-tips.commands.filePathParameter"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="File Path"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/commandParameter&amp;gt;       &lt;br /&gt;
&amp;lt;/command&amp;gt;&lt;/span&gt;&lt;br /&gt;
The handler code looks like:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;public Object execute(ExecutionEvent event) throws ExecutionException {&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; String filePathParam = event.getParameter("com.eclipse-tips.commands.filePathParameter");       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IPath filePath = new Path(filePathParam);       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IWorkbenchPage activePage = ...// get the activePage       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; try {       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IDE.openEditor(activePage, file);       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (PartInitException e) {       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;// display error message       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;       &lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
As you can see, the ExecutionEvent will have all the parameters, which can be accessed thru their ids. Once you get the parameter string, you can use it in your own way. But exactly do we pass different parameters to that command? When you put the command in a toolbar/menu you can specify the parameter:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;menuContribution      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; locationURI="toolbar:org.eclipse.ui.main.toolbar"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;toolbar       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse-tips.commands.toolbar1"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;command       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.commands.someCommand"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse-tips.commands.someCommandInToolBar"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/command&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;command style="push"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.commands.openFileCommand"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label="Opens somefile"&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;parameter       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="com.eclipse-tips.commands.filePathParameter"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="MyProject/somefile.txt"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/parameter&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/command&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;command style="push"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.commands.openFileCommand"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label="Opens some other file"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;parameter       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="com.eclipse-tips.commands.filePathParameter"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="MyProject/someotherfile.txt"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/parameter&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/command&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/toolbar&amp;gt;       &lt;br /&gt;
&amp;lt;/menuContribution&amp;gt;&lt;/span&gt;&lt;br /&gt;
The above example is a naive one. Lets see the real world example: "Show View" command. The command is generic and can show any view. The view id is given to the command as a parameter:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;command      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="%command.showView.name"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; description="%command.showView.description"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; categoryId="org.eclipse.ui.category.views"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="org.eclipse.ui.views.showView"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; defaultHandler="org.eclipse.ui.handlers.ShowViewHandler"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;commandParameter       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="org.eclipse.ui.views.showView.viewId"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="%command.showView.viewIdParameter"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; values="org.eclipse.ui.internal.registry.ViewParameterValues" /&amp;gt;       &lt;br /&gt;
&amp;nbsp; &amp;lt;commandParameter       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="org.eclipse.ui.views.showView.makeFast"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="%command.showView.makeFastParameter"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; optional="true"&amp;gt;       &lt;br /&gt;
&amp;nbsp; &amp;lt;/commandParameter&amp;gt;&lt;/span&gt;&lt;br /&gt;
The list of all possible values of the parameter is given by the class ViewParameterValues. The class would iterate thru the view registry and return it. This information is used in defining the key bindings:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/_hsp14iFkRLs/SVpVpWThmeI/AAAAAAAADVs/5Dbg4k_0jkc/image16.png?imgmax=800"&gt;&lt;img alt="Key bindings for parameterized command" border="0" height="329" src="http://lh5.ggpht.com/_hsp14iFkRLs/SVpVxOUOxZI/AAAAAAAADVw/ZxQz1lNP3Pk/image_thumb12.png?imgmax=800" width="491" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
If we define our own parameter values, we can also get our command in the key bindings page:&lt;br /&gt;
&lt;a href="http://lh4.ggpht.com/_hsp14iFkRLs/SVpV8RjoyYI/AAAAAAAADV0/rRCPAbTI7Uw/image15.png?imgmax=800"&gt;&lt;img alt="image" border="0" height="317" src="http://lh4.ggpht.com/_hsp14iFkRLs/SVpWHcNs6HI/AAAAAAAADV4/QgqC1-gjZGI/image_thumb11.png?imgmax=800" width="367" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
Defining the parameters is all about returning a map of display names &amp;amp; the ids:&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;public class FileParameters implements IParameterValues { &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Map getParameterValues() {      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Map params = new HashMap();       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; params.put("Some File", "MyProject/somefile.txt");       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; params.put("Some Other File", "MyProject/someotherfile.txt");       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return params;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;}&lt;/span&gt;&lt;br /&gt;
The name would be displayed in the key bindings page and the id would be used to invoke the command when the key sequence is pressed.&lt;br /&gt;
&lt;br /&gt;
See also:&lt;br /&gt;
Part 1: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-1-actions-vs-commands.html"&gt;Actions Vs Commands&lt;/a&gt;&lt;br /&gt;
Part 2: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-2-selection-and.html"&gt;Selection and Enablement of Handlers&lt;/a&gt;&lt;br /&gt;
Part 4: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-4-misc-items.html"&gt;Misc items ...&lt;/a&gt;&lt;br /&gt;
Part 5: &lt;a href="http://blog.eclipse-tips.com/2009/02/commands-part-5-authentication-in-rcp.html"&gt;ISourceProvider &amp; dynamically updating Commands&lt;/a&gt;&lt;br /&gt;
Part 6: &lt;a href="http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html"&gt;'toggle' &amp; 'radio' style menu contribution&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-2383263858817820854?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/T7R0J4lGMWg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/2383263858817820854/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=2383263858817820854&amp;isPopup=true" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/2383263858817820854?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/2383263858817820854?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/T7R0J4lGMWg/commands-part-3-parameters-for-commands.html" title="Commands Part 3: Parameters for Commands" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2008/12/commands-part-3-parameters-for-commands.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQGRHs4fSp7ImA9WxVbFEU.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-674024221056304653</id><published>2009-01-05T23:55:00.004+05:30</published><updated>2009-03-31T12:22:05.535+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-31T12:22:05.535+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jface" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="Commands" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Commands Part 2: Selection and Enablement of IHandlers</title><content type="html">In the last tip, we saw that a Handler can be declared separately from a Command. This enables for multiple handler declarations for the same command. We can also customize when a handler is active and visible, thru plugin.xml itself. A handler that doesn't have any of these conditions is called as "default handler". When no other handler is associated with a command in a particular context, then the default handler will be the handler that gets executed. Remember, at any given point of time, there is at most only one handler is associated with a command. Lets have a look into how a particular handler is selected for a given context.&lt;br /&gt;
A handler can be specified with activeWhen condition using the expression language. Say for our command, we have two different handlers. One should be active when the current selection is an IFile and the other should be active when the current selection is IFolder. The expression for these would look like:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;handler      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="com.eclipse_tips.commads.SomeCommandHandler1"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.commands.someCommand"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;activeWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable="selection"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;iterate       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operator="or"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;instanceof       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="org.eclipse.core.resources.IFile"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/instanceof&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/iterate&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/with&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/activeWhen&amp;gt;       &lt;br /&gt;
&amp;lt;/handler&amp;gt;       &lt;br /&gt;
&amp;lt;handler       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="com.eclipse_tips.commads.SomeCommandHandler2"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.commands.someCommand"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;activeWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable="selection"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;iterate       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operator="or"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;instanceof       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="org.eclipse.core.resources.IFolder"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/instanceof&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/iterate&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/with&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/activeWhen&amp;gt;       &lt;br /&gt;
&amp;lt;/handler&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I'll save the explanation for the expression language for a separate tip, but for now a short one line desc: the first handler will be enabled when the selection current contains at least one IFile and the second handler will be enabled when the selection contains at least one IFolder. This raises to two questions.&lt;br /&gt;
1) What if the selection is just an IProject?&lt;br /&gt;
&lt;blockquote&gt;In this case, as none of the handlers are eligible, the command is disabled. This is where the default handler, if you have provided one, would be associated with the command (and the command will be enabled). &lt;/blockquote&gt;2) What if the selection contains both IFile and IFolder?&lt;br /&gt;
&lt;blockquote&gt;Now both the handlers are equally qualified to handle the command. But since the framework cannot pick one randomly the command is simply disabled. Even if you have provided a default handler, it won't be associated with the command, because the other two handlers are more specific than the default one.&lt;/blockquote&gt;How is the "specificness" of a handler is defined? It depends on the conditions that you give in the activeWhen expression. The order is defined in the ISources class. You can go thru the complete set there, to get a glimpse of the most commonly used ones, the order from least specific to most specific is like this:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Active Context (activeContexts) &lt;/li&gt;
&lt;li&gt;Active Actions Sets (activeActionSets) &lt;/li&gt;
&lt;li&gt;Active Shell (activeShell) &lt;/li&gt;
&lt;li&gt;Active Workbench Window (activeWorkbenchWindow) &lt;/li&gt;
&lt;li&gt;Active Editor Id (activeEditorId) &lt;/li&gt;
&lt;li&gt;Active Part Id (activePartId) &lt;/li&gt;
&lt;li&gt;Current Selection (selection) &lt;/li&gt;
&lt;/ul&gt;If a handler has activeWhen defined with active context and the other one with current selection, the second one will be selected as the selection is more specific than the active context. The activeWhen for all the handlers are evaluated and the one that returns true for the most specific condition is selected. When two handlers return true for the available most specific condition (like the selection having both IFile &amp;amp; IFolder in our case), no handler will be associated with the command.&lt;br /&gt;
All these things are done without even loading your handler in the memory. Even without loading your plugin!&amp;nbsp; &lt;br /&gt;
In the previous tip, we saw how a handler is selected with the activeWhen expression, when more than one handler is declared. Now assuming a handler is selected, whether to enable the command or not, is determined by the enabledWhen expression.&lt;br /&gt;
In our previous example, we saw the handler that is active when the selection at least contained one IFile. Now lets we want to enable it only when the total count of the selection is 2. We can specify it as:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;handler      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="com.eclipse_tips.commads.SomeCommandHandler1"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.commands.someCommand"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;activeWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable="selection"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;iterate       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operator="or"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;instanceof       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="org.eclipse.core.resources.IFile"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/instanceof&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/iterate&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/with&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/activeWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;enabledWhen&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;with       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable="selection"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;count       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="2"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/count&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/with&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/enabledWhen&amp;gt;       &lt;br /&gt;
&amp;lt;/handler&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: x-small;"&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt;
So the handler will be active and associated with the command, if the selection contains at least one IFile. Still the command will be enabled only if selection has exactly 2 elements. activeWhen and enabledWhen are similar - with respective to the expression language and lazy loading of the plugin until the command is executed. But there is small difference - your handler might be loaded iff the enabledWhen expression returns true and your plugin is already loaded. The enablement algo works this way:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;No enabledWhen specified, plugin is not loaded - command is enabled &lt;/li&gt;
&lt;li&gt;No enabledWhen specified, but plugin is loaded - consult handler.isEnabled() and set command accordingly &lt;/li&gt;
&lt;li&gt;enabledWhen specified, returns false, command is disabled (no matter plugin is loaded or not) &lt;/li&gt;
&lt;li&gt;enabledWhen specified, returns true, plugin is not loaded - command is enabled &lt;/li&gt;
&lt;li&gt;enabledWhen specified, returns true, plugin is loaded - consult handler.isEnabled() and set command accordingly &lt;/li&gt;
&lt;/ul&gt;So far we saw commands, handlers and their enablements. But what about generalizing a command? That can be done by adding parameters for a command. And that would be the next tip in this series.&lt;br /&gt;
&lt;br /&gt;
Update (31-Mar-2009): Thanks to Hiroki Kondo, a Japanese version of this blog entry is available &lt;a href="http://d.hatena.ne.jp/kompiro/20090326/1238082712"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See also:&lt;br /&gt;
Part 1: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-1-actions-vs-commands.html"&gt;Actions Vs Commands&lt;/a&gt;&lt;br /&gt;
Part 3: &lt;a href="http://blog.eclipse-tips.com/2008/12/commands-part-3-parameters-for-commands.html"&gt;Parameters for Commands&lt;/a&gt;&lt;br /&gt;
Part 4: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-4-misc-items.html"&gt;Misc items ...&lt;/a&gt;&lt;br /&gt;
Part 5: &lt;a href="http://blog.eclipse-tips.com/2009/02/commands-part-5-authentication-in-rcp.html"&gt;ISourceProvider &amp; dynamically updating Commands&lt;/a&gt;&lt;br /&gt;
Part 6: &lt;a href="http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html"&gt;'toggle' &amp; 'radio' style menu contribution&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-674024221056304653?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/6uSuzisT4CM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/674024221056304653/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=674024221056304653&amp;isPopup=true" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/674024221056304653?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/674024221056304653?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/6uSuzisT4CM/commands-part-2-selection-and.html" title="Commands Part 2: Selection and Enablement of IHandlers" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">8</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/01/commands-part-2-selection-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEUMRnsycSp7ImA9WxVbFEU.&quot;"><id>tag:blogger.com,1999:blog-1557780184357927241.post-7125788898108321876</id><published>2009-01-02T23:55:00.005+05:30</published><updated>2009-03-31T12:21:27.599+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-31T12:21:27.599+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jface" /><category scheme="http://www.blogger.com/atom/ns#" term="eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="Commands" /><category scheme="http://www.blogger.com/atom/ns#" term="workbench" /><title>Commands Part 1: Actions Vs Commands</title><content type="html">As you would have seen, there are two different ways to contributing to the Workbench: Actions and Commands. Although Commands are newer and advanced, I've always preferred using Actions, simply because of my comfort level in using them. Now that I've started fixing some bugs in the Command framework, I'm forced to look into the details. The more deeper I look into the Commands, the more I'm loving it. So I decided to write a series of on the Commands and this is the first one in the series. Many of the information presented here is obtained by looking some &lt;a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=154130"&gt;old&lt;/a&gt; &lt;a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=36968"&gt;bugs&lt;/a&gt;, &lt;a href="http://wiki.eclipse.org/index.php/Platform_UI_Command_Design"&gt;wiki&lt;/a&gt; and digging into CVS history&lt;a href="http://blog.eclipse-tips.com/"&gt;.&lt;/a&gt; If I'm missing anything or wrong about something let me know.&lt;br /&gt;
&lt;br /&gt;
Lets start with Actions. We are able to &lt;a href="http://www.eclipse.org/articles/article.php?file=Article-action-contribution/index.html"&gt;contribute to&lt;/a&gt; the menus, toolbars, pull down menu, etc. We are able to specify the UI details like label or tooltip in the plugin.xml itself, which helps in lazy loading. So whats wrong with them? &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;The UI and handling are always tied. There is no way you can separate each other &lt;/li&gt;
&lt;li&gt;While Actions can be contributed to different parts of the workbench (popup menu/tool bar), all of them were different extension points and so you end up duplicating the XML in multiple places. The worst of it is that not all the extension points expect the same configuration. &lt;/li&gt;
&lt;li&gt;Specifying Actions in multiple places is a maintenance nightmare. If you have to change the icon of an action, you need to change in all the places. &lt;/li&gt;
&lt;li&gt;Another issue with duplicating Actions in plugin.xml is that multiple instance of the same Actions will be created in the memory &lt;/li&gt;
&lt;/ul&gt;Lets see how the Commands Framework eliminates all this. Commands are defined by the org.eclipse.ui.commands extension point. A typical command would look like:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;command      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse-tips.commands.someCommand"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name="Some Command"&amp;gt;       &lt;br /&gt;
&amp;lt;/command&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Yeah thats it. That defines a Command! If you want to place this in a tool bar, you have to use the extension point org.eclipse.ui.menus:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;menuContribution      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; locationURI="toolbar:org.eclipse.ui.main.toolbar"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;toolbar       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse-tips.commands.toolbar1"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;command       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.commands.someCommand"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="com.eclipse-tips.commands.someCommandInToolBar"&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/command&amp;gt;       &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/toolbar&amp;gt;       &lt;br /&gt;
&amp;lt;/menuContribution&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: x-small;"&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt;
Now that takes of the placement in the UI. But what about the code that gets executed? That goes into a another extension point, org.eclipse.ui.handlers:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;handler      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="com.eclipse_tips.commads.SomeCommandHandler"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.commands.someCommand"&amp;gt;       &lt;br /&gt;
&amp;lt;/handler&amp;gt; &lt;/span&gt;    &lt;br /&gt;
&lt;br /&gt;
One last piece is to add an icon to the Command&lt;br /&gt;
No price for guessing that you need to use another extension point, org.eclipse.ui.commandImages:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: navy; font-family: Courier New; font-size: small;"&gt;&amp;lt;image      &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; commandId="com.eclipse-tips.commands.someCommand"       &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; icon="icons/sample.gif"&amp;gt;       &lt;br /&gt;
&amp;lt;/image&amp;gt;&lt;/span&gt;     &lt;br /&gt;
&lt;br /&gt;
All set. Lets see the Command in action:&lt;br /&gt;
&lt;a href="http://lh5.ggpht.com/_hsp14iFkRLs/SVpUL_137oI/AAAAAAAADVk/8sn6OBeOSlU/image9.png?imgmax=800"&gt;&lt;img alt="image" border="0" height="154" src="http://lh6.ggpht.com/_hsp14iFkRLs/SVpUVHAHzGI/AAAAAAAADVo/TbLu6O6qgIw/image_thumb5.png?imgmax=800" width="302" /&gt;&lt;/a&gt;&lt;br /&gt;
As you see, in the actions we would just use only one extension point, instead of the four which we have used now. Does it sounds like a round about way or doing things? Probably once we get to know about multiple handlers for a Command and context based association &amp;amp; enablement of the handlers etc, we will see the beauty of the framework. That would be the next in this series.&lt;br /&gt;
&lt;br /&gt;
Update (31-Mar-2009): Thanks to Hiroki Kondo, a Japanese version of this blog entry is available &lt;a href="http://d.hatena.ne.jp/kompiro/20090317/1237253828"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
See also:&lt;br /&gt;
Part 2: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-2-selection-and.html"&gt;Selection and Enablement of Handlers&lt;/a&gt;&lt;br /&gt;
Part 3: &lt;a href="http://blog.eclipse-tips.com/2008/12/commands-part-3-parameters-for-commands.html"&gt;Parameters for Commands&lt;/a&gt;&lt;br /&gt;
Part 4: &lt;a href="http://blog.eclipse-tips.com/2009/01/commands-part-4-misc-items.html"&gt;Misc items ...&lt;/a&gt;&lt;br /&gt;
Part 5: &lt;a href="http://blog.eclipse-tips.com/2009/02/commands-part-5-authentication-in-rcp.html"&gt;ISourceProvider &amp; dynamically updating Commands&lt;/a&gt;&lt;br /&gt;
Part 6: &lt;a href="http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html"&gt;'toggle' &amp; 'radio' style menu contribution&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p style="border: 1px solid rgb(198, 198, 198); padding: 10px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',sans-serif; font-size: 1.1em; background-color: rgb(255, 255, 198); margin-bottom: 10px;"&gt; 
From &lt;a href="http://blog.eclipse-tips.com/"&gt;Eclipse Tips&lt;/a&gt;
&lt;br/&gt;
Like the tip? Subscribe via &lt;a href="http://feeds.feedburner.com/cypal"&gt;RSS&lt;/a&gt; or &lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=cypal&amp;amp;loc=en_US"&gt;Email&lt;/a&gt;
&lt;/p&gt;
&lt;br/&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1557780184357927241-7125788898108321876?l=blog.eclipse-tips.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/cypal/~4/sRxHony7Q0E" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.eclipse-tips.com/feeds/7125788898108321876/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1557780184357927241&amp;postID=7125788898108321876&amp;isPopup=true" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/7125788898108321876?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1557780184357927241/posts/default/7125788898108321876?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/cypal/~3/sRxHony7Q0E/commands-part-1-actions-vs-commands.html" title="Commands Part 1: Actions Vs Commands" /><author><name>Prakash G.R.</name><uri>http://www.blogger.com/profile/13046268367318873066</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="08225524632456251201" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">8</thr:total><feedburner:origLink>http://blog.eclipse-tips.com/2009/01/commands-part-1-actions-vs-commands.html</feedburner:origLink></entry></feed>
