Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions Viewer/ecflowUI/src/Highlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#include <QTextDocument>
#include <QTextDocumentFragment>
#include <QTextLayout>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>

#include "UiLog.hpp"
#include "UserMessage.hpp"
#include "VParam.hpp"
#include "ecflow/core/PTree.hpp"

std::string Highlighter::parFile_;

Expand Down Expand Up @@ -72,13 +72,13 @@ void Highlighter::init(const std::string& parFile) {

void Highlighter::load(QString id) {
// Parse param file using the boost JSON property tree parser
using boost::property_tree::ptree;
ptree pt;

ecf::PTree pt;

try {
read_json(parFile_, pt);
}
catch (const boost::property_tree::json_parser::json_parser_error& e) {
catch (const ecf::PTreeParseError& e) {
std::string errorMessage = e.what();
UserMessage::message(UserMessage::ERROR,
true,
Expand All @@ -87,30 +87,28 @@ void Highlighter::load(QString id) {
return;
}

ptree::const_assoc_iterator itTop = pt.find(id.toStdString());
if (itTop == pt.not_found()) {
auto itTop = pt.find(id.toStdString());
if (itTop == pt.end()) { // Not found!
return;
}

// For each parameter
for (ptree::const_iterator itRule = itTop->second.begin(); itRule != itTop->second.end(); ++itRule) {
// For each Rule
for (auto& [ruleName, ruleValue] : itTop->second) {
QString pattern;
QTextCharFormat format;

ptree ptPar = itRule->second;

if (auto itPar = ptPar.find("pattern"); itPar != ptPar.not_found()) {
if (auto itPar = ruleValue.find("pattern"); itPar != ruleValue.end()) { // Found!
pattern = QString::fromStdString(itPar->second.get_value<std::string>());
}
if (auto itPar = ptPar.find("colour"); itPar != ptPar.not_found()) {
if (auto itPar = ruleValue.find("colour"); itPar != ruleValue.end()) { // Found!
format.setForeground(VProperty::toColour(itPar->second.get_value<std::string>()));
}
if (auto itPar = ptPar.find("bold"); itPar != ptPar.not_found()) {
if (auto itPar = ruleValue.find("bold"); itPar != ruleValue.end()) { // Found!
if (itPar->second.get_value<std::string>() == "true") {
format.setFontWeight(QFont::Bold);
}
}
if (auto itPar = ptPar.find("italic"); itPar != ptPar.not_found()) {
if (auto itPar = ruleValue.find("italic"); itPar != ruleValue.end()) { // Found!
if (itPar->second.get_value<std::string>() == "true") {
format.setFontItalic(true);
}
Expand Down
41 changes: 17 additions & 24 deletions Viewer/ecflowUI/src/InfoPanelHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

#include "InfoPanelHandler.hpp"

#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>

#include "NodeExpression.hpp"
#include "UiLog.hpp"
#include "UserMessage.hpp"
#include "ecflow/core/PTree.hpp"

InfoPanelHandler* InfoPanelHandler::instance_ = nullptr;

Expand All @@ -37,49 +35,44 @@ InfoPanelHandler* InfoPanelHandler::instance() {
}

void InfoPanelHandler::init(const std::string& configFile) {
// parse the response using the boost JSON property tree parser
// Parse JSON file using ecf::PTree (SAX-based, supports repeated keys)

using boost::property_tree::ptree;
ptree pt;
ecf::PTree pt;

try {
read_json(configFile, pt);
}
catch (const boost::property_tree::json_parser::json_parser_error& e) {
catch (const ecf::PTreeParseError& e) {
std::string errorMessage = e.what();
UserMessage::message(
UserMessage::ERROR, true, std::string("Error, unable to parse JSON menu file : " + errorMessage));
return;
}

// iterate over the top level of the tree
for (ptree::const_iterator itTopLevel = pt.begin(); itTopLevel != pt.end(); ++itTopLevel) {
if (itTopLevel->first == "info_panel") {
for (auto& [topLevelName, topLevelValue] : pt) {
if (topLevelName == "info_panel") {
UiLog().dbg() << "Panels:";

ptree const& panelsPt = itTopLevel->second;

// iterate through all the panels
for (ptree::const_iterator itPanel = panelsPt.begin(); itPanel != panelsPt.end(); ++itPanel) {
ptree const& panelPt = itPanel->second;

std::string cname = panelPt.get("name", "");
for (auto& [_, panelValue] : topLevelValue) {
std::string cname = panelValue.get("name", "");

UiLog().dbg() << " " << cname;

auto* def = new InfoPanelDef(cname);

def->setLabel(panelPt.get("label", ""));
def->setIcon(panelPt.get("icon", ""));
def->setDockIcon(panelPt.get("dock_icon", ""));
def->setShow(panelPt.get("show", ""));
def->setTooltip(panelPt.get("tooltip", ""));
def->setButtonTooltip(panelPt.get("button_tooltip", ""));
def->setLabel(panelValue.get("label", ""));
def->setIcon(panelValue.get("icon", ""));
def->setDockIcon(panelValue.get("dock_icon", ""));
def->setShow(panelValue.get("show", ""));
def->setTooltip(panelValue.get("tooltip", ""));
def->setButtonTooltip(panelValue.get("button_tooltip", ""));

std::string enabled = panelPt.get("enabled_for", "");
std::string visible = panelPt.get("visible_for", "");
std::string enabled = panelValue.get("enabled_for", "");
std::string visible = panelValue.get("visible_for", "");

if (panelPt.get("hidden", "") == "1") {
if (panelValue.get("hidden", "") == "1") {
def->setHidden(true);
}

Expand Down
1 change: 0 additions & 1 deletion Viewer/ecflowUI/src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <QSplitter>
#include <QToolBar>
#include <QVBoxLayout>
#include <boost/property_tree/json_parser.hpp>

#include "AboutDialog.hpp"
#include "ChangeNotify.hpp"
Expand Down
1 change: 0 additions & 1 deletion Viewer/ecflowUI/src/MainWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include <QMainWindow>
#include <QSettings>
#include <boost/property_tree/ptree.hpp>

#include "VInfo.hpp"
#include "ui_MainWindow.h"
Expand Down
86 changes: 32 additions & 54 deletions Viewer/ecflowUI/src/MenuHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <QShortcut>
#include <QVBoxLayout>
#include <QWidgetAction>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>

#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include <QRegExp>
Expand All @@ -39,6 +37,7 @@
#include "VNode.hpp"
#include "VProperty.hpp"
#include "ViewerUtil.hpp"
#include "ecflow/core/PTree.hpp"
#include "ecflow/core/Str.hpp"

int MenuItem::idCnt_ = 0;
Expand All @@ -59,15 +58,14 @@ MenuHandler::MenuHandler() {
// ---------------------------------------------------------

bool MenuHandler::readMenuConfigFile(const std::string& configFile) {
// parse the response using the boost JSON property tree parser
// Parse JSON file using ecf::PTree (SAX-based, supports repeated keys)

using boost::property_tree::ptree;
ptree pt;
ecf::PTree pt;

try {
read_json(configFile, pt);
}
catch (const boost::property_tree::json_parser::json_parser_error& e) {
catch (const ecf::PTreeParseError& e) {
std::string errorMessage = e.what();
UserMessage::message(
UserMessage::ERROR, true, std::string("Error, unable to parse JSON menu file : " + errorMessage));
Expand All @@ -76,69 +74,49 @@ bool MenuHandler::readMenuConfigFile(const std::string& configFile) {

// iterate over the top level of the tree

for (ptree::const_iterator itTopLevel = pt.begin(); itTopLevel != pt.end(); ++itTopLevel) {
// parse the menu definitions?
for (auto& [nameTop, valueTop] : pt) {

if (itTopLevel->first == "menus") {
if (nameTop == "menus") {
UiLog().dbg() << "Menus:";

ptree const& menusDef = itTopLevel->second;

// iterate through all the menus

for (ptree::const_iterator itMenus = menusDef.begin(); itMenus != menusDef.end(); ++itMenus) {
ptree const& menuDef = itMenus->second;
for (auto& [menuName, menuValue] : valueTop) {

std::string cname = menuDef.get("name", "NoName");
std::string cname = menuValue.get("name", "NoName");
UiLog().dbg() << " " << cname;
auto* menu = new Menu(cname);

// ptree const &menuModesDef = menuDef.get_child("modes");

// for (ptree::const_iterator itMenuModes = menuModesDef.begin(); itMenuModes != menuModesDef.end();
// ++itMenuModes)
//{
// std::cout << " +" << itMenuModes->second.data() << std::endl;
//}

std::string parentMenuName = menuDef.get("parent", "None");

if (parentMenuName != "None") {}
std::string parentMenuName = menuValue.get("parent", "None");

addMenu(menu); // add to our list of available menus
}
}

// parse the menu items?

else if (itTopLevel->first == "menu_items") {
else if (nameTop == "menu_items") {
UiLog().dbg() << "Menu items:";

ptree const& itemsDef = itTopLevel->second;

// iterate through all the items

for (ptree::const_iterator itItems = itemsDef.begin(); itItems != itemsDef.end(); ++itItems) {
ptree const& ItemDef = itItems->second;

std::string name = ItemDef.get("name", "NoName");
std::string menuName = ItemDef.get("menu", "NoMenu");
std::string command = ItemDef.get("command", "NoCommand");
std::string type = ItemDef.get("type", "Command");
std::string enabled = ItemDef.get("enabled_for", "");
std::string visible = ItemDef.get("visible_for", "");
std::string questFor = ItemDef.get("question_for", "");
std::string question = ItemDef.get("question", "");
std::string questionControl = ItemDef.get("question_control", "");
std::string warning = ItemDef.get("warning", "");
std::string handler = ItemDef.get("handler", "");
std::string views = ItemDef.get("view", "");
std::string icon = ItemDef.get("icon", "");
std::string hidden = ItemDef.get("hidden", "false");
std::string multiSelect = ItemDef.get("multi", "true");
std::string statustip = ItemDef.get("status_tip", "");
std::string shortcut = ItemDef.get("shortcut", "");
std::string panelPopupControl = ItemDef.get("panel_control", "");
// iterator through all menu_items

for (auto& [itemName, itemValue] : valueTop) {

std::string name = itemValue.get("name", "NoName");
std::string menuName = itemValue.get("menu", "NoMenu");
std::string command = itemValue.get("command", "NoCommand");
std::string type = itemValue.get("type", "Command");
std::string enabled = itemValue.get("enabled_for", "");
std::string visible = itemValue.get("visible_for", "");
std::string questFor = itemValue.get("question_for", "");
std::string question = itemValue.get("question", "");
std::string questionControl = itemValue.get("question_control", "");
std::string warning = itemValue.get("warning", "");
std::string handler = itemValue.get("handler", "");
std::string views = itemValue.get("view", "");
std::string icon = itemValue.get("icon", "");
std::string hidden = itemValue.get("hidden", "false");
std::string multiSelect = itemValue.get("multi", "true");
std::string statustip = itemValue.get("status_tip", "");
std::string shortcut = itemValue.get("shortcut", "");
std::string panelPopupControl = itemValue.get("panel_control", "");

// std::cout << " " << name << " :" << menuName << std::endl;

Expand Down
4 changes: 0 additions & 4 deletions Viewer/ecflowUI/src/NodePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,20 +328,16 @@ void NodePanel::writeSettings(VComboSettings* vs) {
vs->put("currentTabId", currentIdx);

for (int i = 0; i < count(); i++) {
// boost::property_tree::ptree ptTab;
if (Dashboard* nw = nodeWidget(i)) {
std::string id = NodePanel::tabSettingsId(i);
vs->beginGroup(id);
nw->writeSettings(vs);
vs->endGroup();
// pt.add_child("tab_"+ ecf::convert_to<std::string>(i),ptTab);
}
}
}

void NodePanel::readSettings(VComboSettings* vs) {
using boost::property_tree::ptree;

auto cnt = vs->get<int>("tabCount", 0);
auto currentIndex = vs->get<int>("currentTabId", -1);

Expand Down
1 change: 0 additions & 1 deletion Viewer/ecflowUI/src/NodePanel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#define ecflow_viewer_NodePanel_HPP

#include <QIcon>
#include <boost/property_tree/ptree.hpp>

#include "TabWidget.hpp"
#include "VInfo.hpp"
Expand Down
2 changes: 0 additions & 2 deletions Viewer/ecflowUI/src/ServerFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

class VSettings;

#include <boost/property_tree/ptree.hpp>

class ServerFilterObserver {
public:
virtual ~ServerFilterObserver() = default;
Expand Down
Loading
Loading