package com.genuitec.piplug.poc;

import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class PiPlugPOCApplication implements IApplication {

	@Override
	public Object start(IApplicationContext context) throws Exception {
		Display display = new Display();
		Rectangle bounds = display.getBounds();
		final Shell shell = new Shell(display, SWT.CLOSE);
		shell.setBounds(0, 0, bounds.width, bounds.height);
		shell.setLayout(new GridLayout(1, false));
		final Label label = new Label(shell, SWT.NONE);
		label.setText("Hello to your Pi.");
		label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
		Button button = new Button(shell, SWT.FLAT);
		button.setText("Click Me");
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent arg0) {
				label.setText("We have been clicked.");
				shell.layout(true);
			}
		});
		button.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
		button = new Button(shell, SWT.FLAT);
		button.setText("Close Me");
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent arg0) {
				shell.close();
				shell.dispose();
			}
		});
		button.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
		shell.setMaximized(true);
		shell.open();
		
		// run the display loop
		while (display.sleep() && !shell.isDisposed()) {
			while (display.readAndDispatch() && !shell.isDisposed());
		}
		return new Integer(0);
	}

	@Override
	public void stop() {
		// nothing to do
	}
}
@@ -794,13 +794,15 @@
 SWT.
-CLOSE
+NO_TRIM
 );%0A%09
@@ -1801,32 +1801,55 @@
 y loop%0A%09%09while (
+!shell.isDisposed() && 
 display.sleep() 
@@ -1847,20 +1847,30 @@
 .sleep()
- && 
+) %7B%0A%09%09%09while (
 !shell.i
@@ -1880,30 +1880,21 @@
 sposed()
-) %7B%0A%09%09%09while (
+ && %09
 display.
@@ -1914,31 +1914,8 @@
 ch()
- && !shell.isDisposed()
 );%0A%09

Switch to NO_TRIM