def __init__(self, netzob): self.netzob = netzob self._view = GrammarView(self) self.log = logging.getLogger(__name__)
class GrammarController(object): def __init__(self, netzob): self.netzob = netzob self._view = GrammarView(self) self.log = logging.getLogger(__name__) @property def view(self): return self._view def restart(self): """Restart the view""" logging.debug("Restarting the grammar perspective") self._view.restart() def activate(self): """Activate the perspective""" self.restart() def deactivate(self): pass def getCurrentProject(self): """Return the current project (can be None)""" return self.netzob.getCurrentProject() def getCurrentWorkspace(self): """Return the current workspace""" return self.netzob.getCurrentWorkspace() def activeGrammarInferring_activate_cb(self, event): if self.getCurrentProject() is None: logging.info("No project loaded.") return agi = AutomaticGrammarInferenceView(self.getCurrentProject()) agi.display() def passiveGrammarInferring_activate_cb(self, event): if self.getCurrentProject() is None: logging.info("No project loaded.") return def createState_activate_cb(self, event): """Callback executed when the user wants to create a state""" if self.getCurrentProject() is None: logging.info("No project loaded.") return createStateController = CreateStateController(self) createStateController.run() def createSemiStochasticTransition_activate_cb(self, event): if self.getCurrentProject() is None: logging.info("No project loaded.") return createTransitionController = CreateSemiStochasticTransitionController(self, None) createTransitionController.run() def createOpenChannelTransition_activate_cb(self, event): if self.getCurrentProject() is None: logging.info("No project loaded.") return createTransitionController = CreateOpenChannelTransitionController(self, None) createTransitionController.run() def createCloseChannelTransition_activate_cb(self, event): if self.getCurrentProject() is None: logging.info("No project loaded.") return createTransitionController = CreateCloseChannelTransitionController(self, None) createTransitionController.run()
class GrammarController(object): def __init__(self, netzob): self.netzob = netzob self._view = GrammarView(self) self.log = logging.getLogger(__name__) @property def view(self): return self._view def restart(self): """Restart the view""" logging.debug("Restarting the grammar perspective") self._view.restart() def activate(self): """Activate the perspective""" self.restart() def deactivate(self): pass def getCurrentProject(self): """Return the current project (can be None)""" return self.netzob.getCurrentProject() def getCurrentWorkspace(self): """Return the current workspace""" return self.netzob.getCurrentWorkspace() def activeGrammarInferring_activate_cb(self, event): if self.getCurrentProject() is None: logging.info("No project loaded.") return agi = AutomaticGrammarInferenceView(self.getCurrentProject()) agi.display() def passiveGrammarInferring_activate_cb(self, event): if self.getCurrentProject() is None: logging.info("No project loaded.") return def createState_activate_cb(self, event): """Callback executed when the user wants to create a state""" if self.getCurrentProject() is None: logging.info("No project loaded.") return createStateController = CreateStateController(self) createStateController.run() def createSemiStochasticTransition_activate_cb(self, event): if self.getCurrentProject() is None: logging.info("No project loaded.") return createTransitionController = CreateSemiStochasticTransitionController( self, None) createTransitionController.run() def createOpenChannelTransition_activate_cb(self, event): if self.getCurrentProject() is None: logging.info("No project loaded.") return createTransitionController = CreateOpenChannelTransitionController( self, None) createTransitionController.run() def createCloseChannelTransition_activate_cb(self, event): if self.getCurrentProject() is None: logging.info("No project loaded.") return createTransitionController = CreateCloseChannelTransitionController( self, None) createTransitionController.run()