;+ ; ; Name: THM_UI_OPEN ; ; Purpose: Opens a themis document ; ; Inputs: The info structure from the main gui ; ; ;$LastChangedBy: nikos $ ;$LastChangedDate: 2013-04-19 21:42:24 -0700 (Fri, 19 Apr 2013) $ ;$LastChangedRevision: 12117 $ ;$URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/thmsoc/tags/tdas_8_00/idl/themis/thm_ui_new/utilities/thm_ui_main_funcs/thm_ui_open.pro $ ;- pro thm_ui_open,info compile_opt idl2 if info.marking ne 0 || info.rubberbanding ne 0 then begin return endif info.ctrl = 0 ;query if users want to delete data. del_text=dialog_message('Loading a document will remove all existing plots and pages,' +thm_ui_newline() +'but you can retain the data.'+thm_ui_newline() +thm_ui_newline()$ +'Do you want to delete the previous data sets?' +thm_ui_newline()+thm_ui_newline()+'(''Yes'' is strongly recommended.)' $ ,/question, /cancel, /center, title='Remove previous data?') if strlowcase(del_text) eq 'yes' then begin nodelete = 0 msg = 'Previous data will be deleted.' thm_ui_message, msg, sb=info.statusBar, hw=info.historywin endif else if strlowcase(del_text) eq 'no' then begin nodelete = 1 msg = 'Previous data will NOT be deleted.' thm_ui_message, msg, sb=info.statusBar, hw=info.historywin endif else begin msg = 'User canceled the loading of a THEMIS document.' thm_ui_message, msg, sb=info.statusBar, hw=info.historywin return endelse ; we want 'Open THEMIS Document' to remember current directory if is_string(info.MainFileName) then currentpath = file_dirname(info.MainFileName) fileName = Dialog_Pickfile(Title='Open THEMIS Document', $ Filter='*.tgd', Dialog_Parent=info.master,/must_exist,path=currentpath) IF(Is_String(fileName)) THEN BEGIN open_themis_document,info=info,filename=fileName,$ statusmsg=statusmsg,statuscode=statuscode,nodelete=nodelete IF (statuscode LT 0) THEN BEGIN dummy=error_message(statusmsg,/ERROR,/CENTER,traceback=0) ENDIF ELSE BEGIN ; If successful, sensitize data controls FOR i=0, N_Elements(info.dataButtons)-1 DO Widget_Control, info.dataButtons[i], sensitive=1 ; Put filename in title bar activeWindow=info.windowStorage->GetActive() activeWindow->GetProperty, Name=name ;result=info.windowMenus->SetFilename(name, filename) info.mainFileName=filename info.gui_title = filename ENDELSE info.statusBar->Update, statusmsg info.historywin->Update,statusmsg ENDIF ELSE BEGIN info.statusBar->Update, 'Invalid Filename' ENDELSE end