1 #include <DatabaseUtils/GUI/TabbedSetOfTreeEditors.h> 2 #include <DatabaseUtils/GUI/ConfigDataTreeEditor.h> 3 #include <DatabaseUtils/GUI/DataTreeCreatorThread.h> 4 #include <DatabaseUtils/GUI/CustomTabBehaviors.h> 5 #include <DatabaseUtils/DAQConfig/NamedConfigUtils.h> 6 #include <boost/shared_ptr.hpp> 7 #include <QtGui/QProgressDialog> 14 TabbedSetOfTreeEditors::
17 const std::vector<std::string>& tableDefinitionList,
18 QWidget *
parent) : QTabWidget(parent),
27 this->addTab(editor,
"unknown table");
43 progressBar.reset(
new QProgressDialog(
"Loading data...",
"Close", 0,
44 this->
count(),
this));
45 progressBar->setWindowModality(Qt::WindowModal);
46 progressBar->setMinimumDuration(250);
49 std::vector<int64_t> subsystemConfigIdList;
51 getSubsystemConfigIdAncestryFromGlobalId(idSpec,
54 subsystemConfigIdList)) {
58 boost::shared_ptr<DataTreeCreatorThread> treeThreadPtr;
59 std::vector<boost::shared_ptr<DataTreeCreatorThread> > treeThreadList;
63 subsystemConfigIdList,
this));
64 treeThreadList.push_back(treeThreadPtr);
68 for (uint32_t
idx = 0;
idx < treeThreadList.size(); ++
idx) {
70 treeThreadPtr = treeThreadList[
idx];
71 treeThreadPtr->wait();
72 boost::shared_ptr<ConfigDataTree> dataTreePtr=treeThreadPtr->getTree();
74 QWidget* theWidget = widget(
idx);
77 if (! editor->
loadData(dataTreePtr)) {status =
false;}
78 this->setTabText(
idx, dataTreePtr->getTableName().c_str());
88 QWidget* theWidget = widget(
idx);
105 progressBar.reset(
new QProgressDialog(
"Loading data...",
"Close", 0,
106 this->
count(),
this));
107 progressBar->setWindowModality(Qt::WindowModal);
108 progressBar->setMinimumDuration(250);
112 std::vector<int64_t> existingSubystemConfigIdList;
114 getSubsystemConfigIdAncestryFromGlobalId(oldGlobalIdSpec,
116 existingSubystemConfigIdList)) {
117 std::cerr <<
"ERROR: unable to fetch the existing named subsystem " 121 int64_t oldSubsystemConfigId = existingSubystemConfigIdList[0];
122 IDSpec oldSubsystemIdSpec(oldSubsystemConfigId, IDSpec::SUBSYSTEM,
124 IDSpec::DAQ : IDSpec::SLOWCONTROLS));
127 if (newGlobalNameSpec.
getConfigName() !=
"InitialGlobalConfig" &&
128 newGlobalNameSpec.
getConfigName() !=
"ColdDetectorSettings") {
131 paramSet.
put(NamedConfigUtils::NAME_COLUMN_NAME, newName);
133 paramSet.
put(NamedConfigUtils::DCMOPMODE_COLUMN_NAME,
135 paramSet.
put(NamedConfigUtils::DESCRIPTION_COLUMN_NAME,
136 "New values from the Configuration Editor GUI.");
137 paramSet.
put(NamedConfigUtils::GLOBALCFGID_COLUMN_NAME,
138 boost::lexical_cast<std::string>
140 int64_t subsystemConfigId;
142 NamedConfigUtils::copySubsystemConfig(oldSubsystemIdSpec,
true,
145 if (resultStatus.
code ==
146 NamedConfigUtils::COPY_FOUND_UPDATE_IN_PROGRESS) {
147 std::cerr <<
"Unable to create a copy of the named " 148 <<
"subsystem configuration with ID = " 149 << oldSubsystemConfigId
150 <<
": the creation of a new configuration is " 151 <<
"already in progress (" 156 else if (resultStatus.
code ==
157 NamedConfigUtils::COPY_FOUND_INTERMEDIATE_UPDATE) {
158 std::cerr <<
"Unable to create a copy of the named " 159 <<
"subsystem configuration with ID = " 160 << oldSubsystemConfigId
161 <<
": intermediate changes would be overwritten by " 162 <<
"this change (" << resultStatus.
message <<
")" 166 else if (resultStatus.
code != NamedConfigUtils::COPY_SUCCEEDED) {
167 std::cerr <<
"Unable to create a copy of the named " 168 <<
"subsystem configuration with ID = " 169 << oldSubsystemConfigId
170 <<
": " << resultStatus.
message 178 QWidget* theWidget = widget(
idx);
181 if (! editor->
saveChanges(oldSubsystemConfigId, subsystemConfigId)) {
186 IDSpec subsystemIdSpec(subsystemConfigId, IDSpec::SUBSYSTEM,
188 IDSpec::DAQ : IDSpec::SLOWCONTROLS));
190 NamedConfigUtils::markConfigDone(subsystemIdSpec,
true);
193 NamedConfigUtils::markConfigDone(subsystemIdSpec,
false);
204 QWidget* theWidget = widget(
idx);
def progressBar(value, endvalue, docdb_id, bar_length=40)
void reactToEditorDataChange()
bool loadData(boost::shared_ptr< daqconfig::ConfigDataTree > dataTree)
int64_t getConfigId() const
void put(const std::string &key, const std::string &value)
void updateTabTextColors(QTabWidget *tabWidget, QTabBar *tabBar)
def connect(endpoint="tcp://127.0.0.1:5555")
bool loadData(const dbutils::daqconfig::IDSpec &idSpec)
bool saveChanges(const int64_t &oldSubsystemConfigId, const int64_t &subsystemConfigId)
std::string getDCMOpMode() const
std::string _subsystemName
std::string getConfigName() const
bool saveChanges(const dbutils::daqconfig::IDSpec &oldGlobalIdSpec, const dbutils::daqconfig::IDSpec &newGlobalIdSpec, const dbutils::daqconfig::GlobalNameSpec &newGlobalNameSpec)
bool isDAQConfiguration() const
std::vector< std::string > _tableDefinitionList