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_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 get_transition_gui_name(transition_path):
    """Return the transition's name shown in the GUI"""
    condition = pynebula.lookup(transition_path).getcondition()
    if condition.isa('neventcondition'):
        type = 'Event'
    else:
        type = 'Script'
    if condition.getfullname() == fsm.get_filteredcondition_of_transition( transition_path ):
        # Find homologous shared event
        shared_cond = fsmtransitiontype.get_event_condition( condition.getevent() )
        value = fsmtransitiontype.get_condition_gui_name( shared_cond ) + "+"
    else:
        value = fsmtransitiontype.get_condition_gui_name( condition.getfullname() )
    return type + " " + value
    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 )