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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : edit_workspace_conf_dlg.cpp
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version May 5 2007)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifdef WX_PRECOMP
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif //__BORLANDC__
#else
#include <wx/wx.h>
#endif //WX_PRECOMP
#include "edit_workspace_conf_dlg.h"
#include "macros.h"
#include "manager.h"
///////////////////////////////////////////////////////////////////////////
EditWorkspaceConfDlg::EditWorkspaceConfDlg( wxWindow* parent, int id, wxString title, wxPoint pos, wxSize size, int style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxHORIZONTAL );
m_wspConfList = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
mainSizer->Add( m_wspConfList, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer* btnSizer;
btnSizer = new wxBoxSizer( wxVERTICAL );
m_buttonRename = new wxButton( this, wxID_ANY, _("&Rename"), wxDefaultPosition, wxDefaultSize, 0 );
btnSizer->Add( m_buttonRename, 0, wxALL, 5 );
m_buttonDelete = new wxButton( this, wxID_ANY, _("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );
btnSizer->Add( m_buttonDelete, 0, wxALL, 5 );
m_buttonClose = new wxButton( this, wxID_CANCEL, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
btnSizer->Add( m_buttonClose, 0, wxALL, 5 );
mainSizer->Add( btnSizer, 0, wxEXPAND, 5 );
this->SetSizer( mainSizer );
this->Layout();
CustomInit();
}
void EditWorkspaceConfDlg::OnListBoxDClick(wxCommandEvent &event)
{
DoRename(event.GetString());
}
void EditWorkspaceConfDlg::CustomInit()
{
//fill the list box
FillList();
ConnectButton(m_buttonDelete, EditWorkspaceConfDlg::OnDelete);
ConnectButton(m_buttonRename, EditWorkspaceConfDlg::OnRename);
ConnectListBoxDClick(m_wspConfList, EditWorkspaceConfDlg::OnRename);
}
void EditWorkspaceConfDlg::FillList()
{
m_wspConfList->Clear();
BuildMatrixPtr matrix = ManagerST::Get()->GetWorkspaceBuildMatrix();
std::list<WorkspaceConfigurationPtr> confs;
confs = matrix->GetConfigurations();
std::list<WorkspaceConfigurationPtr>::iterator iter = confs.begin();
for(; iter != confs.end(); iter++){
m_wspConfList->Append((*iter)->GetName());
m_wspConfList->SetSelection(0);
}
}
void EditWorkspaceConfDlg::OnDelete(wxCommandEvent &event)
{
wxUnusedVar(event);
if(m_wspConfList->GetCount() == 0){
return;
}
wxString delMe = m_wspConfList->GetStringSelection();
if(delMe.IsEmpty()){
return;
}
//remove the requested workspace build configuration
BuildMatrixPtr matrix = ManagerST::Get()->GetWorkspaceBuildMatrix();
wxString msg;
msg << _("Remove workspace configuration '") << delMe << wxT("' ?");
if(wxMessageBox(msg, _("CodeLite"), wxICON_QUESTION | wxYES_NO | wxCANCEL) == wxYES){
matrix->RemoveConfiguration(delMe);
//apply changes
ManagerST::Get()->SetWorkspaceBuildMatrix(matrix);
//refresh list
FillList();
}
}
void EditWorkspaceConfDlg::DoRename(const wxString &selItem)
{
wxTextEntryDialog *dlg = new wxTextEntryDialog(this, _("New Configuration Name:"), _("Rename"), selItem);
if(dlg->ShowModal() == wxID_OK){
wxString newName = dlg->GetValue();
TrimString(newName);
if(!newName.IsEmpty()){
BuildMatrixPtr matrix = ManagerST::Get()->GetWorkspaceBuildMatrix();
WorkspaceConfigurationPtr conf = matrix->GetConfigurationByName(selItem);
//rename the configuration
conf->SetName(newName);
matrix->SetConfiguration(conf);
matrix->RemoveConfiguration(selItem);
//apply changes
ManagerST::Get()->SetWorkspaceBuildMatrix(matrix);
//refresh list
FillList();
}
}
dlg->Destroy();
}
void EditWorkspaceConfDlg::OnRename(wxCommandEvent &event)
{
wxString changeMe;
wxUnusedVar(event);
if(m_wspConfList->GetCount() == 0){
return;
}
changeMe = m_wspConfList->GetStringSelection();
if(changeMe.IsEmpty()){
return;
}
DoRename(changeMe);
}
|