12 from datetime import datetime |
12 from datetime import datetime |
13 from weakref import WeakKeyDictionary |
13 from weakref import WeakKeyDictionary |
14 |
14 |
15 import targets |
15 import targets |
16 import connectors |
16 import connectors |
17 from util.misc import CheckPathPerm, GetClassImporter |
17 from util.misc import CheckPathPerm, GetClassImporter, IECCodeViewer |
18 from util.MiniTextControler import MiniTextControler |
18 from util.MiniTextControler import MiniTextControler |
19 from util.ProcessLogger import ProcessLogger |
19 from util.ProcessLogger import ProcessLogger |
20 from util.FileManagementPanel import FileManagementPanel |
20 from util.FileManagementPanel import FileManagementPanel |
21 from PLCControler import PLCControler |
21 from PLCControler import PLCControler |
22 from TextViewer import TextViewer |
22 from TextViewer import TextViewer |
946 def _OpenView(self, name=None, onlyopened=False): |
946 def _OpenView(self, name=None, onlyopened=False): |
947 if name == "IEC code": |
947 if name == "IEC code": |
948 if self._IECCodeView is None: |
948 if self._IECCodeView is None: |
949 plc_file = self._getIECcodepath() |
949 plc_file = self._getIECcodepath() |
950 |
950 |
951 self._IECCodeView = TextViewer(self.AppFrame.TabsOpened, "", None, None, instancepath=name) |
951 self._IECCodeView = IECCodeViewer(self.AppFrame.TabsOpened, "", None, None, instancepath=name) |
952 #self._IECCodeView.Enable(False) |
|
953 self._IECCodeView.SetTextSyntax("ALL") |
952 self._IECCodeView.SetTextSyntax("ALL") |
954 self._IECCodeView.SetKeywords(IEC_KEYWORDS) |
953 self._IECCodeView.SetKeywords(IEC_KEYWORDS) |
955 try: |
954 try: |
956 text = file(plc_file).read() |
955 text = file(plc_file).read() |
957 except: |
956 except: |
958 text = '(* No IEC code have been generated at that time ! *)' |
957 text = '(* No IEC code have been generated at that time ! *)' |
959 self._IECCodeView.SetText(text = text) |
958 self._IECCodeView.SetText(text = text) |
960 self._IECCodeView.SetIcon(GetBitmap("ST")) |
959 self._IECCodeView.SetIcon(GetBitmap("ST")) |
|
960 setattr(self._IECCodeView, "_OnClose", self.OnCloseEditor) |
961 |
961 |
962 if self._IECCodeView is not None: |
962 if self._IECCodeView is not None: |
963 self.AppFrame.EditProjectElement(self._IECCodeView, name) |
963 self.AppFrame.EditProjectElement(self._IECCodeView, name) |
964 |
964 |
965 return self._IECCodeView |
965 return self._IECCodeView |
966 |
966 |
967 elif name == "IEC raw code": |
967 elif name == "IEC raw code": |
968 if self._IECRawCodeView is None: |
968 if self._IECRawCodeView is None: |
969 controler = MiniTextControler(self._getIECrawcodepath()) |
969 controler = MiniTextControler(self._getIECrawcodepath(), self) |
970 |
970 |
971 self._IECRawCodeView = TextViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath=name) |
971 self._IECRawCodeView = IECCodeViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath=name) |
972 #self._IECRawCodeView.Enable(False) |
|
973 self._IECRawCodeView.SetTextSyntax("ALL") |
972 self._IECRawCodeView.SetTextSyntax("ALL") |
974 self._IECRawCodeView.SetKeywords(IEC_KEYWORDS) |
973 self._IECRawCodeView.SetKeywords(IEC_KEYWORDS) |
975 self._IECRawCodeView.RefreshView() |
974 self._IECRawCodeView.RefreshView() |
976 self._IECRawCodeView.SetIcon(GetBitmap("ST")) |
975 self._IECRawCodeView.SetIcon(GetBitmap("ST")) |
|
976 setattr(self._IECRawCodeView, "_OnClose", self.OnCloseEditor) |
977 |
977 |
978 if self._IECRawCodeView is not None: |
978 if self._IECRawCodeView is not None: |
979 self.AppFrame.EditProjectElement(self._IECRawCodeView, name) |
979 self.AppFrame.EditProjectElement(self._IECRawCodeView, name) |
980 |
980 |
981 return self._IECRawCodeView |
981 return self._IECRawCodeView |