def states_update(self, model, prop_name, info): overview = NotificationOverview(info) if not overview.caused_modification(): return if overview.get_affected_property() == 'state' and \ overview.get_cause() in ["name"]: # , "add_state", "remove_state"]: self.update_tree_store_row(overview.get_affected_model()) # TODO check the work around for get_library_root_state -> maybe the notifications can be avoided if upper lib elif overview.get_affected_property() == 'state' and not overview.get_affected_model().state.get_next_upper_library_root_state() and \ overview.get_cause() in ["add_state", "remove_state"]: self.update(overview.get_affected_model())
def meta_changed_notify_after(self, changed_model, prop_name, info): if not self.with_meta_data_actions: return overview = NotificationOverview(info) if self.busy: return if overview.get_signal_message().origin == 'load_meta_data': return if self.active_action is None or overview.get_signal_message( ).change in ['append_initial_change']: # update last actions after_state_image -> meta-data self.re_initiate_meta_data() elif self.active_action is None or \ overview.get_signal_message().change in ['append_to_last_change'] or \ overview.get_signal_message().origin in ['group_states', 'ungroup_state', 'substitute_state']: # update last actions after_state_image -> meta-data self.active_action.after_state_image = self.active_action.get_state_image( ) self.update_internal_tmp_storage() else: if isinstance(overview.get_affected_model(), AbstractStateModel): changed_parent_model = overview.get_affected_model() else: changed_parent_model = overview.get_affected_model().parent changed_parent_state_path = changed_parent_model.state.get_path() # TODO think about to remove this work around again # ignore meta data changes inside of library states changed_parent_state = self.state_machine_model.get_state_model_by_path( changed_parent_state_path).state if changed_parent_state.get_next_upper_library_root_state(): return if self.count_before == 0: self.active_action = MetaDataAction( changed_parent_model.state.get_path(), state_machine_model=self.state_machine_model, overview=overview) meta_data = self.get_state_element_meta_from_internal_tmp_storage( changed_parent_state_path) state_image = StateImage(meta_data=meta_data) self.active_action.before_state_image = state_image self.finish_new_action(overview) else: logger.info( 'Meta data change signal was emitted while other action was is performed. \n{0}' .format(overview))
def states_update(self, model, prop_name, info): if is_execution_status_update_notification_from_state_machine_model(prop_name, info) or \ self._ongoing_complex_actions: return overview = NotificationOverview(info) if overview.get_affected_property() == 'state' and \ overview.get_cause() in ["name"]: # , "add_state", "remove_state"]: self.update_tree_store_row(overview.get_affected_model()) # TODO check the work around for get_library_root_state -> maybe the notifications can be avoided if upper lib elif overview.get_affected_property() == 'state' and not overview.get_affected_model().state.get_next_upper_library_root_state() and \ overview.get_cause() in ["add_state", "remove_state"]: self.update(overview.get_affected_model())
def notify_state_name_change(self, model, prop_name, info): """Checks whether the name of a state was changed and change the tab label accordingly """ overview = NotificationOverview(info) # avoid updates or checks because of execution status updates if not overview.caused_modification(): return changed_model = overview.get_affected_model() method_name = overview.get_cause() if isinstance(changed_model, AbstractStateModel) and method_name in ['name', 'script_text']: self.update_tab_label(changed_model)
def on_state_execution_status_changed_after(self, model, prop_name, info): """ Show current execution status in the widget This function specifies what happens if the state machine execution status of a state changes :param model: the model of the state that has changed (most likely its execution status) :param prop_name: property name that has been changed :param info: notification info dictionary :return: """ from rafcon.gui.utils.notification_overview import NotificationOverview from rafcon.core.states.state import State def name_and_next_state(state): assert isinstance(state, State) if state.is_root_state_of_library: return state.parent.parent, state.parent.name else: return state.parent, state.name def create_path(state, n=3, separator='/'): next_parent, name = name_and_next_state(state) path = separator + name n -= 1 while n > 0 and isinstance(next_parent, State): next_parent, name = name_and_next_state(next_parent) path = separator + name + path n -= 1 if isinstance(next_parent, State): path = separator + '..' + path return path if 'kwargs' in info and 'method_name' in info['kwargs']: overview = NotificationOverview(info) if overview.get_cause() == 'state_execution_status': active_state = overview.get_affected_model().state assert isinstance(active_state, State) path_depth = rafcon.gui.singleton.global_gui_config.get_config_value( "EXECUTION_TICKER_PATH_DEPTH", 3) message = self._fix_text_of_label + create_path( active_state, path_depth) if rafcon.gui.singleton.main_window_controller.view is not None: self.ticker_text_label.set_text(message) else: logger.warning("Not initialized yet")
def execution_change(self, model, prop_name, info): from rafcon.gui.utils.notification_overview import NotificationOverview overview = NotificationOverview(info) if overview.get_cause() == 'state_execution_status': self.last_execution_change_at_state = overview.get_affected_model( ).state.get_path()