Mar 03

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?

problem_marker_action

Last week I talked about it in the blog post http://www.frankdu.com/weblog/archives/44. 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:
    1.  
    2. protected void createActions() {
    3.         super.createActions();
    4.         PDESelectAnnotationRulerAction action = new PDESelectAnnotationRulerAction(getBundleForConstructedKeys(), "PDESelectAnnotationRulerAction.", this, getVerticalRuler()); //$NON-NLS-1$
    5.         setAction(ITextEditorActionConstants.RULER_CLICK, action);
    6. }
    7.  
  • Share/Bookmark