Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@transactional
def _on_auto_dependency_change(self, button):
self.item.auto_dependency = button.get_active()
self.update()
@transactional
def tree_view_create_diagram(self):
element = self._namespace.get_selected_element()
while not isinstance(element, UML.Package):
element = element.namespace
diagram = self.element_factory.create(UML.Diagram)
diagram.package = element
if element:
diagram.name = f"{element.name} diagram"
else:
diagram.name = "New diagram"
self.select_element(diagram)
self.event_manager.handle(DiagramOpened(diagram))
self.tree_view_rename_selected()
@transactional
def _on_dependency_type_change(self, combo):
combo = self.combo
cls = combo.get_model().get_value(combo.get_active())
self.item.dependency_type = cls
if self.item.subject:
self.element_factory.swap_element(self.item.subject, cls)
self.item.request_update()
@transactional
def _on_aggregation_change(self, combo):
self.subject.aggregation = ("none", "shared", "composite")[combo.get_active()]
@transactional
def connect(self, sink):
"""
Create connection at handle level and at model level.
"""
handle = self.handle
item = self.item
cinfo = item.canvas.get_connection(handle)
try:
callback = DisconnectHandle(self.item, self.handle)
if cinfo and cinfo.connected is sink.item:
# reconnect only constraint - leave model intact
log.debug('performing reconnect constraint')
constraint = sink.port.constraint(item.canvas, item, handle, sink.item)
item.canvas.reconnect_item(item, handle, constraint=constraint)
elif cinfo:
@transactional
def delete_selected_items(self):
assert self.view
items = self.view.selected_items
for i in list(items):
if isinstance(i, UML.Presentation):
i.unlink()
else:
if i.canvas:
i.canvas.remove(i)
@transactional
def update_text(text):
item.subject.name = text
popover.popdown()
return True
@transactional
def _on_ordering_change(self, combo):
value = self.ORDERING_VALUES[combo.get_active()]
self.subject.ordering = value
@transactional
def tree_view_delete(self):
element = self._namespace.get_selected_element()
if isinstance(element, UML.Package):
element.unlink()
elif isinstance(element, UML.Diagram):
m = Gtk.MessageDialog(
None,
Gtk.DialogFlags.MODAL,
Gtk.MessageType.QUESTION,
Gtk.ButtonsType.YES_NO,
"Do you really want to delete diagram %s?\n\n"
"This will possibly delete diagram items\n"
"that are not shown in other diagrams." % (element.name or ""),
)
if m.run() == Gtk.ResponseType.YES:
for i in reversed(element.canvas.get_all_items()):
@transactional
def tree_view_create_package(self):
element = self._namespace.get_selected_element()
package = self.element_factory.create(UML.Package)
package.package = element
if element:
package.name = f"{element.name} package"
else:
package.name = "New model"
self.select_element(package)
self.tree_view_rename_selected()