How to use the gaphor.core.action function in gaphor

To help you get started, we’ve selected a few gaphor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gaphor / gaphor / gaphor / plugins / checkmetamodel / checkmodelgui.py View on Github external
    @action(name="tools-open-check-model", label="Check UML model")
    def open(self):
        self.construct()
        self.run()
github gaphor / gaphor / gaphor / plugins / alignment / __init__.py View on Github external
    @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()
github gaphor / gaphor / gaphor / plugins / alignment / __init__.py View on Github external
    @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()
github gaphor / gaphor / gaphor / ui / diagrampage.py View on Github external
    @action(name="diagram.unselect-all", shortcut="a")
    def unselect_all(self):
        assert self.view
        self.view.unselect_all()
github gaphor / gaphor / gaphor / ui / namespace.py View on Github external
    @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:
github gaphor / gaphor / gaphor / ui / namespace.py View on Github external
    @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__}")
github gaphor / gaphor / gaphor / plugins / alignment / __init__.py View on Github external
    @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()
github gaphor / gaphor / gaphor / plugins / checkmetamodel / checkmodelgui.py View on Github external
    @action(name='tools-open-check-model', label='Check UML model')
    def open(self):
        self.construct()
        self.run()
github gaphor / gaphor / gaphor / ui / diagrampage.py View on Github external
    @action(
        name="diagram.zoom-out", shortcut="minus",
    )
    def zoom_out(self):
        assert self.view
        self.view.zoom(1 / 1.2)
github gaphor / gaphor / gaphor / plugins / pynsource / __init__.py View on Github external
    @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()