src/eric7/Graphics/UMLDiagramBuilder.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2012 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the UML diagram builder base class.
8 """
9
10 from PyQt6.QtCore import QObject
11
12
13 class UMLDiagramBuilder(QObject):
14 """
15 Class implementing the UML diagram builder base class.
16 """
17 def __init__(self, dialog, view, project):
18 """
19 Constructor
20
21 @param dialog reference to the UML dialog
22 @type UMLDialog
23 @param view reference to the view object
24 @type UMLGraphicsView
25 @param project reference to the project object
26 @type Project
27 """
28 super().__init__(dialog)
29
30 self.umlView = view
31 self.scene = self.umlView.scene()
32 self.project = project
33
34 def initialize(self):
35 """
36 Public method to initialize the object.
37 """
38 return
39
40 def buildErrorMessage(self, msg):
41 """
42 Public method to build an error string to be included in the scene.
43
44 @param msg error message
45 @type str
46 @return prepared error string
47 @rtype str
48 """
49 return (
50 "<font color='{0}'>".format(
51 self.umlView.getDrawingColors()[0].name()) +
52 msg +
53 "</font>"
54 )
55
56 def buildDiagram(self):
57 """
58 Public method to build the diagram.
59
60 This class must be implemented in subclasses.
61
62 @exception NotImplementedError raised to indicate that this class
63 must be subclassed
64 """
65 raise NotImplementedError(
66 "Method 'buildDiagram' must be implemented in subclasses.")
67
68 def parsePersistenceData(self, version, data):
69 """
70 Public method to parse persisted data.
71
72 @param version version of the data
73 @type str
74 @param data persisted data to be parsed
75 @type str
76 @return flag indicating success
77 @rtype bool
78 """
79 return True
80
81 def toDict(self):
82 """
83 Public method to collect data to be persisted.
84
85 @return dictionary containing data to be persisted
86 @rtype dict
87 """
88 return {}
89
90 def fromDict(self, version, data):
91 """
92 Public method to populate the class with data persisted by 'toDict()'.
93
94 @param version version of the data
95 @type str
96 @param data dictionary containing the persisted data
97 @type dict
98 @return tuple containing a flag indicating success and an info
99 message in case the diagram belongs to a different project
100 @rtype tuple of (bool, str)
101 """
102 return True, ""

eric ide

mercurial