gaphor/models/Core.override
Arjan Molenaar e64897fc2f
Make Presentation.diagram an association
We can now rely on this association being set. We can set a watch on
changes and slowly move the canvas out of our codebase.
2020-12-24 09:41:23 +01:00

72 lines
1.9 KiB
Plaintext

header
from typing import TYPE_CHECKING
from gaphor.core.modeling.element import Element
if TYPE_CHECKING:
from gaphor.UML import Dependency, Namespace, Package
%%
override Element
# defined above
%%
override NamedElement
# Define extra attributes defined in UML model
class NamedElement(Element):
name: attribute[str]
qualifiedName: derived[List[str]]
visibility: enumeration
namespace: relation_one[Namespace]
clientDependency: relation_many[Dependency]
supplierDependency: relation_many[Dependency]
memberNamespace: relation_many[Namespace]
%%
override NamedElement.qualifiedName(NamedElement.namespace): derived[List[str]]
def _namedelement_qualifiedname(self) -> List[str]:
"""Returns the qualified name of the element as a tuple."""
if self.namespace:
return _namedelement_qualifiedname(self.namespace) + [self.name]
else:
return [self.name]
NamedElement.qualifiedName = derived(
"qualifiedName",
List[str],
0,
1,
lambda obj: [_namedelement_qualifiedname(obj)],
)
%%
override PackageableElement
class PackageableElement(NamedElement):
owningPackage: relation_one[Package]
%%
override StyleSheet
# defined in gaphor.core.modeling.presentation
%%
override StyleSheet.styleSheet
# defined in gaphor.core.modeling.presentation
%%
override Presentation
# defined in gaphor.core.modeling.presentation
%%
override Element.presentation
# defined in gaphor.core.modeling.presentation
%%
override Presentation.diagram
# defined in gaphor.core.modeling.presentation
%%
override Presentation.subject
# defined in gaphor.core.modeling.presentation
%%
override Presentation.parent
# defined in gaphor.core.modeling.presentation
%%
override Presentation.children
# defined in gaphor.core.modeling.presentation
%%
override Diagram
# defined in gaphor.core.modeling.diagram
%%
override Diagram.ownedPresentation
# defined in gaphor.core.modeling.presentation