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?
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:
- It takes 3 steps.
- 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:
- Subclass SelectMarkerRulerAction to invoke your desired action. Please refer to the example class PDESelectAnnotationRulerAction.
- In your text editor, override the method createActions, to set the RulerClick action. The example class is PDESourcePage, and the code snipet:
-
-
protected void createActions() {
-
super.createActions();
-
PDESelectAnnotationRulerAction action = new PDESelectAnnotationRulerAction(getBundleForConstructedKeys(), "PDESelectAnnotationRulerAction.", this, getVerticalRuler()); //$NON-NLS-1$
-
setAction(ITextEditorActionConstants.RULER_CLICK, action);
-
}
-
-
