/*
 *    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.cmap.core.property_support.ui;

import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.mwc.cmap.core.CorePlugin;

public class ValueWithUnitsCellEditor2 extends CellEditor
{
	/**
	 * the control we're using
	 * 
	 */
	private ValueWithUnitsControl _myControl;

	/**
	 * constructor
	 * 
	 * @param parent
	 *          where to stick ourselves
	 * @param textTip
	 *          the tooltip on the text field
	 * @param comboText
	 *          the tooltip on the combo box
	 * @param dataModel
	 *          the data model we're manipulating
	 */
	public ValueWithUnitsCellEditor2(final Composite parent, final String textTip,
			final String comboTip, final ValueWithUnitsDataModel model)
	{
		super(parent);

		if (_myControl != null)
			_myControl.init(textTip, comboTip, model);
		else
			CorePlugin.logError(Status.ERROR, "trying to create ValueWithUnitsCellEditor2 with corrupted control", null);
	}

	@Override
	protected Control createControl(final Composite parent)
	{
		if (_myControl == null)
			_myControl = new ValueWithUnitsControl(parent);
		return _myControl;
	}

	@Override
	protected Object doGetValue()
	{
		return _myControl.getData();
	}

	@Override
	protected void doSetFocus()
	{
		_myControl.setFocus();
	}

	@Override
	protected void doSetValue(final Object value)
	{
		_myControl.setData(value);
	}

}
@@ -857,99 +857,8 @@
 %0D%0A%7B%0D
-%0A%09/**%0D%0A%09 * the control we're using%0D%0A%09 * %0D%0A%09 */%0D%0A%09private ValueWithUnitsControl _myControl;%0D
 %0A%0D%0A%09
@@ -1323,26 +1323,28 @@
 %0D%0A%09%09if (
-_m
+getM
 yControl
  != null
@@ -1335,16 +1335,18 @@
 yControl
+()
  != null
@@ -1351,26 +1351,28 @@
 ll)%0D%0A%09%09%09
-_m
+getM
 yControl
 .init(te
@@ -1363,16 +1363,18 @@
 yControl
+()
 .init(te
@@ -1520,24 +1520,138 @@
  null);%0D%0A%09%7D%0D
+%0A%09%0D%0A%09protected ValueWithUnitsControl getMyControl()%0D%0A%09%7B%0D%0A%09%09return (ValueWithUnitsControl) super.getControl();%0D%0A%09%7D%0D
 %0A%0D%0A%09@Overrid
@@ -1721,16 +1721,64 @@
 %0D%0A%09%09
-if (_myC
+ValueWithUnitsControl control = getMyControl();%0D%0A%09%09if (c
 ontr
@@ -1792,21 +1792,23 @@
 ull)%0D%0A%09%09
-%09_myC
+%7B%0D%0A%09%09%09c
 ontrol =
@@ -1844,16 +1844,21 @@
 rent);%0D%0A
+%09%09%7D%0D%0A
 %09%09return
@@ -1854,28 +1854,25 @@
 %7D%0D%0A%09%09return 
-_myC
+c
 ontrol;%0D%0A%09%7D%0D
@@ -1931,26 +1931,28 @@
 %09return 
-_m
+getM
 yControl
 .getData
@@ -1943,16 +1943,18 @@
 yControl
+()
 .getData
@@ -2008,34 +2008,36 @@
 us()%0D%0A%09%7B%0D%0A%09%09
-_m
+getM
 yControl
 .setFocus();
@@ -2020,24 +2020,26 @@
 getMyControl
+()
 .setFocus();
@@ -2116,18 +2116,20 @@
 %0D%0A%09%09
-_m
+getM
 yControl
 .set
@@ -2124,16 +2124,18 @@
 yControl
+()
 .setData

refactor to overcome FindBugs scariest warning