capint
11/21/2016 - 2:55 PM

Eclipse >> Status handling >> Define a status handler

Eclipse >> Status handling >> Define a status handler

>> 2 ways for contributing handlers to the Workbench:
  1. Using the org.eclipse.ui.statusHandlers extension point
    >> Specify the handler and the binding to a product:
      <extension point="org.eclipse.ui.statusHandlers"> 
        <statusHandler
              class="org.eclipse.ui.statushandlers.SampleStatusHandler"
              id="sampleStatusHandler"/>
        <statusHandlerProductBinding
              handlerId="sampleStatusHandler"
              productId="productId">
        </statusHandlerProductBinding>
      </extension> 
  2. Using a custom workbench advisor and overriding its getWorkbenchErrorHandler() method
    >> Create a custom workbench advisor:
      public class CustomWorkbenchAdvisor extends WorkbenchAdvisor {
        public AbstractStatusHandler getWorkbenchErrorHandler() {
           ...
           
           return customStatusHandler;
        }
      }
    >> Call the custom workbench advisor in the application:
      public class CustomApplication implements IApplication{
        public Object start(IApplicationContext appContext) throws Exception {
           ...
           Display display = createDisplay();
           PlatformUI.createAndRunWorkbench(display, new CustomWorkbenchAdvisor());
           ...
        }
  
        protected Display createDisplay() {
           return PlatformUI.createDisplay();
        }
      }