def refresh_selected_state_machine():
    """Reloads the selected state machine.
    """

    selected_sm_id = rafcon.gui.singleton.state_machine_manager_model.selected_state_machine_id
    selected_sm = state_machine_manager.state_machines[selected_sm_id]
    state_machines_editor_ctrl = rafcon.gui.singleton.main_window_controller.get_controller('state_machines_editor_ctrl')
    states_editor_ctrl = rafcon.gui.singleton.main_window_controller.get_controller('states_editor_ctrl')

    if not is_state_machine_stopped_to_proceed(selected_sm_id, state_machines_editor_ctrl.get_root_window()):
        return

    # check if the a dirty flag is still set
    all_tabs = list(states_editor_ctrl.tabs.values())
    all_tabs.extend(states_editor_ctrl.closed_tabs.values())
    dirty_source_editor = [tab_dict['controller'] for tab_dict in all_tabs if
                           tab_dict['source_code_view_is_dirty'] is True]
    if selected_sm.marked_dirty or dirty_source_editor:

        message_string = "Are you sure you want to reload the currently selected state machine?\n\n" \
                         "The following elements have been modified and not saved. " \
                         "These changes will get lost:"
        message_string = "%s\n* State machine #%s and name '%s'" % (
            message_string, str(selected_sm_id), selected_sm.root_state.name)
        for ctrl in dirty_source_editor:
            if ctrl.model.state.get_state_machine().state_machine_id == selected_sm_id:
                message_string = "%s\n* Source code of state with name '%s' and path '%s'" % (
                    message_string, ctrl.model.state.name, ctrl.model.state.get_path())
        dialog = RAFCONButtonDialog(message_string, ["Reload anyway", "Cancel"],
                                    message_type=Gtk.MessageType.WARNING, parent=states_editor_ctrl.get_root_window())
        response_id = dialog.run()
        dialog.destroy()
        if response_id == 1:  # Reload anyway
            pass
        else:
            logger.debug("Refresh of selected state machine canceled")
            return

    library_manager.clean_loaded_libraries()
    refresh_libraries()
    states_editor_ctrl.close_pages_for_specific_sm_id(selected_sm_id)
    state_machines_editor_ctrl.refresh_state_machine_by_id(selected_sm_id)
def refresh_selected_state_machine ( ) : selected_sm_id = rafcon . gui . singleton . state_machine_manager_model . selected_state_machine_id selected_sm = state_machine_manager . state_machines [ selected_sm_id ] state_machines_editor_ctrl = rafcon . gui . singleton . main_window_controller . get_controller ( 'state_machines_editor_ctrl' ) states_editor_ctrl = rafcon . gui . singleton . main_window_controller . get_controller ( 'states_editor_ctrl' ) if not is_state_machine_stopped_to_proceed ( selected_sm_id , state_machines_editor_ctrl . get_root_window ( ) ) : return all_tabs = list ( states_editor_ctrl . tabs . values ( ) ) all_tabs . extend ( states_editor_ctrl . closed_tabs . values ( ) ) dirty_source_editor = [ tab_dict [ 'controller' ] for tab_dict in all_tabs if tab_dict [ 'source_code_view_is_dirty' ] is True ] if selected_sm . marked_dirty or dirty_source_editor : message_string = "Are you sure you want to reload the currently selected state machine?\n\n" "The following elements have been modified and not saved. " "These changes will get lost:" message_string = "%s\n* State machine #%s and name '%s'" % ( message_string , str ( selected_sm_id ) , selected_sm . root_state . name ) for ctrl in dirty_source_editor : if ctrl . model . state . get_state_machine ( ) . state_machine_id == selected_sm_id : message_string = "%s\n* Source code of state with name '%s' and path '%s'" % ( message_string , ctrl . model . state . name , ctrl . model . state . get_path ( ) ) dialog = RAFCONButtonDialog ( message_string , [ "Reload anyway" , "Cancel" ] , message_type = Gtk . MessageType . WARNING , parent = states_editor_ctrl . get_root_window ( ) ) response_id = dialog . run ( ) dialog . destroy ( ) if response_id == 1 : pass else : logger . debug ( "Refresh of selected state machine canceled" ) return library_manager . clean_loaded_libraries ( ) refresh_libraries ( ) states_editor_ctrl . close_pages_for_specific_sm_id ( selected_sm_id ) state_machines_editor_ctrl . refresh_state_machine_by_id ( selected_sm_id )
Reloads the selected state machine.