922 start = (from_location[0] - start_row, from_location[1] - start_col) |
923 start = (from_location[0] - start_row, from_location[1] - start_col) |
923 end = (to_location[0] - start_row, to_location[1] - start_col) |
924 end = (to_location[0] - start_row, to_location[1] - start_col) |
924 #print from_location, to_location, start_row, start_col, start, end |
925 #print from_location, to_location, start_row, start_col, start, end |
925 if self.AppFrame is not None: |
926 if self.AppFrame is not None: |
926 self.AppFrame.ShowError(infos, start, end) |
927 self.AppFrame.ShowError(infos, start, end) |
927 |
928 |
|
929 _IECCodeView = None |
928 def _showIECcode(self): |
930 def _showIECcode(self): |
929 self._OpenView("IEC code") |
931 self._OpenView("IEC code") |
930 |
932 |
|
933 _IECRawCodeView = None |
931 def _editIECrawcode(self): |
934 def _editIECrawcode(self): |
932 self._OpenView("IEC raw code") |
935 self._OpenView("IEC raw code") |
933 |
936 |
934 def _OpenView(self, name=None): |
937 def _OpenView(self, name=None): |
935 if name == "IEC code": |
938 if name == "IEC code": |
936 plc_file = self._getIECcodepath() |
939 if self._IEC_code_viewer is None: |
937 |
940 plc_file = self._getIECcodepath() |
938 IEC_code_viewer = TextViewer(self.AppFrame.TabsOpened, "", None, None, instancepath=name) |
941 |
939 #IEC_code_viewer.Enable(False) |
942 self._IECCodeView = TextViewer(self.AppFrame.TabsOpened, "", None, None, instancepath=name) |
940 IEC_code_viewer.SetTextSyntax("ALL") |
943 #self._IECCodeViewr.Enable(False) |
941 IEC_code_viewer.SetKeywords(IEC_KEYWORDS) |
944 self._IECCodeView.SetTextSyntax("ALL") |
942 try: |
945 self._IECCodeView.SetKeywords(IEC_KEYWORDS) |
943 text = file(plc_file).read() |
946 try: |
944 except: |
947 text = file(plc_file).read() |
945 text = '(* No IEC code have been generated at that time ! *)' |
948 except: |
946 IEC_code_viewer.SetText(text = text) |
949 text = '(* No IEC code have been generated at that time ! *)' |
947 IEC_code_viewer.SetIcon(self.AppFrame.GenerateBitmap("ST")) |
950 self._IECCodeView.SetText(text = text) |
|
951 self._IECCodeView.SetIcon(self.AppFrame.GenerateBitmap("ST")) |
|
952 |
|
953 self.AppFrame.EditProjectElement(self._IECCodeView, name) |
948 |
954 |
949 self.AppFrame.EditProjectElement(IEC_code_viewer, name) |
955 return self._IECCodeView |
950 |
|
951 return IEC_code_viewer |
|
952 |
956 |
953 elif name == "IEC raw code": |
957 elif name == "IEC raw code": |
954 controler = MiniTextControler(self._getIECrawcodepath()) |
958 if self.IEC_raw_code_viewer is None: |
955 IEC_raw_code_viewer = TextViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath=name) |
959 controler = MiniTextControler(self._getIECrawcodepath()) |
956 #IEC_raw_code_viewer.Enable(False) |
|
957 IEC_raw_code_viewer.SetTextSyntax("ALL") |
|
958 IEC_raw_code_viewer.SetKeywords(IEC_KEYWORDS) |
|
959 IEC_raw_code_viewer.RefreshView() |
|
960 IEC_raw_code_viewer.SetIcon(self.AppFrame.GenerateBitmap("ST")) |
|
961 |
960 |
962 self.AppFrame.EditProjectElement(IEC_raw_code_viewer, name) |
961 self.IEC_raw_code_viewer = TextViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath=name) |
963 |
962 #self.IEC_raw_code_viewer.Enable(False) |
964 return IEC_raw_code_viewer |
963 self.IEC_raw_code_viewer.SetTextSyntax("ALL") |
|
964 self.IEC_raw_code_viewer.SetKeywords(IEC_KEYWORDS) |
|
965 self.IEC_raw_code_viewer.RefreshView() |
|
966 self.IEC_raw_code_viewer.SetIcon(self.AppFrame.GenerateBitmap("ST")) |
|
967 |
|
968 self.AppFrame.EditProjectElement(self.IEC_raw_code_viewer, name) |
|
969 |
|
970 return self.IEC_raw_code_viewer |
965 |
971 |
966 else: |
972 else: |
967 return ConfigTreeNode._OpenView(self, name) |
973 return ConfigTreeNode._OpenView(self, name) |
968 |
974 |
|
975 def OnCloseEditor(self, view): |
|
976 ConfigTreeNode.OnCloseEditor(self, view) |
|
977 if self._IECCodeView == view: |
|
978 self._IECCodeView = None |
|
979 if self._IECRawCodeView == view: |
|
980 self._IECRawCodeView = None |
|
981 |
969 def _Clean(self): |
982 def _Clean(self): |
|
983 self._CloseView(self._IECCodeView) |
970 if os.path.isdir(os.path.join(self._getBuildPath())): |
984 if os.path.isdir(os.path.join(self._getBuildPath())): |
971 self.logger.write(_("Cleaning the build directory\n")) |
985 self.logger.write(_("Cleaning the build directory\n")) |
972 shutil.rmtree(os.path.join(self._getBuildPath())) |
986 shutil.rmtree(os.path.join(self._getBuildPath())) |
973 else: |
987 else: |
974 self.logger.write_error(_("Build directory already clean\n")) |
988 self.logger.write_error(_("Build directory already clean\n")) |