package com.sogeti.rental.ui;


import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;

import com.opcoach.training.rental.Rental;
import com.sogeti.rental.core.RentalActivator;

public class RentalPropertyView extends ViewPart {
	
	private Label rentedObjectLabel;

	private Label whoLabel;
	
	public RentalPropertyView() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void createPartControl(Composite parent) {
		parent.setLayout(new GridLayout(1, false));
		
		Group infoGroup = new Group(parent, SWT.NONE);
		infoGroup.setText("Informations");
		infoGroup.setLayout(new GridLayout(2, false));
		
		rentedObjectLabel = new Label(infoGroup, SWT.BORDER);
		GridData gd = new GridData();
		gd.horizontalSpan = 2;
		gd.horizontalAlignment = SWT.DM_FILL_BACKGROUND;
		rentedObjectLabel.setLayoutData(gd);
		
		Text whoText = new Text(infoGroup, SWT.BORDER);
		whoText.setText("Lou :");
		whoLabel = new Label(infoGroup, SWT.BORDER);

		
		setRental(RentalActivator.getAgency().getRentals().get(0));
		setCustomer(RentalActivator.getAgency().getRentals().get(0));
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub

	}

	private void setRental(Rental r) {
		rentedObjectLabel.setText(r.getRentedObject().getName());
	}
	
	private void setCustomer(Rental r) {
		whoLabel.setText(r.getCustomer().getFirstName() + " " + r.getCustomer().getLastName());
	}
	
}

@@ -552,19 +552,77 @@
 Label;%0D%0A
+%09private Label labelDuDate;%0D%0A%09private Label labelAuDate;%0D%0A
 %09%0D%0A
-
 %09public 
@@ -1290,16 +1290,576 @@
 ORDER);%0D
+%0A%09%09%0D%0A%09%09Group grpDatesDeLocation = new Group(parent, SWT.NONE);%0D%0A%09%09grpDatesDeLocation.setText(%22Dates de location%22);%0D%0A%09%09grpDatesDeLocation.setLayout(new GridLayout(2, false));%0D%0A%09%09%0D%0A%09%09Label lblDu = new Label(grpDatesDeLocation, SWT.NONE);%0D%0A%09%09lblDu.setSize(20, 20);%0D%0A%09%09lblDu.setText(%22du:%22);%0D%0A%09%09%0D%0A%09%09labelDuDate = new Label(grpDatesDeLocation, SWT.NONE);%0D%0A%09%09labelDuDate.setSize(0, 20);%0D%0A%09%09%0D%0A%09%09Label lblAu = new Label(grpDatesDeLocation, SWT.NONE);%0D%0A%09%09lblAu.setText(%22au:%22);%0D%0A%09%09%0D%0A%09%09labelAuDate = new Label(grpDatesDeLocation, SWT.NONE);%0D%0A%09%09labelAuDate.setSize(0, 20);%0D
 %0A%0D%0A%09%09%0D%0A%09
@@ -1981,24 +1981,150 @@
 ).get(0));%0D%0A
+%09%09setDuDate(RentalActivator.getAgency().getRentals().get(0));%0D%0A%09%09setAuDate(RentalActivator.getAgency().getRentals().get(0));%0D%0A
 %09%7D%0D%0A%0D%0A%09@Over
@@ -2441,14 +2441,203 @@
 );%0D%0A%09%7D%0D%0A
-
 %09%0D%0A
+%09private void setDuDate(Rental r) %7B%0D%0A%09%09labelDuDate.setText(r.getStartDate().toString());%0D%0A%09%7D%0D%0A%09%0D%0A%09private void setAuDate(Rental r) %7B%0D%0A%09%09labelAuDate.setText(r.getEndDate().toString());%0D%0A%09%7D%0D%0A
 %7D%0D%0A

Add IHM with WindowBuilder