6

I'm using eclipse RCP with a view and I want to print something on the console when the application is closed.

This is what I have done, but It's not working;

public void createPartControl(final Composite parent){
   parent.getShell().addListener(SWT.CLOSE, new Listener() {

      @Override
      public void handleEvent(Event event) {
         System.out.println("NOW !");
      }
   });
}

EDIT: I found a solution, I needed to add a DisposeListener:

parent.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                // TODO Auto-generated method stub

            }
        });
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Zbarcea Christian
  • 9,367
  • 22
  • 84
  • 137

1 Answers1

4

You want to use the SWT.Close event and not SWT.CLOSE. From the SWT Javadoc:

SWT.Close - The close event type (value is 21).

SWT.CLOSE - Style constant for close box trim (value is 1<<6, since we do not distinguish between CLOSE style and MENU style).

Community
  • 1
  • 1
Marc Baumbach
  • 10,323
  • 2
  • 30
  • 45