eric7/Graphics/UMLDiagramBuilder.py

branch
eric7
changeset 8312
800c432b34c8
parent 8295
3f5e8b0a338e
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the UML diagram builder base class.
8 """
9
10 from PyQt5.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 getPersistenceData(self):
69 """
70 Public method to get a string for data to be persisted.
71
72 @return persisted data string
73 @rtype str
74 """
75 return ""
76
77 def parsePersistenceData(self, version, data):
78 """
79 Public method to parse persisted data.
80
81 @param version version of the data
82 @type str
83 @param data persisted data to be parsed
84 @type str
85 @return flag indicating success
86 @rtype bool
87 """
88 return True
89
90 def toDict(self):
91 """
92 Public method to collect data to be persisted.
93
94 @return dictionary containing data to be persisted
95 @rtype dict
96 """
97 return {}
98
99 def fromDict(self, version, data):
100 """
101 Public method to populate the class with data persisted by 'toDict()'.
102
103 @param version version of the data
104 @type str
105 @param data dictionary containing the persisted data
106 @type dict
107 @return tuple containing a flag indicating success and an info
108 message in case the diagram belongs to a different project
109 @rtype tuple of (bool, str)
110 """
111 return True, ""

eric ide

mercurial