Eclipse: How to add actions for marker clicking

Let’s say that your XML code is invalid in certain line. There is a relative problem marker placed on the vertical ruler. Like the picture below. Now you wish to make the red problem marker click-able, to invoke certain actions, such as pop up quick-fix suggestions. How to do it?


Last week I talked about it in the blog post However, there are two issues with the method:

  1. It takes 3 steps.
  2. It doesn’t work with a MultiPageEditorPart. This is a huge problem.

Well, now let’s do it in a better way. It takes two steps, and works with MultiPageEditorPart. Here we go:

  1. Subclass SelectMarkerRulerAction to invoke your desired action. Please refer to the example class PDESelectAnnotationRulerAction.
  2. In your text editor, override the method createActions, to set the RulerClick action. The example class is PDESourcePage, and the code snipet:
This entry was posted in eclipse and tagged , , , , , , . Bookmark the permalink.

One Response to Eclipse: How to add actions for marker clicking

  1. xcrow says:

    Many-many thanks frank, this code is that I searched for a long time. It works perfectly!
    However, can you exlpain, what does getBundleForConstructedKeys and how to use it? What kind of ResourceBundle is this?

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.