/*
 * Created on Aug 9, 2005
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package org.eclipse.ercp.eswt.sample;

import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.ercp.swt.mobile.*;


/**
 * @author administrator
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class Test implements Runnable, SelectionListener{

	Shell shell;
	Command exitCommand; 
	Button b;
	
	/* (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
	public void run() {
		Display display = new Display();
		shell = new Shell(display, SWT.CLOSE);
		shell.setLayout(new FillLayout());
		
		SortedList list = new SortedList(shell, SWT.NONE, SortedList.FILTER);
		list.add("Milk");
		list.add("Turkey");
		list.add("Banana");	
		Command listCommand = new Command(list, Command.SELECT, 1);
		listCommand.setText("Order"); //NON-NLS-1$
	
		
		DateEditor d = new DateEditor(shell, SWT.BORDER, DateEditor.DATE);
		
		b = new Button(shell, SWT.PUSH);
		b.setText(Msg.getString("Press Here")); //NON-NLS-1$
		b.addSelectionListener(this);
		
		exitCommand = new Command(shell, Command.EXIT, 0);
		exitCommand.setText(Msg.getString("Exit")); //NON-NLS-1$
		exitCommand.addSelectionListener(this);
		
		shell.layout();
		shell.open();
		
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
	}

	public void widgetSelected(SelectionEvent e) {
		if (e.widget == exitCommand)
			shell.dispose();
		else
			b.setText(Msg.getString("Thank you")); //NON-NLS-1$
	}
	
	public void widgetDefaultSelected(SelectionEvent e) {
		
	}
}
