We will now contribute a very basic status handler just to illustrate the steps needed to contribute a status handler implementation to the Workbench. To do this:
Here is the org.eclipse.ui.statusHandlers extension point markup:
<extension point="org.eclipse.ui.statusHandlers"> <statusHandler class="org.eclipse.ui.statushandlers.SampleStatusHandler" id="sampleStatusHandler"/> <statusHandlerProductBinding handlerId="sampleStatusHandler" productId="productId"> </statusHandlerProductBinding> </extension>
A statusHandler is registered with the Workbench. The statusHandlerProductBinding contribution tells the Workbench that the status handler we just defined is bound to our product with the id "productId". The status handling facility uses lazy initialization, so the handler will be instantiated during first access to the facility in the product.
The class defined by the class attribute extends org.eclipse.ui.statushandlers.AbstractStatusHandler
.
The following is sample code that simply writes to the console the message set in the status adapter.
public void handle(final StatusAdapter statusAdapter, int style) { System.out.println(statusAdapter.getStatus().getMessage()); }
When you run the product with the id defined in the statusHandlerProductBinding you will start to use your product handler. For example, if you are self hosting, create a new runtime-workbench launch configuration, choose the "Run a product" option, and select productId from the dropdown.