package devopsdistilled.operp.client.commons.panes.controllers.impl;

import javax.inject.Inject;
import javax.swing.JPanel;

import devopsdistilled.operp.client.abstracts.EntityOperation;
import devopsdistilled.operp.client.commons.panes.ContactInfoPane;
import devopsdistilled.operp.client.commons.panes.controllers.AddressPaneController;
import devopsdistilled.operp.client.commons.panes.controllers.ContactInfoPaneController;
import devopsdistilled.operp.client.commons.panes.models.ContactInfoPaneModel;
import devopsdistilled.operp.client.exceptions.EntityValidationException;
import devopsdistilled.operp.server.data.entity.commons.Address;
import devopsdistilled.operp.server.data.entity.commons.ContactInfo;

public class ContactInfoPaneControllerImpl implements ContactInfoPaneController {

	@Inject
	private ContactInfoPane view;

	@Inject
	private ContactInfoPaneModel model;

	@Inject
	private AddressPaneController addressPaneController;

	@Override
	public ContactInfoPaneModel getModel() {
		return model;
	}

	@Override
	public ContactInfoPane getView() {
		return view;
	}

	@Override
	public void validate() throws EntityValidationException {
		// TODO Auto-generated method stub

	}

	@Override
	public ContactInfo save() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void init(ContactInfo contactInfo, EntityOperation entityOperation) {

		if (EntityOperation.Create == entityOperation) {
			Address address = new Address();
			contactInfo.setAddress(address);
			addressPaneController.init(address, entityOperation);

		} else if (EntityOperation.Edit == entityOperation) {

			addressPaneController.init(contactInfo.getAddress(),
					entityOperation);
		}

		view.setAddressPanel((JPanel) addressPaneController.getView().getPane());
		view.setController(this);

		model.setEntityAndEntityOperation(contactInfo, entityOperation);
		model.registerObserver(view);

		// view.init(); // Not required as dialog isn't required
	}

}

@@ -1621,16 +1621,156 @@
 ion) %7B%0A%0A
+%09%09%09addressPaneController.init(contactInfo.getAddress(),%0A%09%09%09%09%09entityOperation);%0A%0A%09%09%7D else if (EntityOperation.Details == entityOperation) %7B%0A%0A
 %09%09%09addre

Handle init() when "Details"