Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
 def handler(event):
     attribute = event.element
     for row in self.model:
         if row[-1] is attribute:
             row[:] = [
                 UML.format(attribute), attribute.isStatic, attribute
             ]
Пример #6
0
 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)
Пример #7
0
 def _get_rows(self):
     for operation in self._item.subject.ownedOperation:
         yield [
             UML.format(operation),
             operation.isAbstract,
             operation.isStatic,
             operation,
         ]
Пример #8
0
 def render(self):
     """Render the OperationItem."""
     
     return UML.format(self.subject,\
                       visibility=True,\
                       type=True,\
                       multiplicity=True,\
                       default=True) or ''
Пример #9
0
    def render(self):
        """Render the OperationItem."""

        return UML.format(self.subject,\
                          visibility=True,\
                          type=True,\
                          multiplicity=True,\
                          default=True) or ''
Пример #10
0
 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)
Пример #11
0
 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)
Пример #12
0
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
Пример #13
0
 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,
             ]
Пример #14
0
    def render(self):
        """Render the OperationItem."""

        return (UML.format(
            self.subject,
            visibility=True,
            type=True,
            multiplicity=True,
            default=True,
        ) or "")
Пример #15
0
 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,
     )
Пример #16
0
 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
Пример #17
0
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")
Пример #18
0
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"
Пример #19
0
 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()
Пример #20
0
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")
Пример #21
0
 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()
Пример #22
0
 def render(self):
     """
     Return a rendered feature, as a string.
     """
     return UML.format(self.subject, pattern=self.pattern) or ''
Пример #23
0
 def _get_rows(self):
     for attr in self._item.subject.ownedAttribute:
         if not attr.association:
             yield [UML.format(attr), attr.isStatic, attr]
Пример #24
0
 def _get_rows(self):
     for attr in self._item.subject.ownedAttribute:
         if not attr.association:
             yield [UML.format(attr), attr.isStatic, attr]
Пример #25
0
 def lazy_format(operation):
     return lambda: UML.format(
         operation, visibility=True, type=True, multiplicity=True, default=True
     )
Пример #26
0
 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)
Пример #28
0
 def get_text(self):
     return UML.format(editable(self._edit.subject))
Пример #29
0
 def get_text(self):
     return UML.format(editable(self._edit.subject))
Пример #30
0
 def render(self):
     """
     Return a rendered feature, as a string.
     """
     return UML.format(self.subject, pattern=self.pattern) or ""
Пример #31
0
 def _get_rows(self):
     for operation in self._item.subject.ownedOperation:
         yield [UML.format(operation), operation.isAbstract, operation.isStatic, operation]