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 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 after_notification_of_parent_or_state_from_lists(self, model, prop_name, info): # avoid updates because of execution status updates or while multi-actions if self.check_no_update_flags_and_return_combined_flag(prop_name, info): return overview = NotificationOverview(info) # avoid updates because of unimportant methods if overview.get_cause() not in ['name', 'append', '__setitem__', # '__delitem__', 'remove', 'group_states', 'ungroup_state', 'change_data_type', 'from_key', 'to_key', 'from_state', 'to_state', 'modify_origin', 'modify_target']: if self.model.parent: # check for a sibling port change if prop_name == 'states' and overview.get_affected_core_element() is self.model.parent.state and \ (overview.get_affected_core_element() in self.model.parent.state.states and overview.get_cause() in ['add_input_data_port', 'add_output_data_port'] or overview.get_affected_property() in ['data_port', 'scoped_variable'] and overview.get_cause() in ['name', 'change_data_type']): pass else: return else: return try: self.update(initiator=str(overview)) except Exception as e: if self.debug_log: import traceback self.store_debug_log_file(str(overview)) self.store_debug_log_file(str(traceback.format_exc())) logger.error("update of data_flow widget fails while detecting change in state %s %s" % (self.model.state.name, self.model.state.state_id))
def states_update_before(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 ["change_state_type"]: changed_model = self._selected_sm_model.get_state_model_by_path( overview.get_method_args()[1].get_path()) self.observe_model(changed_model)
def check_info_on_no_update_flags(self, info): """Stop updates while multi-actions""" # TODO that could need a second clean up # avoid updates because of state destruction if 'before' in info and info['method_name'] == "remove_state": if info.instance is self.model.state: self.no_update_state_destruction = True else: # if the state it self is removed lock the widget to never run updates and relieve all models removed_state_id = info.args[1] if len( info.args) > 1 else info.kwargs['state_id'] if removed_state_id == self.model.state.state_id or \ not self.model.state.is_root_state and removed_state_id == self.model.parent.state.state_id: self.no_update_self_or_parent_state_destruction = True self.relieve_all_models() elif 'after' in info and info['method_name'] == "remove_state": if info.instance.state_id == self.model.state.state_id: self.no_update_state_destruction = False # reduce NotificationOverview generations by the fact that after could cause False and before could cause True if not self.no_update_state_destruction and not self.no_update_self_or_parent_state_destruction and \ (not self.no_update and 'before' in info or 'after' in info and self.no_update): return overview = NotificationOverview(info) # The method causing the change raised an exception, thus nothing was changed and updates are allowed if 'after' in info and isinstance(overview.get_result(), Exception): self.no_update = False self.no_update_state_destruction = False # self.no_update_self_or_parent_state_destruction = False return if overview.get_cause() in [ 'group_states', 'ungroup_state', "change_state_type", "change_root_state_type" ]: instance_is_self = self.model.state is overview.get_affected_core_element( ) instance_is_parent = self.model.parent and self.model.parent.state is overview.get_affected_core_element( ) instance_is_parent_parent = self.model.parent and self.model.parent.parent and self.model.parent.parent.state is overview.get_affected_core_element( ) # print("no update flag: ", True if 'before' in info and (instance_is_self or instance_is_parent or instance_is_parent_parent) else False) if instance_is_self or instance_is_parent or instance_is_parent_parent: self.no_update = True if 'before' in info else False if overview.get_affected_property() == 'state' and overview.get_cause() in ["change_state_type"] and \ self.model.get_state_machine_m() is not None: changed_model = self.model.get_state_machine_m( ).get_state_model_by_path( overview.get_method_args()[1].get_path()) if changed_model not in self._model_observed: self.observe_model(changed_model)
def after_notification_of_parent_or_state_from_lists( self, model, prop_name, info): """ Activates the update after update if outcomes, transitions or states list has been changed. """ # avoid updates because of execution status updates or while multi-actions if self.check_no_update_flags_and_return_combined_flag( prop_name, info): return overview = NotificationOverview(info) if overview.get_cause() not in [ 'name', 'append', '__setitem__', # '__delitem__', 'remove' 'from_outcome', 'to_outcome', 'from_state', 'to_state', 'modify_origin', 'modify_target' ]: if self.model.parent: # check for sibling port change if prop_name == 'states' and overview.get_affected_core_element() is self.model.parent.state and \ (overview.get_affected_core_element() in self.model.parent.state.states and overview.get_cause() in ['add_outcome'] or overview.get_affected_property() in ['outcome'] and overview.get_cause() in ['name']): pass else: return else: return try: self.update(initiator=str(overview)) except KeyError as e: if self.debug_log: import traceback self.store_debug_log_file(str(overview)) self.store_debug_log_file(str(traceback.format_exc())) logger.error( "update of transition widget fails while detecting list change of state %s %s %s\n%s" % (self.model.state.name, self.model.state.state_id, e, self))