示例#1
0
    def createLink(self,
                   src: OglClass,
                   dst: OglClass,
                   linkType: LinkType = LinkType.AGGREGATION):
        """
        Used to create links;  It is still the caller's responsibility to add the created shape to the
        appropriate diagram

        Args:
            src:        The source OglClass
            dst:        The destination OglClass
            linkType:   The type of link
        """
        sourceClass: PyutClass = cast(PyutClass, src.getPyutObject())
        destinationClass: PyutClass = cast(PyutClass, dst.getPyutObject())

        pyutLink: PyutLink = PyutLink("",
                                      linkType=linkType,
                                      source=sourceClass,
                                      destination=destinationClass)

        oglLinkFactory = getOglLinkFactory()
        oglLink = oglLinkFactory.getOglLink(src, pyutLink, dst, linkType)

        src.addLink(oglLink)
        dst.addLink(oglLink)

        # src.getPyutObject().addLink(pyutLink)       # TODO fix this
        pyutClass: PyutClass = cast(PyutClass, src.getPyutObject())
        pyutClass.addLink(pyutLink)

        return oglLink
示例#2
0
    def _createInheritanceLink(self, child: OglClass,
                               parent: OglClass) -> OglLink:
        """
        Add a parent link between the child and parent objects.

        Args:
            child:  Child PyutClass
            parent: Parent PyutClass

        Returns:
            The inheritance OglLink
        """
        sourceClass: PyutClass = cast(PyutClass, child.pyutObject)
        destinationClass: PyutClass = cast(PyutClass, parent.pyutObject)
        pyutLink: PyutLink = PyutLink("",
                                      linkType=LinkType.INHERITANCE,
                                      source=sourceClass,
                                      destination=destinationClass)
        oglLink: OglLink = getOglLinkFactory().getOglLink(
            child, pyutLink, parent, LinkType.INHERITANCE)

        child.addLink(oglLink)
        parent.addLink(oglLink)

        # add it to the PyutClass
        # child.getPyutObject().addParent(parent.getPyutObject())
        childPyutClass: PyutClass = cast(PyutClass, child.pyutObject)
        parentPyutClass: PyutClass = cast(PyutClass, parent.pyutObject)

        childPyutClass.addParent(parentPyutClass)

        return oglLink
示例#3
0
    def createInterfaceLink(self, src: OglClass,
                            dst: OglClass) -> OglInterface:
        """
        Adds an OglInterface link between src and dst.

        Args:
            src:    source of the link
            dst:    destination of the link

        Returns: the created OglInterface link
        """
        sourceClass: PyutClass = cast(PyutClass, src.getPyutObject())
        destinationClass: PyutClass = cast(PyutClass, dst.getPyutObject())

        pyutLink: PyutLink = PyutLink(linkType=LinkType.INTERFACE,
                                      source=sourceClass,
                                      destination=destinationClass)
        oglInterface: OglInterface = OglInterface(srcShape=src,
                                                  pyutLink=pyutLink,
                                                  dstShape=dst)

        src.addLink(oglInterface)
        dst.addLink(oglInterface)

        self._diagram.AddShape(oglInterface)
        self.Refresh()

        return oglInterface
    def createInheritanceLink(self, child: OglClass,
                              parent: OglClass) -> OglLink:
        """
        TODO: this is a duplicate of CreateOglLinkCommandCommand._createInheritanceLink (this code adds it to the frame)

        Add a parent link between the child and parent objects.

        Args:
            child:  Child PyutClass
            parent: Parent PyutClass

        Returns:
            The inheritance OglLink
        """
        pyutLink = PyutLink("",
                            linkType=LinkType.INHERITANCE,
                            source=child.getPyutObject(),
                            destination=parent.getPyutObject())
        oglLink = getOglLinkFactory().getOglLink(child, pyutLink, parent,
                                                 LinkType.INHERITANCE)

        child.addLink(oglLink)
        parent.addLink(oglLink)

        # add it to the PyutClass
        # child.getPyutObject().addParent(parent.getPyutObject())
        childPyutClass: PyutClass = child.getPyutObject()
        parentPyutClass: PyutClass = parent.getPyutObject()

        childPyutClass.addParent(parentPyutClass)

        self._diagram.AddShape(oglLink)
        self.Refresh()

        return oglLink