~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/contrib/lib_finder/projectconfigurationpanel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
//*)
37
37
 
38
38
#include <wx/tokenzr.h>
 
39
#include <wx/choicdlg.h>
39
40
 
40
41
#include "lib_finder.h"
 
42
#include "headersdetectordlg.h"
41
43
 
42
44
//(*IdInit(ProjectConfigurationPanel)
43
45
const long ProjectConfigurationPanel::ID_LISTBOX1 = wxNewId();
 
46
const long ProjectConfigurationPanel::ID_BUTTON6 = wxNewId();
44
47
const long ProjectConfigurationPanel::ID_CHECKBOX2 = wxNewId();
45
48
const long ProjectConfigurationPanel::ID_BUTTON4 = wxNewId();
46
49
const long ProjectConfigurationPanel::ID_BUTTON1 = wxNewId();
49
52
const long ProjectConfigurationPanel::ID_STATICTEXT1 = wxNewId();
50
53
const long ProjectConfigurationPanel::ID_TEXTCTRL2 = wxNewId();
51
54
const long ProjectConfigurationPanel::ID_CHECKBOX1 = wxNewId();
 
55
const long ProjectConfigurationPanel::ID_BUTTON5 = wxNewId();
52
56
const long ProjectConfigurationPanel::ID_TEXTCTRL1 = wxNewId();
53
57
const long ProjectConfigurationPanel::ID_BUTTON3 = wxNewId();
54
58
const long ProjectConfigurationPanel::ID_STATICTEXT2 = wxNewId();
95
99
        wxStaticBoxSizer* StaticBoxSizer2;
96
100
        wxBoxSizer* BoxSizer6;
97
101
        wxBoxSizer* BoxSizer5;
 
102
        wxBoxSizer* BoxSizer7;
98
103
        wxBoxSizer* BoxSizer2;
99
104
        wxStaticBoxSizer* StaticBoxSizer3;
100
105
        wxBoxSizer* BoxSizer1;
101
106
        wxStaticBoxSizer* StaticBoxSizer1;
102
107
        wxBoxSizer* BoxSizer3;
103
108
        wxStaticBoxSizer* m_DisableAuto;
104
 
 
 
109
        
105
110
        Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY"));
106
111
        BoxSizer1 = new wxBoxSizer(wxVERTICAL);
107
112
        BoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
109
114
        StaticBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL, this, _("Libraries used in project"));
110
115
        m_UsedLibraries = new wxListBox(this, ID_LISTBOX1, wxDefaultPosition, wxSize(147,123), 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX1"));
111
116
        StaticBoxSizer1->Add(m_UsedLibraries, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
 
117
        Button2 = new wxButton(this, ID_BUTTON6, _("Try to detect missing ones"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON6"));
 
118
        StaticBoxSizer1->Add(Button2, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
112
119
        BoxSizer5->Add(StaticBoxSizer1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
113
120
        m_DisableAuto = new wxStaticBoxSizer(wxVERTICAL, this, _("Extra settings"));
114
121
        m_NoAuto = new wxCheckBox(this, ID_CHECKBOX2, _("Don\'t setup automatically"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2"));
140
147
        m_Filter = new wxTextCtrl(this, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
141
148
        BoxSizer4->Add(m_Filter, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
142
149
        StaticBoxSizer2->Add(BoxSizer4, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
 
150
        BoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
143
151
        m_Tree = new wxCheckBox(this, ID_CHECKBOX1, _("Show as tree"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
144
152
        m_Tree->SetValue(true);
145
 
        StaticBoxSizer2->Add(m_Tree, 0, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
 
153
        BoxSizer7->Add(m_Tree, 1, wxLEFT|wxRIGHT|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
 
154
        Button1 = new wxButton(this, ID_BUTTON5, _("Edit"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator, _T("ID_BUTTON5"));
 
155
        Button1->Hide();
 
156
        BoxSizer7->Add(Button1, 0, wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
 
157
        StaticBoxSizer2->Add(BoxSizer7, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
146
158
        BoxSizer3->Add(StaticBoxSizer2, 1, wxBOTTOM|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
147
159
        StaticBoxSizer3 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Unknown library"));
148
160
        m_UnknownLibrary = new wxTextCtrl(this, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
160
172
        Timer1.SetOwner(this, ID_TIMER1);
161
173
        BoxSizer1->Fit(this);
162
174
        BoxSizer1->SetSizeHints(this);
163
 
 
 
175
        
164
176
        Connect(ID_LISTBOX1,wxEVT_COMMAND_LISTBOX_SELECTED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_UsedLibrariesSelect);
 
177
        Connect(ID_BUTTON6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ProjectConfigurationPanel::OnButton2Click);
165
178
        Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_AddScriptClick);
166
179
        Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_AddClick);
167
180
        Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ProjectConfigurationPanel::Onm_RemoveClick);
346
359
    }
347
360
 
348
361
    // Ok, let's present all results
349
 
    m_KnownLibrariesTree->ExpandAll();
 
362
//    m_KnownLibrariesTree->ExpandAll();
350
363
    m_KnownLibrariesTree->Thaw();
351
364
}
352
365
 
569
582
 
570
583
    wxMessageBox(_("Script \"lib_finder.script\" successfully added."),_("lib_finder.script Success"),wxOK|wxICON_INFORMATION,this);
571
584
}
 
585
 
 
586
void ProjectConfigurationPanel::OnButton2Click(wxCommandEvent& event)
 
587
{
 
588
    wxArrayString HeadersBase;
 
589
    if ( HeadersDetectorDlg(this,m_Project,HeadersBase).ShowModal() != wxID_OK )
 
590
    {
 
591
        cbMessageBox( _("Cancelled the search"), _("Cancelled"), wxOK | wxICON_WARNING, this );
 
592
        return;
 
593
    }
 
594
 
 
595
    if ( HeadersBase.IsEmpty() )
 
596
    {
 
597
        cbMessageBox( _("Didn't found any #include directive."), _("Error"), wxOK | wxICON_ERROR, this );
 
598
        return;
 
599
    }
 
600
 
 
601
    // Getting array of all known libraries
 
602
    ResultArray AllArray;
 
603
    for ( int i=0; i<rtCount; i++ )
 
604
    {
 
605
        m_KnownLibs[i].GetAllResults(AllArray);
 
606
    }
 
607
    wxArrayString NewLibs;
 
608
 
 
609
    // Sorting and removing duplicates and processing results
 
610
    HeadersBase.Sort();
 
611
    wxString Previous;
 
612
    for ( size_t i=0; i<HeadersBase.Count(); i++ )
 
613
    {
 
614
        if ( Previous != HeadersBase[i] )
 
615
        {
 
616
            Previous = HeadersBase[i];
 
617
            DetectNewLibs( Previous, AllArray, NewLibs );
 
618
        }
 
619
    }
 
620
 
 
621
    // Filtering detected results
 
622
    wxArrayString NewLibsFiltered;
 
623
    NewLibs.Sort();
 
624
    Previous.Clear();
 
625
    for ( size_t i=0; i<NewLibs.Count(); i++ )
 
626
    {
 
627
        if ( Previous != NewLibs[i] )
 
628
        {
 
629
            Previous = NewLibs[i];
 
630
            if ( m_ConfCopy.m_GlobalUsedLibs.Index(Previous) == wxNOT_FOUND )
 
631
            {
 
632
                NewLibsFiltered.Add( Previous );
 
633
            }
 
634
        }
 
635
    }
 
636
 
 
637
    if ( NewLibsFiltered.IsEmpty() )
 
638
    {
 
639
        cbMessageBox(
 
640
            _("Didn't found any missing library for your project.\n"
 
641
              "\n"
 
642
              "This may mean that you project is fully configured\n"
 
643
              "or that missing libraries are not yet recognized\n"
 
644
              "or fully supported in lib_finder plugin"),
 
645
            _("No libraries found"),
 
646
            wxOK | wxICON_ASTERISK,
 
647
            this );
 
648
        return;
 
649
    }
 
650
 
 
651
    wxArrayInt Choices;
 
652
    wxGetMultipleChoices(
 
653
        Choices,
 
654
        _("Select libraries to include in your project"),
 
655
        _("Adding new libraries"),
 
656
        NewLibsFiltered,
 
657
        this);
 
658
 
 
659
    if ( Choices.IsEmpty() )
 
660
    {
 
661
        return;
 
662
    }
 
663
 
 
664
    for ( size_t i=0; i<Choices.Count(); i++ )
 
665
    {
 
666
        wxString Library = NewLibsFiltered[ Choices[i] ];
 
667
        m_ConfCopy.m_GlobalUsedLibs.Add(Library);
 
668
        m_UsedLibraries->Append(GetUserListName(Library),new ListItemData(Library));
 
669
    }
 
670
 
 
671
    // Make sure that after the scan, used won't be able to manually
 
672
    // add currently selected "known" library (through '<' button)
 
673
    // which has just been added automatically
 
674
    wxTreeEvent ev;
 
675
    Onm_KnownLibrariesTreeSelectionChanged(ev);
 
676
}
 
677
 
 
678
void ProjectConfigurationPanel::DetectNewLibs( const wxString& IncludeName, ResultArray& known, wxArrayString& LibsList )
 
679
{
 
680
    wxString FixedInclude = IncludeName;
 
681
    FixedInclude.MakeLower();
 
682
    FixedInclude.Replace(_T("\\"),_T("/"),true);
 
683
    for ( size_t i=0; i<known.Count(); i++ )
 
684
    {
 
685
        for ( size_t j=0; j<known[i]->Headers.Count(); j++ )
 
686
        {
 
687
            if ( FixedInclude.Matches( known[i]->Headers[j].Lower() ) )
 
688
            {
 
689
                LibsList.Add( known[i]->ShortCode );
 
690
                break;
 
691
            }
 
692
        }
 
693
    }
 
694
}