/*
 *    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.satc_interface.data.wrappers;

import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.io.Serializable;

import MWC.GUI.Editable;

import com.planetmayo.debrief.satc.model.contributions.CoreMeasurementContribution.CoreMeasurement;
import com.planetmayo.debrief.satc.model.contributions.FrequencyMeasurementContribution;
import com.planetmayo.debrief.satc.model.contributions.FrequencyMeasurementContribution.FMeasurement;

public class FMC_Wrapper
		extends
		CoreLayer_Wrapper<FrequencyMeasurementContribution, FMeasurement, FMC_Wrapper.FrequencyMeasurementEditable>
{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public FMC_Wrapper(final FrequencyMeasurementContribution contribution)
	{
		super(contribution);
	}

	protected void addThis(CoreMeasurement meas)
	{
		final FrequencyMeasurementEditable thisMe = new FrequencyMeasurementEditable(
				meas);
		_myElements.add(thisMe);
	}
	

	private FrequencyMeasurementContribution getFMC()
	{
		return (FrequencyMeasurementContribution) super.getBMC();
	}
	
	public double getBaseFrequency()
	{
		return getFMC().getBaseFrequency();
	}

	public void setBaseFrequency(double baseFrequency)
	{
		getFMC().setBaseFrequency(baseFrequency);
	}

	public double getSoundSpeed()
	{
		return getFMC().getSoundSpeed();
	}

	public void setSoundSpeed(double soundSpeed)
	{
		getFMC().setSoundSpeed(soundSpeed);
	}

	@Override
	public EditorType getInfo()
	{
		if (_myEditor == null)
			_myEditor = new FMC_Info(this);
		return _myEditor;
	}

	@SuppressWarnings("rawtypes")
	public class FrequencyMeasurementEditable extends
			CoreLayer_Wrapper.CoreMeasurementWrapper
	{
		private EditorType _myEditor;

		public FrequencyMeasurementEditable(final CoreMeasurement measurement)
		{
			super(measurement);
		}

		@Override
		public EditorType getInfo()
		{
			if (_myEditor == null)
				_myEditor = new Meas_Info(this);
			return _myEditor;
		}

		// ///////////////////////////////////////////////////////////
		// info class
		// //////////////////////////////////////////////////////////
		public class Meas_Info extends Editable.EditorType implements Serializable
		{

			/**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public Meas_Info(final FrequencyMeasurementEditable data)
			{
				super(data, data.getName(), "");
			}

			@Override
			public PropertyDescriptor[] getPropertyDescriptors()
			{
				try
				{
					final PropertyDescriptor[] res =
					{ prop("Active", "whether to use this bearing", EditorType.OPTIONAL) };

					return res;
				}
				catch (final IntrospectionException e)
				{
					return super.getPropertyDescriptors();
				}
			}
		}
	}

	public class FMC_Info extends Editable.EditorType implements Serializable
	{

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		public FMC_Info(final FMC_Wrapper data)
		{
			super(data, data.getName(), "");
		}

		@Override
		public PropertyDescriptor[] getPropertyDescriptors()
		{
			try
			{
				final PropertyDescriptor[] res =
				{
						prop("Name", "name of this contribution", EditorType.FORMAT),
						prop("SoundSpeed", "Speed of Sound (kts)", EditorType.SPATIAL),
						prop("BaseFrequency", "Base radiated frequency", EditorType.SPATIAL)
				};

				return res;
			}
			catch (final IntrospectionException e)
			{
				return super.getPropertyDescriptors();
			}
		}
	}

}
@@ -2298,16 +2298,20 @@
 er%0D%0A%09%7B%0D%0A
+%09%09%0D%0A
 %09%09privat
@@ -2333,24 +2333,57 @@
 yEditor;%0D%0A%0D%0A
+%09%09private double Frequency;%0D%0A%09%09%0D%0A
 %09%09public Fre
@@ -2472,32 +2472,287 @@
 ement);%0D%0A%09%09%7D%0D%0A%0D%0A
+%09%09private FMeasurement getFM()%0D%0A%09%09%7B%0D%0A%09%09%09return (FMeasurement) _myMeas;%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09public double getFrequency()%0D%0A%09%09%7B%0D%0A%09%09%09return getFM().getFrequency();%0D%0A%09%09%7D%0D%0A%0D%0A%09%09public void setFrequency(double frequency)%0D%0A%09%09%7B%0D%0A%09%09%09getFM().setFrequency(frequency);%0D%0A%09%09%7D%0D%0A%0D%0A
 %09%09@Override%0D%0A%09%09p
@@ -3443,16 +3443,25 @@
 %0A%09%09%09%09%09%7B 
+%0D%0A%09%09%09%09%09%09%09
 prop(%22Ac
@@ -3518,17 +3518,104 @@
 PTIONAL)
- 
+,%0D%0A%09%09%09%09%09%09%09prop(%22Frequency%22, %22Measured value of frequency%22, EditorType.SPATIAL),%0D%0A%09%09%09%09%09%09%09
 %7D;%0D%0A%0D%0A%09%09

make more frequency attributes editable