File: new_php_workspace_dlg.cpp

package info (click to toggle)
codelite 12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 95,112 kB
  • sloc: cpp: 424,040; ansic: 18,284; php: 9,569; lex: 4,186; yacc: 2,820; python: 2,294; sh: 312; makefile: 51; xml: 13
file content (65 lines) | stat: -rw-r--r-- 1,813 bytes parent folder | download | duplicates (5)
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
#include "new_php_workspace_dlg.h"
#include <windowattrmanager.h>
#include "php_strings.h"
#include "cl_standard_paths.h"

NewPHPWorkspaceDlg::NewPHPWorkspaceDlg(wxWindow* parent)
    : NewPHPWorkspaceBaseDlg(parent)
{
    m_textCtrlPath->ChangeValue(clStandardPaths::Get().GetDocumentsDir());
    CenterOnParent();
    SetName("NewPHPWorkspaceDlg");
    WindowAttrManager::Load(this);
}

NewPHPWorkspaceDlg::~NewPHPWorkspaceDlg() {}

wxString NewPHPWorkspaceDlg::GetWorkspacePath() const
{
    if(m_textCtrlPath->IsEmpty() || m_textCtrlName->IsEmpty()) {
        return "";
    }

    wxFileName filepath(m_textCtrlPath->GetValue(), m_textCtrlName->GetValue());
    filepath.SetExt(PHPStrings::PHP_WORKSPACE_EXT);
    return filepath.GetFullPath();
}

void NewPHPWorkspaceDlg::OnNameUpdated(wxCommandEvent& event)
{
    event.Skip();
    m_textCtrlPreview->ChangeValue(GetWorkspacePath());
}

void NewPHPWorkspaceDlg::OnOK(wxCommandEvent& event)
{
    EndModal(wxID_OK);
}

void NewPHPWorkspaceDlg::OnCheckMakeSeparateDir(wxCommandEvent& event)
{
    m_textCtrlPreview->ChangeValue(GetWorkspacePath());
}

void NewPHPWorkspaceDlg::OnOKUI(wxUpdateUIEvent& event)
{
    event.Enable(!m_textCtrlPath->GetValue().IsEmpty() && !m_textCtrlName->GetValue().IsEmpty());
}

void NewPHPWorkspaceDlg::OnBrowse(wxCommandEvent& event)
{
    wxString path = ::wxDirSelector(_("select a folder"), m_textCtrlPath->GetValue());
    if(!path.IsEmpty()) {
        m_textCtrlPath->SetValue(path); // we want event here
        m_textCtrlPreview->ChangeValue(GetWorkspacePath());
    }
}

void NewPHPWorkspaceDlg::OnFolderSelected(wxCommandEvent& event)
{
    wxUnusedVar(event);
    wxFileName fn(m_textCtrlPath->GetValue());
    
    // Use the last folder path as the project name
    m_textCtrlName->ChangeValue(fn.GetName());
}