bool DefaultTreeCellEditor::stopCellEditing(void)
{
    if(_EditingValue.type() == typeid(std::string))
    {
        getDefaultStringEditor()->removeActionListener(&_DefaultTextFieldEditorListener);
        getDefaultStringEditor()->removeFocusListener(&_DefaultTextFieldEditorListener);
        getDefaultStringEditor()->removeKeyListener(&_DefaultTextFieldEditorListener);
    }
    else
    {
        getDefaultEditor()->removeActionListener(&_DefaultTextFieldEditorListener);
        getDefaultEditor()->removeFocusListener(&_DefaultTextFieldEditorListener);
        getDefaultEditor()->removeKeyListener(&_DefaultTextFieldEditorListener);
    }

    return Inherited::stopCellEditing();
}
ComponentTransitPtr DefaultTableCellEditor::getTableCellEditorComponent(Table* const table, const boost::any& value, bool isSelected, UInt32 row, UInt32 column)
{
    if(value.empty()){
        return ComponentTransitPtr(NULL);
    }
    TextFieldRefPtr TheTextField = TextField::create();
    std::string tempString;
    try
    {
        tempString = lexical_cast(value);
    }
    catch (boost::bad_lexical_cast &)
    {
        //Could not convert to string
    }
    TheTextField->setText(tempString);
    TheTextField->setPreferredSize(Vec2f(100,30));
    TheTextField->setAlignment(Vec2f(0.5,0.5));
    TheTextField->selectAll();
    TheTextField->setCaretPosition(TheTextField->getText().size());
    ColorLayerRefPtr tempBackground;
    tempBackground = ColorLayer::create();

    TheTextField->setBackground(tempBackground);

    //if(isSelected){
    //	tempBackground->setColor(Color4f(0.4, 0.4, 1.0, 1.0));
    //}
    //else{
    tempBackground->setColor(Color4f(1.0, 1.0, 1.0, 1.0));
    //}

    LineBorderRefPtr tempBorder;

    tempBorder = LineBorder::create();
    tempBorder->setColor(Color4f(0.0, 0.0, 1.0, 1.0));

    TheTextField->setBorder(tempBorder);

    setDefaultStringEditor(TheTextField);
    _EditorActionConnection = getDefaultStringEditor()->connectActionPerformed(boost::bind(&DefaultTableCellEditor::handleEditorAction, this, _1));
    _EditorFocusLostConnection = getDefaultStringEditor()->connectFocusLost(boost::bind(&DefaultTableCellEditor::handleEditorFocusLost, this, _1));
    _EditorKeyPressedConnection = getDefaultStringEditor()->connectKeyPressed(boost::bind(&DefaultTableCellEditor::handleEditorKeyPressed, this, _1));
    return ComponentTransitPtr(getDefaultStringEditor());
}
ComponentTransitPtr DefaultTreeCellEditor::getComponent(void) const
{
    if(_EditingValue.type() == typeid(std::string))
    {
        return ComponentTransitPtr(getDefaultStringEditor());
    }
    else
    {
        return ComponentTransitPtr(getDefaultEditor());
    }
}
boost::any DefaultTreeCellEditor::getCellEditorValue(void) const
{
    if(_EditingValue.type() == typeid(std::string))
    {
        _EditingValue = boost::any(getDefaultStringEditor()->getText());
    }
    else
    {
        _EditingValue = boost::any();
    }
    return _EditingValue;
}
ComponentTransitPtr DefaultTreeCellEditor::getTreeCellEditorComponent(Tree* const TheTree, const boost::any& Value, bool IsSelected, bool IsExpanded, UInt32 row)
{
    _EditingValue = Value;

    if(_EditingValue.empty()){
        return ComponentTransitPtr(NULL);
    }

    if(_EditingValue.type() == typeid(std::string))
    {
        //Use String Text Field As Editing Component
        std::string tempString;
        try
        {
            tempString = lexical_cast(_EditingValue);
        }
        catch (boost::bad_lexical_cast &)
        {
            //Could not convert to string
        }
        getDefaultStringEditor()->setText(tempString);
        getDefaultStringEditor()->selectAll();
        getDefaultStringEditor()->setCaretPosition(getDefaultStringEditor()->getText().size());

        _EditorActionConnection = getDefaultStringEditor()->connectActionPerformed(boost::bind(&DefaultTreeCellEditor::handleEditorAction, this, _1));
        _EditorFocusLostConnection = getDefaultStringEditor()->connectFocusLost(boost::bind(&DefaultTreeCellEditor::handleEditorFocusLost, this, _1));
        _EditorKeyPressedConnection = getDefaultStringEditor()->connectKeyPressed(boost::bind(&DefaultTreeCellEditor::handleEditorKeyPressed, this, _1));

        return ComponentTransitPtr(getDefaultStringEditor());
    }
    else
    {
        //Use Default Text Field As Editing Component
        std::string tempString;
        getDefaultEditor()->setText(tempString);
        getDefaultEditor()->selectAll();
        getDefaultEditor()->setCaretPosition(getDefaultEditor()->getText().size());

        _EditorActionConnection = getDefaultEditor()->connectActionPerformed(boost::bind(&DefaultTreeCellEditor::handleEditorAction, this, _1));
        _EditorFocusLostConnection = getDefaultEditor()->connectFocusLost(boost::bind(&DefaultTreeCellEditor::handleEditorFocusLost, this, _1));
        _EditorKeyPressedConnection = getDefaultEditor()->connectKeyPressed(boost::bind(&DefaultTreeCellEditor::handleEditorKeyPressed, this, _1));

        return ComponentTransitPtr(getDefaultEditor());
    }
}
ComponentRefPtr DefaultTreeCellEditor::getTreeCellEditorComponent(TreeRefPtr TheTree, const boost::any& Value, bool IsSelected, bool IsExpanded, UInt32 row)
{
    _EditingValue = Value;

    if(_EditingValue.empty()){
        return NULL;
    }

    if(_EditingValue.type() == typeid(std::string))
    {
        //Use String Text Field As Editing Component
        std::string tempString;
        try
        {
            tempString = lexical_cast(_EditingValue);
        }
        catch (boost::bad_lexical_cast &)
        {
            //Could not convert to string
        }
        getDefaultStringEditor()->setText(tempString);
        getDefaultStringEditor()->selectAll();
        getDefaultStringEditor()->setCaretPosition(getDefaultStringEditor()->getText().size());

        getDefaultStringEditor()->addActionListener(&_DefaultTextFieldEditorListener);
        getDefaultStringEditor()->addFocusListener(&_DefaultTextFieldEditorListener);
        getDefaultStringEditor()->addKeyListener(&_DefaultTextFieldEditorListener);

        return getDefaultStringEditor();
    }
    else
    {
        //Use Default Text Field As Editing Component
        std::string tempString;
        getDefaultEditor()->setText(tempString);
        getDefaultEditor()->selectAll();
        getDefaultEditor()->setCaretPosition(getDefaultEditor()->getText().size());

        getDefaultEditor()->addActionListener(&_DefaultTextFieldEditorListener);
        getDefaultEditor()->addFocusListener(&_DefaultTextFieldEditorListener);
        getDefaultEditor()->addKeyListener(&_DefaultTextFieldEditorListener);

        return getDefaultEditor();
    }
}
boost::any DefaultTableCellEditor::getCellEditorValue(void) const
{
    _Value = getDefaultStringEditor()->getText();
    return boost::any(_Value);
}