Adding support for saving editor choosen when editing project file for reloading project layout
authorlaurent
Wed, 18 Jul 2012 00:44:29 +0200
changeset 789 b1b1a8f85e2f
parent 788 3cec473bef94
child 790 52d3a084d2b2
Adding support for saving editor choosen when editing project file for reloading project layout
ProjectController.py
util/FileManagementPanel.py
--- a/ProjectController.py	Tue Jul 17 21:25:28 2012 +0200
+++ b/ProjectController.py	Wed Jul 18 00:44:29 2012 +0200
@@ -995,35 +995,40 @@
             
             return self._ProjectFilesView
         
-        elif name is not None and os.path.isfile(name):
-            if not self._FileEditors.has_key(name):
-                file_extension = os.path.splitext(name)[1]
+        elif name is not None and name.find("::") != -1:
+            filepath, editor_name = name.split("::")
+            if not self._FileEditors.has_key(filepath):
+                if os.path.isfile(filepath):
+                    file_extension = os.path.splitext(filepath)[1]
+                        
+                    editors = dict([(editor_name, editor)
+                                    for extension, editor_name, editor in features.file_editors
+                                    if extension == file_extension])
+                    
+                    if editor_name == "":
+                        if len(editors) == 1:
+                            editor_name = editors.keys()[0]
+                        elif len(editors) > 0:
+                            names = editors.keys()
+                            dialog = wx.SingleChoiceDialog(self.AppFrame, 
+                                  _("Select an editor:"), _("Editor selection"), 
+                                  names, wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
+                            if dialog.ShowModal() == wx.ID_OK:
+                                editor_name = names[dialog.GetSelection()]
+                            dialog.Destroy()
+                        
+                    if editor_name != "":
+                        name = "::".join([filepath, editor_name])
+                        
+                        editor = editors[editor_name]()
+                        self._FileEditors[filepath] = editor(self.AppFrame.TabsOpened, self, name, self.AppFrame)
+                        self._FileEditors[filepath].SetIcon(GetBitmap("FILE"))
+            
+            if self._FileEditors.has_key(filepath):
+                editor = self._FileEditors[filepath]
+                self.AppFrame.EditProjectElement(editor, editor.GetTagName())
                 
-                editors = dict([(editor_name, editor)
-                                for extension, editor_name, editor in features.file_editors
-                                if extension == file_extension])
-                
-                editor_name = None
-                if len(editors) == 1:
-                    editor_name = editors.keys()[0]
-                elif len(editors) > 0:
-                    names = editors.keys()
-                    dialog = wx.SingleChoiceDialog(self.ParentWindow, 
-                          _("Select an editor:"), _("Editor selection"), 
-                          names, wx.OK|wx.CANCEL)
-                    if dialog.ShowModal() == wx.ID_OK:
-                        editor_name = names[dialog.GetSelection()]
-                    dialog.Destroy()
-                
-                if editor_name is not None:
-                    editor = editors[editor_name]()
-                    self._FileEditors[name] = editor(self.AppFrame.TabsOpened, self, name, self.AppFrame)
-                    self._FileEditors[name].SetIcon(GetBitmap("FILE"))
-                    
-            if self._FileEditors.has_key(name):
-                self.AppFrame.EditProjectElement(self._FileEditors[name], name)
-            
-            return self._FileEditors[name]
+            return self._FileEditors.get(filepath)
         else:
             return ConfigTreeNode._OpenView(self, self.CTNName(), onlyopened)
 
@@ -1361,6 +1366,7 @@
                 self.ChangesToSave = True
                 if self._View is not None:
                     self._View.RefreshView()
+                if self.AppFrame is not None:
                     self.AppFrame.RefreshTitle()
                     self.AppFrame.RefreshFileMenu()
                     self.AppFrame.RefreshEditMenu()
--- a/util/FileManagementPanel.py	Tue Jul 17 21:25:28 2012 +0200
+++ b/util/FileManagementPanel.py	Wed Jul 18 00:44:29 2012 +0200
@@ -369,7 +369,7 @@
         filepath = self.ManagedDir.GetPath()
         if (os.path.isfile(filepath) and 
             os.path.splitext(filepath)[1] in self.EditableFileExtensions):
-            self.Controler._OpenView(filepath)
+            self.Controler._OpenView(filepath + "::")
         event.Skip()
         
     def CopyFile(self, src, dst):