package com.delormeloic.generator.view.slidesforms;

import com.delormeloic.generator.model.slides.Header;
import com.delormeloic.generator.view.converters.FontStringConverter;
import com.delormeloic.generator.view.helpers.FontsHelper;
import com.delormeloic.generator.view.helpers.GridPaneHelper;
import com.delormeloic.generator.view.helpers.SpinnerHelper;
import com.delormeloic.generator.view.helpers.TextHelper;

import javafx.scene.Node;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.Spinner;
import javafx.scene.control.TextField;
import javafx.scene.text.Font;

/**
 * This class represents an header form.
 *
 * @author DELORME Loïc
 * @since 1.0.0
 */
public class HeaderForm implements IFormable
{
	/**
	 * The header.
	 */
	private final Header header;

	/**
	 * Create an header form.
	 * 
	 * @param header
	 *            The header.
	 */
	public HeaderForm(Header header)
	{
		this.header = header;
	}

	/**
	 * @see com.delormeloic.generator.view.slidesforms.IFormable#toForm()
	 */
	@Override
	public Node toForm()
	{
		final TextField middleTextTextField = new TextField();
		final ComboBox<Font> middleTextFontComboBox = new ComboBox<Font>();
		final Spinner<Integer> middleTextSizeSpinner = new Spinner<Integer>();

		middleTextFontComboBox.getItems().addAll(FontsHelper.getAllAvailableFonts());
		middleTextFontComboBox.setConverter(new FontStringConverter());
		middleTextSizeSpinner.setValueFactory(SpinnerHelper.getDefaultTextSizeSpinnerValueFactory());

		middleTextTextField.textProperty().bindBidirectional(this.header.getMiddleTextProperty());
		middleTextFontComboBox.valueProperty().bindBidirectional(this.header.getMiddleTextFontProperty());
		middleTextSizeSpinner.getValueFactory().valueProperty().bindBidirectional(this.header.getMiddleTextSizeProperty().asObject());

		final Node[] middleTextField = new Node[] { new Label(TextHelper.getText("headerFormMiddleTextField")), middleTextTextField };
		final Node[] middleTextFontField = new Node[] { new Label(TextHelper.getText("headerFormMiddleTextFontField")), middleTextFontComboBox };
		final Node[] middleTextSizeField = new Node[] { new Label(TextHelper.getText("headerFormMiddleTextSizeField")), middleTextSizeSpinner };

		return GridPaneHelper.buildGridPane(new Node[][] { middleTextField, middleTextFontField, middleTextSizeField });
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString()
	{
		return "Header";
	}
}
@@ -295,69 +295,8 @@
 er;%0A
-import com.delormeloic.generator.view.helpers.SpinnerHelper;%0A
 impo
@@ -453,45 +453,8 @@
 el;%0A
-import javafx.scene.control.Spinner;%0A
 impo
@@ -1115,81 +1115,8 @@
 %3E();
-%0A%09%09final Spinner%3CInteger%3E middleTextSizeSpinner = new Spinner%3CInteger%3E();
 %0A%0A%09%09
@@ -1262,104 +1262,8 @@
 ());
-%0A%09%09middleTextSizeSpinner.setValueFactory(SpinnerHelper.getDefaultTextSizeSpinnerValueFactory());
 %0A%0A%09%09
@@ -1457,137 +1457,8 @@
 ());
-%0A%09%09middleTextSizeSpinner.getValueFactory().valueProperty().bindBidirectional(this.header.getMiddleTextSizeProperty().asObject());
 %0A%0A%09%09
@@ -1727,147 +1727,8 @@
 x %7D;
-%0A%09%09final Node%5B%5D middleTextSizeField = new Node%5B%5D %7B new Label(TextHelper.getText(%22headerFormMiddleTextSizeField%22)), middleTextSizeSpinner %7D;
 %0A%0A%09%09
@@ -1818,29 +1818,8 @@
 ield
-, middleTextSizeField
  %7D);

remove useless form component