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