/*******************************************************************************
 * Copyright (c) 2016, 2017 Artal Technologies and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Aurelien Didier (Artal Technologies) - initial API and implementation
 *******************************************************************************/
/**
 * Generated with Acceleo
 */
package org.polarsys.time4sys.ui.views.hrm.parts.forms;

// Start of user code for imports
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.eef.runtime.EEFRuntimePlugin;
import org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent;
import org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart;
import org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext;
import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.part.impl.SectionPropertiesEditingPart;
import org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy;
import org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider;
import org.eclipse.emf.eef.runtime.ui.parts.PartComposer;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.BindingCompositionSequence;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.CompositionSequence;
import org.eclipse.emf.eef.runtime.ui.parts.sequence.CompositionStep;
import org.eclipse.emf.eef.runtime.ui.utils.EditingUtils;
import org.eclipse.emf.eef.runtime.ui.widgets.ButtonsModeEnum;
import org.eclipse.emf.eef.runtime.ui.widgets.EMFComboViewer;
import org.eclipse.emf.eef.runtime.ui.widgets.EObjectFlatComboViewer;
import org.eclipse.emf.eef.runtime.ui.widgets.FormUtils;
import org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable;
import org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable.ReferencesTableListener;
import org.eclipse.emf.eef.runtime.ui.widgets.TabElementTreeSelectionDialog;
import org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings;
import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableContentProvider;
import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.views.properties.tabbed.ISection;
import org.polarsys.time4sys.ui.views.hrm.parts.GeneralPropertiesEditionPart;
import org.polarsys.time4sys.ui.views.hrm.parts.HrmViewsRepository;
import org.polarsys.time4sys.ui.views.hrm.providers.HrmMessages;

// End of user code

/**
 * 
 * 
 */
public class GeneralPropertiesEditionPartForm extends SectionPropertiesEditingPart
		implements IFormPropertiesEditionPart, GeneralPropertiesEditionPart {

	protected Text name;
	protected EMFComboViewer type;
	protected Text family;
	protected EMFComboViewer status;
	protected Text description;
	protected Text speedFactor;
	protected Button memoryProtection;
	protected Text range;
	protected Button isActive;
	protected Button isProtected;
	protected Button isSynchronous;
	protected Button isSerial;
	protected Button isStatic;
	protected Button isNonVolatile;
	protected Text memorySize;
	protected Text addressSize;
	protected Text nbChannels;
	protected Text transferWidth;
	protected Text throughput;
	protected Text level;
	protected Text resMult;
	protected EObjectFlatComboViewer sourcePort;
	protected EObjectFlatComboViewer targetPort;
	protected EObjectFlatComboViewer mainScheduler;
	protected ReferencesTable usedBy;
	protected List<ViewerFilter> usedByBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> usedByFilters = new ArrayList<ViewerFilter>();
	protected ReferencesTable realizedBy;
	protected List<ViewerFilter> realizedByBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> realizedByFilters = new ArrayList<ViewerFilter>();
	protected ReferencesTable arbiters;
	protected List<ViewerFilter> arbitersBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> arbitersFilters = new ArrayList<ViewerFilter>();
	protected ReferencesTable sides;
	protected List<ViewerFilter> sidesBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> sidesFilters = new ArrayList<ViewerFilter>();
	protected ReferencesTable managedMemories;
	protected List<ViewerFilter> managedMemoriesBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> managedMemoriesFilters = new ArrayList<ViewerFilter>();
	protected ReferencesTable controlledMedia;
	protected List<ViewerFilter> controlledMediaBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> controlledMediaFilters = new ArrayList<ViewerFilter>();
	protected ReferencesTable drivenBy;
	protected List<ViewerFilter> drivenByBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> drivenByFilters = new ArrayList<ViewerFilter>();
	protected ReferencesTable brokedResource;
	protected List<ViewerFilter> brokedResourceBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> brokedResourceFilters = new ArrayList<ViewerFilter>();
	protected ReferencesTable ownedElement;
	protected List<ViewerFilter> ownedElementBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> ownedElementFilters = new ArrayList<ViewerFilter>();
	protected ReferencesTable ownedResource;
	protected List<ViewerFilter> ownedResourceBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> ownedResourceFilters = new ArrayList<ViewerFilter>();
	protected ReferencesTable ownedConnector;
	protected List<ViewerFilter> ownedConnectorBusinessFilters = new ArrayList<ViewerFilter>();
	protected List<ViewerFilter> ownedConnectorFilters = new ArrayList<ViewerFilter>();

	/**
	 * For {@link ISection} use only.
	 */
	public GeneralPropertiesEditionPartForm() {
		super();
	}

	/**
	 * Default constructor
	 * 
	 * @param editionComponent
	 *            the {@link IPropertiesEditionComponent} that manage this part
	 * 
	 */
	public GeneralPropertiesEditionPartForm(IPropertiesEditionComponent editionComponent) {
		super(editionComponent);
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart#
	 *      createFigure(org.eclipse.swt.widgets.Composite,
	 *      org.eclipse.ui.forms.widgets.FormToolkit)
	 * 
	 */
	public Composite createFigure(final Composite parent, final FormToolkit widgetFactory) {
		ScrolledForm scrolledForm = widgetFactory.createScrolledForm(parent);
		Form form = scrolledForm.getForm();
		view = form.getBody();
		GridLayout layout = new GridLayout();
		layout.numColumns = 3;
		view.setLayout(layout);
		createControls(widgetFactory, view);
		return scrolledForm;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart#
	 *      createControls(org.eclipse.ui.forms.widgets.FormToolkit,
	 *      org.eclipse.swt.widgets.Composite)
	 * 
	 */
	public void createControls(final FormToolkit widgetFactory, Composite view) {
		CompositionSequence generalStep = new BindingCompositionSequence(propertiesEditionComponent);
		CompositionStep propertiesStep = generalStep.addStep(HrmViewsRepository.General.Properties.class);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.name);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.type);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.family);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.status);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.description);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.speedFactor);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.memoryProtection);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.range);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.isActive);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.isProtected);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.isSynchronous);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.isSerial);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.isStatic);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.isNonVolatile);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.memorySize);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.addressSize);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.nbChannels);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.transferWidth);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.throughput);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.level);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.resMult);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.sourcePort);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.targetPort);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.mainScheduler);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.usedBy);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.realizedBy);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.arbiters);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.sides);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.managedMemories);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.controlledMedia);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.drivenBy);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.brokedResource);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.ownedElement);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.ownedResource);
		propertiesStep.addStep(HrmViewsRepository.General.Properties.ownedConnector);

		composer = new PartComposer(generalStep) {

			@Override
			public Composite addToPart(Composite parent, Object key) {
				if (key == HrmViewsRepository.General.Properties.class) {
					return createPropertiesGroup(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.name) {
					return createNameText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.type) {
					return createTypeEMFComboViewer(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.family) {
					return createFamilyText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.status) {
					return createStatusEMFComboViewer(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.description) {
					return createDescriptionText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.speedFactor) {
					return createSpeedFactorText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.memoryProtection) {
					return createMemoryProtectionCheckbox(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.range) {
					return createRangeText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.isActive) {
					return createIsActiveCheckbox(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.isProtected) {
					return createIsProtectedCheckbox(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.isSynchronous) {
					return createIsSynchronousCheckbox(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.isSerial) {
					return createIsSerialCheckbox(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.isStatic) {
					return createIsStaticCheckbox(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.isNonVolatile) {
					return createIsNonVolatileCheckbox(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.memorySize) {
					return createMemorySizeText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.addressSize) {
					return createAddressSizeText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.nbChannels) {
					return createNbChannelsText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.transferWidth) {
					return createTransferWidthText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.throughput) {
					return createThroughputText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.level) {
					return createLevelText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.resMult) {
					return createResMultText(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.sourcePort) {
					return createSourcePortFlatComboViewer(parent, widgetFactory);
				}
				if (key == HrmViewsRepository.General.Properties.targetPort) {
					return createTargetPortFlatComboViewer(parent, widgetFactory);
				}
				if (key == HrmViewsRepository.General.Properties.mainScheduler) {
					return createMainSchedulerFlatComboViewer(parent, widgetFactory);
				}
				if (key == HrmViewsRepository.General.Properties.usedBy) {
					return createUsedByReferencesTable(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.realizedBy) {
					return createRealizedByReferencesTable(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.arbiters) {
					return createArbitersReferencesTable(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.sides) {
					return createSidesReferencesTable(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.managedMemories) {
					return createManagedMemoriesReferencesTable(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.controlledMedia) {
					return createControlledMediaReferencesTable(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.drivenBy) {
					return createDrivenByReferencesTable(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.brokedResource) {
					return createBrokedResourceReferencesTable(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.ownedElement) {
					return createOwnedElementTableComposition(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.ownedResource) {
					return createOwnedResourceTableComposition(widgetFactory, parent);
				}
				if (key == HrmViewsRepository.General.Properties.ownedConnector) {
					return createOwnedConnectorTableComposition(widgetFactory, parent);
				}
				return parent;
			}
		};
		composer.compose(view);
	}

	/**
	 * 
	 */
	protected Composite createPropertiesGroup(FormToolkit widgetFactory, final Composite parent) {
		Section propertiesSection = widgetFactory.createSection(parent,
				Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
		propertiesSection.setText(HrmMessages.GeneralPropertiesEditionPart_PropertiesGroupLabel);
		GridData propertiesSectionData = new GridData(GridData.FILL_HORIZONTAL);
		propertiesSectionData.horizontalSpan = 3;
		propertiesSection.setLayoutData(propertiesSectionData);
		Composite propertiesGroup = widgetFactory.createComposite(propertiesSection);
		GridLayout propertiesGroupLayout = new GridLayout();
		propertiesGroupLayout.numColumns = 3;
		propertiesGroup.setLayout(propertiesGroupLayout);
		propertiesSection.setClient(propertiesGroup);
		return propertiesGroup;
	}

	protected Composite createNameText(FormToolkit widgetFactory, Composite parent) {
		createDescription(parent, HrmViewsRepository.General.Properties.name,
				HrmMessages.GeneralPropertiesEditionPart_NameLabel);
		name = widgetFactory.createText(parent, ""); //$NON-NLS-1$
		name.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
		widgetFactory.paintBordersFor(parent);
		GridData nameData = new GridData(GridData.FILL_HORIZONTAL);
		name.setLayoutData(nameData);
		name.addFocusListener(new FocusAdapter() {
			/**
			 * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
			 * 
			 */
			@Override
			@SuppressWarnings("synthetic-access")
			public void focusLost(FocusEvent e) {
				if (propertiesEditionComponent != null) {
					propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
							GeneralPropertiesEditionPartForm.this, HrmViewsRepository.General.Properties.name,
							PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, name.getText()));
					propertiesEditionComponent
							.firePropertiesChanged(new PropertiesEditionEvent(GeneralPropertiesEditionPartForm.this,
									HrmViewsRepository.General.Properties.name, PropertiesEditionEvent.FOCUS_CHANGED,
									PropertiesEditionEvent.FOCUS_LOST, null, name.getText()));
				}
			}

			/**
			 * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent)
			 */
			@Override
			public void focusGained(FocusEvent e) {
				if (propertiesEditionComponent != null) {
					propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
							GeneralPropertiesEditionPartForm.this, null, PropertiesEditionEvent.FOCUS_CHANGED,
							PropertiesEditionEvent.FOCUS_GAINED, null, null));
				}
			}
		});
		name.addKeyListener(new KeyAdapter() {
			/**
			 * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
			 * 
			 */
			@Override
			@SuppressWarnings("synthetic-access")
			public void keyPressed(KeyEvent e) {
				if (e.character == SWT.CR) {
					if (propertiesEditionComponent != null)
						propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
								GeneralPropertiesEditionPartForm.this, HrmViewsRepository.General.Properties.name,
								PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, name.getText()));
				}
			}
		});
		EditingUtils.setID(name, HrmViewsRepository.General.Properties.name);
		EditingUtils.setEEFtype(name, "eef::Text"); //$NON-NLS-1$
		FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent
				.getHelpContent(HrmViewsRepository.General.Properties.name, HrmViewsRepository.FORM_KIND), null); // $NON-NLS-1$
		// Start of user code for createNameText

		// End of user code
		return parent;
	}

	protected Composite createTypeEMFComboViewer(FormToolkit widgetFactory, Composite parent) {
		createDescription(parent, HrmViewsRepository.General.Properties.type,
				HrmMessages.GeneralPropertiesEditionPart_TypeLabel);
		type = new EMFComboViewer(parent);
		type.setContentProvider(new ArrayContentProvider());
		type.setLabelProvider(new AdapterFactoryLabelProvider(EEFRuntimePlugin.getDefault().getAdapterFactory()));
		GridData typeData = new GridData(GridData.FILL_HORIZONTAL);
		type.getCombo().setLayoutData(typeData);
		type.addSelectionChangedListener(new ISelectionChangedListener() {

			/**
			 * {@inheritDoc}
			 * 
			 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
			 * 
			 */
			public void selectionChanged(SelectionChangedEvent event) {
				if (propertiesEditionComponent != null)
					propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
							GeneralPropertiesEditionPartForm.this, HrmViewsRepository.General.Properties.type,
							PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, getType()));
			}

		});
		type.setID(HrmViewsRepository.General.Properties.type);
		FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent
				.getHelpContent(HrmViewsRepository.General.Properties.type, HrmViewsRepository.FORM_KIND), null); // $NON-NLS-1$
		// Start of user code for createTypeEMFComboViewer

		// End of user code
		return parent;
	}

	protected Composite createFamilyText(FormToolkit widgetFactory, Composite parent) {
		createDescription(parent, HrmViewsRepository.General.Properties.family,
				HrmMessages.GeneralPropertiesEditionPart_FamilyLabel);
		family = widgetFactory.createText(parent, ""); //$NON-NLS-1$
		family.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
		widgetFactory.paintBordersFor(parent);
		GridData familyData = new GridData(GridData.FILL_HORIZONTAL);
		family.setLayoutData(familyData);
		family.addFocusListener(new FocusAdapter() {
			/**
			 * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
			 * 
			 */
			@Override
			@SuppressWarnings("synthetic-access")
			public void focusLost(FocusEvent e) {
				if (propertiesEditionComponent != null) {
					propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
							GeneralPropertiesEditionPartForm.this, HrmViewsRepository.General.Properties.family,
							PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, family.getText()));
					propertiesEditionComponent
							.firePropertiesChanged(new PropertiesEditionEvent(GeneralPropertiesEditionPartForm.this,
									HrmViewsRepository.General.Properties.family, PropertiesEditionEvent.FOCUS_CHANGED,
									PropertiesEditionEvent.FOCUS_LOST, null, family.getText()));
				}
			}

			/**
			 * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent)
			 */
			@Override
			public void focusGained(FocusEvent e) {
				if (propertiesEditionComponent != null) {
					propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
							GeneralPropertiesEditionPartForm.this, null, PropertiesEditionEvent.FOCUS_CHANGED,
							PropertiesEditionEvent.FOCUS_GAINED, null, null));
				}
			}
		});
		family.addKeyListener(new KeyAdapter() {
			/**
			 * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
			 * 
			 */
			@Override
			@SuppressWarnings("synthetic-access")
			public void keyPressed(KeyEvent e) {
				if (e.character == SWT.CR) {
					if (propertiesEditionComponent != null)
						propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
								GeneralPropertiesEditionPartForm.this, HrmViewsRepository.General.Properties.family,
								PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, family.getText()));
				}
			}
		});
		EditingUtils.setID(family, HrmViewsRepository.General.Properties.family);
		EditingUtils.setEEFtype(family, "eef::Text"); //$NON-NLS-1$
		FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent
				.getHelpContent(HrmViewsRepository.General.Properties.family, HrmViewsRepository.FORM_KIND), null); // $NON-NLS-1$
		// Start of user code for createFamilyText

		// End of user code
		return parent;
	}

	protected Composite createStatusEMFComboViewer(FormToolkit widgetFactory, Composite parent) {
		createDescription(parent, HrmViewsRepository.General.Properties.status,
				HrmMessages.GeneralPropertiesEditionPart_StatusLabel);
		status = new EMFComboViewer(parent);
		status.setContentProvider(new ArrayContentProvider());
		status.setLabelProvider(new AdapterFactoryLabelProvider(EEFRuntimePlugin.getDefault().getAdapterFactory()));
		GridData statusData = new GridData(GridData.FILL_HORIZONTAL);
		status.getCombo().setLayoutData(statusData);
		status.addSelectionChangedListener(new ISelectionChangedListener() {

			/**
			 * {@inheritDoc}
			 * 
			 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
			 * 
			 */
			public void selectionChanged(SelectionChangedEvent event) {
				if (propertiesEditionComponent != null)
					propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
							GeneralPropertiesEditionPartForm.this, HrmViewsRepository.General.Properties.status,
							PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, getStatus()));
			}

		});
		status.setID(HrmViewsRepository.General.Properties.status);
		FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent
				.getHelpContent(HrmViewsRepository.General.Properties.status, HrmViewsRepository.FORM_KIND), null); // $NON-NLS-1$
		// Start of user code for createStatusEMFComboViewer

		// End of user code
		return parent;
	}

	protected Composite createDescriptionText(FormToolkit widgetFactory, Composite parent) {
		createDescription(parent, HrmViewsRepository.General.Properties.description,
				HrmMessages.GeneralPropertiesEditionPart_DescriptionLabel);
		description = widgetFactory.createText(parent, ""); //$NON-NLS-1$
		description.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
		widgetFactory.paintBordersFor(parent);
		GridData descriptionData = new GridData(GridData.FILL_HORIZONTAL);
		description.setLayoutData(descriptionData);
		description.addFocusListener(new FocusAdapter() {
			/**
			 * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
			 * 
			 */
			@Override
			@SuppressWarnings("synthetic-access")
			public void focusLost(FocusEvent e) {
				if (propertiesEditionComponent != null) {
					propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
							GeneralPropertiesEditionPartForm.this, HrmViewsRepository.General.Properties.description,
							PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, description.getText()));
					propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
							GeneralPropertiesEditionPartForm.this, HrmViewsRepository.General.Properties.description,
							PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_LOST, null,
							description.getText()));
				}
			}

			/**
			 * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent)
			 */
			@Override
			public void focusGained(FocusEvent e) {
				if (propertiesEditionComponent != null) {
					propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
							GeneralPropertiesEditionPartForm.this, null, PropertiesEditionEvent.FOCUS_CHANGED,
							PropertiesEditionEvent.FOCUS_GAINED, null, null));
				}
			}
		});
		description.addKeyListener(new KeyAdapter() {
			/**
			 * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
			 * 
			 */
			@Override
			@SuppressWarnings("synthetic-access")
			public void keyPressed(KeyEvent e) {
				if (e.character == SWT.CR) {
					if (propertiesEditionComponent != null)
						propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
								GeneralPropertiesEditionPartForm.this,
								HrmViewsRepository.General.Properties.description, PropertiesEditionEvent.COMMIT,
								PropertiesEditionEvent.SET, null, description.getText()));
				}
			}
		});
		EditingUtils.setID(description, HrmViewsRepository.General.Properties.description);
		EditingUtils.setEEFtype(description, "eef::Text"); //$NON-NLS-1$
		FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent
				.getHelpContent(HrmViewsRepository.General.Properties.description, HrmViewsRepository.FORM_KIND), null); // $NON-NLS-1$
		// Start of user code for createDescriptionText

		// End of user code
		return parent;
	}

	protected Composite createSpeedFactorText(FormToolkit widgetFactory, Composite parent) {
		createDescription(parent, HrmViewsRepository.General.Properties.speedFactor,
				HrmMessages.GeneralPropertiesEditionPart_SpeedFactorLabel);
		speedFactor = widgetFactory.createText(parent, ""); //$NON-NLS-1$
		speedFactor.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
		widgetFactory.paintBordersFor(parent);
		GridData speedFactorData = new GridData(GridData.FILL_HORIZONTAL);
		speedFactor.setLayoutData(speedFactorData);
		speedFactor.addFocusListener(new FocusAdapter() {
			/**
			 * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
			 * 
			 */
			@Override
			@SuppressWarnings("synthetic-access")
			public void focusLost(FocusEvent e) {
				if (propertiesEditionComponent != null) {
					propertiesEditionComponent.firePropertiesChanged(new Propertie