/*
 *    Debrief - the Open Source Maritime Analysis Application
 *    http://debrief.info
 *
 *    (C) 2000-2014, PlanetMayo Ltd
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the Eclipse Public License v1.0
 *    (http://www.eclipse.org/legal/epl-v10.html)
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 */
package org.mwc.debrief.core.wizards.s2r;

import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.mwc.cmap.core.wizards.RangeBearingPage;
import org.mwc.debrief.core.wizards.EnterSolutionPage;
import org.mwc.debrief.core.wizards.EnterSolutionPage.SolutionDataItem;

import MWC.GenericData.WorldDistance;
import MWC.GenericData.WorldSpeed;

public class TMAFromSensorWizard extends Wizard
{
	private static final String PAGE_TITLE = "Generate TMA segment";
	RangeBearingPage selectOffsetPage;
	EnterSolutionPage enterSolutionPage;
	private final double _brgDegs;
	private final WorldDistance _range;
	private final double _initalCourse;
	private final WorldSpeed _initialSpeed;

	public TMAFromSensorWizard(final double brgDegs, final WorldDistance range,
			final double initialCourse, final WorldSpeed initialSpeed)
	{
		_brgDegs = brgDegs;
		_range = range;
		_initalCourse = initialCourse;
		_initialSpeed = initialSpeed;
	}

	public void addPages()
	{
		final String imagePath = "images/grid_wizard.gif";

		final String helpContext = null;
		
		// now for the easy fields
		// ok, we need to let the user enter the solution wrapper name
		selectOffsetPage = new RangeBearingPage(null, PAGE_TITLE,
				"Now specify the offset to the track start",
				"range from ownship to start of track",
				"bearing from ownship to start of track", imagePath, helpContext );

		// give ourselves a default range, if we don't have one
		WorldDistance theRange = _range;
		if(theRange == null)
			theRange = new WorldDistance(5, WorldDistance.NM);
		
		selectOffsetPage.setData(theRange, _brgDegs);

		addPage(selectOffsetPage);

		enterSolutionPage = new EnterSolutionPage(null, PAGE_TITLE,
				"This page lets you enter an initial solution", imagePath, helpContext);
		final SolutionDataItem d2 = (SolutionDataItem) enterSolutionPage.createMe();
		d2._course = _initalCourse;
		d2._speed = _initialSpeed;

		addPage(enterSolutionPage);
	}

	public boolean performFinish()
	{
		return true;
	}

	@Override
	public IWizardPage getPage(final String name)
	{
		return super.getPage(name);
	}

}

@@ -1264,24 +1264,55 @@
 itialSpeed;%0D
+%0A%09private boolean _showOffset;%0D
 %0A%0D%0A%09public T
@@ -1447,16 +1447,251 @@
 d)%0D%0A%09%7B%0D%0A
+%09%09this(brgDegs, range, initialCourse, initialSpeed, true);%0D%0A%09%7D%0D%0A%0D%0A%09public TMAFromSensorWizard(final double brgDegs, final WorldDistance range,%0D%0A%09%09%09final double initialCourse, final WorldSpeed initialSpeed,%0D%0A%09%09%09boolean showOffset)%0D%0A%09%7B%0D%0A
 %09%09_brgDe
@@ -1791,16 +1791,45 @@
 Speed;%0D%0A
+%09%09_showOffset = showOffset;%0D%0A
 %09%7D%0D%0A%0D%0A%09p
@@ -1947,20 +1947,18 @@
  null;%0D%0A
-%09%09
 %0D%0A
+
 %09%09// now
@@ -2269,17 +2269,16 @@
 pContext
- 
 );%0D%0A%0D%0A%09%09
@@ -2374,16 +2374,17 @@
 e;%0D%0A%09%09if
+ 
 (theRang
@@ -2454,12 +2454,10 @@
 );%0D%0A
-%09%09
 %0D%0A
+
 %09%09se
@@ -2499,24 +2499,50 @@
 rgDegs);%0D%0A%0D%0A
+%09%09if (_showOffset)%0D%0A%09%09%7B%0D%0A%09
 %09%09addPage(se
@@ -2558,16 +2558,21 @@
 tPage);%0D
+%0A%09%09%7D%0D
 %0A%0D%0A%09%09ent

make the solution page optional