void ExternalToolsDialog::Apply()
{

    // If a tool doesn't have a name, give it one since this prevents
    // us from putting it in the menu.

    int selectedItem = m_listBox->GetSelection();

    for (unsigned int i = 0; i < m_workingTools.size(); ++i)
    {

        ExternalTool* tool = m_workingTools[i];

        if (tool->GetTitle().IsEmpty())
        {

            tool->SetTitle("Unnamed Tool");

            m_listBox->Delete(i);
            m_listBox->Insert(tool->GetTitle(), i);

        }
    }

    m_listBox->SetSelection(selectedItem);
    UpdateControlsForSelection(selectedItem);

    // Apply the changes.

    CopyVector(*m_appliedTools, m_workingTools);

}
void ExternalToolsDialog::OnAdd(wxCommandEvent& event)
{

    ExternalTool* tool = new ExternalTool;
    m_workingTools.push_back(tool);

    m_listBox->Append(tool->GetTitle());

    int newItem = m_listBox->GetCount() - 1;

    m_listBox->SetSelection(newItem);
    UpdateControlsForSelection(newItem);

    m_titleTextBox->SetFocus();

}
void ExternalToolsDialog::OnTitleTextBoxChanged(wxCommandEvent& event)
{

    ExternalTool* tool = GetSelectedTool();

    if (tool != NULL)
    {

        tool->SetTitle(m_titleTextBox->GetValue());
        int selectedItem = m_listBox->GetSelection();

        m_listBox->Delete(selectedItem);
        m_listBox->Insert(tool->GetTitle(), selectedItem);
        m_listBox->SetSelection(selectedItem);

    }

}