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
|
#include "NodeJSLocator.h"
#include "WebToolsConfig.h"
#include "WebToolsSettings.h"
#include "clNodeJS.h"
#include "globals.h"
#include "windowattrmanager.h"
WebToolsSettings::WebToolsSettings(wxWindow* parent)
: WebToolsSettingsBase(parent)
, m_modified(false)
{
{
WebToolsConfig& config = WebToolsConfig::Get();
// XML
m_checkBoxEnableXmlCC->SetValue(config.HasXmlFlag(WebToolsConfig::kXmlEnableCC));
// HTML
m_checkBoxEnableHtmlCC->SetValue(config.HasHtmlFlag(WebToolsConfig::kHtmlEnableCC));
// NodeJS
m_filePickerNodeJS->SetPath(config.GetNodejs());
m_filePickerNpm->SetPath(config.GetNpm());
m_checkBoxJSLint->SetValue(config.IsLintOnSave());
}
::clSetDialogBestSizeAndPosition(this);
}
WebToolsSettings::~WebToolsSettings() {}
void WebToolsSettings::OnOKUI(wxUpdateUIEvent& event) { event.Enable(m_modified); }
void WebToolsSettings::OnOK(wxCommandEvent& event)
{
DoSave();
event.Skip();
}
void WebToolsSettings::OnModified(wxCommandEvent& event) { m_modified = true; }
void WebToolsSettings::OnSuggestNodeJSPaths(wxCommandEvent& event)
{
NodeJSLocator locator;
locator.Locate();
m_filePickerNodeJS->SetPath(locator.GetNodejs());
m_filePickerNpm->SetPath(locator.GetNpm());
m_modified = true;
}
void WebToolsSettings::OnNodejsPath(wxFileDirPickerEvent& event)
{
m_modified = true;
event.Skip();
}
void WebToolsSettings::OnNpmPath(wxFileDirPickerEvent& event)
{
m_modified = true;
event.Skip();
}
void WebToolsSettings::OnApply(wxCommandEvent& event) { DoSave(); }
void WebToolsSettings::DoSave()
{
WebToolsConfig& config = WebToolsConfig::Get();
// XML
config.EnableXmlFlag(WebToolsConfig::kXmlEnableCC, m_checkBoxEnableXmlCC->IsChecked());
// HTML
config.EnableHtmlFlag(WebToolsConfig::kHtmlEnableCC, m_checkBoxEnableHtmlCC->IsChecked());
// NodeJS
config.SetNodejs(m_filePickerNodeJS->GetPath());
config.SetNpm(m_filePickerNpm->GetPath());
config.SetLintOnSave(m_checkBoxJSLint->IsChecked());
wxFileName fnNodeJS(config.GetNodejs());
wxArrayString hints;
if(fnNodeJS.FileExists()) {
hints.Add(fnNodeJS.GetPath());
}
clNodeJS::Get().Initialise(hints);
m_modified = false;
}
void WebToolsSettings::OnLintOnSave(wxCommandEvent& event)
{
wxUnusedVar(event);
m_modified = true;
}
|