@@ -258,9 +258,9 @@ def setWidgetUndoRedoStack(self, stack):
258258 def new (self , pmr = False ):
259259 self .close ()
260260
261- workflowDir = self ._get_workflow_dir ()
262- if workflowDir :
263- self ._create_new_workflow (workflowDir , pmr )
261+ workflow_dir = self ._get_workflow_dir ()
262+ if workflow_dir :
263+ self ._create_new_workflow (workflow_dir , pmr )
264264
265265 def _workflow_finished (self , successfully ):
266266 if successfully :
@@ -323,7 +323,6 @@ def rm_tree_unsuccessful(_one, _two, _three):
323323 def _create_new_workflow (self , workflow_dir , pmr ):
324324 m = self ._workflowManager
325325 m .new (workflow_dir )
326- m .setPreviousLocation (workflow_dir )
327326
328327 if pmr :
329328 pmr_info = PMR ()
@@ -342,8 +341,7 @@ def _create_new_workflow(self, workflow_dir, pmr):
342341 raise ClientRuntimeError ('Error Creating New' , "Client doesn't have access to PMR" )
343342
344343 self ._undoStack .clear ()
345- self ._ui .graphicsView .setLocation (workflow_dir )
346- self ._graphicsScene .update_model ()
344+ self ._update_location ()
347345 self ._update_ui ()
348346
349347 def newpmr (self ):
@@ -496,18 +494,14 @@ def _load(self, workflow_dir):
496494 try :
497495 m = self ._workflowManager
498496 m .load (workflow_dir , self ._graphicsScene .sceneRect ())
499- m .setPreviousLocation (workflow_dir )
500- self ._graphicsScene .update_model ()
501- self ._ui .graphicsView .setLocation (workflow_dir )
497+ self ._update_location ()
502498 self ._update_ui ()
503499 self .model ().add_recent_workflow (workflow_dir )
504500 self ._update_recent_menu ()
505501 except :
506502 self .close ()
507503 raise
508504
509- self ._options_manager .setOption (PREVIOUS_WORKFLOW , workflow_dir )
510-
511505 def reload (self ):
512506 m = self ._workflowManager
513507 self ._load (m .location ())
@@ -526,10 +520,9 @@ def pixmap(self):
526520 def save (self ):
527521 m = self ._workflowManager
528522 location_set = os .path .exists (m .location ())
529- if location_set :
530- self ._updateLocation ()
531- else :
532- location_set = self ._set_location ()
523+ if not location_set :
524+ location_set = self ._update_location ()
525+
533526 if location_set :
534527 m .scene ().setViewParameters (self ._ui .graphicsView .getViewParameters ())
535528 m .save (self .pixmap ())
@@ -540,35 +533,32 @@ def save(self):
540533
541534 self ._update_ui ()
542535
543- def saveAs (self ):
544- wm = self ._workflowManager
545- workflow_dir = wm .location ()
546- location_set = self ._set_location ()
547- if location_set :
548- self .save ()
549- src_git_dir = os .path .join (workflow_dir , '.git' )
550- if os .path .isdir (src_git_dir ):
551- shutil .copytree (src_git_dir , os .path .join (wm .location (), '.git' ), dirs_exist_ok = True )
536+ def save_as (self ):
537+ new_workflow_dir = self ._get_workflow_dir ()
538+ if not new_workflow_dir :
539+ return
552540
553- def _updateLocation (self ):
554541 m = self ._workflowManager
555542 workflow_dir = m .location ()
556- if m .set_location (workflow_dir ):
557- self ._ui .graphicsView .setLocation (workflow_dir )
558- self ._graphicsScene .update_model ()
543+ self ._update_location (workflow_dir = new_workflow_dir )
544+ self .save ()
545+ src_git_dir = os .path .join (workflow_dir , '.git' )
546+ if os .path .isdir (src_git_dir ):
547+ shutil .copytree (src_git_dir , os .path .join (m .location (), '.git' ), dirs_exist_ok = True )
559548
560- def _set_location (self ):
561- location_set = False
549+ self ._update_location (workflow_dir = workflow_dir )
550+ self ._update_ui ()
551+
552+ def _update_location (self , workflow_dir = None ):
562553 m = self ._workflowManager
563- workflow_dir = self ._get_workflow_dir ()
564- if workflow_dir :
565- m .setPreviousLocation (workflow_dir )
566- m .set_location (workflow_dir )
567- self ._ui .graphicsView .setLocation (workflow_dir )
568- self ._graphicsScene .update_model ()
569- location_set = True
554+ workflow_dir = m .location () if workflow_dir is None else workflow_dir
555+ update_made = m .set_location (workflow_dir )
556+ m .setPreviousLocation (workflow_dir )
557+ self ._options_manager .setOption (PREVIOUS_WORKFLOW , workflow_dir )
558+ self ._ui .graphicsView .setLocation (workflow_dir )
559+ self ._graphicsScene .update_model ()
570560
571- return location_set
561+ return update_made
572562
573563 def commitChanges (self , workflowDir ):
574564 pmr_info = PMR ()
@@ -698,7 +688,7 @@ def _create_menu_items(self):
698688 self .action_Save = QtGui .QAction ('&Save' , menu_file )
699689 self ._set_action_properties (self .action_Save , 'action_Save' , self .save , 'Ctrl+S' , 'Save Workflow' )
700690 self .action_SaveAs = QtGui .QAction ('Save As' , menu_file )
701- self ._set_action_properties (self .action_SaveAs , 'action_SaveAs' , self .saveAs , '' , 'Save Workflow as ...' )
691+ self ._set_action_properties (self .action_SaveAs , 'action_SaveAs' , self .save_as , '' , 'Save Workflow as ...' )
702692 self .action_Execute = QtGui .QAction ('E&xecute' , menu_workflow )
703693 self ._set_action_properties (self .action_Execute , 'action_Execute' , self .executeWorkflow , 'Ctrl+X' ,
704694 'Execute Workflow' )
0 commit comments