@@ -86,6 +86,34 @@ def __init__(self):
8686 # When an ExperimentDialog is closed, update the experiment info
8787 self .experiment_closed .connect (self .load_and_refresh_experiment_info )
8888
89+ def on_edit_workspace_clicked (self ):
90+ logger .debug ('[MLC_MANAGER] [EDIT_WORKSPACE] - On_edit_workspace_location triggered' )
91+ new_workspace_dir = QFileDialog .getExistingDirectory (self , 'Choose the new workspace directory' ,
92+ '.' , QFileDialog .ShowDirsOnly )
93+
94+ if not new_workspace_dir :
95+ # User clicked 'Cancel' or simply closed the Dialog
96+ return
97+
98+ # Edit the GUI Config to the new workspace location
99+ self ._gui_config .set ('MAIN' , 'workspace' , new_workspace_dir )
100+ config_filepath = os .path .join (os .path .abspath ("." ), MLC_GUI .GUI_CONFIG_FILE )
101+ with open (config_filepath , "w" ) as f :
102+ self ._gui_config .write (f )
103+
104+ # Reload the MLC repository
105+ self ._mlc_local = MLCLocal (new_workspace_dir )
106+ self ._experiments_manager = ExperimentsManager (self ._mlc_local , self ._gui_config )
107+ logger .info ('[MLC_GUI] [EDIT_WORKSPACE] - Workspace location has been succesfully changed. '
108+ 'New Workspace directory: {0}' .format (self ._gui_config .get ('MAIN' , 'workspace' )))
109+
110+ QMessageBox .information (self , 'Edit Workspace' ,
111+ 'Workspace location has been succesfully changed. '
112+ 'New workspace location: {0}' .format (new_workspace_dir ))
113+
114+ self .load_and_refresh_experiments_info ()
115+ self ._clean_experiment_selection ()
116+
89117 def on_new_button_clicked (self ):
90118 logger .debug ('[MLC_MANAGER] [NEW_EXPERIMENT] - New experiment button clicked' )
91119 experiment_name = ""
@@ -304,7 +332,7 @@ def on_rename_button_clicked(self):
304332
305333 while True :
306334 renamed_experiment , dialog_ok = QInputDialog .getText (self , 'Rename Experiment' ,
307- 'Enter the new name of the experiment:' )
335+ 'Enter the new name of the experiment:' )
308336
309337 if dialog_ok :
310338 if renamed_experiment == "" :
@@ -382,40 +410,46 @@ def on_experiment_list_context_menu(self, point):
382410
383411 menu .popup (self ._autogenerated_object .experiment_list .mapToGlobal (point ))
384412
413+ def on_experiment_list_clicked (self , model_index ):
414+ list_view = self ._autogenerated_object .experiment_list
415+ experiment_name = list_view .model ().itemFromIndex (model_index ).text ()
416+ self ._refresh_experiment_description (experiment_name )
417+
385418 def load_gui_config (self ):
386419 abspath = os .path .abspath ("." )
387420 config_filepath = os .path .join (abspath , MLC_GUI .GUI_CONFIG_FILE )
421+ workspace_dir = ""
388422
389423 if not os .path .isfile (config_filepath ):
390424 reply = QMessageBox .question (self , 'Message' ,
391425 "Workspace has not been set yet. Do you want to set it?" ,
392426 QMessageBox .Yes | QMessageBox .No ,
393427 QMessageBox .Yes )
394428
395- if reply == QMessageBox .Yes :
396- workspace_dir = QFileDialog .getExistingDirectory (self , 'Set workspace Directory' ,
397- '.' , QFileDialog .ShowDirsOnly )
398- if workspace_dir == "" :
399- QMessageBox .critical (self , 'MLC Manager' ,
400- 'Workspace has not been set. Aborting program' ,
401- QMessageBox .Ok )
402- logger .debug ('[MLC_GUI] [LOAD_GUI] - Workspace was not set. Aborting program' )
403- self .close ()
404- sys .exit (0 )
405- else :
406- self ._create_gui_config_from_scratch (config_filepath , workspace_dir )
407- QMessageBox .information (self , 'MLC Manager' ,
408- 'Workspace was succesfully set' ,
409- QMessageBox .Ok )
410- logger .debug ('[MLC_GUI] [LOAD_GUI] - Workspace was succesfully set: {0}' .format (workspace_dir ))
411- else :
429+ if reply == QMessageBox .No :
430+ QMessageBox .critical (self , 'MLC Manager' ,
431+ 'Workspace has not been set. Aborting program' ,
432+ QMessageBox .Ok )
433+ logger .debug ('[MLC_GUI] [LOAD_GUI] - Workspace was not set. Aborting program' )
434+ self .close ()
435+ sys .exit (0 )
436+
437+ workspace_dir = QFileDialog .getExistingDirectory (self , 'Set workspace Directory' ,
438+ '.' , QFileDialog .ShowDirsOnly )
439+ if workspace_dir == "" :
412440 QMessageBox .critical (self , 'MLC Manager' ,
413441 'Workspace has not been set. Aborting program' ,
414442 QMessageBox .Ok )
415443 logger .debug ('[MLC_GUI] [LOAD_GUI] - Workspace was not set. Aborting program' )
416444 self .close ()
417445 sys .exit (0 )
418446
447+ self ._create_gui_config_from_scratch (config_filepath , workspace_dir )
448+ QMessageBox .information (self , 'MLC Manager' ,
449+ 'Workspace was succesfully set' ,
450+ QMessageBox .Ok )
451+ logger .debug ('[MLC_GUI] [LOAD_GUI] - Workspace was succesfully set: {0}' .format (workspace_dir ))
452+
419453 # Load GUI config
420454 self ._gui_config = ConfigParser .ConfigParser ()
421455 self ._gui_config .read (config_filepath )
@@ -450,11 +484,6 @@ def menu_about(self):
450484 dialog = MLCAboutDialog (self )
451485 dialog .exec_ ()
452486
453- def on_experiment_list_clicked (self , model_index ):
454- list_view = self ._autogenerated_object .experiment_list
455- experiment_name = list_view .model ().itemFromIndex (model_index ).text ()
456- self ._refresh_experiment_description (experiment_name )
457-
458487 def _create_gui_config_from_scratch (self , config_filepath , workspace_dir ):
459488 self ._gui_config = ConfigParser .ConfigParser ()
460489 self ._gui_config .add_section ('MAIN' )
0 commit comments