def _set_object_value(self, row, col, value): attr = row[-1] if col == 0: UML.parse(attr, value) row[0] = UML.format(attr) elif col == 1: attr.isStatic = not attr.isStatic row[1] = attr.isStatic elif col == 2: # Value in attribute object changed: row[0] = UML.format(attr) row[1] = attr.isStatic
def _set_object_value(self, row, col, value): operation = row[-1] if col == 0: UML.parse(operation, value) row[0] = UML.format(operation) elif col == 1: operation.isAbstract = not operation.isAbstract row[1] = operation.isAbstract elif col == 2: operation.isStatic = not operation.isStatic row[2] = operation.isStatic elif col == 3: row[0] = UML.format(operation) row[1] = operation.isAbstract row[2] = operation.isStatic
def handler(event): attribute = event.element for row in self.model: if row[-1] is attribute: row[:] = [ UML.format(attribute), attribute.isStatic, attribute ]
def handler(event): if not entry.props.has_focus: entry.handler_block(changed_id) entry.set_text(UML.format(self.subject, visibility=True, is_derived=True, multiplicity=True) or '') #entry.set_text(UML.format(self.subject, multiplicity=True) or '') entry.handler_unblock(changed_id)
def _get_rows(self): for operation in self._item.subject.ownedOperation: yield [ UML.format(operation), operation.isAbstract, operation.isStatic, operation, ]
def render(self): """Render the OperationItem.""" return UML.format(self.subject,\ visibility=True,\ type=True,\ multiplicity=True,\ default=True) or ''
def get_text(self): if self._edit is self._item: return self._edit.subject.name return UML.format(self._edit.subject, visibility=True, is_derived=True, type=True, multiplicity=True, default=True)
def association_item_inline_editor(item, view, pos=None) -> bool: """Text edit support for Named items.""" @transactional def update_text(text): item.subject.name = text return True @transactional def update_end_text(text): assert end_item UML.parse(end_item.subject, text) return True subject = item.subject if not subject: return False end_item = None if pos and distance_point_point_fast(item.handles()[0].pos, pos) < 50: end_item = item.head_end elif pos and distance_point_point_fast(item.handles()[-1].pos, pos) < 50: end_item = item.tail_end if end_item: text = ( UML.format( end_item.subject, visibility=True, is_derived=True, type=True, multiplicity=True, default=True, ) or "" ) def escape(): assert end_item UML.parse(end_item.subject, text) entry = popup_entry(text, update_end_text) bb = end_item.name_bounds x, y = view.get_matrix_i2v(item).transform_point(bb.x, bb.y) box = Rectangle(x, y, 10, 10) else: text = item.subject.name or "" def escape(): item.subject.name = text entry = popup_entry(text, update_text) box = editable_text_box(view, view.hovered_item) show_popover(entry, view, box, escape) return True
def handler(event): operation = event.element for row in self.model: if row[-1] is operation: row[:] = [ UML.format(operation), operation.isAbstract, operation.isStatic, operation, ]
def render(self): """Render the OperationItem.""" return (UML.format( self.subject, visibility=True, type=True, multiplicity=True, default=True, ) or "")
def get_text(self): if self._edit is self._item: return self._edit.subject.name return UML.format( self._edit.subject, visibility=True, is_derived=True, type=True, multiplicity=True, default=True, )
def update_end_name(self, builder, end_name, subject): name = builder.get_object(f"{end_name}-name") new_name = ( UML.format(subject, visibility=True, is_derived=True, multiplicity=True,) or "" ) if not name.is_focus() and not self.semaphore: self.semaphore += 1 name.set_text(new_name) self.semaphore -= 1 return name
def test_interface_with_attributes_and_operation(diagram, element_factory): iface = element_factory.create(UML.Interface) attr = element_factory.create(UML.Property) UML.parse(attr, "- attr: str") iface.ownedAttribute = attr oper = element_factory.create(UML.Operation) UML.parse(oper, "- oper(inout param: str): str") iface.ownedOperation = oper iface_item = diagram.create(InterfaceItem, subject=iface) new_items = copy_clear_and_paste({iface_item}, diagram, element_factory) new_iface_item = new_items.pop() assert isinstance(new_iface_item, InterfaceItem) assert UML.format( new_iface_item.subject.ownedAttribute[0]) == "- attr: str" assert (UML.format(new_iface_item.subject.ownedOperation[0]) == "- oper(inout param: str): str")
def test_class_with_attributes(diagram, element_factory): cls = element_factory.create(UML.Class) attr = element_factory.create(UML.Property) UML.parse(attr, "- attr: str") cls.ownedAttribute = attr cls_item = diagram.create(ClassItem, subject=cls) new_items = copy_clear_and_paste({cls_item}, diagram, element_factory) new_cls_item = new_items.pop() assert isinstance(new_cls_item, ClassItem) assert UML.format(new_cls_item.subject.ownedAttribute[0]) == "- attr: str"
def set_text(self): """Set the text on the association end.""" if self.subject: try: n, m = UML.format(self.subject) except ValueError: # need more than 0 values to unpack: property was rendered as # attribute while in a UNDO action for example. pass else: self._name = n self._mult = m self.request_update()
def test_class_with_operation(diagram, element_factory): cls = element_factory.create(UML.Class) oper = element_factory.create(UML.Operation) UML.parse(oper, "- oper(inout param: str): str") cls.ownedOperation = oper cls_item = diagram.create(ClassItem, subject=cls) new_items = copy_clear_and_paste({cls_item}, diagram, element_factory) new_cls_item = new_items.pop() assert isinstance(new_cls_item, ClassItem) assert (UML.format(new_cls_item.subject.ownedOperation[0]) == "- oper(inout param: str): str")
def set_text(self): """ Set the text on the association end. """ if self.subject: try: n, m = UML.format(self.subject) except ValueError: # need more than 0 values to unpack: property was rendered as # attribute while in a UNDO action for example. pass else: self._name = n self._mult = m self.request_update()
def render(self): """ Return a rendered feature, as a string. """ return UML.format(self.subject, pattern=self.pattern) or ''
def _get_rows(self): for attr in self._item.subject.ownedAttribute: if not attr.association: yield [UML.format(attr), attr.isStatic, attr]
def lazy_format(operation): return lambda: UML.format( operation, visibility=True, type=True, multiplicity=True, default=True )
def lazy_format(attribute): # str(), so we never ever get an error on a property part of an association return lambda: (UML.format(attribute))
def lazy_format(slot): return lambda: UML.format(slot)
def get_text(self): return UML.format(editable(self._edit.subject))
def render(self): """ Return a rendered feature, as a string. """ return UML.format(self.subject, pattern=self.pattern) or ""
def _get_rows(self): for operation in self._item.subject.ownedOperation: yield [UML.format(operation), operation.isAbstract, operation.isStatic, operation]