Ember
Loading...
Searching...
No Matches
ParserConfigDialog.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5#include <wx/grid.h>
6#include <wx/listbox.h>
7#include <wx/listctrl.h>
8#include <wx/notebook.h>
9#include <wx/scrolwin.h>
10#include <wx/spinctrl.h>
11#include <wx/wx.h>
12
13// Include ParserConfig for NamingConvention enum
15
16// Forward declarations
17namespace EmberCore {
18class ParserProfile;
19class ConfigManager;
20} // namespace EmberCore
21
25class HelpDialog : public wxDialog {
26 public:
27 HelpDialog(wxWindow *parent, const wxString &title, const wxString &content)
28 : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxSize(700, 600)) {
29 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
30
31 // KEEP IT SIMPLE - just create a text control with content directly
32 wxTextCtrl *textCtrl = new wxTextCtrl(this, wxID_ANY,
33 content, // Set content DIRECTLY in constructor
34 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
35
36 // Dark theme
37 textCtrl->SetBackgroundColour(wxColour(50, 50, 50));
38 textCtrl->SetForegroundColour(wxColour(255, 255, 255));
39
40 mainSizer->Add(textCtrl, 1, wxEXPAND | wxALL, 10);
41
42 // OK button
43 wxButton *okBtn = new wxButton(this, wxID_OK, "OK");
44 mainSizer->Add(okBtn, 0, wxALIGN_CENTER | wxALL, 10);
45
46 SetSizer(mainSizer);
47 CenterOnParent();
48 }
49};
50
57class ParserConfigDialog : public wxDialog {
58 public:
59 explicit ParserConfigDialog(wxWindow *parent);
61
62 private:
63 // UI Creation methods
64 void CreateLayout();
65 wxPanel *CreateLeftSidebar(wxWindow *parent);
66 wxPanel *CreateRightPanel(wxWindow *parent);
67
68 // Tab creation methods
69 wxPanel *CreateDocumentStructureTab(wxNotebook *notebook);
70 wxPanel *CreateTreeElementsTab(wxNotebook *notebook);
71 wxPanel *CreateNodeElementsTab(wxNotebook *notebook);
72 wxPanel *CreateNodeClassificationTab(wxNotebook *notebook);
73 wxPanel *CreateBlackboardTab(wxNotebook *notebook);
74 wxPanel *CreateAdvancedTab(wxNotebook *notebook);
75
76 wxPanel *CreateBottomPanel(wxWindow *parent);
77
78 // Event handlers
79 void OnProfileSelected(wxListEvent &event);
80 void OnNewProfile(wxCommandEvent &event);
81 void OnCloneProfile(wxCommandEvent &event);
82 void OnDeleteProfile(wxCommandEvent &event);
83 void OnImportProfile(wxCommandEvent &event);
84 void OnExportProfile(wxCommandEvent &event);
85 void OnSetActiveProfile(wxCommandEvent &event);
86
87 void OnTestValidate(wxCommandEvent &event);
88 void OnPreviewJSON(wxCommandEvent &event);
89 void OnResetDefaults(wxCommandEvent &event);
90 void OnSave(wxCommandEvent &event);
91 void OnSaveAs(wxCommandEvent &event);
92 void OnCancel(wxCommandEvent &event);
93
94 // Node type list management
95 void OnAddControlType(wxCommandEvent &event);
96 void OnRemoveControlType(wxCommandEvent &event);
97 void OnAddDecoratorType(wxCommandEvent &event);
98 void OnRemoveDecoratorType(wxCommandEvent &event);
99 void OnAddActionType(wxCommandEvent &event);
100 void OnRemoveActionType(wxCommandEvent &event);
101 void OnAddConditionType(wxCommandEvent &event);
102 void OnRemoveConditionType(wxCommandEvent &event);
103
104 // Blackboard type mapping management
105 void OnAddTypeMapping(wxCommandEvent &event);
106 void OnRemoveTypeMapping(wxCommandEvent &event);
107
108 // Custom validation toggle
109 void OnToggleCustomValidation(wxCommandEvent &event);
110
111 // Configuration management
112 void LoadProfiles();
113 void LoadProfileData(std::shared_ptr<EmberCore::ParserProfile> profile);
114 void SaveCurrentProfile();
115 void SaveCurrentProfileIfModified(); // Helper to save only if modified
116 std::shared_ptr<EmberCore::ParserConfig> GetConfigFromUI();
117 void SetUIFromConfig(const EmberCore::ParserConfig &config);
118 bool ValidateCurrentConfig(wxString &errorMsg);
119
120 // Helper methods
121 void UpdateProfileList();
122 void EnableProfileControls(bool enable);
123 wxString GetSelectedProfileName() const;
124
125 private:
126 // Left sidebar components
127 wxListCtrl *m_profileList; // Changed from wxListBox to support per-item coloring
133 wxButton *m_setActiveBtn;
134
135 // Right panel - tabs
136 wxNotebook *m_notebook;
137
138 // Tab 1: Document Structure
139 wxTextCtrl *m_rootElement;
140 wxTextCtrl *m_mainTreeAttr;
141 wxCheckBox *m_caseSensitive;
147
148 // Tab 2: Tree Elements
150 wxTextCtrl *m_treeIdAttr;
152 wxTextCtrl *m_subtreeElement;
153 wxTextCtrl *m_subtreeRefAttr;
155 wxCheckBox *m_requireRootNode;
156
157 // Tab 3: Node Elements
158 wxTextCtrl *m_controlElement;
159 wxTextCtrl *m_actionElement;
163 wxTextCtrl *m_nodeIdAttr;
164 wxTextCtrl *m_nodeNameAttr;
165 wxTextCtrl *m_nodeTypeAttr;
167
168 // Tab 4: Node Classification
183 wxTextCtrl *m_typeAttrName;
184
185 // Tab 5: Blackboard
189 wxTextCtrl *m_entryElement;
190 wxTextCtrl *m_entryKeyAttr;
191 wxTextCtrl *m_entryTypeAttr;
192 wxTextCtrl *m_entryValueAttr;
197
198 // Tab 6: Advanced
200 wxCheckBox *m_detailedErrors;
201 wxCheckBox *m_trackLineColumn;
204 wxTextCtrl *m_xmlNamespace;
209
210 // Bottom panel
211 wxTextCtrl *m_profileName;
216 wxButton *m_saveBtn;
217 wxButton *m_saveAsBtn;
218 wxButton *m_cancelBtn;
219
220 // Data
221 std::shared_ptr<EmberCore::ParserProfile> m_currentProfile;
223
224 // Validation pulse animation
225 wxTimer *m_pulseTimer;
226 float m_pulsePhase; // 0.0 to 1.0, drives the animation
227 wxColour m_normalBg;
229
230 void OnPulseTimer(wxTimerEvent &event);
231 void UpdateFieldColors();
232 wxColour InterpolateColor(const wxColour &color1, const wxColour &color2, float t);
233 bool IsFieldEmpty(wxTextCtrl *field);
234 bool IsFieldEmpty(wxChoice *field);
235 bool HasInvalidCharacters(wxTextCtrl *field);
236 bool IsValidXMLName(const wxString &name);
237 bool IsValidXMLName(const wxString &name, EmberCore::ParserConfig::NamingConvention convention);
239 void OnFieldChanged(wxCommandEvent &event);
240 void OnAnyControlChanged(wxCommandEvent &event); // Generic handler for any control change
241 void OnNamingConventionChanged(wxCommandEvent &event);
242
244
245 // Control IDs
246 enum {
254
263
266
268
274
276 };
277};
Manages parser configuration profiles.
Configuration for XML parser behavior and element/attribute mappings.
NamingConvention
Naming convention strictness.
A named parser configuration profile with metadata.
HelpDialog(wxWindow *parent, const wxString &title, const wxString &content)
void OnSaveAs(wxCommandEvent &event)
wxCheckBox * m_allowUndefinedKeys
wxCheckBox * m_allowCustomAttrs
void OnAddControlType(wxCommandEvent &event)
wxTextCtrl * m_genericNodeElement
wxTextCtrl * m_blackboardParentAttr
wxPanel * CreateNodeClassificationTab(wxNotebook *notebook)
void OnRemoveConditionType(wxCommandEvent &event)
wxTextCtrl * m_entryValueAttr
void SetUIFromConfig(const EmberCore::ParserConfig &config)
wxTextCtrl * m_subtreeRefAttr
wxChoice * m_classificationStrategy
wxCheckBox * m_enableProgressReporting
wxTextCtrl * m_conditionElement
wxPanel * CreateNodeElementsTab(wxNotebook *notebook)
void OnRemoveActionType(wxCommandEvent &event)
wxTextCtrl * m_decoratorElement
void OnNewProfile(wxCommandEvent &event)
wxTextCtrl * m_blackboardElement
wxListBox * m_decoratorTypesList
void OnFieldChanged(wxCommandEvent &event)
void OnSetActiveProfile(wxCommandEvent &event)
wxTextCtrl * m_profileDescription
void OnAddActionType(wxCommandEvent &event)
wxCheckBox * m_preserveComments
wxPanel * CreateDocumentStructureTab(wxNotebook *notebook)
wxCheckBox * m_trackLineColumn
void OnExportProfile(wxCommandEvent &event)
wxString GetSelectedProfileName() const
wxCheckBox * m_namingConventionLoose
wxCheckBox * m_requireRootNode
wxListBox * m_conditionTypesList
wxTextCtrl * m_controlElement
void OnCloneProfile(wxCommandEvent &event)
wxButton * m_removeControlTypeBtn
wxButton * m_removeConditionTypeBtn
wxCheckBox * m_namingConventionStrict
void OnAnyControlChanged(wxCommandEvent &event)
void OnDeleteProfile(wxCommandEvent &event)
wxCheckBox * m_validateStructure
wxCheckBox * m_allowMultipleTrees
wxTextCtrl * m_blackboardIdAttr
wxCheckBox * m_allowUnknownElements
void OnToggleCustomValidation(wxCommandEvent &event)
bool HasInvalidCharacters(wxTextCtrl *field)
void OnPreviewJSON(wxCommandEvent &event)
void OnPulseTimer(wxTimerEvent &event)
wxTextCtrl * m_behaviorTreeElement
void OnCancel(wxCommandEvent &event)
void EnableProfileControls(bool enable)
bool IsValidXMLName(const wxString &name)
void OnRemoveTypeMapping(wxCommandEvent &event)
wxButton * m_removeDecoratorTypeBtn
ParserConfigDialog(wxWindow *parent)
wxPanel * CreateBlackboardTab(wxNotebook *notebook)
void OnAddTypeMapping(wxCommandEvent &event)
std::shared_ptr< EmberCore::ParserProfile > m_currentProfile
wxCheckBox * m_enableCustomValidation
wxCheckBox * m_preserveAttrOrder
void OnAddConditionType(wxCommandEvent &event)
bool IsFieldEmpty(wxTextCtrl *field)
void OnRemoveControlType(wxCommandEvent &event)
void OnTestValidate(wxCommandEvent &event)
EmberCore::ParserConfig::NamingConvention GetCurrentNamingConvention() const
void OnAddDecoratorType(wxCommandEvent &event)
wxPanel * CreateLeftSidebar(wxWindow *parent)
wxTextCtrl * m_subtreeElement
bool ValidateCurrentConfig(wxString &errorMsg)
wxTextCtrl * m_customValidation
wxCheckBox * m_namingConventionBalanced
void OnImportProfile(wxCommandEvent &event)
wxPanel * CreateTreeElementsTab(wxNotebook *notebook)
wxPanel * CreateBottomPanel(wxWindow *parent)
void OnNamingConventionChanged(wxCommandEvent &event)
void OnResetDefaults(wxCommandEvent &event)
wxSpinCtrl * m_maxRecursionDepth
wxColour InterpolateColor(const wxColour &color1, const wxColour &color2, float t)
void OnRemoveDecoratorType(wxCommandEvent &event)
void LoadProfileData(std::shared_ptr< EmberCore::ParserProfile > profile)
void OnSave(wxCommandEvent &event)
wxPanel * CreateAdvancedTab(wxNotebook *notebook)
wxCheckBox * m_detailedErrors
void OnProfileSelected(wxListEvent &event)
std::shared_ptr< EmberCore::ParserConfig > GetConfigFromUI()
wxPanel * CreateRightPanel(wxWindow *parent)
Main types header for EmberCore.