package gerenciamento_compra;

import gerenciamento_pagamento.InterfacePagamento;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
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 Principal {

	public static Display display;
	public static Shell shell;
	public static String login = null;

	// cookies
	public static String getName() {
		return login;
	}

	public static void setName(String loga) {
		login = loga;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		display = new Display();
		shell = new Shell(display);
		shell.setSize(700, 700);
		shell.setText("Mercado VR & CIA");

		Button button = new Button(shell, SWT.PUSH);
		button.setText("Produtos");
		button.setBounds(250, 100, 100, 50);
		Button button2 = new Button(shell, SWT.PUSH);
		button2.setText("Pagamentos");
		button2.setBounds(250, 200, 100, 50);
		Button button3 = new Button(shell, SWT.PUSH);
		button3.setText("Sair");		
		button3.setBounds(250, 500, 100, 50);
		Button button4 = new Button(shell, SWT.PUSH);
		button4.setText("Login");
		button4.setBounds(250, 300, 100, 50);

		Label text1 = new Label(shell, SWT.NONE);
		text1.setText("Supermercados VR");
		text1.setBounds(250, 30, 100, 20);		

		SelectionAdapter tipo1 = new SelectionAdapter() {
			public void widgetSelected(SelectionEvent arg0) {
				InterfaceCompra I_CompraProduto = new InterfaceCompra();
				I_CompraProduto.SolicitaCompra();
			}
		};

		SelectionAdapter tipo2 = new SelectionAdapter() {
			public void widgetSelected(SelectionEvent arg0) {
				InterfacePagamento I_PagaCompra = new InterfacePagamento();
				I_PagaCompra.SolicitaPagamento();
			}
		};

		SelectionAdapter tipo3 = new SelectionAdapter() {
			public void widgetSelected(SelectionEvent arg0) {
				display.dispose();
			}
		};

		SelectionAdapter tipo4 = new SelectionAdapter() {
			public void widgetSelected(SelectionEvent arg0) {
				InterfaceCompra logar = new InterfaceCompra();
				logar.loga_usuario();
			}
		};

		button.addSelectionListener(tipo1);
		button2.addSelectionListener(tipo2);
		button3.addSelectionListener(tipo3);
		button4.addSelectionListener(tipo4);

		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}

		display.dispose();
	}

}
