144 |
144 |
145 import wx.lib.buttons, wx.lib.statbmp |
145 import wx.lib.buttons, wx.lib.statbmp |
146 import TextCtrlAutoComplete, cPickle |
146 import TextCtrlAutoComplete, cPickle |
147 from BrowseValuesLibraryDialog import BrowseValuesLibraryDialog |
147 from BrowseValuesLibraryDialog import BrowseValuesLibraryDialog |
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, MiniTextControler, 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, AppendMenu, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE, SCALING, PAGETITLES, USE_AUI |
153 from PLCOpenEditor import IDEFrame, AppendMenu, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE, SCALING, PAGETITLES, USE_AUI |
154 from PLCOpenEditor import EditorPanel, Viewer, TextViewer, GraphicViewer, ResourceEditor, ConfigurationEditor, DataTypeEditor |
154 from PLCOpenEditor import EditorPanel, Viewer, TextViewer, GraphicViewer, ResourceEditor, ConfigurationEditor, DataTypeEditor |
557 if projectOpen is not None and os.path.isdir(projectOpen): |
557 if projectOpen is not None and os.path.isdir(projectOpen): |
558 self.PluginRoot = PluginsRoot(self, self.Log) |
558 self.PluginRoot = PluginsRoot(self, self.Log) |
559 self.Controler = self.PluginRoot |
559 self.Controler = self.PluginRoot |
560 result = self.PluginRoot.LoadProject(projectOpen, buildpath) |
560 result = self.PluginRoot.LoadProject(projectOpen, buildpath) |
561 if not result: |
561 if not result: |
|
562 self.LibraryPanel.SetControler(self.Controler) |
562 self.RefreshConfigRecentProjects(os.path.abspath(projectOpen)) |
563 self.RefreshConfigRecentProjects(os.path.abspath(projectOpen)) |
563 self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
564 self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
564 self.RefreshAll() |
565 self.RefreshAll() |
565 else: |
566 else: |
566 self.ResetView() |
567 self.ResetView() |
567 self.ShowErrorMessage(result) |
568 self.ShowErrorMessage(result) |
568 else: |
569 else: |
569 self.PluginRoot = plugin_root |
570 self.PluginRoot = plugin_root |
570 self.Controler = plugin_root |
571 self.Controler = plugin_root |
571 if plugin_root is not None: |
572 if plugin_root is not None: |
|
573 self.LibraryPanel.SetControler(self.Controler) |
572 self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
574 self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
573 self.RefreshAll() |
575 self.RefreshAll() |
574 if self.EnableDebug: |
576 if self.EnableDebug: |
575 self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
577 self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
576 |
578 |
671 GraphicViewer, |
673 GraphicViewer, |
672 ResourceEditor, |
674 ResourceEditor, |
673 ConfigurationEditor, |
675 ConfigurationEditor, |
674 DataTypeEditor))): |
676 DataTypeEditor))): |
675 return ("plugin", tab.Controler.PlugFullName()) |
677 return ("plugin", tab.Controler.PlugFullName()) |
|
678 elif (isinstance(tab, TextViewer) and |
|
679 (tab.Controler is None or isinstance(tab.Controler, MiniTextControler))): |
|
680 return ("plugin", None, tab.GetInstancePath()) |
676 else: |
681 else: |
677 return IDEFrame.GetTabInfos(self, tab) |
682 return IDEFrame.GetTabInfos(self, tab) |
678 |
683 |
679 def LoadTab(self, notebook, page_infos): |
684 def LoadTab(self, notebook, page_infos): |
680 if page_infos[0] == "plugin": |
685 if page_infos[0] == "plugin": |
681 plugin = self.PluginRoot.GetChildByName(page_infos[1]) |
686 if page_infos[1] is None: |
682 return notebook.GetPageIndex(plugin._OpenView()) |
687 plugin = self.PluginRoot |
|
688 else: |
|
689 plugin = self.PluginRoot.GetChildByName(page_infos[1]) |
|
690 return notebook.GetPageIndex(plugin._OpenView(*page_infos[2:])) |
683 else: |
691 else: |
684 return IDEFrame.LoadTab(self, notebook, page_infos) |
692 return IDEFrame.LoadTab(self, notebook, page_infos) |
685 |
693 |
686 def OnCloseFrame(self, event): |
694 def OnCloseFrame(self, event): |
687 if self.PluginRoot is None or self.CheckSaveBeforeClosing(_("Close Application")): |
695 if self.PluginRoot is None or self.CheckSaveBeforeClosing(_("Close Application")): |
1671 plugin_root = PluginsRoot(self, self.Log) |
1679 plugin_root = PluginsRoot(self, self.Log) |
1672 result = plugin_root.NewProject(projectpath) |
1680 result = plugin_root.NewProject(projectpath) |
1673 if not result: |
1681 if not result: |
1674 self.PluginRoot = plugin_root |
1682 self.PluginRoot = plugin_root |
1675 self.Controler = self.PluginRoot |
1683 self.Controler = self.PluginRoot |
|
1684 self.LibraryPanel.SetControler(self.Controler) |
1676 self.RefreshConfigRecentProjects(projectpath) |
1685 self.RefreshConfigRecentProjects(projectpath) |
1677 if self.EnableDebug: |
1686 if self.EnableDebug: |
1678 self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
1687 self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
1679 self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
1688 self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
1680 self.RefreshAll() |
1689 self.RefreshAll() |
1705 self.ResetView() |
1714 self.ResetView() |
1706 self.PluginRoot = PluginsRoot(self, self.Log) |
1715 self.PluginRoot = PluginsRoot(self, self.Log) |
1707 self.Controler = self.PluginRoot |
1716 self.Controler = self.PluginRoot |
1708 result = self.PluginRoot.LoadProject(projectpath) |
1717 result = self.PluginRoot.LoadProject(projectpath) |
1709 if not result: |
1718 if not result: |
|
1719 self.LibraryPanel.SetControler(self.Controler) |
1710 self.RefreshConfigRecentProjects(projectpath) |
1720 self.RefreshConfigRecentProjects(projectpath) |
1711 if self.EnableDebug: |
1721 if self.EnableDebug: |
1712 self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
1722 self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
1713 self.LoadProjectOrganization() |
1723 self.LoadProjectOrganization() |
1714 self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
1724 self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |