DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SchemaClassEditor.cpp
Go to the documentation of this file.
1
2#include <QMessageBox>
3#include <QListWidget>
4#include <QInputDialog>
12#include "ui_SchemaClassEditor.h"
13
14using namespace dunedaq::oks;
15
17 : QWidget ( parent ),
18 ui ( new Ui::SchemaClassEditor ),
19 SchemaClass ( ClassInfo ),
20 MethodModel ( nullptr ),
21 AttributeModel ( nullptr ),
22 RelationshipModel ( nullptr ),
23 SuperClassModel ( nullptr ),
24 SubClassModel ( nullptr ),
25 ContextMenuAttribute ( nullptr ),
26 ContextMenuRelationship ( nullptr ),
27 ContextMenuMethod ( nullptr ),
28 ContextMenuClass ( nullptr )
29{
30 QWidget::setAttribute(Qt::WA_DeleteOnClose);
31
33 ui->setupUi ( this );
34 setWindowTitle (
35 QString ( "Class Editor : %1" ).arg ( QString::fromStdString (
36 SchemaClass->get_name() ) ) );
37 setObjectName ( QString::fromStdString ( SchemaClass->get_name() ) );
43}
44
46
48{
49 connect ( ui->SaveButton, SIGNAL ( clicked() ), this, SLOT ( ProxySlot() ) );
50 connect ( ui->AddButtonAttribute, SIGNAL ( clicked() ), this, SLOT ( AddNewAttribute() ) );
51 connect ( ui->AddButtonSuperClass, SIGNAL ( clicked() ), this, SLOT ( AddNewSuperClass() ) );
52 connect ( ui->AddButtonRelationship, SIGNAL ( clicked() ), this,
53 SLOT ( AddNewRelationship() ) );
54 connect ( ui->AddButtonMethod, SIGNAL ( clicked() ), this, SLOT ( AddNewMethod() ) );
55 connect ( ui->RelationshipView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
56 SLOT ( OpenRelationshipEditor ( QModelIndex ) ) );
57 connect ( ui->MethodsView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
58 SLOT ( OpenMethodEditor ( QModelIndex ) ) );
59 connect ( ui->AttributeView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
60 SLOT ( OpenAttributeEditor ( QModelIndex ) ) );
61 connect ( ui->SuperClassView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
62 SLOT ( OpenSuperClass ( QModelIndex ) ) );
63 connect ( ui->SubClassView, SIGNAL ( doubleClicked ( QModelIndex ) ), this,
64 SLOT ( OpenSubClass ( QModelIndex ) ) );
65 connect ( ui->AttributeView, SIGNAL ( customContextMenuRequested ( QPoint ) ), this,
66 SLOT ( CustomMenuAttributeView ( QPoint ) ) );
67 connect ( ui->RelationshipView, SIGNAL ( customContextMenuRequested ( QPoint ) ), this,
68 SLOT ( CustomMenuRelationshipView ( QPoint ) ) );
69 connect ( ui->MethodsView, SIGNAL ( customContextMenuRequested ( QPoint ) ), this,
70 SLOT ( CustomMenuMethodView ( QPoint ) ) );
71 connect ( ui->SuperClassView, SIGNAL ( customContextMenuRequested ( QPoint ) ), this,
72 SLOT ( CustomMenuClassView ( QPoint ) ) );
73 connect ( ui->ShowDerivedAttributes, &QCheckBox::toggled, this, &SchemaClassEditor::BuildAttributeModelSlot );
74 connect ( ui->ShowDerivedRelationships, &QCheckBox::toggled, this, &SchemaClassEditor::BuildRelationshipModelSlot );
75 connect ( ui->ShowDerivedMethods, &QCheckBox::toggled, this, &SchemaClassEditor::BuildMethodModelSlot );
76 connect ( ui->ShowAllSuperClasses, &QCheckBox::toggled, this, &SchemaClassEditor::BuildSuperClassModelSlot );
77 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassRemoved ( QString ) ), this,
78 SLOT ( ClassRemoved ( QString ) ) );
79 connect ( &KernelWrapper::GetInstance(), SIGNAL ( ClassUpdated ( QString ) ), this,
80 SLOT ( ClassUpdated ( QString ) ) );
81}
82
84{
85 if(className == objectName()) {
86 QWidget::close();
87 }
88}
89
91{
92 if(className == objectName()) {
93 BuildModels();
94 InitialSettings();
95 }
96}
97
99{
100 BuildSubClassModelSlot();
101 BuildSuperClassModelSlot();
102 BuildMethodModelSlot();
103 BuildAttributeModelSlot();
104 BuildRelationshipModelSlot();
105}
106
108{
109 ui->AttributeView->setContextMenuPolicy ( Qt::ContextMenuPolicy::CustomContextMenu );
110 ui->RelationshipView->setContextMenuPolicy ( Qt::ContextMenuPolicy::CustomContextMenu );
111 ui->MethodsView->setContextMenuPolicy ( Qt::ContextMenuPolicy::CustomContextMenu );
112 ui->SuperClassView->setContextMenuPolicy ( Qt::ContextMenuPolicy::CustomContextMenu );
113 ui->SubClassView->setContextMenuPolicy ( Qt::ContextMenuPolicy::CustomContextMenu );
114
116 ui->ClassNameLineEdit->setText ( QString::fromStdString ( SchemaClass->get_name() ) );
117 ui->ClassNameLineEdit->setEnabled ( false );
119 ui->SchemaFileLineEdit->setText ( QString::fromStdString ( SchemaClass->get_file()->get_short_file_name() ) );
120 ui->SchemaFileLineEdit->setEnabled ( false );
122 ui->DescriptionTextEdit->setPlainText ( QString::fromStdString ( SchemaClass->get_description() ) );
123
125 if ( SchemaClass->get_is_abstract() )
126 {
127 ui->AbstractComboBox->setCurrentIndex ( 0 );
128 }
129 else
130 {
131 ui->AbstractComboBox->setCurrentIndex ( 1 );
132 }
133}
134
136{
137 bool WidgetFound = false;
138
139 for ( QWidget * Editor : QApplication::allWidgets() )
140 {
141 SchemaAttributeEditor * Widget = dynamic_cast<SchemaAttributeEditor *> ( Editor );
142
143 if ( Widget != nullptr )
144 {
145 if ( ( Widget->objectName() ).compare ( Name ) == 0 )
146 {
147 Widget->raise();
148 Widget->setVisible ( true );
149 Widget->activateWindow();
150 WidgetFound = true;
151 }
152 }
153 }
154
155 return !WidgetFound;
156}
157
159{
160 bool WidgetFound = false;
161
162 for ( QWidget * Editor : QApplication::allWidgets() )
163 {
164 SchemaRelationshipEditor * Widget = dynamic_cast<SchemaRelationshipEditor *> ( Editor );
165
166 if ( Widget != nullptr )
167 {
168 if ( ( Widget->objectName() ).compare ( Name ) == 0 )
169 {
170 Widget->raise();
171 Widget->setVisible ( true );
172 Widget->activateWindow();
173 WidgetFound = true;
174 }
175 }
176 }
177
178 return !WidgetFound;
179}
180
182{
183 bool WidgetFound = false;
184
185 for ( QWidget * Editor : QApplication::allWidgets() )
186 {
187 SchemaMethodEditor * Widget = dynamic_cast<SchemaMethodEditor *> ( Editor );
188
189 if ( Widget != nullptr )
190 {
191 if ( ( Widget->objectName() ).compare ( Name ) == 0 )
192 {
193 Widget->raise();
194 Widget->setVisible ( true );
195 Widget->activateWindow();
196 WidgetFound = true;
197 }
198 }
199 }
200
201 return !WidgetFound;
202}
203
205{
206 const std::string& attributeName = CurrentRow.at ( 0 ).toStdString();
207 OksAttribute * SchemaAttribute = SchemaClass->find_direct_attribute( attributeName );
208 if(SchemaAttribute != nullptr) {
210 SchemaClass, SchemaAttribute, SchemaAttribute->get_name(), SchemaAttribute->get_type(),
211 SchemaAttribute->get_is_multi_values(), SchemaAttribute->get_range(),
212 SchemaAttribute->get_init_value(), SchemaAttribute->get_description(),
213 SchemaAttribute->get_is_no_null(), SchemaAttribute->get_format() );
214 } else {
215 QMessageBox::warning ( 0, "Schema editor",
216 QString::fromStdString( "Cannot remove attribute \"" + attributeName +
217 "\" because it is not a direct attribute of \"" + SchemaClass->get_name() + "\"") );
218 }
219}
220
222{
223 const std::string& relationshipName = CurrentRow.at ( 0 ).toStdString();
224 OksRelationship * SchemaRelationship = SchemaClass->find_direct_relationship( relationshipName );
225 if(SchemaRelationship != nullptr) {
227 SchemaClass, SchemaRelationship, SchemaRelationship->get_name(),
228 SchemaRelationship->get_description(), SchemaRelationship->get_type(),
229 SchemaRelationship->get_is_composite(), SchemaRelationship->get_is_exclusive(),
230 SchemaRelationship->get_is_dependent(),
231 SchemaRelationship->get_low_cardinality_constraint(),
232 SchemaRelationship->get_high_cardinality_constraint() );
233 } else {
234 QMessageBox::warning ( 0, "Schema editor",
235 QString::fromStdString( "Cannot remove relationship \"" + relationshipName +
236 "\" because it is not a direct relationship of \"" + SchemaClass->get_name() + "\"") );
237 }
238}
239
241{
242 const std::string& methodName = CurrentRow.at ( 0 ).toStdString();
243 OksMethod * SchemaMethod = SchemaClass->find_direct_method ( methodName );
244 if(SchemaMethod != nullptr) {
245 KernelWrapper::GetInstance().PushRemoveMethodCommand ( SchemaClass, SchemaMethod,
246 SchemaMethod->get_name(),
247 SchemaMethod->get_description() );
248 } else {
249 QMessageBox::warning ( 0, "Schema editor",
250 QString::fromStdString( "Cannot remove method \"" + methodName +
251 "\" because it is not a direct method of \"" + SchemaClass->get_name() + "\"") );
252 }
253}
254
256{
257 const std::string& superClassName = CurrentRow.at ( 0 ).toStdString();
258 if(SchemaClass->has_direct_super_class(superClassName))
259 {
260 KernelWrapper::GetInstance().PushRemoveSuperClassCommand(SchemaClass, superClassName);
261 }
262 else
263 {
264 QMessageBox::warning ( 0, "Schema editor",
265 QString::fromStdString( "Cannot remove super-class \"" + superClassName +
266 "\" because it is not a direct super-class of \"" + SchemaClass->get_name() + "\"") );
267 }
268}
269
270
272{
273 ParseToSave();
274}
275
277{
278 std::string NewDescription = ui->DescriptionTextEdit->toPlainText().toStdString();
279
280 bool Abstract = false;
281
282 if ( ui->AbstractComboBox->currentIndex() == 0 )
283 {
284 Abstract = true;
285 }
286 else
287 {
288 Abstract = false;
289 }
290
291 if ( Abstract != SchemaClass->get_is_abstract() )
292 {
294 }
295
296 if ( NewDescription != SchemaClass->get_description() )
297 {
298 KernelWrapper::GetInstance().PushSetDescriptionClassCommand ( SchemaClass, NewDescription );
299 }
300
301 close();
302}
303
305{
306 QWidget* w = new QWidget();
307
308 QLabel* label = new QLabel("Double click on a list item to add the corresponding super-class");
309 label->setWordWrap(true);
310
311 QLabel* status = new QLabel();
312 status->setStyleSheet("QLabel { color : green; }");
313
314 QListWidget* qlw = new QListWidget();
315 QStringList allClasses;
317 qlw->addItems(allClasses);
318
319 connect ( qlw, &QListWidget::itemDoubleClicked,
320 this, [=] () {
321 const std::string& className = qlw->currentItem()->text().toStdString();
323 BuildModels();
324 status->setText(QString::fromStdString(className + " added as a super-class of " + SchemaClass->get_name()));
325 });
326
327 QVBoxLayout* l = new QVBoxLayout();
328 l->addWidget(label);
329 l->addWidget(qlw);
330 l->addWidget(status);
331
332 w->setWindowTitle("Select super-classe(s)");
333 w->setLayout(l);
334 w->setParent(this, Qt::Dialog);
335 w->show();
336}
337
339{
340 SchemaAttributeEditor * Editor = new SchemaAttributeEditor ( SchemaClass );
341 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildAttributeModelSlot() ) );
342 Editor->show();
343}
344
346{
347 SchemaRelationshipEditor * Editor = new SchemaRelationshipEditor ( SchemaClass );
348 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildRelationshipModelSlot() ) );
349 Editor->show();
350}
351
353{
354 SchemaMethodEditor * Editor = new SchemaMethodEditor ( SchemaClass );
355 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildMethodModelSlot() ) );
356 Editor->show();
357}
358
360{
361 QStringList Row = AttributeModel->getRowFromIndex ( Index );
362 bool ShouldOpen = ShouldOpenAttributeEditor ( Row.at ( 0 ) );
363
364 if ( !Row.isEmpty() && ShouldOpen )
365 {
367 SchemaClass, SchemaClass->find_attribute ( Row.at ( 0 ).toStdString() ) );
368 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildAttributeModelSlot() ) );
369 Editor->show();
370 }
371}
372
374{
375 QStringList Row = RelationshipModel->getRowFromIndex ( Index );
376 bool ShouldOpen = ShouldOpenRelationshipEditor ( Row.at ( 0 ) );
377
378 if ( !Row.isEmpty() && ShouldOpen )
379 {
381 SchemaClass, SchemaClass->find_relationship ( Row.at ( 0 ).toStdString() ) );
382 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildRelationshipModelSlot() ) );
383 Editor->show();
384 }
385}
386
388{
389 QStringList Row = MethodModel->getRowFromIndex ( Index );
390 bool ShouldOpen = ShouldOpenMethodEditor ( Row.at ( 0 ) );
391
392 if ( !Row.isEmpty() && ShouldOpen )
393 {
395 SchemaClass, SchemaClass->find_method ( Row.at ( 0 ).toStdString() ) );
396 connect ( Editor, SIGNAL ( RebuildModel() ), this, SLOT ( BuildMethodModelSlot() ) );
397 Editor->show();
398 }
399}
400
402{
403 QStringList Row = SuperClassModel->getRowFromIndex ( Index );
404
405 if ( !Row.isEmpty() )
406 {
407 QString ClassName = Row.at ( 0 );
408 OpenNewClassEditor(ClassName);
409 }
410}
411
413{
414 QStringList Row = SubClassModel->getRowFromIndex ( Index );
415
416 if ( !Row.isEmpty() )
417 {
418 QString ClassName = Row.at ( 0 );
419 OpenNewClassEditor(ClassName);
420 }
421}
422
423void dbse::SchemaClassEditor::OpenNewClassEditor ( const QString& ClassName )
424{
425 bool WidgetFound = false;
426 OksClass * ClassInfo = KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() );
427
428 for ( QWidget * Editor : QApplication::allWidgets() )
429 {
430 SchemaClassEditor * Widget = dynamic_cast<SchemaClassEditor *> ( Editor );
431
432 if ( Widget != nullptr )
433 {
434 if ( ( Widget->objectName() ).compare ( ClassName ) == 0 )
435 {
436 Widget->raise();
437 Widget->setVisible ( true );
438 Widget->activateWindow();
439 WidgetFound = true;
440 }
441 }
442 }
443
444 if ( !WidgetFound )
445 {
446 SchemaClassEditor * Editor = new SchemaClassEditor ( ClassInfo );
447 Editor->show();
448 }
449}
450
452{
453 QStringList AttributeHeaders
454 { "Name", "Type" };
455
456 if ( AttributeModel == nullptr ) AttributeModel = new CustomAttributeModel ( SchemaClass,
457 AttributeHeaders,
458 ui->ShowDerivedAttributes->isChecked());
459 else
460 {
461 delete AttributeModel;
462 AttributeModel = new CustomAttributeModel ( SchemaClass, AttributeHeaders, ui->ShowDerivedAttributes->isChecked() );
463 }
464
465 ui->AttributeView->setModel ( AttributeModel );
466 ui->AttributeView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
467 ui->AttributeView->setSelectionBehavior ( QAbstractItemView::SelectRows );
468}
469
471{
472 QStringList RelationshipHeaders
473 { "Name", "Type", "Low cc", "High cc" };
474
475 if ( RelationshipModel == nullptr ) RelationshipModel = new CustomRelationshipModel (
476 SchemaClass, RelationshipHeaders, ui->ShowDerivedRelationships->isChecked() );
477 else
478 {
479 delete RelationshipModel;
480 RelationshipModel = new CustomRelationshipModel ( SchemaClass, RelationshipHeaders, ui->ShowDerivedRelationships->isChecked() );
481 }
482
483 ui->RelationshipView->setModel ( RelationshipModel );
484 ui->RelationshipView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
485 ui->RelationshipView->setSelectionBehavior ( QAbstractItemView::SelectRows );
486}
487
489{
490 QStringList MethodHeaders
491 { "Method Name" };
492
493 if ( MethodModel == nullptr )
494 {
495 MethodModel = new CustomMethodModel ( SchemaClass, MethodHeaders, ui->ShowDerivedMethods->isChecked() );
496 }
497 else
498 {
499 delete MethodModel;
500 MethodModel = new CustomMethodModel ( SchemaClass, MethodHeaders, ui->ShowDerivedMethods->isChecked() );
501 }
502
503 ui->MethodsView->setModel ( MethodModel );
504 ui->MethodsView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
505 ui->MethodsView->setSelectionBehavior ( QAbstractItemView::SelectRows );
506}
507
509{
510 QStringList SuperClassHeaders
511 { "Class Name" };
512
513 if ( SuperClassModel == nullptr )
514 {
515 SuperClassModel = new CustomSuperClassModel ( SchemaClass, SuperClassHeaders, ui->ShowAllSuperClasses->isChecked() );
516 }
517 else
518 {
519 delete SuperClassModel;
520 SuperClassModel = new CustomSuperClassModel ( SchemaClass, SuperClassHeaders, ui->ShowAllSuperClasses->isChecked() );
521 }
522
523 ui->SuperClassView->setModel ( SuperClassModel );
524 ui->SuperClassView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
525 ui->SuperClassView->setSelectionBehavior ( QAbstractItemView::SelectRows );
526}
527
529{
530 QStringList SubClassHeaders
531 { "Class Name" };
532
533 if ( SubClassModel == nullptr )
534 {
535 SubClassModel = new CustomSubClassModel ( SchemaClass, SubClassHeaders );
536 }
537 else
538 {
539 delete SubClassModel;
540 SubClassModel = new CustomSubClassModel ( SchemaClass, SubClassHeaders );
541 }
542
543 ui->SubClassView->setModel ( SubClassModel );
544 ui->SubClassView->horizontalHeader()->setSectionResizeMode ( QHeaderView::Stretch );
545 ui->SubClassView->setSelectionBehavior ( QAbstractItemView::SelectRows );
546}
547
549{
550 if ( ContextMenuClass == nullptr )
551 {
552 ContextMenuClass = new QMenu ( this );
553
554 QAction * Add = new QAction ( tr ( "&Add" ), this );
555 Add->setShortcut ( tr ( "Ctrl+A" ) );
556 Add->setShortcutContext ( Qt::WidgetShortcut );
557 connect ( Add, SIGNAL ( triggered() ), this, SLOT ( AddNewSuperClass() ) );
558
559 QAction * Remove = new QAction ( tr ( "&Remove" ), this );
560 Remove->setShortcut ( tr ( "Ctrl+R" ) );
561 Remove->setShortcutContext ( Qt::WidgetShortcut );
562 connect ( Remove, SIGNAL ( triggered() ), this, SLOT ( RemoveSuperClass() ) );
563
564 ContextMenuClass->addAction ( Add );
565 ContextMenuClass->addAction ( Remove );
566 }
567
568 QModelIndex Index = ui->SuperClassView->currentIndex();
569
570 if ( Index.isValid() )
571 {
572 CurrentRow = SuperClassModel->getRowFromIndex ( Index );
573 ContextMenuClass->exec ( ui->SuperClassView->mapToGlobal ( pos ) );
574 }
575}
576
578{
579 if ( ContextMenuAttribute == nullptr )
580 {
581 ContextMenuAttribute = new QMenu ( this );
582
583 QAction * Add = new QAction ( tr ( "&Add" ), this );
584 Add->setShortcut ( tr ( "Ctrl+A" ) );
585 Add->setShortcutContext ( Qt::WidgetShortcut );
586 connect ( Add, SIGNAL ( triggered() ), this, SLOT ( AddNewAttribute() ) );
587
588 QAction * Remove = new QAction ( tr ( "&Remove" ), this );
589 Remove->setShortcut ( tr ( "Ctrl+R" ) );
590 Remove->setShortcutContext ( Qt::WidgetShortcut );
591 connect ( Remove, SIGNAL ( triggered() ), this, SLOT ( RemoveAttribute() ) );
592
593 ContextMenuAttribute->addAction ( Add );
594 ContextMenuAttribute->addAction ( Remove );
595 }
596
597 QModelIndex Index = ui->AttributeView->currentIndex();
598
599 if ( Index.isValid() )
600 {
601 CurrentRow = AttributeModel->getRowFromIndex ( Index );
602 ContextMenuAttribute->exec ( ui->AttributeView->mapToGlobal ( pos ) );
603 }
604}
605
607{
608 if ( ContextMenuRelationship == nullptr )
609 {
610 ContextMenuRelationship = new QMenu ( this );
611
612 QAction * Add = new QAction ( tr ( "&Add" ), this );
613 Add->setShortcut ( tr ( "Ctrl+A" ) );
614 Add->setShortcutContext ( Qt::WidgetShortcut );
615 connect ( Add, SIGNAL ( triggered() ), this, SLOT ( AddNewRelationship() ) );
616
617 QAction * Remove = new QAction ( tr ( "&Remove" ), this );
618 Remove->setShortcut ( tr ( "Ctrl+R" ) );
619 Remove->setShortcutContext ( Qt::WidgetShortcut );
620 connect ( Remove, SIGNAL ( triggered() ), this, SLOT ( RemoveRelationship() ) );
621
622 ContextMenuRelationship->addAction ( Add );
623 ContextMenuRelationship->addAction ( Remove );
624 }
625
626 QModelIndex Index = ui->RelationshipView->currentIndex();
627
628 if ( Index.isValid() )
629 {
630 CurrentRow = RelationshipModel->getRowFromIndex ( Index );
631 ContextMenuRelationship->exec ( ui->RelationshipView->mapToGlobal ( pos ) );
632 }
633}
634
636{
637 if ( ContextMenuMethod == nullptr )
638 {
639 ContextMenuMethod = new QMenu ( this );
640
641 QAction * Add = new QAction ( tr ( "&Add" ), this );
642 Add->setShortcut ( tr ( "Ctrl+A" ) );
643 Add->setShortcutContext ( Qt::WidgetShortcut );
644 connect ( Add, SIGNAL ( triggered() ), this, SLOT ( AddNewMethod() ) );
645
646 QAction * Remove = new QAction ( tr ( "&Remove" ), this );
647 Remove->setShortcut ( tr ( "Ctrl+R" ) );
648 Remove->setShortcutContext ( Qt::WidgetShortcut );
649 connect ( Remove, SIGNAL ( triggered() ), this, SLOT ( RemoveMethod() ) );
650
651 ContextMenuMethod->addAction ( Add );
652 ContextMenuMethod->addAction ( Remove );
653 }
654
655 QModelIndex Index = ui->MethodsView->currentIndex();
656
657 if ( Index.isValid() )
658 {
659 CurrentRow = MethodModel->getRowFromIndex ( Index );
660 ContextMenuMethod->exec ( ui->MethodsView->mapToGlobal ( pos ) );
661 }
662}
663
665{
666 auto createNewClass = [] (const std::string& className) -> bool {
667 if ( !KernelWrapper::GetInstance().IsActive() )
668 {
669 QMessageBox::warning (
670 0,
671 "Schema editor",
672 QString (
673 "There is no active schema set!\n\nPlease set a schema file as active and continue!" ) );
674
675 return false;
676 }
677
678 if ( !KernelWrapper::GetInstance().FindClass ( className ) )
679 {
681 "", false );
682 return true;
683 }
684 else
685 {
686 QMessageBox::warning ( 0, "Schema editor",
687 QString ( "Can not create class because class already exist !" ) );
688
689 return false;
690 }
691 };
692
693 bool ok;
694 QString text = QInputDialog::getText(nullptr, "Schema editor: create new class",
695 "New class name:", QLineEdit::Normal,
696 "NewOksClass", &ok);
697
698 if(ok && !text.isEmpty()) {
699 if(createNewClass(text.toStdString())) {
700 SchemaClassEditor * Editor = new SchemaClassEditor(KernelWrapper::GetInstance().FindClass(text.toStdString()));
701 Editor->show();
702 }
703 }
704}
void PushRemoveSuperClassCommand(dunedaq::oks::OksClass *Class, std::string SuperClass)
void GetClassListString(QStringList &ClassListString) const
static KernelWrapper & GetInstance()
void PushSetAbstractClassCommand(dunedaq::oks::OksClass *Class, bool Value)
dunedaq::oks::OksClass * FindClass(std::string ClassName) const
void PushAddSuperClassCommand(dunedaq::oks::OksClass *Class, std::string SuperClass)
void PushRemoveAttributeCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksAttribute *Attribute, std::string name, std::string type, bool is_mv, std::string range, std::string init_values, std::string description, bool is_null, dunedaq::oks::OksAttribute::Format format=dunedaq::oks::OksAttribute::Format::Dec)
void PushSetDescriptionClassCommand(dunedaq::oks::OksClass *Class, std::string Description)
void PushRemoveRelationship(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, std::string Name, std::string Description, std::string Type, bool Composite, bool Exclusive, bool Dependent, dunedaq::oks::OksRelationship::CardinalityConstraint LowCc, dunedaq::oks::OksRelationship::CardinalityConstraint HighCc)
void PushRemoveMethodCommand(dunedaq::oks::OksClass *Class, dunedaq::oks::OksMethod *Method, std::string name, std::string description)
void PushCreateClassCommand(std::string ClassName, std::string ClassDescription, bool Abstract)
void CustomMenuMethodView(QPoint pos)
void OpenRelationshipEditor(QModelIndex Index)
void ClassUpdated(QString className)
bool ShouldOpenAttributeEditor(QString Name)
Helper functions.
bool ShouldOpenRelationshipEditor(QString Name)
bool ShouldOpenMethodEditor(QString Name)
void RemoveAttribute()
Remove Functions.
void CustomMenuRelationshipView(QPoint pos)
void ClassRemoved(QString className)
void OpenSuperClass(QModelIndex Index)
SchemaClassEditor(dunedaq::oks::OksClass *ClassInfo, QWidget *parent=nullptr)
dunedaq::oks::OksClass * SchemaClass
void CustomMenuClassView(QPoint pos)
void OpenMethodEditor(QModelIndex Index)
void OpenSubClass(QModelIndex Index)
std::unique_ptr< dbse::Ui::SchemaClassEditor > ui
void OpenAttributeEditor(QModelIndex Index)
void OpenNewClassEditor(const QString &ClassName)
void CustomMenuAttributeView(QPoint pos)
Context Menu Functions.
OKS attribute class.
bool get_is_multi_values() const noexcept
const std::string & get_type() const noexcept
Get attribute string type.
const std::string & get_range() const noexcept
Get attribute range.
const std::string & get_name() const noexcept
out stream operator
const std::string & get_init_value() const noexcept
const std::string & get_description() const noexcept
bool get_is_no_null() const noexcept
Format get_format() const noexcept
Get attribute format.
The OKS class.
Definition class.hpp:200
const std::string & get_name() const noexcept
Definition class.hpp:363
OKS method class.
Definition method.hpp:153
const std::string & get_description() const noexcept
Definition method.hpp:214
const std::string & get_name() const noexcept
Definition method.hpp:196
bool get_is_exclusive() const noexcept
bool get_is_composite() const noexcept
bool get_is_dependent() const noexcept
const std::string & get_name() const noexcept
CardinalityConstraint get_high_cardinality_constraint() const noexcept
Get relationship high cardinality constraint.
const std::string & get_description() const noexcept
CardinalityConstraint get_low_cardinality_constraint() const noexcept
Get relationship low cardinality constraint.
const std::string & get_type() const noexcept