title: Java close listener for ViewPart
body: <p>I'm using eclipse RCP with a view and I want to print something on the console when the application is closed.</p>
  
  <p>This is what I have done, but It's not working;</p>
  
  <pre><code>public void createPartControl(final Composite parent){
     parent.getShell().addListener(SWT.CLOSE, new Listener() {
  
        @Override
        public void handleEvent(Event event) {
           System.out.println("NOW !");
        }
     });
  }
  </code></pre>
  
  <p><strong>EDIT:</strong>
  I found a solution, I needed to add a DisposeListener:</p>
  
  <pre><code>parent.addDisposeListener(new DisposeListener() {
  
              @Override
              public void widgetDisposed(DisposeEvent e) {
                  // TODO Auto-generated method stub
  
              }
          });
  </code></pre>