/*******************************************************************************
 * Caleydo - Visualization for Molecular Biology - http://caleydo.org
 * Copyright (c) The Caleydo Team. All rights reserved.
 * Licensed under the new BSD license, available at http://caleydo.org/license
 ******************************************************************************/
package org.caleydo.core.internal.gui;

import java.util.Map;

import org.caleydo.core.internal.MyPreferences;
import org.caleydo.core.startup.IStartupAddon;
import org.caleydo.core.startup.IStartupProcedure;
import org.caleydo.core.util.collection.Pair;
import org.eclipse.jface.wizard.Wizard;

/**
 * Wizard that appears after Caleydo startup.
 *
 * @author Marc Streit
 * @author Werner Puff
 * @author Alexander Lex
 */
public class CaleydoProjectWizard
	extends Wizard {

	private IStartupProcedure result;
	private final Map<String, IStartupAddon> addons;
	/**
	 * Constructor.
	 */
	public CaleydoProjectWizard(Map<String, IStartupAddon> addons) {

		this.setWindowTitle("Caleydo - Choose Data Source");
		this.addons = addons;
	}

	@Override
	public void addPages() {
		addPage(new ChooseProjectTypePage(addons));
	}

	private ChooseProjectTypePage getChosenProjectTypePage() {
		return (ChooseProjectTypePage) getPage(ChooseProjectTypePage.PAGE_NAME);
	}

	@Override
	public boolean canFinish() {
		return (getChosenProjectTypePage().isPageComplete());
	}

	@Override
	public boolean performFinish() {
		ChooseProjectTypePage page = getChosenProjectTypePage();
		Pair<String, IStartupAddon> addon = page.getSelectedAddon();
		if (page.isPageComplete() && addon.getSecond().validate()) {
			MyPreferences.setLastChosenProjectMode(addon.getFirst());
			MyPreferences.flush();

			setResult(addon.getSecond().create());
			return true;
		}

		return false;
	}

	/**
	 * @param result
	 *            setter, see {@link result}
	 */
	public void setResult(IStartupProcedure result) {
		this.result = result;
	}

	/**
	 * @return the result, see {@link #result}
	 */
	public IStartupProcedure getResult() {
		return result;
	}

	@Override
	public boolean performCancel() {
		return true;
	}
}

@@ -471,16 +471,64 @@
 rences;%0A
+import org.caleydo.core.manager.GeneralManager;%0A
 import o
@@ -1099,28 +1099,55 @@
 ydo 
-- Choose Data Source
+%22 + GeneralManager.VERSION + %22 - Project Wizard
 %22);%0A

add version in startup wizard