Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name="edit-copy", label=_("Copy"), icon_name="edit-copy", shortcut="c"
)
def copy_action(self):
view = self.diagrams.get_current_view()
if view.is_focus():
items = view.selected_items
self.copy(items)
win_action_group = view.get_action_group("win")
if win_action_group:
win_action_group.lookup_action("edit-paste").set_enabled(
bool(self.copy_buffer)
)
def construct(self):
page = super(AssociationPropertyPage, self).construct()
if not self.subject:
return page
hbox = Gtk.HBox()
label = Gtk.Label(label="")
label.set_justify(Gtk.Justification.LEFT)
self.size_group.add_widget(label)
hbox.pack_start(label, False, True, 0)
button = Gtk.CheckButton(label=_("Show direction"))
button.set_active(self.item.show_direction)
button.connect("toggled", self._on_show_direction_change)
hbox.pack_start(button, True, True, 0)
button = Gtk.Button(label=_("Invert Direction"))
button.connect("clicked", self._on_invert_direction_change)
hbox.pack_start(button, True, True, 0)
page.pack_start(hbox, False, True, 0)
box = self.construct_end(_("Head"), self.item.head_end)
if box:
page.pack_start(box, False, True, 0)
box = self.construct_end(_("Tail"), self.item.tail_end)
if box:
def construct(self):
page = Gtk.VBox()
hbox = create_hbox_label(self, page, _("Dependency type"))
self.combo = create_uml_combo(
self.DEPENDENCY_TYPES, self._on_dependency_type_change
)
hbox.pack_start(self.combo, False, True, 0)
hbox = create_hbox_label(self, page, "")
button = Gtk.CheckButton(_("Automatic"))
button.set_active(self.item.auto_dependency)
button.connect("toggled", self._on_auto_dependency_change)
hbox.pack_start(button, True, True, 0)
self.watcher.watch("subject", self._on_subject_change).register_handlers()
button.connect("destroy", self.watcher.unregister_handlers)
self.update()
return page
self.item.show_operations = button.get_active()
self.item.request_update()
@PropertyPages.register(items.DependencyItem)
class DependencyPropertyPage(PropertyPageBase):
"""Dependency item editor."""
order = 0
element_factory = inject("element_factory")
DEPENDENCY_TYPES = (
(_("Dependency"), UML.Dependency),
(_("Usage"), UML.Usage),
(_("Realization"), UML.Realization),
(_("Implementation"), UML.Implementation),
)
def __init__(self, item):
super(DependencyPropertyPage, self).__init__()
self.item = item
self.size_group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
self.watcher = EventWatcher(self.item)
def construct(self):
page = Gtk.VBox()
hbox = create_hbox_label(self, page, _("Dependency type"))
self.combo = create_uml_combo(
self.DEPENDENCY_TYPES, self._on_dependency_type_change
subject = self.subject
if not subject:
return page
hbox = Gtk.HBox()
page.pack_start(hbox, False, True, 0)
if isinstance(subject, UML.JoinNode):
hbox = create_hbox_label(self, page, _("Join specification"))
entry = Gtk.Entry()
entry.set_text(subject.joinSpec or "")
entry.connect("changed", self._on_join_spec_change)
hbox.pack_start(entry, True, True, 0)
button = Gtk.CheckButton(_("Horizontal"))
button.set_active(self.item.matrix[2] != 0)
button.connect("toggled", self._on_horizontal_change)
page.pack_start(button, False, True, 0)
return page
def construct(self):
page = super(MessagePropertyPage, self).construct()
item = self.item
subject = item.subject
if not subject:
return page
if item.is_communication():
self._messages = CommunicationMessageModel(item)
tree_view = create_tree_view(self._messages, (_("Message"),))
tree_view.set_headers_visible(False)
frame = Gtk.Frame.new(label=_("Additional Messages"))
frame.add(tree_view)
page.pack_start(frame, True, True, 0)
self._inverted_messages = CommunicationMessageModel(item, inverted=True)
tree_view = create_tree_view(self._inverted_messages, (_("Message"),))
tree_view.set_headers_visible(False)
frame = Gtk.Frame.new(label=_("Inverted Messages"))
frame.add(tree_view)
page.pack_end(frame, True, True, 0)
else:
hbox = create_hbox_label(self, page, _("Message sort"))
sort_data = self.MESSAGE_SORT
lifeline = None
cinfo = item.canvas.get_connection(item.tail)
if cinfo:
"zoom-out-symbolic", "diagram.zoom-out", _("Zoom out") + f" ({primary()}+-)"
),
False,
False,
0,
)
box.show()
return box
class ElementEditor(UIComponent, ActionProvider):
"""The ElementEditor class is a utility window used to edit UML elements.
It will display the properties of the currently selected element in the
diagram."""
title = _("Element Editor")
size = (275, -1)
def __init__(self, event_manager, element_factory, diagrams):
"""Constructor. Build the action group for the element editor window.
This will place a button for opening the window in the toolbar.
The widget attribute is a PropertyEditor."""
self.event_manager = event_manager
self.element_factory = element_factory
self.diagrams = diagrams
self.vbox: Optional[Gtk.Box] = None
self._current_item = None
self._expanded_pages = {_("Properties"): True}
def open(self):
"""Display the ElementEditor pane."""
def zoom_buttons():
box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
box.get_style_context().add_class("linked")
box.pack_start(
icon_button(
"zoom-in-symbolic", "diagram.zoom-in", _("Zoom in") + f" ({primary()}++)"
),
False,
False,
0,
)
box.pack_start(
icon_button(
"zoom-original-symbolic",
"diagram.zoom-100",
_("Zoom 100%") + f" ({primary()}+0)",
),
False,
False,
0,
)
box.pack_start(
@open_action(name='ElementEditor:open', label=_('Editor'), stock_id='gtk-edit', accel='e')
def open_elementeditor(self):
"""Display the element editor when the toolbar button is toggled. If
active, the element editor is displayed. Otherwise, it is hidden."""
if not self.widget.get_parent():
return self
button.set_active(self.item.show_operations)
button.connect("toggled", self._on_show_operations_change)
hbox.pack_start(button, True, True, 0)
page.pack_start(hbox, False, True, 0)
def create_model():
return ClassOperations(self.item, (str, bool, bool, object))
self.model = create_model()
tip = """\
Add and edit class operations according to UML syntax. Operation syntax examples
- call()
- + call(a: int, b: str)
- # call(a: int: b: str): bool
"""
tree_view = create_tree_view(self.model, (_("Operation"), _("A"), _("S")), tip)
page.pack_start(tree_view, True, True, 0)
@AsyncIO(single=True)
def handler(event):
if not tree_view.props.has_focus and self.item and self.item.subject:
self.model = create_model()
tree_view.set_model(self.model)
self.watcher.watch("ownedOperation.name", handler).watch(
"ownedOperation.isAbstract", handler
).watch("ownedOperation.visibility", handler).watch(
"ownedOperation.returnResult.lowerValue", handler
).watch(
"ownedOperation.returnResult.upperValue", handler
).watch(
"ownedOperation.returnResult.typeValue", handler