Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Add a Toggle Breakpoint Option in Popup Menu of WST Editor

DZone's Guide to

How to Add a Toggle Breakpoint Option in Popup Menu of WST Editor

· Java Zone ·
Free Resource

Microservices. Streaming data. Event Sourcing and CQRS. Concurrency, routing, self-healing, persistence, clustering...learn how Akka enables Java developers to do all this out of the box! Brought to you in partnership with Lightbend.

This problem is a little tricky if your custom editor is extending the WST editor. By default, the WST editor popup menu doesn’t contain the toggle breakpoint option as compared to the Java Editor. You can compare the popup menus shown by these two editors by looking at these figures.

 

Java                xml

              Java Editor – popupMenu                                  XML Editor - popupMenu

 

Now if you want to implement a toggle breakpoint into your pop up menu, you would need to follow the process given below:

The popup menu has two types of contribution, one is object contribution and the other is viewer contribution. For adding a toggle breakpoint in the pop up menu you need to implement viewer contribution. Here is the code snippet which will help you in implementation:

<extension point="org.eclipse.ui.popupMenus">
<viewerContribution id="com.xyz.debug.ui.RulerPopupActions"
targetID="com.xyz.Editor.ID">

<action
id="com.xyz.Editor.toggleBreakpointAction" label="Toggle Breakpoint"
class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
menubarPath="additions">
</action>
</viewerContribution>
</extension>

 

The trick involved here is to find the targetID for the viewer configuration. You can find it at many places. On the web targetID looks like ->

 >content type<.>editor type keyword<.>place to contribute keyword<

What if you want to know what the exact target ID of your editor? You can find exact target id by debugging AbstractTextEditor.getRulerContextMenuId() method which gives you the run time actual ruler context menu id (TargetId) of your custom editor.

Now you are good to go with setting up the toggle breakpoint in your custom language editor.

Microservices. Streaming data. Event Sourcing and CQRS. Concurrency, routing, self-healing, persistence, clustering...learn how Akka enables Java developers to do all this out of the box! Brought to you in partnership with Lightbend. 

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}