Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
dbutils::gui::BasicEditorDisplay Class Referenceabstract

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-02/DatabaseUtils/cxx/include/GUI/BasicEditorDisplay.h"

Inheritance diagram for dbutils::gui::BasicEditorDisplay:
dbutils::gui::DAQConfigEditorDisplay dbutils::gui::DCSConfigEditorDisplay

Public Slots

void reloadCurrentDataset ()
 
void loadNewDataset ()
 
void saveChanges ()
 
void saveChangesWithNewName ()
 
void showHelpDialog ()
 
virtual void reactToDataChange ()
 
virtual void reactToDataSave ()
 

Public Member Functions

 BasicEditorDisplay (QWidget *parent=0)
 
virtual ~BasicEditorDisplay ()
 
virtual bool hasChanges () const =0
 

Protected Member Functions

virtual bool _doReloadCurrentDataset (const dbutils::daqconfig::IDSpec &idSpec)=0
 
virtual bool _doLoadNewDataset (const dbutils::daqconfig::IDSpec &idSpec)=0
 
virtual bool _doSaveChanges (const dbutils::daqconfig::IDSpec &oldIdSpec, const dbutils::daqconfig::IDSpec &newIdSpec, const dbutils::daqconfig::GlobalNameSpec &newNameSpec)=0
 
virtual void closeEvent (QCloseEvent *event)
 
bool _confirmSave ()
 
bool _getUserResponseToGlobalCopyFailure (const novadaq::Status &status)
 
void _addHelpMenu (std::string customText="")
 

Protected Attributes

QAction * _saveAction
 
QAction * _saveAsAction
 
SettingsDisplay_settingsDisplay
 
boost::shared_ptr< dbutils::daqconfig::GlobalNameSpec_globalNameSpecPtr
 
int64_t _currentGlobalConfigId
 

Private Attributes

std::string _customHelpText
 

Detailed Description

Class for providing the core functionality for graphical configuration editors.

Author
Kurt Biery
Version
Revision
1.8.24.1
Date
2019/09/27 00:07:04

Definition at line 25 of file BasicEditorDisplay.h.

Constructor & Destructor Documentation

dbutils::gui::BasicEditorDisplay::BasicEditorDisplay ( QWidget *  parent = 0)

Definition at line 17 of file BasicEditorDisplay.cpp.

References _saveAction, _saveAsAction, close(), g4zmq::connect(), loadNewDataset(), reloadCurrentDataset(), saveChanges(), saveChangesWithNewName(), and make_root_from_grid_output::tr.

17  : QMainWindow(parent)
18 {
19 
20  this->setGeometry(0, 0, 750, 468);
21 
22  QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
23 
24  QAction* reloadAction = fileMenu->addAction(tr("&Reload"));
25  QObject::connect(reloadAction, SIGNAL(triggered()),
26  this, SLOT(reloadCurrentDataset()));
27 
28  QAction* openAction = fileMenu->addAction(tr("&Open"));
29  QObject::connect(openAction, SIGNAL(triggered()),
30  this, SLOT(loadNewDataset()));
31 
32  _saveAction = fileMenu->addAction(tr("&Save"));
33  QObject::connect(_saveAction, SIGNAL(triggered()),
34  this, SLOT(saveChanges()));
35  _saveAction->setEnabled(false);
36 
37  _saveAsAction = fileMenu->addAction(tr("Save &As"));
38  QObject::connect(_saveAsAction, SIGNAL(triggered()),
39  this, SLOT(saveChangesWithNewName()));
40  _saveAsAction->setEnabled(false);
41 
42  QAction* exitAction = fileMenu->addAction(tr("E&xit"));
43  QObject::connect(exitAction, SIGNAL(triggered()),
44  this, SLOT(close()));
45 }
def connect(endpoint="tcp://127.0.0.1:5555")
Definition: g4zmq.py:15
procfile close()
virtual dbutils::gui::BasicEditorDisplay::~BasicEditorDisplay ( )
inlinevirtual

Member Function Documentation

void dbutils::gui::BasicEditorDisplay::_addHelpMenu ( std::string  customText = "")
protected

Definition at line 512 of file BasicEditorDisplay.cpp.

References _customHelpText, g4zmq::connect(), showHelpDialog(), and make_root_from_grid_output::tr.

Referenced by dbutils::gui::DAQConfigEditorDisplay::DAQConfigEditorDisplay(), and dbutils::gui::DCSConfigEditorDisplay::DCSConfigEditorDisplay().

513 {
514  _customHelpText = customText;
515 
516  QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
517  QAction* helpAction =
518  helpMenu->addAction(tr("&Help"));
519  QObject::connect(helpAction, SIGNAL(triggered()),
520  this, SLOT(showHelpDialog()));
521 }
def connect(endpoint="tcp://127.0.0.1:5555")
Definition: g4zmq.py:15
bool dbutils::gui::BasicEditorDisplay::_confirmSave ( )
protected

Definition at line 416 of file BasicEditorDisplay.cpp.

References _getUserResponseToGlobalCopyFailure(), novadaq::EnvVarCache::getEnvVar(), novadaq::EnvVarCache::getInstance(), hasChanges(), runNovaSAM::retCode, and string.

Referenced by saveChanges(), saveChangesWithNewName(), and ~BasicEditorDisplay().

417 {
418  if (! hasChanges()) {return false;}
419 
420  std::string dbString =
422  QMessageBox confirmBox(this);
423 
424  std::string msgText = "You are about to update the \"";
425  msgText.append(dbString);
426  msgText.append("\" database.");
427  confirmBox.setText(msgText.c_str());
428 
429  msgText = "Are you sure that you want to save your changes to the \"";
430  msgText.append(dbString);
431  msgText.append("\" database?");
432  confirmBox.setInformativeText(msgText.c_str());
433 
434  confirmBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
435  confirmBox.setDefaultButton(QMessageBox::No);
436  int retCode = confirmBox.exec();
437 
438  return (retCode == QMessageBox::Yes);
439 }
static EnvVarCache & getInstance()
Definition: EnvVarCache.cpp:12
virtual bool hasChanges() const =0
std::string getEnvVar(std::string name)
Definition: EnvVarCache.cpp:33
enum BeamMode string
virtual bool dbutils::gui::BasicEditorDisplay::_doLoadNewDataset ( const dbutils::daqconfig::IDSpec idSpec)
protectedpure virtual
virtual bool dbutils::gui::BasicEditorDisplay::_doReloadCurrentDataset ( const dbutils::daqconfig::IDSpec idSpec)
protectedpure virtual
virtual bool dbutils::gui::BasicEditorDisplay::_doSaveChanges ( const dbutils::daqconfig::IDSpec oldIdSpec,
const dbutils::daqconfig::IDSpec newIdSpec,
const dbutils::daqconfig::GlobalNameSpec newNameSpec 
)
protectedpure virtual
bool dbutils::gui::BasicEditorDisplay::_getUserResponseToGlobalCopyFailure ( const novadaq::Status status)
protected

Definition at line 442 of file BasicEditorDisplay.cpp.

References _currentGlobalConfigId, om::cerr, novadaq::Status::code, allTimeWatchdog::endl, novadaq::Status::message, runNovaSAM::retCode, and string.

Referenced by _confirmSave(), saveChanges(), saveChangesWithNewName(), and ~BasicEditorDisplay().

443 {
444  if (statusObj.code ==
445  NamedConfigUtils::COPY_FOUND_UPDATE_IN_PROGRESS) {
446  std::string msgText = "A problem was found when saving changes to ";
447  msgText.append("the database.<br/><br/>");
448  msgText.append("The creation of a configuration with the same ");
449  msgText.append("name and DCM operating mode is currently in ");
450  msgText.append("progress. (Attempting to copy global ");
451  msgText.append("configuration with ID ");
452  msgText.append(boost::lexical_cast<std::string>
454  msgText.append(".)");
455  msgText.append("<ul><li>Detailed message: \"");
456  msgText.append(statusObj.message);
457  msgText.append("\"</li></ul>");
458  msgText.append("Please try again in a few minutes, or if ");
459  msgText.append("this problem persists, use the ");
460  msgText.append("<a href=\"https://cdcvs.fnal.gov/redmine/projects/novadaq-config-mgmt/wiki/How_To_recover_from_a_failed_pedestal_upload_-_December_2011\">MarkConfigChangesDone</a> utility to fix the issue.");
461  msgText.append("<br/><br/>Another alternative is to save ");
462  msgText.append("this configuration dataset with a different ");
463  msgText.append("name (use File-&gt;Save As).");
464  QMessageBox::warning(this, "Save Warning", msgText.c_str());
465 
466  return false;
467  }
468  else if (statusObj.code ==
469  NamedConfigUtils::COPY_FOUND_INTERMEDIATE_UPDATE) {
470  QMessageBox messageBox(this);
471  messageBox.setIcon(QMessageBox::Warning);
472  messageBox.setWindowTitle("Save Warning");
473 
474  std::string msgText = "A problem was found when saving changes to ";
475  msgText.append("the database.<br/><br/>");
476  msgText.append("Intermediate changes will be obscured by ");
477  msgText.append("this change. (Attempting to copy global ");
478  msgText.append("configuration with ID ");
479  msgText.append(boost::lexical_cast<std::string>
481  msgText.append(".)");
482  msgText.append("<ul><li>Detailed message: \"");
483  msgText.append(statusObj.message);
484  msgText.append("\"</li></ul>");
485  messageBox.setText(msgText.c_str());
486 
487  msgText = "Do you want to save anyway? (<b>Please Note</b> that ";
488  msgText.append("if you say Yes, the dataset that you are ");
489  msgText.append("currently saving will take precedence over the ");
490  msgText.append("existing one with the same name and DCM operating ");
491  msgText.append("mode <b>and</b> differences will <b>not</b> be ");
492  msgText.append("automatically brought forward.)");
493  messageBox.setInformativeText(msgText.c_str());
494 
495  messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
496  messageBox.setDefaultButton(QMessageBox::No);
497  int retCode = messageBox.exec();
498 
499  return (retCode == QMessageBox::Yes);
500  }
501  else if (statusObj.code != NamedConfigUtils::COPY_SUCCEEDED) {
502  std::cerr << "Unable to create a copy of the named "
503  << "global configuration with ID = "
504  << _currentGlobalConfigId << ": " << statusObj.message
505  << std::endl;
506  return false;
507  }
508 
509  return true;
510 }
OStream cerr
Definition: OStream.cxx:7
enum BeamMode string
void dbutils::gui::BasicEditorDisplay::closeEvent ( QCloseEvent *  event)
protectedvirtual

Definition at line 395 of file BasicEditorDisplay.cpp.

References hasChanges(), runNovaSAM::retCode, and string.

Referenced by ~BasicEditorDisplay().

396 {
397  if (! hasChanges()) {event->accept(); return;}
398 
399  QMessageBox confirmBox(this);
400 
401  std::string msgText = "There are changes that haven't been saved yet.";
402  confirmBox.setText(msgText.c_str());
403 
404  msgText = "Are you sure that you want to exit without saving ";
405  msgText.append("your changes to the database?");
406  confirmBox.setInformativeText(msgText.c_str());
407 
408  confirmBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
409  confirmBox.setDefaultButton(QMessageBox::No);
410  int retCode = confirmBox.exec();
411 
412  if (retCode == QMessageBox::Yes) {event->accept(); return;}
413  else {event->ignore(); return;}
414 }
virtual bool hasChanges() const =0
enum BeamMode string
virtual bool dbutils::gui::BasicEditorDisplay::hasChanges ( ) const
pure virtual
void dbutils::gui::BasicEditorDisplay::loadNewDataset ( )
slot

Definition at line 90 of file BasicEditorDisplay.cpp.

References _currentGlobalConfigId, _doLoadNewDataset(), _globalNameSpecPtr, _settingsDisplay, om::cerr, allTimeWatchdog::endl, hasChanges(), runNovaSAM::retCode, string, and dbutils::gui::SettingsDisplay::updateNamedConfiguration().

Referenced by BasicEditorDisplay(), dbutils::gui::DAQConfigEditorDisplay::DAQConfigEditorDisplay(), and ~BasicEditorDisplay().

91 {
92  if (hasChanges()) {
93  QMessageBox confirmBox(this);
94  std::string msgText = "There are changes that haven't been saved yet.";
95  confirmBox.setText(msgText.c_str());
96 
97  msgText = "Are you sure that you want to load a new dataset without ";
98  msgText.append("saving the existing changes to the database?");
99  confirmBox.setInformativeText(msgText.c_str());
100 
101  confirmBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
102  confirmBox.setDefaultButton(QMessageBox::No);
103  int retCode = confirmBox.exec();
104 
105  if (retCode == QMessageBox::No) {return;}
106  }
107 
108  ConfigSelectionDialog selectDialog((_globalNameSpecPtr->
109  isSlowControlsConfiguration() ?
110  IDSpec::SLOWCONTROLS : IDSpec::DAQ),
111  _globalNameSpecPtr->getDetectorName(), this);
112  int retCode = selectDialog.exec();
113  if (retCode == QDialog::Rejected) {
114  return;
115  }
116 
117  boost::shared_ptr<dbutils::daqconfig::GlobalNameSpec> nameSpecPtr;
118  if (selectDialog.getSelectedTime()==NamedConfigUtils::LATEST_TIME_STRING) {
119  nameSpecPtr.
120  reset(new GlobalNameSpec(selectDialog.getSelectedConfigName(),
121  selectDialog.getSelectedDCMOpMode(),
122  _globalNameSpecPtr->getDetectorName()));
123  }
124  else {
125  nameSpecPtr.
126  reset(new GlobalNameSpec(selectDialog.getSelectedConfigName(),
127  selectDialog.getSelectedDCMOpMode(),
128  _globalNameSpecPtr->getDetectorName(),
129  selectDialog.getSelectedTime()));
130  }
131  nameSpecPtr->isSlowControlsConfiguration(_globalNameSpecPtr->
132  isSlowControlsConfiguration());
133  int64_t globalConfigId = -1;
134  if (! NamedConfigUtils::getGlobalConfigId((*nameSpecPtr),
135  globalConfigId)) {
136  std::cerr << "Error fetching globalConfigId." << std::endl;
137  return;
138  }
139  IDSpec idSpec(globalConfigId, IDSpec::GLOBAL,
140  (_globalNameSpecPtr->isSlowControlsConfiguration() ?
141  IDSpec::SLOWCONTROLS : IDSpec::DAQ));
142 
143  if (_doLoadNewDataset(idSpec)) {
144  _globalNameSpecPtr = nameSpecPtr;
145  _currentGlobalConfigId = globalConfigId;
146  if (_settingsDisplay != 0) {
148  }
149  }
150  else {
151  std::string msgText = "The loading of the new dataset failed. ";
152  msgText.append("Depending on when the failure occurred, you may have an inconsistent set of data displayed in this editor. Please retry the loading of the new dataset until success is achieved before editing the data in the display.");
153  QMessageBox::critical(this, "Data Loading Error",
154  msgText.c_str());
155  return;
156  }
157 }
OStream cerr
Definition: OStream.cxx:7
void updateNamedConfiguration(const dbutils::daqconfig::GlobalNameSpec &nameSpec)
boost::shared_ptr< dbutils::daqconfig::GlobalNameSpec > _globalNameSpecPtr
virtual bool _doLoadNewDataset(const dbutils::daqconfig::IDSpec &idSpec)=0
virtual bool hasChanges() const =0
enum BeamMode string
void dbutils::gui::BasicEditorDisplay::reactToDataChange ( )
virtualslot

Definition at line 375 of file BasicEditorDisplay.cpp.

References _saveAction, _saveAsAction, novadaq::EnvVarCache::getEnvVar(), novadaq::EnvVarCache::getInstance(), hasChanges(), and string.

Referenced by dbutils::gui::DAQConfigEditorDisplay::DAQConfigEditorDisplay(), dbutils::gui::DCSConfigEditorDisplay::DCSConfigEditorDisplay(), and ~BasicEditorDisplay().

376 {
377  if (hasChanges()) {
378  std::string dbUser =
380  if (dbUser != "nova_reader") {
381  _saveAction->setEnabled(true);
382  _saveAsAction->setEnabled(true);
383  }
384  }
385 }
static EnvVarCache & getInstance()
Definition: EnvVarCache.cpp:12
virtual bool hasChanges() const =0
std::string getEnvVar(std::string name)
Definition: EnvVarCache.cpp:33
enum BeamMode string
void dbutils::gui::BasicEditorDisplay::reactToDataSave ( )
virtualslot
void dbutils::gui::BasicEditorDisplay::reloadCurrentDataset ( )
slot

Definition at line 47 of file BasicEditorDisplay.cpp.

References _currentGlobalConfigId, _doReloadCurrentDataset(), _globalNameSpecPtr, om::cerr, allTimeWatchdog::endl, hasChanges(), runNovaSAM::retCode, and string.

Referenced by BasicEditorDisplay(), dbutils::gui::DCSConfigEditorDisplay::loadHVAndTemps(), dbutils::gui::DAQConfigEditorDisplay::loadThresholdsAndMasks(), and ~BasicEditorDisplay().

48 {
49  if (hasChanges()) {
50  QMessageBox confirmBox(this);
51  std::string msgText = "There are changes that haven't been saved yet.";
52  confirmBox.setText(msgText.c_str());
53 
54  msgText = "Are you sure that you want to reload this dataset without ";
55  msgText.append("saving the existing changes to the database?");
56  confirmBox.setInformativeText(msgText.c_str());
57 
58  confirmBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
59  confirmBox.setDefaultButton(QMessageBox::No);
60  int retCode = confirmBox.exec();
61 
62  if (retCode == QMessageBox::No) {return;}
63  }
64 
65  int64_t globalConfigId = _currentGlobalConfigId;
66  if (! _globalNameSpecPtr->hasTimestamp()) {
67  if (! NamedConfigUtils::getGlobalConfigId((*_globalNameSpecPtr),
68  globalConfigId)) {
69  std::cerr << "Error fetching globalConfigId." << std::endl;
70  return;
71  }
72  }
73 
74  IDSpec idSpec(globalConfigId, IDSpec::GLOBAL,
75  (_globalNameSpecPtr->isSlowControlsConfiguration() ?
76  IDSpec::SLOWCONTROLS : IDSpec::DAQ));
77 
78  if (_doReloadCurrentDataset(idSpec)) {
79  //_globalNameSpecPtr = nameSpecPtr;
80  _currentGlobalConfigId = globalConfigId;
81  //if (_settingsDisplay != 0) {
82  // _settingsDisplay->updateNamedConfiguration(*_globalNameSpecPtr);
83  //}
84  }
85 }
virtual bool _doReloadCurrentDataset(const dbutils::daqconfig::IDSpec &idSpec)=0
OStream cerr
Definition: OStream.cxx:7
boost::shared_ptr< dbutils::daqconfig::GlobalNameSpec > _globalNameSpecPtr
virtual bool hasChanges() const =0
enum BeamMode string
void dbutils::gui::BasicEditorDisplay::saveChanges ( )
slot

Definition at line 159 of file BasicEditorDisplay.cpp.

References _confirmSave(), _currentGlobalConfigId, _doSaveChanges(), _getUserResponseToGlobalCopyFailure(), _globalNameSpecPtr, _settingsDisplay, novadaq::Status::code, novadaq::Status::message, dbutils::SimpleParameterSet::put(), fabricate::status, string, and dbutils::gui::SettingsDisplay::updateNamedConfiguration().

Referenced by BasicEditorDisplay(), and ~BasicEditorDisplay().

160 {
161  if (! _confirmSave()) {return;}
162 
163  IDSpec oldGlobalIdSpec(_currentGlobalConfigId, IDSpec::GLOBAL,
164  (_globalNameSpecPtr->isSlowControlsConfiguration() ?
165  IDSpec::SLOWCONTROLS : IDSpec::DAQ));
166 
168  paramSet.put(NamedConfigUtils::DESCRIPTION_COLUMN_NAME,
169  "New values from the Configuration Editor GUI.");
170  int64_t globalConfigId;
171  novadaq::Status resultStatus =
172  NamedConfigUtils::copyGlobalConfig(oldGlobalIdSpec, true, paramSet,
173  "", false, globalConfigId);
174  if (resultStatus.code != NamedConfigUtils::COPY_SUCCEEDED) {
175  bool userChoice = _getUserResponseToGlobalCopyFailure(resultStatus);
176  if (! userChoice) {return;}
177 
178  resultStatus =
179  NamedConfigUtils::copyGlobalConfig(oldGlobalIdSpec, true, paramSet,
180  "", true, globalConfigId);
181  if (resultStatus.code != NamedConfigUtils::COPY_SUCCEEDED) {
182  std::string msgText = "Unable to create a copy of the named ";
183  msgText.append("global configuration with ID = ");
184  msgText.append(boost::lexical_cast<std::string>
186  msgText.append(": ");
187  msgText.append(resultStatus.message);
188  QMessageBox::critical(this, "Save Error", msgText.c_str());
189  return;
190  }
191  }
192 
193  // 12-Dec-2011, KAB - this copying of the GlobalNameSpec is simply
194  // to get rid of any timestamp that may be present in the existing
195  // _globalNameSpecPtr (since the act of saving will create a new latest)
196  boost::shared_ptr<dbutils::daqconfig::GlobalNameSpec>
197  nameSpecPtr(new GlobalNameSpec(_globalNameSpecPtr->getConfigName(),
198  _globalNameSpecPtr->getDCMOpMode(),
199  _globalNameSpecPtr->getDetectorName()));
200  nameSpecPtr->
201  isSlowControlsConfiguration(_globalNameSpecPtr->
202  isSlowControlsConfiguration());
203  IDSpec globalIdSpec(globalConfigId, IDSpec::GLOBAL,
204  (_globalNameSpecPtr->isSlowControlsConfiguration() ?
205  IDSpec::SLOWCONTROLS : IDSpec::DAQ));
206  if (_doSaveChanges(oldGlobalIdSpec, globalIdSpec, (*nameSpecPtr))) {
207  if (NamedConfigUtils::markConfigDone(globalIdSpec, true)) {
208  _globalNameSpecPtr = nameSpecPtr;
209  _currentGlobalConfigId = globalConfigId;
210  if (_settingsDisplay != 0) {
212  }
213  }
214  }
215  else {
216  bool status = NamedConfigUtils::markConfigDone(globalIdSpec, false);
217 
218  std::string msgText = "An error occurred when saving changes to ";
219  msgText.append("the database.<br/><br/>");
220 
221  if (status) {
222  msgText.append("However, the new configuration was ");
223  msgText.append("successfully marked as Done (changes have ");
224  msgText.append("finished). Please try saving again in a few ");
225  msgText.append("minutes, but realize that you may need to ");
226  msgText.append("over-write the incomplete save that just ");
227  msgText.append("failed (the GUI will guide you through that).");
228  }
229  else {
230  msgText.append("In addition, the new configuration was not ");
231  msgText.append("successfully marked as Done (so it still ");
232  msgText.append("appears that there is a change in progress ");
233  msgText.append("in the DB table). If so, you'll need ");
234  msgText.append("to use the ");
235  msgText.append("<a href=\"https://cdcvs.fnal.gov/redmine/projects/novadaq-config-mgmt/wiki/How_To_recover_from_a_failed_pedestal_upload_-_December_2011\">MarkConfigChangesDone</a> utility to mark the change as Done.");
236  msgText.append("In any case, please try saving again in a few ");
237  msgText.append("minutes - the GUI will guide you through any ");
238  msgText.append("extra steps that you need to take.");
239  }
240 
241  QMessageBox::critical(this, "Save Error", msgText.c_str());
242  }
243 }
bool _getUserResponseToGlobalCopyFailure(const novadaq::Status &status)
int status
Definition: fabricate.py:1613
void put(const std::string &key, const std::string &value)
int32_t code
Definition: Status.h:22
void updateNamedConfiguration(const dbutils::daqconfig::GlobalNameSpec &nameSpec)
virtual bool _doSaveChanges(const dbutils::daqconfig::IDSpec &oldIdSpec, const dbutils::daqconfig::IDSpec &newIdSpec, const dbutils::daqconfig::GlobalNameSpec &newNameSpec)=0
boost::shared_ptr< dbutils::daqconfig::GlobalNameSpec > _globalNameSpecPtr
std::string message
Definition: Status.h:24
enum BeamMode string
void dbutils::gui::BasicEditorDisplay::saveChangesWithNewName ( )
slot

Definition at line 245 of file BasicEditorDisplay.cpp.

References _confirmSave(), _currentGlobalConfigId, _doSaveChanges(), _getUserResponseToGlobalCopyFailure(), _globalNameSpecPtr, _settingsDisplay, novadaq::Status::code, novadaq::Status::message, lem_server::msg, art::Normal, dbutils::SimpleParameterSet::put(), fabricate::status, string, make_root_from_grid_output::tr, and dbutils::gui::SettingsDisplay::updateNamedConfiguration().

Referenced by BasicEditorDisplay(), and ~BasicEditorDisplay().

246 {
247  if (! _confirmSave()) {return;}
248 
250  NamedConfigUtils::
251  getAvailableGlobalConfigs((_globalNameSpecPtr->
252  isSlowControlsConfiguration() ?
253  IDSpec::SLOWCONTROLS : IDSpec::DAQ),
254  _globalNameSpecPtr->getDetectorName(),
255  globalNameMap);
256 
257  bool status;
258  std::string msg = "Please enter the new configuration name.";
259  if (globalNameMap.size() > 0) {
260  msg.append("<br/><br/>Recent choices for the name and the DCM ");
261  msg.append("operating mode include the following:<ul>");
262  NamedConfigUtils::GlobalNameSpecMap::const_iterator iter;
263  NamedConfigUtils::GlobalNameSpecMap::const_iterator iterEnd =
264  globalNameMap.end();
265  for (iter = globalNameMap.begin(); iter != iterEnd; ++iter) {
266  msg.append("<li>");
267  msg.append((*iter).first.getConfigName());
268  msg.append(" ");
269  msg.append((*iter).first.getDCMOpMode());
270  msg.append("</li>");
271  }
272  msg.append("</ul>");
273  }
274  QString newConfigName =
275  QInputDialog::getText(this, tr("Configuration Name"), msg.c_str(),
277  _globalNameSpecPtr->getConfigName().c_str(),
278  &status);
279  if (! status) {return;}
280 
281  msg = "Please enter the new DCM operating mode.";
282  if (globalNameMap.size() > 0) {
283  msg.append("<br/><br/>Recent choices for the name and the DCM ");
284  msg.append("operating mode include the following:<ul>");
285  NamedConfigUtils::GlobalNameSpecMap::const_iterator iter;
286  NamedConfigUtils::GlobalNameSpecMap::const_iterator iterEnd =
287  globalNameMap.end();
288  for (iter = globalNameMap.begin(); iter != iterEnd; ++iter) {
289  msg.append("<li>");
290  msg.append((*iter).first.getConfigName());
291  msg.append(" ");
292  msg.append((*iter).first.getDCMOpMode());
293  msg.append("</li>");
294  }
295  msg.append("</ul>");
296  }
297  QString newDCMOpMode =
298  QInputDialog::getText(this, tr("DCM Operating Mode"), msg.c_str(),
300  _globalNameSpecPtr->getDCMOpMode().c_str(),
301  &status);
302  if (! status) {return;}
303 
304  IDSpec oldGlobalIdSpec(_currentGlobalConfigId, IDSpec::GLOBAL,
305  (_globalNameSpecPtr->isSlowControlsConfiguration() ?
306  IDSpec::SLOWCONTROLS : IDSpec::DAQ));
307 
309  paramSet.put(NamedConfigUtils::NAME_COLUMN_NAME,
310  newConfigName.toStdString());
311  paramSet.put(NamedConfigUtils::DCMOPMODE_COLUMN_NAME,
312  newDCMOpMode.toStdString());
313  paramSet.put(NamedConfigUtils::DESCRIPTION_COLUMN_NAME,
314  "New named configuration from the Configuration Editor GUI.");
315  int64_t globalConfigId;
316  novadaq::Status resultStatus =
317  NamedConfigUtils::copyGlobalConfig(oldGlobalIdSpec, true, paramSet,
318  "", false, globalConfigId);
319  if (resultStatus.code != NamedConfigUtils::COPY_SUCCEEDED) {
320  bool userChoice = _getUserResponseToGlobalCopyFailure(resultStatus);
321  if (! userChoice) {return;}
322 
323  resultStatus =
324  NamedConfigUtils::copyGlobalConfig(oldGlobalIdSpec, true, paramSet,
325  "", true, globalConfigId);
326  if (resultStatus.code != NamedConfigUtils::COPY_SUCCEEDED) {
327  std::string msgText = "Unable to create a copy of the named ";
328  msgText.append("global configuration with ID = ");
329  msgText.append(boost::lexical_cast<std::string>
331  msgText.append(": ");
332  msgText.append(resultStatus.message);
333  QMessageBox::critical(this, "Save Error", msgText.c_str());
334  return;
335  }
336  }
337 
338  boost::shared_ptr<dbutils::daqconfig::GlobalNameSpec>
339  nameSpecPtr(new GlobalNameSpec(newConfigName.toStdString(),
340  newDCMOpMode.toStdString(),
341  _globalNameSpecPtr->getDetectorName()));
342  nameSpecPtr->
343  isSlowControlsConfiguration(_globalNameSpecPtr->
344  isSlowControlsConfiguration());
345  IDSpec globalIdSpec(globalConfigId, IDSpec::GLOBAL,
346  (_globalNameSpecPtr->isSlowControlsConfiguration() ?
347  IDSpec::SLOWCONTROLS : IDSpec::DAQ));
348  if (_doSaveChanges(oldGlobalIdSpec, globalIdSpec, (*nameSpecPtr))) {
349  if (NamedConfigUtils::markConfigDone(globalIdSpec, true)) {
350  _globalNameSpecPtr = nameSpecPtr;
351  _currentGlobalConfigId = globalConfigId;
352  if (_settingsDisplay != 0) {
354  }
355  }
356  }
357  else {
358  NamedConfigUtils::markConfigDone(globalIdSpec, false);
359  }
360 }
bool _getUserResponseToGlobalCopyFailure(const novadaq::Status &status)
int status
Definition: fabricate.py:1613
void put(const std::string &key, const std::string &value)
int32_t code
Definition: Status.h:22
void updateNamedConfiguration(const dbutils::daqconfig::GlobalNameSpec &nameSpec)
std::map< GlobalNameSpec, std::vector< GlobalNameSpec > > GlobalNameSpecMap
virtual bool _doSaveChanges(const dbutils::daqconfig::IDSpec &oldIdSpec, const dbutils::daqconfig::IDSpec &newIdSpec, const dbutils::daqconfig::GlobalNameSpec &newNameSpec)=0
boost::shared_ptr< dbutils::daqconfig::GlobalNameSpec > _globalNameSpecPtr
std::string message
Definition: Status.h:24
enum BeamMode string
void dbutils::gui::BasicEditorDisplay::showHelpDialog ( )
slot

Definition at line 362 of file BasicEditorDisplay.cpp.

References _customHelpText, and string.

Referenced by _addHelpMenu(), and ~BasicEditorDisplay().

363 {
364  std::string msgText = "Helpful hints:";
365  msgText.append("<ul>");
366  msgText.append("<li>To edit a value, double-click on it [left mouse button]. (A single mouse click simply selects the value, it doesn't enable editing.)</li>");
367  msgText.append("<li>Once you have edited a value, you should single-click on a different cell in the table to ensure that the editor captures your change. (Pressing the Tab or Enter key after you enter your change will also work.)</li>");
368  msgText.append("<li>For \"mask\" values, a bitmap editor is provided. To open the bitmap editor, right-mouse-click on the value that you want to edit, and select the \"Open bitmap editor\" option from the popup menu.</li>");
369  msgText.append("</ul>");
370  msgText.append(_customHelpText);
371  QMessageBox::information(this, "Configuration editor help",
372  msgText.c_str());
373 }
enum BeamMode string

Member Data Documentation

int64_t dbutils::gui::BasicEditorDisplay::_currentGlobalConfigId
protected
std::string dbutils::gui::BasicEditorDisplay::_customHelpText
private

Definition at line 72 of file BasicEditorDisplay.h.

Referenced by _addHelpMenu(), and showHelpDialog().

boost::shared_ptr<dbutils::daqconfig::GlobalNameSpec> dbutils::gui::BasicEditorDisplay::_globalNameSpecPtr
protected
QAction* dbutils::gui::BasicEditorDisplay::_saveAction
protected

Definition at line 62 of file BasicEditorDisplay.h.

Referenced by BasicEditorDisplay(), reactToDataChange(), and reactToDataSave().

QAction* dbutils::gui::BasicEditorDisplay::_saveAsAction
protected

Definition at line 63 of file BasicEditorDisplay.h.

Referenced by BasicEditorDisplay(), reactToDataChange(), and reactToDataSave().

SettingsDisplay* dbutils::gui::BasicEditorDisplay::_settingsDisplay
protected

The documentation for this class was generated from the following files: