--- a/Beremiz.py Sun Sep 07 15:54:09 2008 +0200
+++ b/Beremiz.py Sun Sep 07 16:43:05 2008 +0200
@@ -254,7 +254,7 @@
kind=wx.ITEM_NORMAL, text=u'Open\tCTRL+O')
parent.Append(help='', id=wx.ID_SAVE,
kind=wx.ITEM_NORMAL, text=u'Save\tCTRL+S')
- parent.Append(help='', id=wx.ID_CLOSE,
+ parent.Append(help='', id=wx.ID_CLOSE_ALL, kind=wx.ITEM_NORMAL, text=u'Close Project')
parent.Append(help='', id=wx.ID_PROPERTIES,
@@ -412,27 +412,29 @@
# create temporary directory for runtime working directory
self.local_runtime_tmpdir = tempfile.mkdtemp()
# choose an arbitrary random port for runtime
- runtime_port = int(random.random() * 1000) + 61131
+ self.runtime_port = int(random.random() * 1000) + 61131 self.local_runtime = ProcessLogger(self.Log,
"\"%s\" \"%s\" -p %s -i localhost %s"%(sys.executable,
Bpath("Beremiz_service.py"),
self.local_runtime_tmpdir),
# Add beremiz's icon in top left corner of the frame
self.SetIcon(wx.Icon(Bpath( "images", "brz.ico"), wx.BITMAP_TYPE_ICO))
- self.PluginRoot = PluginsRoot(self, self.Log, runtime_port)
self.DisableEvents = False
+ self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) self.PluginRoot.LoadProject(projectOpen)
@@ -454,18 +456,18 @@
def SearchLineForError(self):
- text = self.LogConsole.GetRange(0, self.LogConsole.GetInsertionPoint())
- line = self.LogConsole.GetLineText(len(text.splitlines()) - 1)
- result = MATIEC_ERROR_MODEL.match(line)
- first_line, first_column, last_line, last_column, error = result.groups()
- infos = self.PluginRoot.ShowError(self.Log,
- (int(first_line), int(first_column)),
- (int(last_line), int(last_column)))
+ if self.PluginRoot is not None: + text = self.LogConsole.GetRange(0, self.LogConsole.GetInsertionPoint()) + line = self.LogConsole.GetLineText(len(text.splitlines()) - 1) + result = MATIEC_ERROR_MODEL.match(line) + first_line, first_column, last_line, last_column, error = result.groups() + infos = self.PluginRoot.ShowError(self.Log, + (int(first_line), int(first_column)), + (int(last_line), int(last_column))) def OnCloseFrame(self, event):
- if self.PluginRoot.HasProjectOpened():
+ if self.PluginRoot is not None: if self.PluginRoot.ProjectTestModified():
dialog = wx.MessageDialog(self,
@@ -496,23 +498,22 @@
def OnFrameActivated(self, event):
- if not event.GetActive():
+ if not event.GetActive() and self.PluginRoot is not None: self.PluginRoot.RefreshPluginsBlockLists()
def RefreshMainMenu(self):
- if self.PluginRoot.HasProjectOpened():
-## self.MenuBar.EnableTop(1, True)
-## self.MenuBar.EnableTop(2, True)
- self.FileMenu.Enable(wx.ID_SAVE, True)
- self.FileMenu.Enable(wx.ID_CLOSE, True)
- self.FileMenu.Enable(wx.ID_PROPERTIES, True)
-## self.MenuBar.EnableTop(1, False)
-## self.MenuBar.EnableTop(2, False)
- self.FileMenu.Enable(wx.ID_SAVE, False)
- self.FileMenu.Enable(wx.ID_CLOSE, False)
- self.FileMenu.Enable(wx.ID_PROPERTIES, False)
+ if self.PluginRoot is not None: +## self.MenuBar.EnableTop(1, True) +## self.MenuBar.EnableTop(2, True) + self.FileMenu.Enable(wx.ID_SAVE, True) + self.FileMenu.Enable(wx.ID_CLOSE, True) + self.FileMenu.Enable(wx.ID_PROPERTIES, True) +## self.MenuBar.EnableTop(1, False) +## self.MenuBar.EnableTop(2, False) + self.FileMenu.Enable(wx.ID_SAVE, False) + self.FileMenu.Enable(wx.ID_CLOSE, False) + self.FileMenu.Enable(wx.ID_PROPERTIES, False) def RefreshScrollBars(self):
xstart, ystart = self.PLCConfig.GetViewStart()
@@ -529,7 +530,7 @@
self.ClearSizer(self.PLCParamsSizer)
- if self.PluginRoot.HasProjectOpened():
+ if self.PluginRoot is not None: plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
if self.PluginRoot.PlugTestModified():
bkgdclr = CHANGED_TITLE_COLOUR
@@ -673,7 +674,7 @@
def RefreshPluginTree(self):
self.ClearSizer(self.PluginTreeSizer)
- if self.PluginRoot.HasProjectOpened():
+ if self.PluginRoot is not None: for child in self.PluginRoot.IECSortedChilds():
self.GenerateTreeBranch(child)
if not self.PluginInfos[child]["expanded"]:
@@ -1172,13 +1173,16 @@
def OnNewProjectMenu(self, event):
- defaultpath = self.PluginRoot.GetProjectPath()
+ if self.PluginRoot is not None: + defaultpath = self.PluginRoot.GetProjectPath() defaultpath = os.getcwd()
dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON)
if dialog.ShowModal() == wx.ID_OK:
projectpath = dialog.GetPath()
+ self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) res = self.PluginRoot.NewProject(projectpath)
@@ -1191,13 +1195,16 @@
def OnOpenProjectMenu(self, event):
- defaultpath = self.PluginRoot.GetProjectPath()
+ if self.PluginRoot is not None: + defaultpath = self.PluginRoot.GetProjectPath() defaultpath = os.getcwd()
dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON)
if dialog.ShowModal() == wx.ID_OK:
projectpath = dialog.GetPath()
if os.path.isdir(projectpath):
+ self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) result = self.PluginRoot.LoadProject(projectpath)
@@ -1215,16 +1222,28 @@
def OnCloseProjectMenu(self, event):
- self.PluginRoot.CloseProject()
- self.RefreshPLCParams()
- self.RefreshPluginTree()
+ if self.PluginRoot is not None: + if self.PluginRoot.ProjectTestModified(): + dialog = wx.MessageDialog(self, + wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) + answer = dialog.ShowModal() + if answer == wx.ID_YES: + self.PluginRoot.SaveProject() + elif answer == wx.ID_CANCEL: + self.RefreshPLCParams() + self.RefreshPluginTree() def OnSaveProjectMenu(self, event):
- if self.PluginRoot.HasProjectOpened():
+ if self.PluginRoot is not None: self.PluginRoot.SaveProject()
--- a/plugger.py Sun Sep 07 15:54:09 2008 +0200
+++ b/plugger.py Sun Sep 07 16:43:05 2008 +0200
@@ -690,12 +690,6 @@
def PlugTestModified(self):
return self.ChangesToSave or not self.ProjectIsSaved()
- def HasProjectOpened(self):
- Return if a project is actually opened
- return self.ProjectPath != None
@@ -797,10 +791,6 @@
self.PLCEditor.RefreshTitle()
- def CloseProject(self):
- self.ProjectPath = None
- self.PluggedChilds = {}
# Update PLCOpenEditor Plugin Block types from loaded plugins
def RefreshPluginsBlockLists(self):
if getattr(self, "PluggedChilds", None) is not None: