/* ----------------------------------------
 * Origin  : GFI INFORMATIQUE 
 * Project : CDPP Propagation Tool 
 * ----------------------------------------
 * History 
 * Version : 01/05/2015 : SCA : V2.1
 * Version : 14/04/2016 : SCA : V2.2 (PSWS-H2020)
 * ----------------------------------------
 */
package fr.tlse.irap.pt.client.controller.tools.catalog;

import java.util.Map;

import fr.tlse.irap.pt.client.controller.common.ISelectedItem;
import fr.tlse.irap.pt.client.controller.common.Item;
import fr.tlse.irap.pt.client.controller.common.SpaceElementCollection;
import fr.tlse.irap.spaceElement.Comet;
import fr.tlse.irap.spaceElement.Planet;
import fr.tlse.irap.spaceElement.Probe;

public class CatalogItemBuilder {

	/**
	 * return the list of alls item.
	 */
	public static Item getAllItem(Map<Item, ISelectedItem> map, final ICatalog catalogMenu) {

		Item allItems = new Item("All");

		map.put(allItems, new ISelectedItem() {
			@Override
			public void run() {
				catalogMenu.runChooseAll();
			}
		});
		return allItems;
	}

	/**
	 * return the list of item on start planet.
	 */
	public static Item getPlanetItem(Map<Item, ISelectedItem> map, final ICatalog catalogMenu) {

		Item planetItems = new Item("Planets");

		for (final Planet planet : SpaceElementCollection.getPlanets()) {
			Item itemPlanet = new Item(planet.getName());
			planetItems.add(itemPlanet);
			map.put(itemPlanet, new ISelectedItem() {
				@Override
				public void run() {
					catalogMenu.runChooseElement(planet);
				}
			});
		}

		return planetItems;
	}

	/**
	 * return the list of item on start probe.
	 */
	public static Item getProbeItem(Map<Item, ISelectedItem> map, final ICatalog catalogMenu) {

		Item probeItems = new Item("Probes");

		for (final Probe probe : SpaceElementCollection.getProbes()) {
			Item itemProbe = new Item(probe.getLongName());
			probeItems.add(itemProbe);
			map.put(itemProbe, new ISelectedItem() {
				@Override
				public void run() {
					catalogMenu.runChooseElement(probe);
				}
			});
		}

		return probeItems;
	}

	/**
	 * return the list of item on start comets.
	 */
	public static Item getCometItem(Map<Item, ISelectedItem> map, final ICatalog catalogMenu) {

		Item cometItems = new Item("Comets");

		for (final Comet comet : SpaceElementCollection.getComets()) {
			Item itemComet = new Item(comet.getName());
			cometItems.add(itemComet);
			map.put(itemComet, new ISelectedItem() {
				@Override
				public void run() {
					catalogMenu.runChooseElement(comet);
				}
			});
		}

		return cometItems;
	}

}