package com.impart.kurs.swt;

import java.util.Vector;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Resource;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

public class PersonTable extends Composite {
	Composite parent=null;
	Display display=null;
	Vector vResource = new Vector();
	
	Table table=null;

	public PersonTable(Composite parent, int style) {
		super(parent, style);
		this.parent=parent;
		display=parent.getDisplay();
		this.setSize(200,200);
		this.setLayout(new FillLayout());
		createPartControl();
	}
	protected void createPartControl() {
		Group group=new Group(this, this.getStyle());
		group.setText("Person");
		FormLayout formLayout = new FormLayout ();
		formLayout.marginHeight = 10;
		formLayout.marginWidth = 10;
		group.setLayout(formLayout);

		table=new Table(group,SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
		table.setLinesVisible(true);
		table.setHeaderVisible(true);
		FormData tableData=new FormData();
		tableData.height=50;
		table.setLayoutData(tableData);
		table.addSelectionListener(new SelectionAdapter(){

			@Override
			public void widgetSelected(SelectionEvent e) {
				table.getBounds();
			}
			
		});
		
		TableColumn colName=new TableColumn(table,SWT.CENTER);
		colName.setText("Name");
		colName.setWidth(100);
		
		
		TableColumn colVorname=new TableColumn(table,SWT.CENTER );
		colVorname.setText("Vorname");
		colVorname.setWidth(100);
		
		{
			TableItem item1=new TableItem(table,SWT.NONE);
			item1.setText(0,"Roth");
			item1.setText(1,"Matthias");
			
			
			TableItem item2=new TableItem(table,SWT.NONE);
			item2.setText(0,"Meinen");
			item2.setText(1,"Samuel");
			}
		{
			TableItem item1=new TableItem(table,SWT.NONE);
			item1.setText(0,"Roth");
			item1.setText(1,"Matthias");
			
			
			TableItem item2=new TableItem(table,SWT.NONE);
			item2.setText(0,"Meinen");
			item2.setText(1,"Samuel");
			}
		{
			TableItem item1=new TableItem(table,SWT.NONE);
			item1.setText(0,"Roth");
			item1.setText(1,"Matthias");
			
			
			TableItem item2=new TableItem(table,SWT.NONE);
			item2.setText(0,"Meinen");
			item2.setText(1,"Samuel");
			}
		{
			TableItem item1=new TableItem(table,SWT.NONE);
			item1.setText(0,"Roth");
			item1.setText(1,"Matthias");
			
			
			TableItem item2=new TableItem(table,SWT.NONE);
			item2.setText(0,"Meinen");
			item2.setText(1,"Samuel");
			}
		
		


	}
	

	public void dispose() {
		super.dispose();
		for (int i = 0; i < vResource.size(); i++) {
			try {
				((Resource) vResource.get(i)).dispose();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

}
