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) |
421 self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
421 self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
422 self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
422 self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
423 self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
423 self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
424 self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
424 self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
425 |
425 |
|
426 self.AddToMenuToolBar([(wx.ID_NEW, wx.ART_NEW, _(u'New'), None), |
|
427 (wx.ID_OPEN, wx.ART_FILE_OPEN, _(u'Open'), None), |
|
428 (wx.ID_SAVE, wx.ART_FILE_SAVE, _(u'Save'), None), |
|
429 (wx.ID_SAVEAS, wx.ART_FILE_SAVE_AS, _(u'Save As...'), None), |
|
430 (wx.ID_PRINT, wx.ART_PRINT, _(u'Print'), None)]) |
|
431 |
426 def _init_coll_HelpMenu_Items(self, parent): |
432 def _init_coll_HelpMenu_Items(self, parent): |
427 parent.Append(help='', id=wx.ID_HELP, |
433 parent.Append(help='', id=wx.ID_HELP, |
428 kind=wx.ITEM_NORMAL, text=_(u'Beremiz\tF1')) |
434 kind=wx.ITEM_NORMAL, text=_(u'Beremiz\tF1')) |
429 parent.Append(help='', id=wx.ID_ABOUT, |
435 parent.Append(help='', id=wx.ID_ABOUT, |
430 kind=wx.ITEM_NORMAL, text=_(u'About')) |
436 kind=wx.ITEM_NORMAL, text=_(u'About')) |
549 if self.EnableDebug: |
555 if self.EnableDebug: |
550 self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
556 self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
551 |
557 |
552 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
558 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
553 |
559 |
554 self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
560 self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
555 self.RefreshPluginMenu() |
561 self.RefreshPluginMenu() |
556 self.LogConsole.SetFocus() |
562 self.LogConsole.SetFocus() |
557 |
563 |
558 def RiseLogConsole(self): |
564 def RiseLogConsole(self): |
559 self.BottomNoteBook.SetSelection(self.BottomNoteBook.GetPageIndex(self.LogConsole)) |
565 self.BottomNoteBook.SetSelection(self.BottomNoteBook.GetPageIndex(self.LogConsole)) |
680 if self.TabsOpened.GetPageCount() > 0: |
687 if self.TabsOpened.GetPageCount() > 0: |
681 self.FileMenu.Enable(wx.ID_CLOSE, True) |
688 self.FileMenu.Enable(wx.ID_CLOSE, True) |
682 if graphic_viewer: |
689 if graphic_viewer: |
683 self.FileMenu.Enable(wx.ID_PREVIEW, True) |
690 self.FileMenu.Enable(wx.ID_PREVIEW, True) |
684 self.FileMenu.Enable(wx.ID_PRINT, True) |
691 self.FileMenu.Enable(wx.ID_PRINT, True) |
|
692 MenuToolBar.EnableTool(wx.ID_PRINT, True) |
685 else: |
693 else: |
686 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
694 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
687 self.FileMenu.Enable(wx.ID_PRINT, False) |
695 self.FileMenu.Enable(wx.ID_PRINT, False) |
|
696 MenuToolBar.EnableTool(wx.ID_PRINT, False) |
688 else: |
697 else: |
689 self.FileMenu.Enable(wx.ID_CLOSE, False) |
698 self.FileMenu.Enable(wx.ID_CLOSE, False) |
690 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
699 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
691 self.FileMenu.Enable(wx.ID_PRINT, False) |
700 self.FileMenu.Enable(wx.ID_PRINT, False) |
|
701 MenuToolBar.EnableTool(wx.ID_PRINT, False) |
692 self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
702 self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
693 self.FileMenu.Enable(wx.ID_SAVE, self.PluginRoot.ProjectTestModified()) |
703 project_modified = self.PluginRoot.ProjectTestModified() |
|
704 self.FileMenu.Enable(wx.ID_SAVE, project_modified) |
|
705 MenuToolBar.EnableTool(wx.ID_SAVE, project_modified) |
694 self.FileMenu.Enable(wx.ID_SAVEAS, True) |
706 self.FileMenu.Enable(wx.ID_SAVEAS, True) |
|
707 MenuToolBar.EnableTool(wx.ID_SAVEAS, True) |
695 self.FileMenu.Enable(wx.ID_PROPERTIES, True) |
708 self.FileMenu.Enable(wx.ID_PROPERTIES, True) |
696 self.FileMenu.Enable(wx.ID_CLOSE_ALL, True) |
709 self.FileMenu.Enable(wx.ID_CLOSE_ALL, True) |
697 else: |
710 else: |
698 self.FileMenu.Enable(wx.ID_CLOSE, False) |
711 self.FileMenu.Enable(wx.ID_CLOSE, False) |
699 self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
712 self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
700 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
713 self.FileMenu.Enable(wx.ID_PREVIEW, False) |
701 self.FileMenu.Enable(wx.ID_PRINT, False) |
714 self.FileMenu.Enable(wx.ID_PRINT, False) |
|
715 MenuToolBar.EnableTool(wx.ID_PRINT, False) |
702 self.FileMenu.Enable(wx.ID_SAVE, False) |
716 self.FileMenu.Enable(wx.ID_SAVE, False) |
|
717 MenuToolBar.EnableTool(wx.ID_SAVE, False) |
703 self.FileMenu.Enable(wx.ID_SAVEAS, False) |
718 self.FileMenu.Enable(wx.ID_SAVEAS, False) |
|
719 MenuToolBar.EnableTool(wx.ID_SAVEAS, False) |
704 self.FileMenu.Enable(wx.ID_PROPERTIES, False) |
720 self.FileMenu.Enable(wx.ID_PROPERTIES, False) |
705 self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
721 self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
706 |
722 |
707 def RefreshRecentProjectsMenu(self): |
723 def RefreshRecentProjectsMenu(self): |
708 for i in xrange(self.RecentProjectsMenu.GetMenuItemCount()): |
724 for i in xrange(self.RecentProjectsMenu.GetMenuItemCount()): |
1651 else: |
1667 else: |
1652 self.ResetView() |
1668 self.ResetView() |
1653 self.ShowErrorMessage(result) |
1669 self.ShowErrorMessage(result) |
1654 else: |
1670 else: |
1655 self.ShowErrorMessage(_("\"%s\" folder is not a valid Beremiz project\n") % projectpath) |
1671 self.ShowErrorMessage(_("\"%s\" folder is not a valid Beremiz project\n") % projectpath) |
1656 self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU) |
1672 self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
1657 |
1673 |
1658 def OnCloseProjectMenu(self, event): |
1674 def OnCloseProjectMenu(self, event): |
1659 if self.PluginRoot is not None and not self.CheckSaveBeforeClosing(): |
1675 if self.PluginRoot is not None and not self.CheckSaveBeforeClosing(): |
1660 return |
1676 return |
1661 |
1677 |
1662 self.ResetView() |
1678 self.ResetView() |
1663 self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU) |
1679 self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
1664 self.RefreshAll() |
1680 self.RefreshAll() |
1665 |
1681 |
1666 def OnSaveProjectMenu(self, event): |
1682 def OnSaveProjectMenu(self, event): |
1667 if self.PluginRoot is not None: |
1683 if self.PluginRoot is not None: |
1668 self.PluginRoot.SaveProject() |
1684 self.PluginRoot.SaveProject() |