Line data Source code
1 : /// Including QT
2 : #include <QMessageBox>
3 : /// Including Schema
4 : #include "dbe/SchemaKernelWrapper.hpp"
5 : /// Include oks
6 : #include "oks/kernel.hpp"
7 : #include "oks/class.hpp"
8 : #include "oks/file.hpp"
9 :
10 : using namespace dunedaq;
11 : using namespace dunedaq::oks;
12 :
13 0 : dbse::KernelWrapper & dbse::KernelWrapper::GetInstance()
14 : {
15 0 : static KernelWrapper KernelManager;
16 0 : return KernelManager;
17 : }
18 :
19 0 : OksKernel * dbse::KernelWrapper::GetKernel()
20 : {
21 0 : return Kernel;
22 : }
23 :
24 0 : void dbse::KernelWrapper::SetActiveSchema ( const std::string & ActiveSchema )
25 : {
26 0 : OksFile * File = Kernel->find_schema_file ( ActiveSchema );
27 :
28 0 : if ( File && IsFileWritable( ActiveSchema ))
29 : {
30 0 : Kernel->set_active_schema ( File );
31 0 : emit active_updated();
32 : }
33 0 : }
34 :
35 0 : void dbse::KernelWrapper::GetClassList ( std::vector<OksClass *> & ClassList ) const
36 : {
37 0 : for ( OksClass::Map::const_iterator i = Kernel->classes().begin();
38 0 : i != Kernel->classes().end(); ++i )
39 : {
40 0 : ClassList.push_back ( i->second );
41 : }
42 0 : }
43 :
44 0 : void dbse::KernelWrapper::GetClassListString ( QStringList & ClassListString ) const
45 : {
46 0 : std::vector<OksClass *> ClassList;
47 :
48 0 : for ( OksClass::Map::const_iterator i = Kernel->classes().begin();
49 0 : i != Kernel->classes().end(); ++i )
50 : {
51 0 : ClassList.push_back ( i->second );
52 : }
53 :
54 0 : for ( OksClass * ClassInfo : ClassList )
55 : {
56 0 : ClassListString.append ( QString::fromStdString ( ClassInfo->get_name() ) );
57 : }
58 0 : }
59 :
60 0 : std::string dbse::KernelWrapper::GetActiveSchema () const
61 : {
62 0 : auto file = Kernel->get_active_schema();
63 0 : if ( file) {
64 0 : return file->get_full_file_name();
65 : }
66 : else {
67 0 : return "";
68 : }
69 : }
70 :
71 : // void dbse::KernelWrapper::AddInclude( std::string IncludeFile ) const
72 : // {
73 : // auto ActiveSchema = Kernel->get_active_schema();
74 : // ActiveSchema->add_include_file( IncludeFile );
75 : // Kernel->load_schema( IncludeFile, ActiveSchema );
76 : // }
77 0 : void dbse::KernelWrapper::AddInclude( std::string schemaFile, std::string IncludeFile ) const
78 : {
79 0 : auto ParentSchema = Kernel->find_schema_file( schemaFile );
80 0 : if ( ParentSchema != nullptr) {
81 0 : ParentSchema->add_include_file( IncludeFile );
82 0 : Kernel->load_schema( IncludeFile, ParentSchema );
83 : }
84 0 : }
85 :
86 0 : void dbse::KernelWrapper::RemoveInclude( std::string schemaFile, std::string IncludeFile ) const
87 : {
88 0 : auto ParentSchema = Kernel->find_schema_file( schemaFile );
89 0 : if (ParentSchema != nullptr) {
90 0 : ParentSchema->remove_include_file( IncludeFile );
91 : }
92 0 : }
93 :
94 0 : void dbse::KernelWrapper::GetSchemaFiles ( std::vector<std::string> & SchemaFiles )
95 : {
96 0 : for ( OksFile::Map::const_iterator i = Kernel->schema_files().begin();
97 0 : i != Kernel->schema_files().end(); ++i )
98 : {
99 0 : SchemaFiles.push_back ( * ( i->first ) );
100 : }
101 0 : }
102 :
103 0 : void dbse::KernelWrapper::GetSchemaFiles ( std::vector<OksFile*> & SchemaFiles )
104 : {
105 0 : for (auto [name, file]: Kernel->schema_files())
106 : {
107 0 : SchemaFiles.push_back ( file );
108 : }
109 0 : }
110 :
111 : std::vector<OksClass*>
112 0 : dbse::KernelWrapper::get_schema_classes (std::string& filename)
113 : {
114 0 : auto file = Kernel->find_schema_file ( filename );
115 0 : std::vector<OksClass*> list;
116 0 : auto klist = Kernel->create_list_of_schema_classes(file);
117 0 : if (klist != nullptr) {
118 0 : for (auto cls: *klist) {
119 0 : list.push_back(cls/*->get_name()*/);
120 : }
121 0 : delete klist;
122 : }
123 0 : return list;
124 0 : }
125 :
126 0 : void dbse::KernelWrapper::GetIncludedList ( const std::string & filename,
127 : std::set<std::string> & included_files )
128 : {
129 0 : Kernel->get_includes ( filename, included_files );
130 0 : }
131 0 : void dbse::KernelWrapper::get_all_includes ( const std::string & filename,
132 : std::set<std::string> & included_files )
133 : {
134 0 : auto parentschema = Kernel->find_schema_file( filename );
135 0 : if ( parentschema != nullptr) {
136 0 : std::set<OksFile*> includes;
137 0 : parentschema->get_all_include_files(Kernel, includes);
138 0 : for (auto file : includes) {
139 0 : included_files.insert(file->get_full_file_name());
140 : }
141 0 : }
142 0 : }
143 :
144 0 : void dbse::KernelWrapper::get_direct_includes ( const std::string & filename,
145 : std::set<std::string> & included_files )
146 : {
147 0 : auto parentschema = Kernel->find_schema_file( filename );
148 0 : if ( parentschema != nullptr) {
149 0 : for (auto file : parentschema->get_include_files()) {
150 0 : included_files.insert(file);
151 0 : }
152 : }
153 0 : }
154 :
155 0 : bool dbse::KernelWrapper::IsFileWritable (const std::string & FileName ) const
156 : {
157 0 : OksFile * File = Kernel->find_schema_file ( FileName );
158 :
159 0 : if ( File )
160 : {
161 0 : return ( !File->is_read_only() );
162 : }
163 :
164 : return false;
165 : }
166 :
167 0 : bool dbse::KernelWrapper::is_file_modified (const std::string & FileName ) const
168 : {
169 0 : OksFile* file = Kernel->find_schema_file ( FileName );
170 0 : if (file != nullptr) {
171 0 : return file->is_updated();
172 : }
173 : return false;
174 : }
175 :
176 0 : OksClass * dbse::KernelWrapper::FindClass ( std::string ClassName ) const
177 : {
178 0 : return Kernel->find_class ( ClassName );
179 : }
180 :
181 0 : void dbse::KernelWrapper::LoadSchema ( const std::string & SchemaName ) const
182 : {
183 0 : Kernel->load_schema ( SchemaName );
184 0 : }
185 :
186 0 : void dbse::KernelWrapper::SaveAllSchema() const
187 : {
188 0 : Kernel->save_all_schema();
189 0 : }
190 :
191 0 : std::string dbse::KernelWrapper::ModifiedSchemaFiles() const
192 : {
193 0 : std::string modified{""};
194 0 : for (auto [name, file] : Kernel->schema_files()) {
195 0 : if (file->is_updated()) {
196 0 : modified += file->get_full_file_name() + "\n\n";
197 : }
198 : }
199 0 : return modified;
200 0 : }
201 :
202 0 : std::vector<std::string> dbse::KernelWrapper::get_modified_schema_files() const
203 : {
204 0 : std::vector<std::string> modified;
205 0 : for (auto [name, file] : Kernel->schema_files()) {
206 0 : if (file->is_updated()) {
207 0 : modified.push_back(file->get_full_file_name());
208 : }
209 : }
210 0 : return modified;
211 0 : }
212 :
213 0 : std::string dbse::KernelWrapper::SaveModifiedSchema() const
214 : {
215 0 : std::string saved{""};
216 0 : for (auto [name, file] : Kernel->schema_files()) {
217 0 : if (file->is_updated()) {
218 0 : Kernel->save_schema(file);
219 0 : saved += file->get_full_file_name() + "\n\n";
220 : }
221 : }
222 0 : return saved;
223 0 : }
224 :
225 0 : void dbse::KernelWrapper::SaveSchema(const std::string& schema_file) const
226 : {
227 0 : OksFile * file = Kernel->find_schema_file ( schema_file );
228 0 : Kernel->save_schema(file);
229 0 : }
230 :
231 :
232 0 : void dbse::KernelWrapper::CloseAllSchema() const
233 : {
234 0 : Kernel->close_all_schema();
235 0 : }
236 :
237 0 : void dbse::KernelWrapper::CreateNewSchema ( const std::string & SchemaName ) const
238 : {
239 0 : Kernel->new_schema ( SchemaName );
240 0 : }
241 :
242 0 : bool dbse::KernelWrapper::AnyClassReferenceThis ( OksClass * SchemaClass )
243 : {
244 0 : std::vector<OksClass *> ClassList;
245 0 : GetClassList ( ClassList );
246 :
247 0 : for ( OksClass * ClassInfo : ClassList )
248 : {
249 0 : const std::list<OksRelationship *> * RelationshipList = ClassInfo->direct_relationships();
250 :
251 0 : if ( RelationshipList != nullptr )
252 : {
253 0 : for ( OksRelationship * RelationshipInfo : *RelationshipList )
254 : {
255 0 : if ( RelationshipInfo->get_class_type()->get_name() == SchemaClass->get_name() )
256 : {
257 0 : return true;
258 : }
259 : }
260 : }
261 : }
262 :
263 0 : return false;
264 0 : }
265 :
266 0 : QString dbse::KernelWrapper::GetCardinalityStringRelationship (
267 : OksRelationship * SchemaRelationship ) const
268 : {
269 0 : QString RelationshipLowCc (
270 0 : OksRelationship::card2str ( SchemaRelationship->get_low_cardinality_constraint() ) );
271 0 : QString RelationshipHighCc (
272 0 : OksRelationship::card2str ( SchemaRelationship->get_high_cardinality_constraint() ) );
273 :
274 0 : if ( RelationshipLowCc == "zero" )
275 : {
276 0 : RelationshipLowCc = "0";
277 : }
278 0 : else if ( RelationshipLowCc == "one" )
279 : {
280 0 : RelationshipLowCc = "1";
281 : }
282 0 : else if ( RelationshipLowCc == "many" )
283 : {
284 0 : RelationshipLowCc = "n";
285 : }
286 :
287 0 : if ( RelationshipHighCc == "zero" )
288 : {
289 0 : RelationshipHighCc = "0";
290 : }
291 0 : else if ( RelationshipHighCc == "one" )
292 : {
293 0 : RelationshipHighCc = "1";
294 : }
295 0 : else if ( RelationshipHighCc == "many" )
296 : {
297 0 : RelationshipHighCc = "n";
298 : }
299 :
300 0 : return QString ( RelationshipLowCc + ':' + RelationshipHighCc );
301 0 : }
302 :
303 0 : bool dbse::KernelWrapper::IsActive() const
304 : {
305 0 : OksFile * ActiveSchemaFile = Kernel->get_active_schema();
306 0 : return ( ActiveSchemaFile != nullptr );
307 : }
308 :
309 0 : void dbse::KernelWrapper::SetInheritanceMode ( bool Mode )
310 : {
311 0 : InheritanceMode = Mode;
312 0 : }
313 :
314 0 : bool dbse::KernelWrapper::GetInheritanceMode() const
315 : {
316 0 : return InheritanceMode;
317 : }
318 :
319 0 : QUndoStack * dbse::KernelWrapper::GetUndoStack()
320 : {
321 0 : return CommandStack;
322 : }
323 :
324 0 : void dbse::KernelWrapper::PushSetAbstractClassCommand ( OksClass * Class, bool Value )
325 : {
326 0 : try
327 : {
328 0 : CommandStack->push ( new SetAbstractClassCommand ( Class, Value ) );
329 : }
330 0 : catch ( oks::exception & Ex )
331 : {
332 0 : QMessageBox::warning ( 0, "Schema editor",
333 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
334 0 : }
335 0 : }
336 :
337 0 : void dbse::KernelWrapper::PushSetDescriptionClassCommand ( OksClass * Class,
338 : std::string Description )
339 : {
340 0 : try
341 : {
342 0 : CommandStack->push ( new SetDescriptionClassCommand ( Class, Description ) );
343 : }
344 0 : catch ( oks::exception & Ex )
345 : {
346 0 : QMessageBox::warning ( 0, "Schema editor",
347 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
348 0 : }
349 0 : }
350 :
351 0 : void dbse::KernelWrapper::PushAddSuperClassCommand ( OksClass * Class,
352 : std::string SuperClass )
353 : {
354 0 : try
355 : {
356 0 : CommandStack->push ( new AddSuperClassCommand ( Class, SuperClass ) );
357 : }
358 0 : catch ( oks::exception & Ex )
359 : {
360 0 : QMessageBox::warning ( 0, "Schema editor",
361 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
362 0 : }
363 0 : }
364 :
365 0 : void dbse::KernelWrapper::PushRemoveSuperClassCommand ( OksClass * Class,
366 : std::string SuperClass )
367 : {
368 0 : try
369 : {
370 0 : CommandStack->push ( new RemoveSuperClassCommand ( Class, SuperClass ) );
371 : }
372 0 : catch ( oks::exception & Ex )
373 : {
374 0 : QMessageBox::warning ( 0, "Schema editor",
375 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
376 0 : }
377 0 : }
378 :
379 0 : void dbse::KernelWrapper::PushCreateClassCommand ( std::string ClassName,
380 : std::string ClassDescription,
381 : bool Abstract )
382 : {
383 0 : try
384 : {
385 0 : CommandStack->push ( new CreateClassCommand ( ClassName, ClassDescription, Abstract ) );
386 : }
387 0 : catch ( ... )
388 : {
389 0 : QMessageBox::warning ( 0, "Schema editor", QString ( "Error" ) );
390 0 : }
391 0 : }
392 :
393 0 : void dbse::KernelWrapper::PushRemoveClassCommand ( OksClass * Class, std::string ClassName,
394 : std::string ClassDescription, bool Abstract )
395 : {
396 0 : try
397 : {
398 0 : CommandStack->push ( new RemoveClassCommand ( Class, ClassName, ClassDescription,
399 0 : Abstract ) );
400 : }
401 0 : catch ( oks::exception & Ex )
402 : {
403 0 : QMessageBox::warning ( 0, "Schema editor",
404 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
405 0 : }
406 0 : }
407 :
408 0 : void dbse::KernelWrapper::PushSetNameRelationshipCommand ( OksClass* Class,
409 : OksRelationship * Relationship,
410 : std::string Name )
411 : {
412 0 : try
413 : {
414 0 : CommandStack->push ( new SetNameRelationshipCommand ( Class, Relationship, Name ) );
415 : }
416 0 : catch ( oks::exception & Ex )
417 : {
418 0 : QMessageBox::warning ( 0, "Schema editor",
419 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
420 0 : }
421 0 : }
422 :
423 0 : void dbse::KernelWrapper::PushSetClassTypeRelationshipCommand ( OksClass* Class,
424 : OksRelationship * Relationship,
425 : std::string ClassType )
426 : {
427 0 : try
428 : {
429 0 : CommandStack->push ( new SetClassTypeRelationshipCommand ( Class, Relationship, ClassType ) );
430 : }
431 0 : catch ( oks::exception & Ex )
432 : {
433 0 : QMessageBox::warning ( 0, "Schema editor",
434 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
435 0 : }
436 0 : }
437 :
438 0 : void dbse::KernelWrapper::PushSetDescriptionRelationshipCommand (
439 : OksClass* Class,
440 : OksRelationship * Relationship,
441 : std::string Description )
442 : {
443 0 : try
444 : {
445 0 : CommandStack->push ( new SetDescriptionRelationshipCommand ( Class, Relationship, Description ) );
446 : }
447 0 : catch ( oks::exception & Ex )
448 : {
449 0 : QMessageBox::warning ( 0, "Schema editor",
450 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
451 0 : }
452 0 : }
453 :
454 0 : void dbse::KernelWrapper::PushSetLowCcRelationshipCommand (
455 : OksClass* Class, OksRelationship * Relationship, OksRelationship::CardinalityConstraint NewCardinality )
456 : {
457 0 : try
458 : {
459 0 : CommandStack->push ( new SetLowCcRelationshipCommand ( Class, Relationship, NewCardinality ) );
460 : }
461 0 : catch ( oks::exception & Ex )
462 : {
463 0 : QMessageBox::warning ( 0, "Schema editor",
464 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
465 0 : }
466 0 : }
467 :
468 0 : void dbse::KernelWrapper::PushSetHighCcRelationshipCommand (
469 : OksClass* Class, OksRelationship * Relationship, OksRelationship::CardinalityConstraint NewCardinality )
470 : {
471 0 : try
472 : {
473 0 : CommandStack->push ( new SetHighCcRelationshipCommand ( Class, Relationship, NewCardinality ) );
474 : }
475 0 : catch ( oks::exception & Ex )
476 : {
477 0 : QMessageBox::warning ( 0, "Schema editor",
478 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
479 0 : }
480 0 : }
481 :
482 0 : void dbse::KernelWrapper::PushSetIsCompositeRelationshipCommand (
483 : OksClass* Class, OksRelationship * Relationship,
484 : bool Value )
485 : {
486 0 : try
487 : {
488 0 : CommandStack->push ( new SetIsCompositeRelationshipCommand ( Class, Relationship, Value ) );
489 : }
490 0 : catch ( oks::exception & Ex )
491 : {
492 0 : QMessageBox::warning ( 0, "Schema editor",
493 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
494 0 : }
495 0 : }
496 :
497 0 : void dbse::KernelWrapper::PushSetIsDependentRelationshipCommand (
498 : OksClass* Class,
499 : OksRelationship * Relationship,
500 : bool Value )
501 : {
502 0 : try
503 : {
504 0 : CommandStack->push ( new SetIsDependentRelationshipCommand ( Class, Relationship, Value ) );
505 : }
506 0 : catch ( oks::exception & Ex )
507 : {
508 0 : QMessageBox::warning ( 0, "Schema editor",
509 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
510 0 : }
511 0 : }
512 :
513 0 : void dbse::KernelWrapper::PushSetIsExclusiveRelationshipCommand (
514 : OksClass* Class,
515 : OksRelationship * Relationship,
516 : bool Value )
517 : {
518 0 : try
519 : {
520 0 : CommandStack->push ( new SetIsExclusiveRelationshipCommand ( Class, Relationship, Value ) );
521 : }
522 0 : catch ( oks::exception & Ex )
523 : {
524 0 : QMessageBox::warning ( 0, "Schema editor",
525 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
526 0 : }
527 0 : }
528 :
529 0 : void dbse::KernelWrapper::PushAddRelationship ( OksClass * Class, std::string Name,
530 : std::string Description, std::string Type,
531 : bool Composite, bool Exclusive, bool Dependent,
532 : OksRelationship::CardinalityConstraint LowCc,
533 : OksRelationship::CardinalityConstraint HighCc )
534 : {
535 0 : try
536 : {
537 0 : CommandStack->push (
538 : new AddRelationship ( Class, Name, Description, Type, Composite, Exclusive, Dependent,
539 0 : LowCc, HighCc ) );
540 : }
541 0 : catch ( oks::exception & Ex )
542 : {
543 0 : QMessageBox::warning ( 0, "Schema editor",
544 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
545 0 : }
546 0 : }
547 :
548 0 : void dbse::KernelWrapper::PushRemoveRelationship ( OksClass * Class,
549 : OksRelationship * Relationship,
550 : std::string Name, std::string Description,
551 : std::string Type, bool Composite, bool Exclusive,
552 : bool Dependent,
553 : OksRelationship::CardinalityConstraint LowCc,
554 : OksRelationship::CardinalityConstraint HighCc )
555 : {
556 0 : try
557 : {
558 0 : CommandStack->push (
559 : new RemoveRelationship ( Class, Relationship, Name, Description, Type, Composite,
560 0 : Exclusive, Dependent, LowCc, HighCc ) );
561 : }
562 0 : catch ( oks::exception & Ex )
563 : {
564 0 : QMessageBox::warning ( 0, "Schema editor",
565 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
566 0 : }
567 0 : }
568 :
569 0 : void dbse::KernelWrapper::PushSetMethodImplementationLanguage ( OksClass * Class,
570 : OksMethod * Method,
571 : OksMethodImplementation * Implementation,
572 : std::string Language )
573 : {
574 0 : try
575 : {
576 0 : CommandStack->push ( new SetMethodImplementationLanguage ( Class, Method, Implementation, Language ) );
577 : }
578 0 : catch ( oks::exception & Ex )
579 : {
580 0 : QMessageBox::warning ( 0, "Schema editor",
581 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
582 0 : }
583 0 : }
584 :
585 0 : void dbse::KernelWrapper::PushSetMethodImplementationPrototype (
586 : OksClass * Class, OksMethod * Method, OksMethodImplementation * Implementation, std::string Prototype )
587 : {
588 0 : try
589 : {
590 0 : CommandStack->push ( new SetMethodImplementationPrototype ( Class, Method, Implementation, Prototype ) );
591 : }
592 0 : catch ( oks::exception & Ex )
593 : {
594 0 : QMessageBox::warning ( 0, "Schema editor",
595 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
596 0 : }
597 0 : }
598 :
599 0 : void dbse::KernelWrapper::PushSetMethodImplementationBody ( OksClass * Class,
600 : OksMethod * Method,
601 : OksMethodImplementation * Implementation,
602 : std::string Body )
603 : {
604 0 : try
605 : {
606 0 : CommandStack->push ( new SetMethodImplementationBody ( Class, Method, Implementation, Body ) );
607 : }
608 0 : catch ( oks::exception & Ex )
609 : {
610 0 : QMessageBox::warning ( 0, "Schema editor",
611 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
612 0 : }
613 0 : }
614 :
615 0 : void dbse::KernelWrapper::PushAddMethodImplementationComand ( OksClass * Class,
616 : OksMethod * Method,
617 : std::string Language,
618 : std::string Prototype, std::string Body )
619 : {
620 0 : try
621 : {
622 0 : CommandStack->push ( new AddMethodImplementationComand ( Class, Method, Language, Prototype,
623 0 : Body ) );
624 : }
625 0 : catch ( oks::exception & Ex )
626 : {
627 0 : QMessageBox::warning ( 0, "Schema editor",
628 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
629 0 : }
630 0 : }
631 :
632 0 : void dbse::KernelWrapper::PushRemoveMethodImplementationComand ( OksClass * Class,
633 : OksMethod * Method,
634 : std::string Language,
635 : std::string Prototype,
636 : std::string Body )
637 : {
638 0 : try
639 : {
640 0 : CommandStack->push ( new RemoveMethodImplementationComand ( Class, Method, Language, Prototype,
641 0 : Body ) );
642 : }
643 0 : catch ( oks::exception & Ex )
644 : {
645 0 : QMessageBox::warning ( 0, "Schema editor",
646 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
647 0 : }
648 0 : }
649 :
650 0 : void dbse::KernelWrapper::PushSetNameMethodCommand ( OksClass * Class, OksMethod * Method, std::string name )
651 : {
652 0 : try
653 : {
654 0 : CommandStack->push ( new SetNameMethodCommand ( Class, Method, name ) );
655 : }
656 0 : catch ( oks::exception & Ex )
657 : {
658 0 : QMessageBox::warning ( 0, "Schema editor",
659 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
660 0 : }
661 0 : }
662 :
663 0 : void dbse::KernelWrapper::PushSetDescriptionMethodCommand ( OksClass * Class, OksMethod * Method,
664 : std::string description )
665 : {
666 0 : try
667 : {
668 0 : CommandStack->push ( new SetDescriptionMethodCommand ( Class, Method, description ) );
669 : }
670 0 : catch ( oks::exception & Ex )
671 : {
672 0 : QMessageBox::warning ( 0, "Schema editor",
673 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
674 0 : }
675 0 : }
676 :
677 0 : void dbse::KernelWrapper::PushAddMethodCommand ( OksClass * Class, std::string name,
678 : std::string description )
679 : {
680 0 : try
681 : {
682 0 : CommandStack->push ( new AddMethodCommand ( Class, name, description ) );
683 : }
684 0 : catch ( oks::exception & Ex )
685 : {
686 0 : QMessageBox::warning ( 0, "Schema editor",
687 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
688 0 : }
689 0 : }
690 :
691 0 : void dbse::KernelWrapper::PushRemoveMethodCommand ( OksClass * Class, OksMethod * Method,
692 : std::string name, std::string description )
693 : {
694 0 : try
695 : {
696 0 : CommandStack->push ( new RemoveMethodCommand ( Class, Method, name, description ) );
697 : }
698 0 : catch ( oks::exception & Ex )
699 : {
700 0 : QMessageBox::warning ( 0, "Schema editor",
701 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
702 0 : }
703 0 : }
704 :
705 0 : void dbse::KernelWrapper::PushSetAttributeNameCommand ( OksClass * Class,
706 : OksAttribute * Attribute,
707 : std::string NewName )
708 : {
709 0 : try
710 : {
711 0 : CommandStack->push ( new SetAttributeNameCommand ( Class, Attribute, NewName ) );
712 : }
713 0 : catch ( oks::exception & Ex )
714 : {
715 0 : QMessageBox::warning ( 0, "Schema editor",
716 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
717 0 : }
718 0 : }
719 :
720 0 : void dbse::KernelWrapper::PushSetAttributeDescriptionCommand ( OksClass * Class,
721 : OksAttribute * Attribute,
722 : std::string NewDescription )
723 : {
724 0 : try
725 : {
726 0 : CommandStack->push ( new SetAttributeDescriptionCommand ( Class, Attribute, NewDescription ) );
727 : }
728 0 : catch ( oks::exception & Ex )
729 : {
730 0 : QMessageBox::warning ( 0, "Schema editor",
731 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
732 0 : }
733 0 : }
734 :
735 0 : void dbse::KernelWrapper::PushSetAttributeTypeCommand ( OksClass * Class,
736 : OksAttribute * Attribute,
737 : std::string NewType )
738 : {
739 0 : try
740 : {
741 0 : CommandStack->push ( new SetAttributeTypeCommand ( Class, Attribute, NewType ) );
742 : }
743 0 : catch ( oks::exception & Ex )
744 : {
745 0 : QMessageBox::warning ( 0, "Schema editor",
746 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
747 0 : }
748 0 : }
749 :
750 0 : void dbse::KernelWrapper::PushSetAttributeRangeCommand ( OksClass * Class,
751 : OksAttribute * Attribute,
752 : std::string NewRange )
753 : {
754 0 : try
755 : {
756 0 : CommandStack->push ( new SetAttributeRangeCommand ( Class, Attribute, NewRange ) );
757 : }
758 0 : catch ( oks::exception & Ex )
759 : {
760 0 : QMessageBox::warning ( 0, "Schema editor",
761 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
762 0 : }
763 0 : }
764 :
765 0 : void dbse::KernelWrapper::PushSetAttributeFormatCommand ( OksClass * Class,
766 : OksAttribute * Attribute,
767 : OksAttribute::Format NewFormat )
768 : {
769 0 : try
770 : {
771 0 : CommandStack->push ( new SetAttributeFormatCommand ( Class, Attribute, NewFormat ) );
772 : }
773 0 : catch ( oks::exception & Ex )
774 : {
775 0 : QMessageBox::warning ( 0, "Schema editor",
776 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
777 0 : }
778 0 : }
779 :
780 0 : void dbse::KernelWrapper::PushSetAttributeMultiCommand ( OksClass * Class,
781 : OksAttribute * Attribute,
782 : bool NewIsMulti )
783 : {
784 0 : try
785 : {
786 0 : CommandStack->push ( new SetAttributeMultiCommand ( Class, Attribute, NewIsMulti ) );
787 : }
788 0 : catch ( oks::exception & Ex )
789 : {
790 0 : QMessageBox::warning ( 0, "Schema editor",
791 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
792 0 : }
793 0 : }
794 :
795 0 : void dbse::KernelWrapper::PushSetAttributeIsNullCommand ( OksClass * Class,
796 : OksAttribute * Attribute,
797 : bool NewIsNull )
798 : {
799 0 : try
800 : {
801 0 : CommandStack->push ( new SetAttributeIsNullCommand ( Class, Attribute, NewIsNull ) );
802 : }
803 0 : catch ( oks::exception & Ex )
804 : {
805 0 : QMessageBox::warning ( 0, "Schema editor",
806 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
807 0 : }
808 0 : }
809 :
810 0 : void dbse::KernelWrapper::PushSetAttributeInitialValuesCommand ( OksClass * Class,
811 : OksAttribute * Attribute,
812 : std::string NewValues )
813 : {
814 0 : try
815 : {
816 0 : CommandStack->push ( new SetAttributeInitialValuesCommand ( Class, Attribute, NewValues ) );
817 : }
818 0 : catch ( oks::exception & Ex )
819 : {
820 0 : QMessageBox::warning ( 0, "Schema editor",
821 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
822 0 : }
823 0 : }
824 :
825 0 : void dbse::KernelWrapper::PushAddAttributeCommand ( OksClass * Class, std::string name,
826 : std::string type,
827 : bool is_mv, std::string range,
828 : std::string init_values, std::string description,
829 : bool is_null, OksAttribute::Format format )
830 : {
831 0 : try
832 : {
833 0 : CommandStack->push (
834 : new AddAttributeCommand ( Class, name, type, is_mv, range, init_values, description,
835 0 : is_null, format ) );
836 : }
837 0 : catch ( oks::exception & Ex )
838 : {
839 0 : QMessageBox::warning ( 0, "Schema editor",
840 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
841 0 : }
842 0 : }
843 :
844 0 : void dbse::KernelWrapper::PushRemoveAttributeCommand ( OksClass * Class,
845 : OksAttribute * Attribute,
846 : std::string name, std::string type, bool is_mv,
847 : std::string range, std::string init_values,
848 : std::string description, bool is_null,
849 : OksAttribute::Format format )
850 : {
851 0 : try
852 : {
853 0 : CommandStack->push (
854 : new RemoveAttributeCommand ( Class, Attribute, name, type, is_mv, range, init_values,
855 0 : description, is_null, format ) );
856 : }
857 0 : catch ( oks::exception & Ex )
858 : {
859 0 : QMessageBox::warning ( 0, "Schema editor",
860 0 : QString ( "Error : \n\n %1" ).arg ( Ex.what() ) );
861 0 : }
862 0 : }
863 :
864 0 : dbse::KernelWrapper::KernelWrapper ( QObject * parent )
865 : : QObject ( parent ),
866 0 : Kernel ( new OksKernel() ),
867 0 : CommandStack ( new QUndoStack() ),
868 0 : InheritanceMode ( false )
869 : {
870 0 : }
|