Ember
Loading...
Searching...
No Matches
PropertiesTab.cpp
Go to the documentation of this file.
1#include "Tabs/PropertiesTab.h"
2
3namespace Ember {
4namespace Monitor {
5
7
8void PropertiesTab::CreateContentLayout(wxPanel *contentPanel) {
9 SetupPropertyGrid(contentPanel);
10
11 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
12 sizer->Add(m_propertyGrid, 1, wxEXPAND | wxALL, 5);
13 contentPanel->SetSizer(sizer);
14}
15
16void PropertiesTab::SetStateManager(std::shared_ptr<Network::StateManager> stateManager) {
17 m_stateManager = stateManager;
18}
19
21
23 if (m_selectedNode) {
24 m_propertyGrid->Clear();
26 m_propertyGrid->Refresh();
27 }
28}
29
38
41 return;
42
43 m_propertyGrid->Append(new wxPropertyCategory("Status"));
44 int status = static_cast<int>(m_stateManager->GetNodeStatus(static_cast<int64_t>(m_selectedNode->GetId())));
45 m_propertyGrid->Append(new wxStringProperty("Current Status", wxPG_LABEL, StatusToString(status)));
46 m_propertyGrid->Append(
47 new wxIntProperty("Current Tick", wxPG_LABEL, static_cast<int>(m_stateManager->GetCurrentTick())));
48
49 bool inPath = false;
50 const auto &path = m_stateManager->GetExecutionPath();
51 int64_t nodeId = static_cast<int64_t>(m_selectedNode->GetId());
52 for (auto id : path) {
53 if (id == nodeId) {
54 inPath = true;
55 break;
56 }
57 }
58 m_propertyGrid->Append(new wxBoolProperty("In Execution Path", wxPG_LABEL, inPath));
59}
60
62 wxPropertyGridIterator it = m_propertyGrid->GetIterator();
63 while (!it.AtEnd()) {
64 wxPGProperty *prop = *it;
65 prop->Enable(false);
66 it.Next();
67 }
68}
69
70wxString PropertiesTab::StatusToString(int status) const {
71 switch (status) {
72 case 0:
73 return "Idle";
74 case 1:
75 return "Running";
76 case 2:
77 return "Success";
78 case 3:
79 return "Failure";
80 case 4:
81 return "Halted";
82 default:
83 return "Unknown";
84 }
85}
86
87} // namespace Monitor
88} // namespace Ember
void InitLayout()
Initializes the tab layout (stack, placeholder, content panels).
PropertiesTabBase(wxWindow *parent)
void SetupPropertyGrid(wxPanel *parent)
Creates and configures the property grid in the given parent.
EmberCore::ITreeNode * m_selectedNode
void ClearSelection()
Clears the current selection.
void AddBasicNodeInfo()
Adds basic node info (name, type) to the property grid.
wxString StatusToString(int status) const
void ClearNode()
Clears the currently selected node and resets the property display.
void CreateContentLayout(wxPanel *contentPanel) override
Builds the content layout for the property panel.
void SetStateManager(std::shared_ptr< Network::StateManager > stateManager)
Assigns the state manager used for live status lookups.
void PopulateProperties() override
Fills the property grid with node properties and status.
void Refresh() override
Refreshes the tab content.
PropertiesTab(wxWindow *parent)
std::shared_ptr< Network::StateManager > m_stateManager