/**
 * 
 */
package com.planimod.ui.views.admin.team;

import java.util.Arrays;
import java.util.List;

import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.window.IShellProvider;

import com.patrikdufresne.managers.ManagedObject;
import com.patrikdufresne.util.Localized;
import com.planimod.core.PlanimodManagers;
import com.planimod.core.Team;
import com.planimod.ui.theme.Resources;
import com.planimod.ui.views.AbstractAddAction;

/**
 * Action to create a new Team.
 * 
 * @author Patrik Dufresne
 * 
 */
public class AddTeamAction extends AbstractAddAction {
	/**
	 * Create a new action.
	 * 
	 * @param shellProvider
	 *            a shell provider in case the action need to display a message
	 *            box.
	 */
	public AddTeamAction(PlanimodManagers managers,
			IShellProvider shellProvider, ISelectionProvider selectionProvider) {
		super(managers, shellProvider, selectionProvider);
		setText(Localized.get(AddTeamAction.class, "AddTeamAction.text")); //$NON-NLS-1$
		setToolTipText(Localized.get(AddTeamAction.class,
				"AddTeamAction.tooltipText")); //$NON-NLS-1$
		setImageDescriptor(Resources
				.getImageDescriptor(Resources.ICON_LIST_ADD_16));
	}

	/**
	 * This implementation always return true.
	 * 
	 * @see net.ekwos.gymkhana.ui.views.AbstractAddAction#canCreateObject()
	 */
	@Override
	protected boolean canCreateObject() {
		return true;
	}

	/**
	 * This implementation create a new team.
	 * 
	 * @see net.ekwos.gymkhana.ui.views.AbstractAddAction#createObjects()
	 */
	@Override
	protected List<? extends ManagedObject> createObjects() {
		Team t = new Team();
		t.setName(Localized.get(AddTeamAction.class,
				"AddTeamAction.newTeamName")); //$NON-NLS-1$
		return Arrays.asList(t);
	}
}