# Update alert handler # notifies user if a rollforward or merge should be performed # requires timed_event class #********************************************************************** # Exemplar for update alert handler #********************************************************************** remex(:update_alert) $ def_slotted_exemplar(:update_alert, { {:grs, _unset}, {:interval, _unset}, {:update_status, _unset}, {:timer, _unset} }) $ # grs = graphic_system for message handling # interval = interval in seconds to check for updated alternatives # update_status = hash table recording changes to gis_ds_views # timer = timed_event object to handle the event #********************************************************************** # Methods for update alert handler #********************************************************************** _method update_alert.new(a_grs, _optional an_interval) ## Create a new update alert handler for graphics_system A_GRS that ## will check for updated alternative(s) every AN_INTERVAL seconds, ## default 60. .grs << a_grs .interval << an_interval.default(60) .update_status << hash_table.new() >> _self _endmethod _method update_alert.go() ## Begin the update alert _if .timer _is _unset _then the_proc << _proc(alert) alert.check_for_update() _endproc .timer << timed_event.new(.interval,the_proc,_self) _endif _if .timer.return_status() _is :running _then _return _endif .timer.go() _endmethod _method update_alert.stop() ## Stop the update alert _if .timer _is _unset _then _return _endif _if .timer.return_status() _is :stopped _then _return _endif .timer.stop() _endmethod _method update_alert.check_for_update() ## This is the method executed every interval. the_msg << internal_text_output_stream.new() the_msg.write("Updates Detected:") take_action? << _false _for v _over gis_program_manager.cached_datasets() _loop k << v.name _if v.class_name _isnt :gis_ds_view _then _continue _endif _if .update_status[k] _is _unset _then .update_status[k] << _false _endif _if v.writable? _then # if alternative is writable, check for parent update _if v.base_has_changed?() _then _if .update_status[k] _then _continue _endif .update_status[k] << _true s << character.newline + v.external_name + ": parent updated, please merge" the_msg.write(s) take_action? << _true _else .update_status[k] << _false _endif _else # if alternative is read-only, check if updated _if v.is_out_of_date?() _then _if .update_status[k] _then _continue _endif .update_status[k] << _true s << character.newline + v.external_name + ": updated, please rollforward" the_msg.write(s) take_action? << _true _else .update_status[k] << _false _endif _endif _endloop _if take_action? _then .grs.show_message(the_msg.string) _endif _endmethod