FileDocCategorySizeDatePackage
testOSX.javaAPI DocAzureus 3.0.3.43657Thu Feb 09 19:43:10 GMT 2006org.gudy.azureus2.ui.swt.nico

testOSX

public class testOSX extends Object
author
Olivier

Fields Summary
private org.eclipse.swt.widgets.Display
display
private org.eclipse.swt.widgets.Shell
mainWindow
Constructors Summary
public testOSX()


    //The Main Window
    display = new Display();
    mainWindow = new Shell(display, SWT.RESIZE | SWT.BORDER | SWT.CLOSE | SWT.MAX | SWT.MIN);
    mainWindow.setText("Test OSX"); //$NON-NLS-1$
    
    /*Listener printer = new Listener() { 
    	public void handleEvent(Event evt) { 
    		System.out.println("-->" + evt.type); 
    	}
    };
    mainWindow.addListener(SWT.Close,printer);
    mainWindow.addListener(SWT.Dispose,printer);
    mainWindow.addListener(SWT.KeyDown,printer);
    mainWindow.addListener(SWT.KeyUp,printer);
    */
      
    mainWindow.open();
    //mainWindow.forceActive();
    
    /*
    mainWindow.addDisposeListener(new DisposeListener() {
    	public void widgetDisposed(DisposeEvent arg0) {
    		System.out.println("NICO disposelistener 002\n");
    		if (mainWindow != null) {
    			System.out.println("NICO disposelistener 002a\n");
    			mainWindow.removeDisposeListener(this);
    			System.out.println("NICO disposelistener 002b\n");
    			dispose();
    			System.out.println("NICO disposelistener 002c\n");
    		}
    		System.out.println("NICO disposelistener 003\n");
    	}      
    });
    */

    mainWindow.addShellListener(new ShellAdapter() {
      public void shellClosed(ShellEvent event) {
        if(getExitConfirmation()) {
          dispose();
        } else {
          event.doit = false;
        }
      }
    });
  
Methods Summary
public voiddispose()

    if(mainWindow != null && ! mainWindow.isDisposed())
      mainWindow.dispose();
  
private booleangetExitConfirmation()

return
true, if the user choosed OK in the exit dialog
author
Rene Leonhardt

    MessageBox mb = new MessageBox(mainWindow, SWT.ICON_WARNING | SWT.YES | SWT.NO);
    mb.setText("Confirm");
    mb.setMessage("Do you really want to exit?");
    if(mb.open() == SWT.YES)
      return true;
    return false;
  
public static voidmain(java.lang.String[] args)

	
    testOSX mw = new testOSX();
    mw.waitForClose();
  
public voidwaitForClose()

  	while (!mainWindow.isDisposed()) {
  		try {
  			if (!display.readAndDispatch())
  				display.sleep();
  		}
  		catch (Exception e) {
  			Debug.printStackTrace( e );
  		}
  	}
  	display.dispose();