package test;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import transition.Transition;
import transition.TransitionListener;
import transition.Transitionable;
/**
* 2007
* @author Ahmed Mahran (ahmahran)
* ahmahran@gmail.com
*/
public class TransitionTest {
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="10,10"
private Button button = null;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/* Before this is run, be sure to set up the launch configuration (Arguments->VM Arguments)
* for the correct SWT library path in order to run with the SWT dlls.
* The dlls are located in the SWT plugin jar.
* For example, on Windows the Eclipse SWT 3.1 plugin jar is:
* installation_directory\plugins\org.eclipse.swt.win32_3.1.0.jar
*/
Display display = Display.getDefault();
TransitionTest thisClass = new TransitionTest();
thisClass.createSShell();
thisClass.sShell.open();
while (!thisClass.sShell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
/**
* This method initializes sShell
*/
private void createSShell() {
sShell = new Shell();
sShell.setText("Shell");
sShell.setSize(new Point(800, 600));
sShell.setLayout(new FillLayout());
button = new Button(sShell, SWT.NONE);
new Transition (new Transitionable() {
public void setSelection(int index) {
}
public int getSelection() {
return 0;
}
public Control getControl(int index) {
return button;
}
public Composite getComposite() {
return sShell;
}
public int compare(int index1, int index2) {
return 0;
}
public void addSelectionListener(final SelectionListener listener) {
button.addSelectionListener(listener);
}
}).addTransitionListener(new TransitionListener() {
public void transitionFinished(Transition transition) {
System.out.println("End Of Transition! current item: "
+ transition.getTransitionable().getSelection());
}
});
}
}