File: ExternalToolsManager.cpp

package info (click to toggle)
codelite 14.0+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 112,816 kB
  • sloc: cpp: 483,662; ansic: 150,144; php: 9,569; lex: 4,186; python: 3,417; yacc: 2,820; sh: 1,147; makefile: 52; xml: 13
file content (66 lines) | stat: -rw-r--r-- 2,092 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "ExternalToolsManager.h"
#include <algorithm>
#include "ExternalToolsProcessManager.h"
#include "globals.h"
#include "bitmap_loader.h"
#include "imanager.h"

ExternalToolsManager::ExternalToolsManager(wxWindow* parent)
    : ExternalToolsManagerBase(parent)
{
    DoPopulateTable();
}

ExternalToolsManager::~ExternalToolsManager() {}

void ExternalToolsManager::OnKill(wxCommandEvent& event)
{
    wxDataViewItemArray arr;
    m_dvListCtrlTasks->GetSelections(arr);
    for(size_t i = 0; i < arr.size(); ++i) {
        wxDataViewItem item = arr.Item(i);
        ExternalToolItemData* cd = (ExternalToolItemData*)m_dvListCtrlTasks->GetItemData(item);
        ToolsTaskManager::Instance()->Stop(cd->m_pid);
    }
    DoPopulateTable();
}

void ExternalToolsManager::OnKillAll(wxCommandEvent& event)
{
    ToolsTaskManager::Instance()->StopAll();
    DoPopulateTable();
}

void ExternalToolsManager::OnKillAllUI(wxUpdateUIEvent& event) { event.Enable(m_dvListCtrlTasks->GetItemCount()); }
void ExternalToolsManager::OnKillUI(wxUpdateUIEvent& event)
{
    event.Enable(m_dvListCtrlTasks->GetSelectedItemsCount());
}

void ExternalToolsManager::DoPopulateTable()
{
    DoClear();
    BitmapLoader* b = clGetManager()->GetStdIcons();
    const ExternalToolItemData::Map_t& tools = ToolsTaskManager::Instance()->GetTools();
    std::for_each(tools.begin(), tools.end(), [&](const std::pair<int, ExternalToolItemData>& p) {
        wxVector<wxVariant> cols;
        cols.push_back(::MakeIconText(wxString() << p.first, b->LoadBitmap("cog")));
        cols.push_back(p.second.m_command);
        m_dvListCtrlTasks->AppendItem(cols, (wxUIntPtr)p.second.Clone());
    });
}

void ExternalToolsManager::DoClear()
{
    for(int i = 0; i < m_dvListCtrlTasks->GetItemCount(); ++i) {
        ExternalToolItemData* cd =
            (ExternalToolItemData*)m_dvListCtrlTasks->GetItemData(m_dvListCtrlTasks->RowToItem(i));
        delete cd;
    }
    m_dvListCtrlTasks->DeleteAllItems();
}
void ExternalToolsManager::OnRefresh(wxCommandEvent& event)
{
    wxUnusedVar(event);
    DoPopulateTable();
}