diff -r cb4e5bbf3a2c -r 3f5e8b0a338e eric6/Graphics/AssociationItem.py --- a/eric6/Graphics/AssociationItem.py Thu May 06 19:46:00 2021 +0200 +++ b/eric6/Graphics/AssociationItem.py Sat May 08 18:34:08 2021 +0200 @@ -616,3 +616,27 @@ "type": self.assocType.value, "topToBottom": self.topToBottom, } + + @classmethod + def fromDict(cls, data, umlItems, colors=None): + """ + Class method to create an association item from persisted data. + + @param data dictionary containing the persisted data as generated + by toDict() + @type dict + @param umlItems list of UML items + @type list of UMLItem + @param colors tuple containing the foreground and background colors + @type tuple of (QColor, QColor) + @return created association item + @rtype AssociationItem + """ + try: + return cls(umlItems[data["src"]], + umlItems[data["dst"]], + assocType=AssociationType(data["type"]), + topToBottom=data["topToBottom"], + colors=colors) + except (KeyError, ValueError): + return None