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.TextHelper;

import javafx.scene.Node;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
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>();

		middleTextFontComboBox.getItems().addAll(FontsHelper.getAllAvailableFonts());
		middleTextFontComboBox.setConverter(new FontStringConverter());

		middleTextTextField.textProperty().bindBidirectional(this.header.getMiddleTextProperty());
		middleTextFontComboBox.valueProperty().bindBidirectional(this.header.getMiddleTextFontProperty());

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

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

	/**
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString()
	{
		return "Header";
	}
}
@@ -275,24 +275,27 @@
 helpers.
-GridPane
+FormBuilder
 Helper;%0A
@@ -421,43 +421,8 @@
 ox;%0A
-import javafx.scene.control.Label;%0A
 impo
@@ -456,16 +456,56 @@
 tField;%0A
+import javafx.scene.control.TitledPane;%0A
 import j
@@ -1050,16 +1050,110 @@
 ield();%0A
+%09%09middleTextTextField.textProperty().bindBidirectional(this.header.getMiddleTextProperty());%0A%0A
 %09%09final 
@@ -1215,55 +1215,8 @@
 nt%3E(
-);%0A%0A%09%09middleTextFontComboBox.getItems().addAll(
 Font
@@ -1317,102 +1317,8 @@
 ());
-%0A%0A%09%09middleTextTextField.textProperty().bindBidirectional(this.header.getMiddleTextProperty());
 %0A%09%09m
@@ -1416,38 +1416,42 @@
 ty());%0A%0A%09%09final 
-Node%5B%5D
+TitledPane
  middleTextField
@@ -1449,38 +1449,35 @@
 Text
-Field = new Node%5B%5D %7B new Label
+TitledPane = new TitledPane
 (Tex
@@ -1513,23 +1513,27 @@
 ddleText
-Field%22)
+TitledPane%22
 ), middl
@@ -1550,71 +1550,117 @@
 ield
- %7D;%0A%09%09final Node%5B%5D middleTextFontField = new Node%5B%5D %7B new Label
+);%0A%09%09middleTextTitledPane.setCollapsible(false);%0A%09%09final TitledPane middleTextFontTitledPane = new TitledPane
 (Tex
@@ -1704,15 +1704,19 @@
 Font
-Field%22)
+TitledPane%22
 ), m
@@ -1740,30 +1740,111 @@
 oBox
- %7D;%0A%0A%09%09return GridPane
+);%0A%09%09middleTextFontTitledPane.setCollapsible(false);%0A%0A%09%09final TitledPane middleTitledPane = FormBuilder
 Help
@@ -1855,27 +1855,83 @@
 uild
-Gri
+Title
 dPane(
-new Node%5B%5D
+TextHelper.getText(%22headerFormMiddleTitledPane%22), new TitledPane
 %5B%5D %7B
@@ -1941,21 +1941,26 @@
 ddleText
-Field
+TitledPane
 , middle
@@ -1967,21 +1967,142 @@
 TextFont
-Field
+TitledPane %7D);%0A%0A%09%09return FormBuilderHelper.buildTitledPane(TextHelper.getText(%22dataForm%22), new TitledPane%5B%5D %7B middleTitledPane
  %7D);%0A%09%7D%0A

improve visual layout by using titled pane instead of gridpane