Beispiel #1
0
class ContextualMenuOnStateController(object):
    """Contextual menu on state"""

    def __init__(self, grammarController, state):
        self.grammarController = grammarController
        self.state = state
        self._view = ContextualMenuOnStateView(self)
        self.log = logging.getLogger(__name__)

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

    def run(self, event):
        self._view.run(event)

    def getState(self):
        return self.state

    def editState_cb(self, widget):
        """callback executed when the user wants to edit a state"""
        controller = EditStateController(self.grammarController, self.state)
        controller.run()

    def deleteState_cb(self, widget):
        """callback executed when the user wants to delete a state"""
        controller = DeleteStateController(self.grammarController, self.state)
        controller.run()

    def editTransition_cb(self, widget, event, transition):
        """callback executed when the user wants to edit a transition"""

        transitionType = transition.getType()
        if SemiStochasticTransition.TYPE == transitionType:
            createTransitionController = CreateSemiStochasticTransitionController(self.grammarController, transition)
            createTransitionController.run()
        elif OpenChannelTransition.TYPE == transitionType:
            createTransitionController = CreateOpenChannelTransitionController(self.grammarController, transition)
            createTransitionController.run()
        elif CloseChannelTransition.TYPE == transitionType:
            createTransitionController = CreateCloseChannelTransitionController(self.grammarController, transition)
            createTransitionController.run()

    def deleteTransition_cb(self, widget, event, transition):
        """callback executed when the user wants to delete a transition"""
        controller = DeleteTransitionController(self.grammarController, transition)
        controller.run()
Beispiel #2
0
 def __init__(self, grammarController, state):
     self.grammarController = grammarController
     self.state = state
     self._view = ContextualMenuOnStateView(self)
     self.log = logging.getLogger(__name__)