package dfatool.gui.wizard;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

public class CreationPage extends WizardPage{
	
	

	private Composite container;
	private Text name;

	protected CreationPage() {
		super("DFATool project");
	    setTitle("DFATool project");
	    setDescription("DFATool project wizard");
	}

	public void createControl(Composite parent) {
	    container = new Composite(parent, SWT.NONE);
	    GridLayout layout = new GridLayout();
	    container.setLayout(layout);
	    layout.numColumns = 2;
	    Label label1 = new Label(container, SWT.NONE);
	    label1.setText("Project name");
	    name = new Text(container, SWT.BORDER | SWT.SINGLE);
	    name.setText("");
	    name.addKeyListener(new KeyListener() {
			
			@Override
			public void keyReleased(KeyEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void keyPressed(KeyEvent e) {
				if (!name.getText().isEmpty()) {
			          setPageComplete(true);
	        	}
			}
		});
	    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	    name.setLayoutData(gd);
	    // required to avoid an error in the system
	    setControl(container);
	    setPageComplete(false);

	  }
	
	public String getName() {
		return name.getText();
	}

}
