package FIT.Menus;

import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

import FIT.AgentGUI;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class TextIn extends org.eclipse.swt.widgets.Composite {
	private Text Input;
	private Button Submit;
	private AgentGUI myParent;


	public TextIn(Composite parent, int style, int num, int rows, String[] labels, String[] tasks) {
		super(parent, style);
		myParent = (AgentGUI)this.getParent();
		initGUI();
		setButtonLabel(labels[0]);
	}

	private void initGUI() {
		try {
			this.setLayout(new FormLayout());
			this.setSize(600, 350);
			{
				FormData SubmitLData = new FormData();
				SubmitLData.width = 59;
				SubmitLData.height = 49;
				SubmitLData.left =  new FormAttachment(0, 1000, 451);
				SubmitLData.top =  new FormAttachment(0, 1000, 121);
				Submit = new Button(this, SWT.PUSH | SWT.CENTER);
				Submit.setLayoutData(SubmitLData);
				Submit.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent evt) {
						SubmitWidgetSelected(evt);
					}
				});
			}
			{
				FormData InputLData = new FormData();
				InputLData.width = 379;
				InputLData.height = 49;
				InputLData.left =  new FormAttachment(0, 1000, 46);
				InputLData.top =  new FormAttachment(0, 1000, 119);
				Input = new Text(this, SWT.BORDER);
				Input.setLayoutData(InputLData);
			}
			this.layout();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void SubmitWidgetSelected(SelectionEvent evt) {
		myParent.handleText(Input.getText());
	}

	public void setButtonLabel(String btn1) {
		Submit.setText(btn1);
	}

}
