//
// https://www.ramecera.it/myscrewdriver.html
// e-mail: screwdriver@ramecera.it
//
/* 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 */
package it.ramecera.screwdriver.component;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;

import it.ramecera.salad.everyday.Candies;
import it.ramecera.salad.everyday.ExactException;
import it.ramecera.salad.everyday.Strings;
import it.ramecera.salad.file.Equipment;
import it.ramecera.screwdriver.CandyScrew;
import it.ramecera.screwdriver.Markup;
import it.ramecera.screwdriver.Skill;
import it.ramecera.screwdriver.Train;

/** @author M. Maglioni */
final public class Bootstrap_css extends FileComponent {

	/** @param skill set of descriptive data of the application
	 * @param snippetG position of the fragments */
	public Bootstrap_css(Skill skill, String snippetG) {
		super();
		this.skill = skill;
		this.snippetG = snippetG;
	}

	/** @throws ExactException exception specified by a numeric code */
	@Override
	public void synthesis(HashMap<String, Markup> markupE,
			List<Train> trainE, CandyScrew candyScrew)

			throws FileNotFoundException, IOException, ExactException {

		String g = skill.candies.snippetsYS + snippetG;
		producedMaterial = Equipment.oneString(g) + Candies.LF;

		if (skill.pckg != null) {
			producedMaterial = producedMaterial.replaceAll(
					"\\x2bzoccolo\\x2b", skill.pckg);
		}
		if (skill.applicationNameLower != null) {
			producedMaterial = Strings.replaceFirst(producedMaterial,
					"+titolo+", skill.applicationNameLower);
		}
		if (markupE.get("indexjsp").recurrenceE.size() > 0 && markupE
				.get("indexjsp").recurrenceE.get(0).wagonE.containsKey(
						"ooptioncolor")) {
			producedMaterial = producedMaterial.replaceAll(
					"\\x2booptioncolor\\x2b", markupE.get(
							"indexjsp").recurrenceE.get(0).wagonE.get(
									"ooptioncolor").text);
			producedMaterial = producedMaterial.replaceAll(
					"\\x2booptmaincolor\\x2b", markupE.get(
							"indexjsp").recurrenceE.get(0).wagonE.get(
									"ooptioncolor").text);

		} else {
			producedMaterial = producedMaterial.replaceAll(
					"\\x2bmozColor1\\x2b", "black");
		}
		if (markupE.get("indexjsp").recurrenceE.size() > 0 && markupE
				.get("indexjsp").recurrenceE.get(0).wagonE.containsKey(
						"ooptionhover")) {
			producedMaterial = producedMaterial.replaceAll(
					"\\x2booptionhover\\x2b", markupE.get(
							"indexjsp").recurrenceE.get(0).wagonE.get(
									"ooptionhover").text);
		} else {
			producedMaterial = producedMaterial.replaceAll(
					"\\x2bmozColor1\\x2b", "white");
		}
		if (skill.backColorFormAction != null) {
			producedMaterial = Strings.replaceFirst(producedMaterial,
					"+backformaction+", skill.backColorFormAction);
		}
		if (markupE.get("indexjsp").recurrenceE.size() > 0 && markupE
				.get("indexjsp").recurrenceE.get(0).wagonE.containsKey(
						"ooptbackcol1")) {
			producedMaterial = producedMaterial.replaceAll(
					"\\x2bmozColor1\\x2b", markupE.get(
							"indexjsp").recurrenceE.get(0).wagonE.get(
									"ooptbackcol1").text);
		} else {
			producedMaterial = producedMaterial.replaceAll(
					"\\x2bmozColor1\\x2b", "black");
		}
		if (markupE.get("indexjsp").recurrenceE.size() > 0 && markupE
				.get("indexjsp").recurrenceE.get(0).wagonE.containsKey(
						"ooptbackcol2")) {
			producedMaterial = producedMaterial.replaceAll(
					"\\x2bmozColor2\\x2b", markupE.get(
							"indexjsp").recurrenceE.get(0).wagonE.get(
									"ooptbackcol2").text);
		} else {
			producedMaterial = producedMaterial.replaceAll(
					"\\x2bmozColor1\\x2b", "white");
		}
	}

	/* written only to comply with the abstract class FileComponent */
	@SuppressWarnings("javadoc")
	@Override
	/** @param markupE the list of markups
	 * @param skill together with the characteristics of the application
	 * @param trash file where the deleted files are moved
	 * @throws ExactException exception specified by a numeric code */
	public void directory(HashMap<String, Markup> markupE)

			throws ExactException {

	}
}
