--- a/Beremiz.py Fri Jul 06 21:00:43 2012 +0200
+++ b/Beremiz.py Wed Jul 18 01:33:48 2012 +0200
@@ -168,6 +168,7 @@
from docutil import OpenHtmlFrame
from PLCOpenEditor import IDEFrame, AppendMenu, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES
from PLCOpenEditor import EditorPanel, Viewer, TextViewer, GraphicViewer, ResourceEditor, ConfigurationEditor, DataTypeEditor
+from PLCOpenEditor import EncodeFileSystemPath, DecodeFileSystemPath from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY, ITEM_PROJECT, ITEM_RESOURCE
@@ -435,9 +436,15 @@
# Add beremiz's icon in top left corner of the frame
self.SetIcon(wx.Icon(Bpath("images", "brz.ico"), wx.BITMAP_TYPE_ICO))
+ if projectOpen is not None: + projectOpen = DecodeFileSystemPath(projectOpen, False) if ctr is None and projectOpen is None and self.Config.HasEntry("currenteditedproject"):
- projectOpen = str(self.Config.Read("currenteditedproject"))
+ projectOpen = DecodeFileSystemPath(self.Config.Read("currenteditedproject")) if projectOpen is not None and os.path.isdir(projectOpen):
@@ -591,7 +598,7 @@
project_path = os.path.realpath(self.CTR.GetProjectPath())
- self.Config.Write("currenteditedproject", project_path)
+ self.Config.Write("currenteditedproject", EncodeFileSystemPath(project_path)) @@ -645,7 +652,8 @@
self.FileMenu.Enable(wx.ID_CLOSE_ALL, False)
def RefreshRecentProjectsMenu(self):
- recent_projects = cPickle.loads(str(self.Config.Read("RecentProjects", cPickle.dumps([]))))
+ recent_projects = map(DecodeFileSystemPath, + self.GetConfigEntry("RecentProjects", [])) self.FileMenu.Enable(ID_FILEMENURECENTPROJECTS, len(recent_projects) > 0)
for idx, projectpath in enumerate(recent_projects):
text = u'%d: %s' % (idx + 1, projectpath)
@@ -780,11 +788,13 @@
self.DebugVariablePanel.SetDataProducer(None)
def RefreshConfigRecentProjects(self, projectpath):
- recent_projects = cPickle.loads(str(self.Config.Read("RecentProjects", cPickle.dumps([]))))
+ recent_projects = map(DecodeFileSystemPath, + self.GetConfigEntry("RecentProjects", [])) if projectpath in recent_projects:
recent_projects.remove(projectpath)
recent_projects.insert(0, projectpath)
- self.Config.Write("RecentProjects", cPickle.dumps(recent_projects[:MAX_RECENT_PROJECTS]))
+ self.Config.Write("RecentProjects", cPickle.dumps( + map(EncodeFileSystemPath, recent_projects[:MAX_RECENT_PROJECTS]))) def ResetPerspective(self):
@@ -799,15 +809,16 @@
if self.CTR is not None and not self.CheckSaveBeforeClosing():
- if not self.Config.HasEntry("lastopenedfolder"):
+ defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder")) defaultpath = os.path.expanduser("~")
- defaultpath = self.Config.Read("lastopenedfolder")
dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, wx.DD_NEW_DIR_BUTTON)
if dialog.ShowModal() == wx.ID_OK:
projectpath = dialog.GetPath()
- self.Config.Write("lastopenedfolder", os.path.dirname(projectpath))
+ self.Config.Write("lastopenedfolder", + EncodeFileSystemPath(os.path.dirname(projectpath))) ctr = ProjectController(self, self.Log)
@@ -833,10 +844,10 @@
if self.CTR is not None and not self.CheckSaveBeforeClosing():
- if not self.Config.HasEntry("lastopenedfolder"):
+ defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder")) defaultpath = os.path.expanduser("~")
- defaultpath = self.Config.Read("lastopenedfolder")
dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, wx.DD_NEW_DIR_BUTTON)
if dialog.ShowModal() == wx.ID_OK:
@@ -845,7 +856,8 @@
def OpenProject(self, projectpath):
if os.path.isdir(projectpath):
- self.Config.Write("lastopenedfolder", os.path.dirname(projectpath))
+ self.Config.Write("lastopenedfolder", + EncodeFileSystemPath(os.path.dirname(projectpath))) self.CTR = ProjectController(self, self.Log)
--- a/ProjectController.py Fri Jul 06 21:00:43 2012 +0200
+++ b/ProjectController.py Wed Jul 18 01:33:48 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]
- editors = dict([(editor_name, editor)
- for extension, editor_name, editor in features.file_editors
- if extension == file_extension])
+ 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]) + editor_name = editors.keys()[0] + 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()] + 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())
- editor_name = editors.keys()[0]
- 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()]
- 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) return ConfigTreeNode._OpenView(self, self.CTNName(), onlyopened)
@@ -1361,6 +1366,7 @@
self.ChangesToSave = True
if self._View is not None:
+ if self.AppFrame is not None: self.AppFrame.RefreshTitle()
self.AppFrame.RefreshFileMenu()
self.AppFrame.RefreshEditMenu()
--- a/util/FileManagementPanel.py Fri Jul 06 21:00:43 2012 +0200
+++ b/util/FileManagementPanel.py Wed Jul 18 01:33:48 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 + "::") def CopyFile(self, src, dst):
--- a/util/ProcessLogger.py Fri Jul 06 21:00:43 2012 +0200
+++ b/util/ProcessLogger.py Wed Jul 18 01:33:48 2012 +0200
@@ -27,7 +27,7 @@
import subprocess, ctypes
from threading import Timer, Lock, Thread, Semaphore
from signal import SIGTERM, SIGKILL
@@ -86,7 +86,10 @@
self.Command_str = subprocess.list2cmdline(self.Command)
+ self.Command = map(lambda x: x.encode(sys.getfilesystemencoding()), self.finish_callback = finish_callback
self.no_stdout = no_stdout
self.no_stderr = no_stderr