14 |
14 |
15 from E5Gui import E5MessageBox, E5FileDialog |
15 from E5Gui import E5MessageBox, E5FileDialog |
16 |
16 |
17 from .UMLItem import UMLItem |
17 from .UMLItem import UMLItem |
18 from .AssociationItem import AssociationItem |
18 from .AssociationItem import AssociationItem |
|
19 from .ClassItem import ClassItem |
|
20 from .ModuleItem import ModuleItem |
|
21 from .PackageItem import PackageItem |
19 from .UMLSceneSizeDialog import UMLSceneSizeDialog |
22 from .UMLSceneSizeDialog import UMLSceneSizeDialog |
20 from .ZoomDialog import ZoomDialog |
23 from .ZoomDialog import ZoomDialog |
21 |
24 |
22 import UI.Config |
25 import UI.Config |
23 import UI.PixmapCache |
26 import UI.PixmapCache |
601 for item in self.filteredItems(self.scene().items(), AssociationItem): |
604 for item in self.filteredItems(self.scene().items(), AssociationItem): |
602 lines.append("association: {0}".format(item.buildAssociationItemDataString())) |
605 lines.append("association: {0}".format(item.buildAssociationItemDataString())) |
603 |
606 |
604 return lines |
607 return lines |
605 |
608 |
606 def parsePersistenceData(self, data): |
609 def parsePersistenceData(self, version, data): |
607 """ |
610 """ |
608 Public method to parse persisted data. |
611 Public method to parse persisted data. |
609 |
612 |
610 @param dat persisted data to be parsed (string) |
613 @param version version of the data (string) |
611 """ |
614 @param data persisted data to be parsed (list of string) |
612 # TODO: implement this |
615 @return tuple of flag indicating success (boolean) and faulty line |
613 return |
616 number (integer) |
|
617 """ |
|
618 umlItems = {} |
|
619 |
|
620 if not data[0].startswith("diagram_name:"): |
|
621 return False, 0 |
|
622 self.diagramName = data[0].split(": ", 1)[1].strip() |
|
623 |
|
624 linenum = 0 |
|
625 for line in data[1:]: |
|
626 linenum += 1 |
|
627 if not line.startswith(("item:", "association:")): |
|
628 return False, linenum |
|
629 |
|
630 key, value = line.split(": ", 1) |
|
631 if key == "item": |
|
632 id, x, y, itemType, itemData = value.split(", ", 4) |
|
633 try: |
|
634 id = int(id.split("=", 1)[1].strip()) |
|
635 x = float(x.split("=", 1)[1].strip()) |
|
636 y = float(y.split("=", 1)[1].strip()) |
|
637 itemType = itemType.split("=", 1)[1].strip() |
|
638 if itemType == ClassItem.ItemType: |
|
639 itm = ClassItem(x=x, y=y, scene=self.scene()) |
|
640 elif itemType == ModuleItem.ItemType: |
|
641 itm = ModuleItem(x=x, y=y, scene=self.scene()) |
|
642 elif itemType == PackageItem.ItemType: |
|
643 itm = PackageItem(x=x, y=y, scene=self.scene()) |
|
644 itm.setId(id) |
|
645 umlItems[id] = itm |
|
646 if not itm.parseItemDataString(version, itemData): |
|
647 return False, linenum |
|
648 except ValueError: |
|
649 return False, linenum |
|
650 elif key == "association": |
|
651 srcId, dstId, assocType, topToBottom = \ |
|
652 AssociationItem.parseAssociationItemDataString(value.strip()) |
|
653 assoc = AssociationItem(umlItems[srcId], umlItems[dstId], |
|
654 assocType, topToBottom) |
|
655 self.scene().addItem(assoc) |
|
656 |
|
657 return True, -1 |