######################################################################## #### #### Title: loader.magik #### Author: Mark Cederholm #### Last Revised: 09-Jul-2001 #### #### Notes: #### #### Utility to save and load user visibility and view settings or the #### current trail to a file. See individual methods for more info. #### ######################################################################## #********************************************************************** # Exemplars for loader utility #********************************************************************** remex(:loader_utility) $ def_slotted_exemplar(:loader_utility, { {:grs, _unset}, {:stat_item, _unset}, {:fs, _unset} }, :model) $ #********************************************************************** # Method to launch loader utility #********************************************************************** _method graphics_system.launch_loader_utility() menu_key << :loader_utility _if (menu << .sub_menus[menu_key]) _is _unset _then menu << .sub_menus[menu_key] << loader_utility.new(_self) _endif menu.activate() >> menu _endmethod $ #********************************************************************** # Methods for loader utility #********************************************************************** _method loader_utility.new(a_grs) >> _clone.init(a_grs) _endmethod _private _method loader_utility.init(a_grs) # init grs .grs << a_grs >> _super.init() _endmethod _method loader_utility.activate_in(a_frame) _self.title << "Load and Save Utility" p << panel.new(a_frame) p.min_width << 200 .stat_item << label_item.new(p,"Idle.") p.start_row() button_item.new(p,"Save Visibility/View Settings to File",_self,:prompt_for_ace_save|()|). resize? << _true p.start_row() button_item.new(p,"Load Visibility/View Settings from File",_self,:prompt_for_ace_load|()|). resize? << _true p.start_row() button_item.new(p,"Save Trail to File",_self,:prompt_for_trail_save|()|). resize? << _true p.start_row() button_item.new(p,"Load Trail from File",_self,:prompt_for_trail_load|()|). resize? << _true p.start_row() button_item.new(p,"Quit",_self,:quit|()|).resize? << _true _endmethod _method loader_utility.prompt_for_ace_save() _self.launch_fs(:save, :do_ace_save|()|, "Visibility/View Save File") _endmethod _method loader_utility.prompt_for_ace_load() _self.launch_fs(:load, :do_ace_load|()|, "Visibility/View Load File") _endmethod _method loader_utility.prompt_for_trail_save() _self.launch_fs(:save, :do_trail_save|()|, "Trail Save File") _endmethod _method loader_utility.prompt_for_trail_load() _self.launch_fs(:load, :do_trail_load|()|, "Trail Load File") _endmethod _method loader_utility.launch_fs(option, ok_method, title) _if option _is :save _then check_option << :do_creation_check? _else check_option << :do_existence_check? _endif .fs << file_selection.open(_self,title, ok_method, _unset, :directory, system.temp_directory_name, check_option, _true) _endmethod _method loader_utility.do_ace_save(a_file_name) .fs.quit() .stat_item.label << "Running..." .grs.ace.unload_to_file(a_file_name,{:usr_visibility,:views}) .stat_item.label << "Done." _endmethod _method loader_utility.do_ace_load(a_file_name) .fs.quit() .stat_item.label << "Running..." # bypass .grs.ace.load_from_file # because it doesn't work on existing ACE in << ace_input_stream.new(a_file_name) _if in.get_next() _isnt :ace _orif (( version << in.get_next()) _isnt 203 _andif version _isnt 210 _andif version _isnt 220) _then _self.show_alert("Invalid file.") _return _endif (n,t) << in.get_next() _if t _isnt :string _orif n.size _is 0 _then _self.show_alert("Invalid file.") _return _endif ace_view << gis_program_manager.ace_view ace_table << ace_view.collections[:sw_gis!ace] _if (the_ace << ace_table.at(n)) _is _unset _then _self.show_alert("ACE " + n + " not found.") _return _endif the_ace.int!load_from(in, {:dataset_usr_visibility,:views}, version) in.close() .stat_item.label << "Done." m << _self.show_question("Yes", "No", "Perform hard reset (in order to see changes)?") _if m _then .grs.hard_reset() _endif _endmethod _method loader_utility.do_trail_save(a_file_name) .fs.quit() tr << .grs.gtrail _if tr.empty? _then _self.show_alert("No trail!") _return _endif .stat_item.label << "Running..." tr.dump(a_file_name) .stat_item.label << "Done." _endmethod _method loader_utility.do_trail_load(a_file_name) .fs.quit() .stat_item.label << "Running..." .grs.load_trail_from_file(a_file_name) .stat_item.label << "Done." _endmethod