class DeleteTransitionController(object):
    """Manages the deletion of a transition"""

    def __init__(self, grammarController, transition):
        self.grammarController = grammarController
        self.transition = transition
        self._view = DeleteTransitionView(self, self.transition)
        self.log = logging.getLogger(__name__)

    @property
    def view(self):
        return self._view

    def deleteButton_clicked_cb(self, widget):
        currentProject = self.grammarController.getCurrentProject()
        if currentProject is None or self.transition is None:
            return
        grammar = currentProject.getGrammar()
        automata = grammar.getAutomata()
        if automata is None:
            return

        automata.removeTransition(self.transition)
        self._view.destroy()

        self.grammarController.restart()

    def cancelButton_clicked_cb(self, widget):
        self._view.destroy()

    def run(self):
        self._view.run()
 def __init__(self, grammarController, transition):
     self.grammarController = grammarController
     self.transition = transition
     self._view = DeleteTransitionView(self, self.transition)
     self.log = logging.getLogger(__name__)