148 import types, time, re, platform, time, traceback, commands |
148 import types, time, re, platform, time, traceback, commands |
149 from plugger import PluginsRoot, MATIEC_ERROR_MODEL |
149 from plugger import PluginsRoot, MATIEC_ERROR_MODEL |
150 from wxPopen import ProcessLogger |
150 from wxPopen import ProcessLogger |
151 |
151 |
152 from docutils import * |
152 from docutils import * |
153 from PLCOpenEditor import IDEFrame, Viewer, AppendMenu, TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE, SCALING, PAGETITLES, USE_AUI |
153 from PLCOpenEditor import IDEFrame, Viewer, AppendMenu, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE, SCALING, PAGETITLES, USE_AUI |
154 from PLCControler import LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
154 from PLCControler import LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
155 |
155 |
156 SCROLLBAR_UNIT = 10 |
156 SCROLLBAR_UNIT = 10 |
157 WINDOW_COLOUR = wx.Colour(240,240,240) |
157 WINDOW_COLOUR = wx.Colour(240,240,240) |
158 TITLE_COLOUR = wx.Colour(200,200,220) |
158 TITLE_COLOUR = wx.Colour(200,200,220) |
432 self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
432 self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
433 self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
433 self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
434 self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
434 self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
435 self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
435 self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
436 |
436 |
|
437 self.AddToMenuToolBar([(wx.ID_NEW, "new.png", _(u'New'), None), |
|
438 (wx.ID_OPEN, "open.png", _(u'Open'), None), |
|
439 (wx.ID_SAVE, "save.png", _(u'Save'), None), |
|
440 (wx.ID_SAVEAS, "saveas.png", _(u'Save As...'), None), |
|
441 (wx.ID_PRINT, "print.png", _(u'Print'), None)]) |
|
442 |
437 def _init_coll_HelpMenu_Items(self, parent): |
443 def _init_coll_HelpMenu_Items(self, parent): |
438 parent.Append(help='', id=wx.ID_HELP, |
444 parent.Append(help='', id=wx.ID_HELP, |
439 kind=wx.ITEM_NORMAL, text=_(u'Beremiz\tF1')) |
445 kind=wx.ITEM_NORMAL, text=_(u'Beremiz\tF1')) |
440 parent.Append(help='', id=wx.ID_ABOUT, |
446 parent.Append(help='', id=wx.ID_ABOUT, |
441 kind=wx.ITEM_NORMAL, text=_(u'About')) |
447 kind=wx.ITEM_NORMAL, text=_(u'About')) |
560 if self.EnableDebug: |
566 if self.EnableDebug: |
561 self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
567 self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
562 |
568 |
563 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
569 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
564 |
570 |
565 self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
571 self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
566 self.RefreshPluginMenu() |
572 self.RefreshPluginMenu() |
567 self.LogConsole.SetFocus() |
573 self.LogConsole.SetFocus() |
568 |
574 |
569 def RiseLogConsole(self): |
575 def RiseLogConsole(self): |
570 self.BottomNoteBook.SetSelection(self.BottomNoteBook.GetPageIndex(self.LogConsole)) |
576 self.BottomNoteBook.SetSelection(self.BottomNoteBook.GetPageIndex(self.LogConsole)) |
692 if self.TabsOpened.GetPageCount() > 0: |
699 if self.TabsOpened.GetPageCount() > 0: |
693 self.FileMenu.Enable(wx.ID_CLOSE, True) |
700 self.FileMenu.Enable(wx.ID_CLOSE, True) |
694 if graphic_viewer: |
701 if graphic_viewer: |
695 self.FileMenu.Enable(wx.ID_PREVIEW, True) |
702 self.FileMenu.Enable(wx.ID_PREVIEW, True) |
696 self.FileMenu.Enable(wx.ID_PRINT, True) |
703 self.FileMenu.Enable(wx.ID_PRINT, True) |
|
704 MenuToolBar.EnableTool(wx.ID_PRINT, True) |
697 else: |
705 else: |
698 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
706 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
699 self.FileMenu.Enable(wx.ID_PRINT, False) |
707 self.FileMenu.Enable(wx.ID_PRINT, False) |
|
708 MenuToolBar.EnableTool(wx.ID_PRINT, False) |
700 else: |
709 else: |
701 self.FileMenu.Enable(wx.ID_CLOSE, False) |
710 self.FileMenu.Enable(wx.ID_CLOSE, False) |
702 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
711 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
703 self.FileMenu.Enable(wx.ID_PRINT, False) |
712 self.FileMenu.Enable(wx.ID_PRINT, False) |
|
713 MenuToolBar.EnableTool(wx.ID_PRINT, False) |
704 self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
714 self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
705 self.FileMenu.Enable(wx.ID_SAVE, self.PluginRoot.ProjectTestModified()) |
715 project_modified = self.PluginRoot.ProjectTestModified() |
|
716 self.FileMenu.Enable(wx.ID_SAVE, project_modified) |
|
717 MenuToolBar.EnableTool(wx.ID_SAVE, project_modified) |
706 self.FileMenu.Enable(wx.ID_SAVEAS, True) |
718 self.FileMenu.Enable(wx.ID_SAVEAS, True) |
|
719 MenuToolBar.EnableTool(wx.ID_SAVEAS, True) |
707 self.FileMenu.Enable(wx.ID_PROPERTIES, True) |
720 self.FileMenu.Enable(wx.ID_PROPERTIES, True) |
708 self.FileMenu.Enable(wx.ID_CLOSE_ALL, True) |
721 self.FileMenu.Enable(wx.ID_CLOSE_ALL, True) |
709 else: |
722 else: |
710 self.FileMenu.Enable(wx.ID_CLOSE, False) |
723 self.FileMenu.Enable(wx.ID_CLOSE, False) |
711 self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
724 self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
712 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
725 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
713 self.FileMenu.Enable(wx.ID_PRINT, False) |
726 self.FileMenu.Enable(wx.ID_PRINT, False) |
|
727 MenuToolBar.EnableTool(wx.ID_PRINT, False) |
714 self.FileMenu.Enable(wx.ID_SAVE, False) |
728 self.FileMenu.Enable(wx.ID_SAVE, False) |
|
729 MenuToolBar.EnableTool(wx.ID_SAVE, False) |
715 self.FileMenu.Enable(wx.ID_SAVEAS, False) |
730 self.FileMenu.Enable(wx.ID_SAVEAS, False) |
|
731 MenuToolBar.EnableTool(wx.ID_SAVEAS, False) |
716 self.FileMenu.Enable(wx.ID_PROPERTIES, False) |
732 self.FileMenu.Enable(wx.ID_PROPERTIES, False) |
717 self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
733 self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
718 |
734 |
719 def RefreshRecentProjectsMenu(self): |
735 def RefreshRecentProjectsMenu(self): |
720 for i in xrange(self.RecentProjectsMenu.GetMenuItemCount()): |
736 for i in xrange(self.RecentProjectsMenu.GetMenuItemCount()): |
1361 for name, XSDClass, help in plugin.PlugChildsTypes: |
1377 for name, XSDClass, help in plugin.PlugChildsTypes: |
1362 new_id = wx.NewId() |
1378 new_id = wx.NewId() |
1363 main_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=_("Append ")+help) |
1379 main_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=_("Append ")+help) |
1364 self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, plugin), id=new_id) |
1380 self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, plugin), id=new_id) |
1365 self.PopupMenuXY(main_menu) |
1381 self.PopupMenuXY(main_menu) |
|
1382 main_menu.Destroy() |
1366 return AddPluginMenu |
1383 return AddPluginMenu |
1367 |
1384 |
1368 def GetButtonCallBackFunction(self, plugin, method): |
1385 def GetButtonCallBackFunction(self, plugin, method): |
1369 """ Generate the callbackfunc for a given plugin method""" |
1386 """ Generate the callbackfunc for a given plugin method""" |
1370 def OnButtonClick(event): |
1387 def OnButtonClick(event): |
1663 else: |
1680 else: |
1664 self.ResetView() |
1681 self.ResetView() |
1665 self.ShowErrorMessage(result) |
1682 self.ShowErrorMessage(result) |
1666 else: |
1683 else: |
1667 self.ShowErrorMessage(_("\"%s\" folder is not a valid Beremiz project\n") % projectpath) |
1684 self.ShowErrorMessage(_("\"%s\" folder is not a valid Beremiz project\n") % projectpath) |
1668 self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU) |
1685 self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
1669 |
1686 |
1670 def OnCloseProjectMenu(self, event): |
1687 def OnCloseProjectMenu(self, event): |
1671 if self.PluginRoot is not None and not self.CheckSaveBeforeClosing(): |
1688 if self.PluginRoot is not None and not self.CheckSaveBeforeClosing(): |
1672 return |
1689 return |
1673 |
1690 |
1674 self.ResetView() |
1691 self.ResetView() |
1675 self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU) |
1692 self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
1676 self.RefreshAll() |
1693 self.RefreshAll() |
1677 |
1694 |
1678 def OnSaveProjectMenu(self, event): |
1695 def OnSaveProjectMenu(self, event): |
1679 if self.PluginRoot is not None: |
1696 if self.PluginRoot is not None: |
1680 self.PluginRoot.SaveProject() |
1697 self.PluginRoot.SaveProject() |