File: NodeJSNewWorkspaceDlg.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 (50 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (6)
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
#include "NodeJSNewWorkspaceDlg.h"
#include "cl_standard_paths.h"

NodeJSNewWorkspaceDlg::NodeJSNewWorkspaceDlg(wxWindow* parent)
    : NodeJSNewWorkspaceDlgBase(parent)
{
    m_dirPickerFolder->SetPath(clStandardPaths::Get().GetDocumentsDir());
    CenterOnParent();
}

NodeJSNewWorkspaceDlg::~NodeJSNewWorkspaceDlg() {}

void NodeJSNewWorkspaceDlg::OnFolderSelected(wxFileDirPickerEvent& event)
{
    event.Skip();
    if(m_textCtrllName->IsEmpty()) {
        wxFileName fn(m_dirPickerFolder->GetPath(), "");
        if(fn.GetDirCount()) {
            m_textCtrllName->ChangeValue(fn.GetDirs().Last());
        }
    }
    UpdatePreview();
}

void NodeJSNewWorkspaceDlg::OnOKUI(wxUpdateUIEvent& event)
{
    wxFileName fn(m_staticTextPreview->GetLabel());
    event.Enable(fn.IsOk() && !m_textCtrllName->GetValue().IsEmpty());
}

void NodeJSNewWorkspaceDlg::OnTextUpdate(wxCommandEvent& event)
{
    event.Skip();
    UpdatePreview();
}

void NodeJSNewWorkspaceDlg::UpdatePreview()
{
    // An empty new workspace
    wxFileName fn(m_dirPickerFolder->GetPath(), m_textCtrllName->GetValue());
    fn.SetExt("workspace");
    if(m_checkBoxNewFolder->IsChecked() && !m_textCtrllName->GetValue().IsEmpty()) {
        fn.AppendDir(m_textCtrllName->GetValue());
    }
    m_staticTextPreview->SetLabel(fn.GetFullPath());
    GetSizer()->Layout();
}

void NodeJSNewWorkspaceDlg::OnCheckNewFolder(wxCommandEvent& event) { UpdatePreview(); }
void NodeJSNewWorkspaceDlg::OnExistingFolderSelected(wxFileDirPickerEvent& event) { UpdatePreview(); }