/* ----------------------------------------
 * 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.searchComets;

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

public class SearchCometsItemBuilder {

	private static final String PLANETS = "Planets";
	private static final String SUN = "SUN";

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

		Item itemPlanets = new Item(PLANETS);

		for (final SpaceElement spaceElement : SpaceElementCollection.getPlanets()) {
			Item itemPlanet = new Item(spaceElement.getName());
			itemPlanets.add(itemPlanet);
			map.put(itemPlanet, new ISelectedItem() {
				@Override
				public void run() {
					searchCometsMenu.runChoose(spaceElement);
				}
			});
		}

		return itemPlanets;
	}
	
	/**
	 * return end sun item.
	 */
	public static Item getSunItem(Map<Item, ISelectedItem> map, final ISearchComets searchCometsMenu) {

		Item sunItem = new Item(SUN);

		map.put(sunItem, new ISelectedItem() {
			@Override
			public void run() {
				searchCometsMenu.runChoose(SpaceElementCollection.getSpaceElementWrapper().getSun());
			}
		});

		return sunItem;
	}
}