def __on_change_type(self, event):
     if self.transition_path != None and not self.skip_change_type_event:
         # Remove transition from state
         transition = self.__get_transition()
         state = self.__get_state()
         state.removetransition(transition)
         # Get free conditions for the selected transition type
         state_path = fsm.get_state_of_transition(self.transition_path)
         conds_paths = get_free_conditions(event.GetSelection(), state_path)
         # Delete condition if it's an event condition with filter
         cond_path = fsm.get_filteredcondition_of_transition(
             self.transition_path)
         try:
             pynebula.lookup(cond_path)
             pynebula.delete(cond_path)
         except:
             pass
         # Set first free condition for the selected transition type
         transition.setcondition(pynebula.lookup(conds_paths[0]))
         # Add transition to state
         state.addtransition(transition)
         # Refresh condition parameters panel
         if self.GetSelection() == 0:
             self.panel_event.set_transition(self.transition_path)
         else:
             self.panel_script.set_transition(self.transition_path)
         # Signal change
         fsmevents.signal_fsm_change(self, self.transition_path)
 def __on_change_type(self, event):
     if self.transition_path != None and not self.skip_change_type_event:
         # Remove transition from state
         transition = self.__get_transition()
         state = self.__get_state()
         state.removetransition( transition )
         # Get free conditions for the selected transition type
         state_path = fsm.get_state_of_transition( self.transition_path )
         conds_paths = get_free_conditions( event.GetSelection(), state_path )
         # Delete condition if it's an event condition with filter
         cond_path = fsm.get_filteredcondition_of_transition( self.transition_path )
         try:
             pynebula.lookup( cond_path )
             pynebula.delete( cond_path )
         except:
             pass
         # Set first free condition for the selected transition type
         transition.setcondition( pynebula.lookup(conds_paths[0]) )
         # Add transition to state
         state.addtransition( transition )
         # Refresh condition parameters panel
         if self.GetSelection() == 0:
             self.panel_event.set_transition( self.transition_path )
         else:
             self.panel_script.set_transition( self.transition_path )
         # Signal change
         fsmevents.signal_fsm_change( self, self.transition_path )
 def __on_select_script(self, event):
     transition = pynebula.lookup(self.transition_path)
     state_path = fsm.get_state_of_transition(self.transition_path)
     state = pynebula.lookup(state_path)
     state.removetransition(transition)
     condition = servers.get_fsm_server().getscriptcondition(
         str(self.choice_script.GetStringSelection()))
     transition.setcondition(condition)
     state.addtransition(transition)
     fsmevents.signal_fsm_change(self, self.transition_path)
 def __on_select_script(self, event):
     transition = pynebula.lookup( self.transition_path )
     state_path = fsm.get_state_of_transition( self.transition_path )
     state = pynebula.lookup( state_path )
     state.removetransition( transition )
     condition = servers.get_fsm_server().getscriptcondition(
         str(self.choice_script.GetStringSelection()) )
     transition.setcondition( condition )
     state.addtransition( transition )
     fsmevents.signal_fsm_change( self, self.transition_path )
 def __update_script_list(self):
     self.choice_script.Clear()
     if self.transition_path != None:
         cond_path = pynebula.lookup( self.transition_path ).getcondition().getfullname()
         state_path = fsm.get_state_of_transition( self.transition_path )
         paths = get_free_script_conditions( state_path, cond_path )
         for path in paths:
             index = self.choice_script.Append( format.get_name(path) )
             if path == cond_path:
                 self.choice_script.Select( index )
 def __update_script_list(self):
     self.choice_script.Clear()
     if self.transition_path != None:
         cond_path = pynebula.lookup(
             self.transition_path).getcondition().getfullname()
         state_path = fsm.get_state_of_transition(self.transition_path)
         paths = get_free_script_conditions(state_path, cond_path)
         for path in paths:
             index = self.choice_script.Append(format.get_name(path))
             if path == cond_path:
                 self.choice_script.Select(index)
 def __on_update_condition(self, event):
     # Remove transition from state
     transition = self.__get_transition()
     state_path = fsm.get_state_of_transition(self.transition_path)
     state = pynebula.lookup(state_path)
     state.removetransition(transition)
     # Get old event and filter
     old_cond_obj = transition.getcondition()
     old_event_id = old_cond_obj.getevent()
     old_filter_obj = old_cond_obj.getfiltercondition()
     # Get new event and filter
     #        new_event_name = self.choice_event.GetStringSelection()
     #        new_event_id = servers.get_fsm_server().geteventcondition( str(new_event_name) ).getevent()
     new_event_id = self.event_ids[self.choice_event.GetSelection()]
     new_filter_name = self.choice_filter.GetStringSelection()
     new_filter_obj = None
     if new_filter_name != "<none>":
         new_filter_obj = servers.get_fsm_server().getscriptcondition(
             str(new_filter_name))
     # Act depending on filter condition existance and selection
     local_cond_path = fsm.get_filteredcondition_of_transition(
         self.transition_path)
     if old_filter_obj == None:
         if new_filter_obj == None:
             # Neither the old or the new conditions have a filter
             # Just select a shared condition
             new_cond_obj = get_event_condition(
                 new_event_id
             )  #servers.get_fsm_server().geteventcondition( str(new_event_name) )
         else:
             # The old condition doesn't have a filter, but the new one does
             # Create a local condition, with the same event and new filter
             new_cond_obj = pynebula.new('neventcondition', local_cond_path)
             new_cond_obj.setevent(new_event_id)
             new_cond_obj.setfiltercondition(new_filter_obj)
     else:
         if new_filter_obj == None:
             # The old condition has a filter, but the new one doesn't
             # Remove the local condition and select a shared condition
             old_cond_obj = None
             pynebula.delete(str(local_cond_path))
             new_cond_obj = get_event_condition(
                 new_event_id
             )  #servers.get_fsm_server().geteventcondition( str(new_event_name) )
         else:
             # Both the old and the new conditions have a filter
             # Update the local condition with the new event
             new_cond_obj = old_cond_obj
             new_cond_obj.setevent(new_event_id)
     # Reinsert the transition into the state
     transition.setcondition(new_cond_obj)
     state.addtransition(transition)
     # Signal the change
     fsmevents.signal_fsm_change(self, self.transition_path)
 def __update_event_list(self):
     self.choice_event.Clear()
     self.event_ids = []
     if self.transition_path != None:
         cond = self.__get_transition().getcondition()
         cond_path = get_event_condition(cond.getevent())
         ##            if cond_path == fsm.get_filteredcondition_of_transition( self.transition_path ):
         ##                cond_path = get_event_condition( pynebula.lookup(cond_path).getevent() )
         state_path = fsm.get_state_of_transition(self.transition_path)
         paths = get_free_event_conditions(state_path, cond_path)
         for path in paths:
             index = self.choice_event.Append(get_condition_gui_name(path))
             self.event_ids.append(pynebula.lookup(path).getevent())
             if path == cond_path:
                 self.choice_event.Select(index)
    def __update_event_list(self):
        self.choice_event.Clear()
        self.event_ids = []
        if self.transition_path != None:
            cond = self.__get_transition().getcondition()
            cond_path = get_event_condition( cond.getevent() )
##            if cond_path == fsm.get_filteredcondition_of_transition( self.transition_path ):
##                cond_path = get_event_condition( pynebula.lookup(cond_path).getevent() )
            state_path = fsm.get_state_of_transition( self.transition_path )
            paths = get_free_event_conditions( state_path, cond_path )
            for path in paths:
                index = self.choice_event.Append( get_condition_gui_name(path) )
                self.event_ids.append( pynebula.lookup(path).getevent() )
                if path == cond_path:
                    self.choice_event.Select( index )
    def __on_update_condition(self, event):
        # Remove transition from state
        transition = self.__get_transition()
        state_path = fsm.get_state_of_transition( self.transition_path )
        state = pynebula.lookup( state_path )
        state.removetransition( transition )
        # Get old event and filter
        old_cond_obj = transition.getcondition()
        old_event_id = old_cond_obj.getevent()
        old_filter_obj = old_cond_obj.getfiltercondition()
        # Get new event and filter
#        new_event_name = self.choice_event.GetStringSelection()
#        new_event_id = servers.get_fsm_server().geteventcondition( str(new_event_name) ).getevent()
        new_event_id = self.event_ids[ self.choice_event.GetSelection() ]
        new_filter_name = self.choice_filter.GetStringSelection()
        new_filter_obj = None
        if new_filter_name != "<none>":
            new_filter_obj = servers.get_fsm_server().getscriptcondition( str(new_filter_name) )
        # Act depending on filter condition existance and selection
        local_cond_path = fsm.get_filteredcondition_of_transition( self.transition_path )
        if old_filter_obj == None:
            if new_filter_obj == None:
                # Neither the old or the new conditions have a filter
                # Just select a shared condition
                new_cond_obj = get_event_condition( new_event_id ) #servers.get_fsm_server().geteventcondition( str(new_event_name) )
            else:
                # The old condition doesn't have a filter, but the new one does
                # Create a local condition, with the same event and new filter
                new_cond_obj = pynebula.new( 'neventcondition', local_cond_path )
                new_cond_obj.setevent( new_event_id )
                new_cond_obj.setfiltercondition( new_filter_obj )
        else:
            if new_filter_obj == None:
                # The old condition has a filter, but the new one doesn't
                # Remove the local condition and select a shared condition
                old_cond_obj = None
                pynebula.delete( str(local_cond_path) )
                new_cond_obj = get_event_condition( new_event_id ) #servers.get_fsm_server().geteventcondition( str(new_event_name) )
            else:
                # Both the old and the new conditions have a filter
                # Update the local condition with the new event
                new_cond_obj = old_cond_obj
                new_cond_obj.setevent( new_event_id )
        # Reinsert the transition into the state
        transition.setcondition( new_cond_obj )
        state.addtransition( transition )
        # Signal the change
        fsmevents.signal_fsm_change( self, self.transition_path )
 def __on_changing_type(self, event):
     if self.transition_path != None and not self.skip_change_type_event:
         # Forbid change type if there isn't any condition available
         # for the new transition type
         state_path = fsm.get_state_of_transition(self.transition_path)
         conds_paths = get_free_conditions(event.GetSelection(), state_path)
         if len(conds_paths) == 0:
             if event.GetSelection() == ID_EventTransition:
                 name1 = "an event"
                 name2 = "events"
             else:
                 name1 = "a script"
                 name2 = "condition scripts"
             cjr.show_error_message(
                 "Cannot transform this transition in " \
                 + name1 + " transition.\nThis state has already " \
                 "transitions for all the available " + name2 + "."
                 )
             event.Veto()
             return
 def __on_changing_type(self, event):
     if self.transition_path != None and not self.skip_change_type_event:
         # Forbid change type if there isn't any condition available
         # for the new transition type
         state_path = fsm.get_state_of_transition( self.transition_path )
         conds_paths = get_free_conditions( event.GetSelection(), state_path )
         if len(conds_paths) == 0:
             if event.GetSelection() == ID_EventTransition:
                 name1 = "an event"
                 name2 = "events"
             else:
                 name1 = "a script"
                 name2 = "condition scripts"
             cjr.show_error_message(
                 "Cannot transform this transition in " \
                 + name1 + " transition.\nThis state has already " \
                 "transitions for all the available " + name2 + "."
                 )
             event.Veto()
             return
Exemple #13
0
 def select_transition(self, transition_path, target_index):
     state_path = fsm.get_state_of_transition(transition_path)
     self.select_state(state_path)
     self.ctrl_transitions.select_transition(transition_path, target_index)
 def select_transition(self, transition_path, target_index):
     state_path = fsm.get_state_of_transition( transition_path )
     self.select_state( state_path )
     self.ctrl_transitions.select_transition( transition_path, target_index )