
import java.util.Vector;
import javax.swing.table.DefaultTableModel;
import tmcsim.client.cadclientgui.data.Unit;
/** Spike to try to fix the concurrency error that shows up intermittently
 *  as noted in ticket #87.
 * @author jdalbey
 */
class CADDataSpike
{
    DefaultTableModel unitStatusTableModel;
    Vector<String> unitStatusHeaders;
    Vector<Unit> units;
    /**
     * Accessor to the Unit Status table model 
     *
     * @return DefaultTableModel for UnitStatus
     */
    public DefaultTableModel tableForUnitStatus()
    {
        Vector<Object> toUnitTableVector = new Vector<Object>();

        // build a new unit table 
        for (Unit unit: units)
        {
            toUnitTableVector.add(unit.toVector());
        }
        // Exception occurred here: http://pastebin.com/fvifM5i8
        // Probably a distributed object concurrency problem.
        // Assign the unit status table from the newly created vector
        unitStatusTableModel
                .setDataVector(toUnitTableVector, unitStatusHeaders);
        // return a reference to the updated table
        return unitStatusTableModel;
    }

}
