<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9216584232348687087</id><updated>2011-11-16T17:09:55.772-08:00</updated><title type='text'>Eclipse RCP Experiments</title><subtitle type='html'>Useful Eclipse RCP code snippets that I could not find anywhere else on the Internet</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9216584232348687087.post-8518404095391087510</id><published>2010-03-31T14:36:00.001-07:00</published><updated>2010-03-31T14:42:49.893-07:00</updated><title type='text'>How to remove unwanted Preference Pages from your RCP application</title><content type='html'>When you use some of the Eclipse IDE plugins they may contribute preference pages that you may not necessarily want to show to your users.&lt;br /&gt;&lt;br /&gt;Remove them in the ApplicationWorkbenchWindowAdvisor.postWindowCreate():&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;PreferenceManager pm = PlatformUI.getWorkbench( ).getPreferenceManager();&lt;br /&gt;pm.remove("org.eclipse.ui.preferencePages.Workbench");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The "org.eclipse.ui.preferencePages.Workbench" id removes the "General" preference page group. If you do not know the id for the page you want to remove. You can first print them like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;PreferenceManager pm = PlatformUI.getWorkbench( ).getPreferenceManager();&lt;br /&gt;IPreferenceNode[] arr = pm.getRootSubNodes();&lt;br /&gt;        &lt;br /&gt;for(IPreferenceNode pn:arr){&lt;br /&gt;    System.out.println("Label:" + pn.getLabelText() + " ID:" + pn.getId());&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9216584232348687087-8518404095391087510?l=rcpexperiments.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/8518404095391087510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9216584232348687087&amp;postID=8518404095391087510' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/8518404095391087510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/8518404095391087510'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/2010/03/how-to-remove-unwanted-preference-pages.html' title='How to remove unwanted Preference Pages from your RCP application'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9216584232348687087.post-4036862007170235604</id><published>2010-03-19T10:01:00.000-07:00</published><updated>2010-03-19T10:30:12.074-07:00</updated><title type='text'>Setting colors and fonts for a table cell in SWT/JFace</title><content type='html'>&lt;span style="font-size:180%;"&gt;How to set color and font for a table cell using TableViewer in JFace?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;All you need to do is make your ITableLabelProvider implementation also implement &lt;a href="http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/viewers/ITableFontProvider.html"&gt;ITableFontProvider&lt;/a&gt; and &lt;a href="http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/viewers/ITableColorProvider.html"&gt;ITableColorProvider&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;public class TypeLabelProvider implements ITableLabelProvider, &lt;br /&gt;ITableFontProvider, ITableColorProvider {&lt;br /&gt;     ...&lt;br /&gt;     ...&lt;br /&gt;     ITableLabelProvider methods&lt;br /&gt;     ...&lt;br /&gt;     ...&lt;br /&gt;&lt;br /&gt;     @Override&lt;br /&gt;     public Font getFont(Object element, int columnIndex) {&lt;br /&gt;           return JFaceResources.getFontRegistry().getBold(&lt;br /&gt;                                   JFaceResources.DIALOG_FONT);&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     @Override&lt;br /&gt;     public Color getBackground(Object element, int columnIndex) {&lt;br /&gt;           return new Color(display, new RGB(125,189,0));&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     @Override&lt;br /&gt;     public Color getForeground(Object element, int columnIndex) {&lt;br /&gt;         return new Color(display, new RGB(125,189,0));&lt;br /&gt;     }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9216584232348687087-4036862007170235604?l=rcpexperiments.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/4036862007170235604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9216584232348687087&amp;postID=4036862007170235604' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/4036862007170235604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/4036862007170235604'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/2010/03/setting-colors-and-fonts-for-table-cell.html' title='Setting colors and fonts for a table cell in SWT/JFace'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9216584232348687087.post-2711236785364864810</id><published>2009-07-17T10:11:00.000-07:00</published><updated>2009-07-17T11:22:55.893-07:00</updated><title type='text'>Commands, key Bindings and Contexts in Eclipse RCP</title><content type='html'>&lt;span style="font-size:180%;"&gt;How to create a key binding in your Eclipse RCP application?&lt;/span&gt;&lt;br /&gt;You need to create a command and its command handler and then create a key binding for it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;1. Define a command:&lt;/span&gt;&lt;br /&gt;See an example below for a Save command:&lt;br /&gt;I have a defaulthandler specified and I have categorized this command under the MyCategory category. This is useful when this command is shown in the Keys view in the Preferences dialog.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;extension point="org.eclipse.ui.commands"&amp;gt;&lt;br /&gt;   &amp;lt;category description="My category for commands" id="MyCategory" name="My Category"&amp;gt;&lt;br /&gt;   &amp;lt;/category&amp;gt;&lt;br /&gt;   &amp;lt;command categoryid="MyCategory" description="Save the active screen" defaulthandler="my.package.MySaveHandler" id="save.command" name="Save"&amp;gt;&lt;br /&gt;   &amp;lt;/command&amp;gt;&lt;br /&gt;&amp;lt;/extension&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;2. Create a command handler for the command:&lt;/span&gt;&lt;br /&gt;In the above step I defined the defaultHandler as my.package.MySaveHandler. This is the fully qualified class name for the handler class that implements IHandler. This is called when this command is executed.&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;3. Create a key binding for and bind it to the command:&lt;/span&gt;&lt;br /&gt;Shown below is the minimal key binding for the CTRL+S key sequence. It is bound to the save command through the commandId property. the schemeId  is set to the default key binding scheme. This works for me because there arent any other key bindings for CTRL+S defined in the default scheme. If you are faced with a situation where the default scheme already has a binding for your sequence, then you can either define your key binding in another scheme (See the 'Defining your own key binding scheme' section below for more information.) or you can define your key binding's active context. ( See How to selectively enable or disable the key binding)&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;extension point="org.eclipse.ui.bindings"&amp;gt;&lt;br /&gt;   &amp;lt;key commandid="save.command" schemeid="org.eclipse.ui.defaultAcceleratorConfiguration" sequence="M1+S"&amp;gt;&lt;br /&gt;   &amp;lt;/key&amp;gt;&lt;br /&gt;&amp;lt;/extension&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;How to selectively enable or disable the key binding?&lt;/span&gt;&lt;br /&gt;This is the same as enabling or disabling the command associated with the key binding.&lt;br /&gt;&lt;br /&gt;You do this by using the org.eclipse.ui.handlers extension point. In the example below I enable my handler for the command only if a specific part is active&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;extension point="org.eclipse.ui.handlers"&amp;gt;&lt;br /&gt;   &amp;lt;handler class="my.package.MySaveHandler" commandid="save.command"&amp;gt;&lt;br /&gt;      &amp;lt;enabledwhen&amp;gt;&lt;br /&gt;       &amp;lt;with variable="activePartId"&amp;gt;&lt;br /&gt;          &amp;lt;equals value="my.package.editors.MyEditor"&amp;gt;&lt;br /&gt;         &amp;lt;/equals&amp;gt;&lt;br /&gt;      &amp;lt;/with&amp;gt;&lt;br /&gt;   &amp;lt;/enabledwhen&amp;gt;&lt;br /&gt;&amp;lt;/handler&amp;gt;&lt;br /&gt;&amp;lt;/extension&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The handlers extension is also useful when you want to have multiple handlers for the same command. For e.g. if you want your save command to save the currently active editor, and you have different types of editors in your application each requiring a different saving mechanism, you can define three different handlers, bind them all to the Save command through the commandId property and just make sure only one of them is active based on which editor is active at the time the command is invoked. Actually, when it comes to editors you can get away with one handler because all editors that extend IEditorPart have a doSave method anyways which can be called by the common handler. You implement your differing save mechanisms by overriding the doSave method in your editor.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;How to override an existing key binding?&lt;/span&gt;&lt;br /&gt;There are two ways to do this, one, by defining your key binding in your own scheme, or two, by defining the context in which this key binding is active.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;1. Defining your own key binding scheme:&lt;/span&gt;&lt;br /&gt;Using the bindings extension point you can define your own scheme and then using the schemeId property of the key element you can define your key binding to belong to your schema.&lt;br /&gt;See &lt;a href="http://www.vogella.de/articles/EclipseCommands/article.html#keybinding"&gt;this Vogel.de tutorial&lt;/a&gt; on how to do this.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;2: Defining context for your key binding:&lt;/span&gt;&lt;br /&gt;there are three steps as shown below...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;a. Define your context: &lt;/span&gt;&lt;br /&gt;You can do this using the org.eclipse.ui.contexts extension.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;extension point="org.eclipse.ui.contexts"&amp;gt;&lt;br /&gt;    &amp;lt;context id="my.context" name="My Context" parentid="org.eclipse.ui.contexts.window"&amp;gt;&lt;br /&gt;    &amp;lt;/context&amp;gt;&lt;br /&gt;&amp;lt;/extension&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;&lt;br /&gt;&lt;br /&gt;b. Set the key binding's context to the one you defined in a.:&lt;/span&gt;&lt;br /&gt;Each key binding has the contextId property that you can use for this..&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; &amp;lt;extension point="org.eclipse.ui.bindings"&amp;gt;&lt;br /&gt;    &amp;lt;key commandid="save.command" contextid="my.context" schemeid="org.eclipse.ui.defaultAcceleratorConfiguration" sequence="M1+S"&amp;gt;&lt;br /&gt;    &amp;lt;/key&amp;gt;&lt;br /&gt; &amp;lt;/extension&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;c. Switch the context in your application&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {&lt;br /&gt;   public void run() {&lt;br /&gt;    ((IContextService) PlatformUI.getWorkbench()&lt;br /&gt;     .getService(IContextService.class))&lt;br /&gt;      .activateContext("my.context");&lt;br /&gt;   }&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you want to do this at the start a good place to do it is in the createInitialLayout method of the IPerspectiveFactory class.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Resources:&lt;/span&gt;&lt;br /&gt;http://www.vogella.de/articles/EclipseCommands/article.html#keybinding&lt;br /&gt;http://sry-for-my-english.blogspot.com/2007/05/rcp-keybinding-issues.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9216584232348687087-2711236785364864810?l=rcpexperiments.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/2711236785364864810/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9216584232348687087&amp;postID=2711236785364864810' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/2711236785364864810'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/2711236785364864810'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/2009/07/commands-key-bindings-and-contexts-in.html' title='Commands, key Bindings and Contexts in Eclipse RCP'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9216584232348687087.post-268331192072198708</id><published>2009-07-08T08:36:00.001-07:00</published><updated>2009-07-08T08:50:14.644-07:00</updated><title type='text'>How to show children of matched tree nodes in a Filtered Tree</title><content type='html'>When you use the FilteredTree with a PatternFilter, the visible nodes include the leaves as well as their parents in the tree that match the filter text. However if your usecase requires that a matched node's children also be shown then you need to use a custom PatternFilter which will select an element if any of its ancestors are a match.&lt;br /&gt;&lt;br /&gt;Here is how I did it:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class ShowChildrenPatternFilter extends PatternFilter {&lt;br /&gt;&lt;br /&gt; protected boolean isChildMatch(Viewer viewer, Object element) {&lt;br /&gt;  System.out.println("inchildmatch");&lt;br /&gt;  Object parent = ((ITreeContentProvider) ((AbstractTreeViewer) viewer)&lt;br /&gt;             .getContentProvider()).getParent(element);&lt;br /&gt;&lt;br /&gt;  if(parent!=null){&lt;br /&gt;   return (isLeafMatch(viewer, parent)?true:isChildMatch(viewer,parent));&lt;br /&gt;  }&lt;br /&gt;  return false;&lt;br /&gt; &lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; &lt;br /&gt; @Override&lt;br /&gt; protected boolean isLeafMatch(Viewer viewer, Object element) {&lt;br /&gt;  String labelText = ((ILabelProvider) ((StructuredViewer) viewer)&lt;br /&gt;             .getLabelProvider()).getText(element);&lt;br /&gt;  &lt;br /&gt;     if(labelText == null) {&lt;br /&gt;   return false;&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;     return (wordMatches(labelText)?true:isChildMatch(viewer, element));&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Now from a good UI design perspective we should also show the actual pattern matches in a bold font similar to how the default Preferences Dialog filtered tree works.&lt;br /&gt;&lt;br /&gt;For that we need our ILabelProvider to implement IFontProvider and in the getFont method we need to call the FilteredTree.getBoldFont method. This method takes a PatternFilter as an argument. This is the filter that is used to select which elements are shown in bold. Since we just want our true matches ( and not their children) to be bolded, we cannot use our modified ShowChildrenPatterFilter. Instead we can just use the regular PatternFilter here. Here is how your LabelProvider class will look:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class MyFilteredTreeLabelProvider implements ILabelProvider,IFontProvider {&lt;br /&gt;&lt;br /&gt;&lt;object,image&gt;&lt;object,image&gt; private FilteredTree filterTree;&lt;br /&gt; private PatternFilter filterForBoldElements = new PatternFilter();&lt;br /&gt;&lt;br /&gt; public TypeSystemTreeLabelProvider(FilteredTree filterTree) {&lt;br /&gt;  super();&lt;br /&gt;  this.filterTree = filterTree;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; @Override&lt;br /&gt; public String getText(Object element) {&lt;br /&gt;      //your code to get the display text for the element&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; @Override&lt;br /&gt; public void addListener(ILabelProviderListener listener) {}&lt;br /&gt;&lt;br /&gt; @Override&lt;br /&gt; public void dispose() {}&lt;br /&gt;&lt;br /&gt; @Override&lt;br /&gt; public boolean isLabelProperty(Object element, String property) {&lt;br /&gt;  return false;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; @Override&lt;br /&gt; public void removeListener(ILabelProviderListener listener) {}&lt;br /&gt; &lt;br /&gt; public Font getFont(Object element) {&lt;br /&gt;  return FilteredTree.getBoldFont(element, filterTree,&lt;br /&gt;    filterForBoldElements);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/object,image&gt;&lt;/object,image&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9216584232348687087-268331192072198708?l=rcpexperiments.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/268331192072198708/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9216584232348687087&amp;postID=268331192072198708' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/268331192072198708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/268331192072198708'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/2009/07/how-to-show-children-of-matched-tree.html' title='How to show children of matched tree nodes in a Filtered Tree'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9216584232348687087.post-1186187751986765265</id><published>2009-07-06T15:03:00.000-07:00</published><updated>2009-07-06T15:56:16.307-07:00</updated><title type='text'>AnnotationPainter does not highlight annotations</title><content type='html'>If you are using Annotations to do some text decorations and highlighting in your TextEditor or StatusTextEditor sub classes, you have to make sure to add the AnnotationPainter as a TextPresentationListener to the SourceViewer, in addition to adding it as a Painter. This is required when you want to use text styling strategies (ITextStyleStrategy) instead of the IDrawingStrategy.&lt;br /&gt;&lt;br /&gt;The easiest way to highlight text in your color using the AnnotationPainter is to use its inbuilt addHighlightAnnotationType method.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class AnnotatedDocumentEditor extends StatusTextEditor{&lt;br /&gt;&lt;br /&gt; public static final String ID = "edu.pitt.dbmi.odie.ui.editors.AnnotatedDocumentEditor";&lt;br /&gt; private AnnotationPainter annotationPainter;&lt;br /&gt; &lt;br /&gt; public AnnotatedDocumentEditor() {&lt;br /&gt;  super();&lt;br /&gt;  setDocumentProvider(new AnnotatedDocumentProvider());&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; @Override&lt;br /&gt; protected ISourceViewer createSourceViewer(Composite parent,&lt;br /&gt;   IVerticalRuler ruler, int styles) {&lt;br /&gt;  SourceViewer sv = (SourceViewer) super.createSourceViewer(parent, ruler, styles);&lt;br /&gt;  initAnnotationPainter(sv);&lt;br /&gt;  &lt;br /&gt;  sv.addPainter(annotationPainter);&lt;br /&gt;  sv.addTextPresentationListener(annotationPainter);&lt;br /&gt;  return sv;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; private void initAnnotationPainter(SourceViewer sv) {&lt;br /&gt;  IAnnotationAccess annotationAccess = new IAnnotationAccess() {&lt;br /&gt;   public Object getType(Annotation annotation) {&lt;br /&gt;       return annotation.getType();&lt;br /&gt;   }&lt;br /&gt;   public boolean isMultiLine(Annotation annotation) {&lt;br /&gt;       return true;&lt;br /&gt;   }&lt;br /&gt;   public boolean isTemporary(Annotation annotation) {&lt;br /&gt;       return true;&lt;br /&gt;   }&lt;br /&gt;  };&lt;br /&gt;   &lt;br /&gt;  annotationPainter = new AnnotationPainter(sv,annotationAccess);&lt;br /&gt;  &lt;br /&gt;  annotationPainter.addHighlightAnnotationType("DUMMY1");&lt;br /&gt;  annotationPainter.addHighlightAnnotationType("DUMMY2");&lt;br /&gt;  annotationPainter.addHighlightAnnotationType("DUMMY3");&lt;br /&gt;  &lt;br /&gt;  Display display = Display.getDefault();&lt;br /&gt;  &lt;br /&gt;  annotationPainter.setAnnotationTypeColor("DUMMY1", new Color(display, new RGB(125,189,0)));&lt;br /&gt;  annotationPainter.setAnnotationTypeColor("DUMMY2", new Color(display, new RGB(228,142,52)));&lt;br /&gt;  annotationPainter.setAnnotationTypeColor("DUMMY3", new Color(display, new RGB(244,229,61)));&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Please note that the above code is not complete. You need to create the AnnotationModel for each document using your implementation of the AbstractDocumentProvider&lt;br /&gt;&lt;br /&gt;See the following links for good tutorials on using AnnotationPainter and extending TextEditors in Eclipse:&lt;br /&gt;&lt;br /&gt;http://eclipse.dzone.com/articles/beyond-rich-text-tricks-using-&lt;br /&gt;http://www.realsolve.co.uk/site/tech/jface-text.php&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9216584232348687087-1186187751986765265?l=rcpexperiments.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/1186187751986765265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9216584232348687087&amp;postID=1186187751986765265' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/1186187751986765265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/1186187751986765265'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/2009/07/annotationpainter-does-not-highlight.html' title='AnnotationPainter does not highlight annotations'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9216584232348687087.post-6032730894102767637</id><published>2009-07-01T11:25:00.000-07:00</published><updated>2009-07-08T11:27:13.808-07:00</updated><title type='text'>Indeterminate progress  bar in Eclipse RCP</title><content type='html'>If you dont know the amount of work involved you need an indeterminate progress bar.&lt;br /&gt;&lt;br /&gt;If using ProgressMonitorDialog, in the run method of IRunnableWithProgress, instead of specifying an integer indicating the total as an argument do this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public void run(IProgressMonitor monitor) throws InvocationTargetException,InterruptedException {&lt;br /&gt;     monitor.beginTask("Task name",IProgressMonitor.UNKNOWN);&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9216584232348687087-6032730894102767637?l=rcpexperiments.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/6032730894102767637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9216584232348687087&amp;postID=6032730894102767637' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/6032730894102767637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/6032730894102767637'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/2009/07/indeterminate-progress-bar-in-eclipse.html' title='Indeterminate progress  bar in Eclipse RCP'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9216584232348687087.post-1359637881966421375</id><published>2008-10-27T07:25:00.000-07:00</published><updated>2009-07-08T11:30:48.269-07:00</updated><title type='text'>how to add the slope / swoosh to tabs in RCP</title><content type='html'>&lt;div&gt;I looked for this for a while. Eclipse 3.x has the swooshed tab headers that taper towards the end. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To get that in your RCP application where you may use IFolderLayout to group views, or have multiple editors you need to make your Eclipse application a product and do the following:&lt;/div&gt;&lt;div&gt;&lt;a href="http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/msg07001.html"&gt;http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/msg07001.html&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;To get the swoosh on any tabfolder that you create in your code. You have to use CTabFolder as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;CTabFolder tabFolder = new CTabFolder(shell, SWT.CLOSE | SWT.BOTTOM);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The following line does the magic: &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;tabFolder.setSimple(false);&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9216584232348687087-1359637881966421375?l=rcpexperiments.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/1359637881966421375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9216584232348687087&amp;postID=1359637881966421375' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/1359637881966421375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/1359637881966421375'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/2008/10/how-to-add-slope-swoosh-to-tabs-in-rcp.html' title='how to add the slope / swoosh to tabs in RCP'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9216584232348687087.post-746837363424702420</id><published>2008-09-10T14:19:00.001-07:00</published><updated>2009-07-08T11:28:51.935-07:00</updated><title type='text'>Find a view</title><content type='html'>&lt;div&gt;The following technique can be used to get the currently active page and any view within that page.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();&lt;br /&gt;IViewPart view = page.findView(MyView.ID);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The MyView.ID specified the ID of the view as declared in the plugin.xml file.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9216584232348687087-746837363424702420?l=rcpexperiments.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/746837363424702420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9216584232348687087&amp;postID=746837363424702420' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/746837363424702420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/746837363424702420'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/2008/09/find-view.html' title='Find a view'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9216584232348687087.post-4214384940615094403</id><published>2008-09-10T09:13:00.000-07:00</published><updated>2008-09-10T11:16:23.177-07:00</updated><title type='text'>JFace Dialog in an RCP application</title><content type='html'>If you want to add a custom dialog to a JFace application the easiest way is to override the JFace Dialog class as follows:&lt;br /&gt;&lt;pre style="font-size:110%;background-color:#E8E8E8;"&gt;public class MyDialog extends Dialog {&lt;br /&gt;/**&lt;br /&gt;* @param parentShell&lt;br /&gt;*/&lt;br /&gt;public MyDialog(Shell parentShell) {&lt;br /&gt;super(parentShell);&lt;br /&gt;&lt;br /&gt;        //forces open method to block until window is closed.&lt;br /&gt;setBlockOnOpen(true);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;protected void createButtonsForButtonBar(Composite parent) {&lt;br /&gt;createButton(parent, IDialogConstants.OK_ID,&lt;br /&gt;      IDialogConstants.OK_LABEL, true);&lt;br /&gt;  createButton(parent, IDialogConstants.CANCEL_ID,&lt;br /&gt;      IDialogConstants.CANCEL_LABEL, false);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;protected Control createDialogArea(Composite parent) {&lt;br /&gt;&lt;br /&gt;Composite container = (Composite) super.createDialogArea(parent);&lt;br /&gt;&lt;br /&gt;Label nameLabel = new Label(container,SWT.NONE);&lt;br /&gt;nameLabel.setText("Name:");&lt;br /&gt;Text nameText = new Text(container, SWT.BORDER);&lt;br /&gt;&lt;br /&gt;return container;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;The way you call it within any Action is as follows:&lt;br /&gt;&lt;pre style="font-size:110%;background-color:#E8E8E8;"&gt;MyDialog d = new MyDialog(Display.getCurrent().getActiveShell());&lt;br /&gt;int status = d.open();&lt;br /&gt;&lt;/pre&gt;For this example the open method will return OK or CANCEL. It is user-definable by overriding the getReturnCode() method on Dialog.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Make the Dialog resizable&lt;/span&gt;&lt;div&gt;By default it isnt, You must call this in the Dialog constructor:&lt;/div&gt;&lt;pre style="font-size: 110%; background-color: rgb(232, 232, 232); "&gt;Dialog.setShellStyle(SWT.RESIZE)&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Change the Dialog title&lt;/span&gt;&lt;div&gt;You need to override the Window.configureShell method as follows&lt;/div&gt;&lt;pre style="font-size: 110%; background-color: rgb(232, 232, 232); "&gt;&lt;br /&gt;protected void configureShell(Shell newShell) {&lt;br /&gt;  super.configureShell(newShell);&lt;br /&gt;  newShell.setText("My Dialog Title");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9216584232348687087-4214384940615094403?l=rcpexperiments.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/4214384940615094403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9216584232348687087&amp;postID=4214384940615094403' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/4214384940615094403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/4214384940615094403'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/2008/09/jface-dialog-in-rcp-application.html' title='JFace Dialog in an RCP application'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9216584232348687087.post-3680076386750830177</id><published>2008-09-10T08:11:00.000-07:00</published><updated>2008-09-10T08:33:47.845-07:00</updated><title type='text'>First!!</title><content type='html'>When I started working on a new project at work, I had to decide on the UI platform I wanted to develop in. We have considerable Java experience in-house and hence we were limited to something on the Java platform. I have considerable experience designing in Swing, but I was really smitten by the Eclipse IDE UI. After researching other options that were available, Eclipse RCP seemed to be the most robust, with a well developed code-base, community support and online resources. However as I have started to work with Eclipse RCP, I realized that versions changed quite often and the literature wasnt keeping up. Good online resources that really go in-depth and teach complex tasks were very scarce. The best way to learn how to do stuff was to look at the Eclipse IDE codebase.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I started this blog as a place to document RCP/JFace/SWT tips and tricks that I learnt the hard way.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9216584232348687087-3680076386750830177?l=rcpexperiments.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rcpexperiments.blogspot.com/feeds/3680076386750830177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9216584232348687087&amp;postID=3680076386750830177' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/3680076386750830177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9216584232348687087/posts/default/3680076386750830177'/><link rel='alternate' type='text/html' href='http://rcpexperiments.blogspot.com/2008/09/first.html' title='First!!'/><author><name>Girish</name><uri>http://www.blogger.com/profile/06511369763973586739</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://bp3.blogger.com/_WTC3LEED-OU/R4V8atQWswI/AAAAAAAAByg/-1i3HubFUWY/S220/megoodboy.png'/></author><thr:total>0</thr:total></entry></feed>
