Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@action(name="tools-open-check-model", label="Check UML model")
def open(self):
self.construct()
self.run()
@action(name='align-left', label='Left',
tooltip="Vertically align diagram elements on the left", accel='l')
@transactional
def align_left(self):
items = self.get_items()
fitem = self.get_focused_item()
target_x= fitem.matrix[4]
for item in items:
x = target_x - item.matrix[4]
item.matrix.translate(x,0)
item.request_update()
@action(name='align-top', label='Top',
tooltip="Horizontally align diagram elements on their tops", accel='t')
@transactional
def align_top(self):
items = self.get_items()
fitem = self.get_focused_item()
target_y = fitem.matrix[5]
for item in items:
y = target_y - item.matrix[5]
item.matrix.translate(0,y)
item.request_update()
@action(name="diagram.unselect-all", shortcut="a")
def unselect_all(self):
assert self.view
self.view.unselect_all()
@action(name="tree-view.delete")
@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:
@action(name="tree-view.open")
def tree_view_open_selected(self):
element = self._namespace.get_selected_element()
# TODO: Candidate for adapter?
if isinstance(element, UML.Diagram):
self.event_manager.handle(DiagramOpened(element))
else:
log.debug(f"No action defined for element {type(element).__name__}")
@action(
name="align-center",
label="Center",
tooltip="Vertically align diagram elements on their centers",
shortcut="c",
)
@transactional
def align_center(self):
items = self.get_items()
fitem = self.get_focused_item()
min_x = min(self.getXCoordsLeft(items))
max_x = max(self.getXCoordsRight(items))
center_x = fitem.matrix[4] + (fitem.width / 2)
for item in items:
x = center_x - (item.width / 2) - item.matrix[4]
item.matrix.translate(x, 0)
item.request_update()
@action(name='tools-open-check-model', label='Check UML model')
def open(self):
self.construct()
self.run()
@action(
name="diagram.zoom-out", shortcut="minus",
)
def zoom_out(self):
assert self.view
self.view.zoom(1 / 1.2)
@action(name='file-import-pynsource', label='Python source code',
tooltip='Import Python source code')
def execute(self):
dialog = self.create_dialog()
response = dialog.run()
if response != gtk.RESPONSE_OK:
dialog.destroy()
self.reset()
return
files = []
for row in self.filelist:
files.append(row[0])
dialog.destroy()