65 usage() |
65 usage() |
66 sys.exit() |
66 sys.exit() |
67 elif len(args) == 1: |
67 elif len(args) == 1: |
68 fileOpen = args[0] |
68 fileOpen = args[0] |
69 CWD = sys.path[0] |
69 CWD = sys.path[0] |
70 |
|
71 |
|
72 # Test if identifier is valid |
|
73 def TestIdentifier(identifier): |
|
74 if identifier[0].isdigit(): |
|
75 return False |
|
76 words = identifier.split('_') |
|
77 for i, word in enumerate(words): |
|
78 if len(word) == 0 and i != 0: |
|
79 return False |
|
80 if len(word) != 0 and not word.isalnum(): |
|
81 return False |
|
82 return True |
|
83 |
70 |
84 [wxID_PLCOPENEDITOR, wxID_PLCOPENEDITORPROJECTTREE, |
71 [wxID_PLCOPENEDITOR, wxID_PLCOPENEDITORPROJECTTREE, |
85 wxID_PLCOPENEDITORSPLITTERWINDOW1, wxID_PLCOPENEDITOREDITORPANEL, |
72 wxID_PLCOPENEDITORSPLITTERWINDOW1, wxID_PLCOPENEDITOREDITORPANEL, |
86 wxID_PLCOPENEDITORTABSOPENED, wxID_PLCOPENEDITORTOOLBAR, |
73 wxID_PLCOPENEDITORTABSOPENED, wxID_PLCOPENEDITORTOOLBAR, |
87 wxID_PLCOPENEDITORDEFAULTTOOLBAR, wxID_PLCOPENEDITORSFCTOOLBAR, |
74 wxID_PLCOPENEDITORDEFAULTTOOLBAR, wxID_PLCOPENEDITORSFCTOOLBAR, |
404 self.RefreshFileMenu() |
396 self.RefreshFileMenu() |
405 self.RefreshEditMenu() |
397 self.RefreshEditMenu() |
406 self.RefreshToolBar() |
398 self.RefreshToolBar() |
407 |
399 |
408 def RefreshFileMenu(self): |
400 def RefreshFileMenu(self): |
409 if self.Controler.HasOpenedProject(): |
401 if self.FileMenu: |
410 if self.TabsOpened.GetPageCount() > 0: |
402 if self.Controler.HasOpenedProject(): |
411 self.FileMenu.FindItemByPosition(2).Enable(True) |
403 if self.TabsOpened.GetPageCount() > 0: |
|
404 self.FileMenu.FindItemByPosition(2).Enable(True) |
|
405 else: |
|
406 self.FileMenu.FindItemByPosition(2).Enable(False) |
|
407 self.FileMenu.FindItemByPosition(3).Enable(True) |
|
408 self.FileMenu.FindItemByPosition(5).Enable(True) |
|
409 self.FileMenu.FindItemByPosition(6).Enable(True) |
|
410 self.FileMenu.FindItemByPosition(7).Enable(True) |
|
411 self.FileMenu.FindItemByPosition(9).Enable(True) |
412 else: |
412 else: |
413 self.FileMenu.FindItemByPosition(2).Enable(False) |
413 self.FileMenu.FindItemByPosition(2).Enable(False) |
414 self.FileMenu.FindItemByPosition(3).Enable(True) |
414 self.FileMenu.FindItemByPosition(3).Enable(False) |
415 self.FileMenu.FindItemByPosition(5).Enable(True) |
415 self.FileMenu.FindItemByPosition(5).Enable(False) |
416 self.FileMenu.FindItemByPosition(6).Enable(True) |
416 self.FileMenu.FindItemByPosition(6).Enable(False) |
417 self.FileMenu.FindItemByPosition(7).Enable(True) |
417 self.FileMenu.FindItemByPosition(7).Enable(False) |
418 self.FileMenu.FindItemByPosition(9).Enable(True) |
418 self.FileMenu.FindItemByPosition(9).Enable(False) |
419 else: |
|
420 self.FileMenu.FindItemByPosition(2).Enable(False) |
|
421 self.FileMenu.FindItemByPosition(3).Enable(False) |
|
422 self.FileMenu.FindItemByPosition(5).Enable(False) |
|
423 self.FileMenu.FindItemByPosition(6).Enable(False) |
|
424 self.FileMenu.FindItemByPosition(7).Enable(False) |
|
425 self.FileMenu.FindItemByPosition(9).Enable(False) |
|
426 |
419 |
427 def RefreshEditMenu(self): |
420 def RefreshEditMenu(self): |
428 self.EditMenu.FindItemByPosition(1).Enable(False) |
421 if self.EditMenu: |
429 self.EditMenu.FindItemByPosition(2).Enable(False) |
422 self.EditMenu.FindItemByPosition(1).Enable(False) |
430 if self.Controler.HasOpenedProject(): |
423 self.EditMenu.FindItemByPosition(2).Enable(False) |
431 if self.TabsOpened.GetPageCount() > 0: |
424 if self.Controler.HasOpenedProject(): |
432 self.EditMenu.FindItemByPosition(0).Enable(True) |
425 if self.TabsOpened.GetPageCount() > 0: |
|
426 self.EditMenu.FindItemByPosition(0).Enable(True) |
|
427 else: |
|
428 self.EditMenu.FindItemByPosition(0).Enable(False) |
|
429 self.EditMenu.FindItemByPosition(8).Enable(True) |
|
430 self.EditMenu.FindItemByPosition(9).Enable(True) |
433 else: |
431 else: |
434 self.EditMenu.FindItemByPosition(0).Enable(False) |
432 self.EditMenu.FindItemByPosition(0).Enable(False) |
435 self.EditMenu.FindItemByPosition(8).Enable(True) |
433 self.EditMenu.FindItemByPosition(8).Enable(False) |
436 self.EditMenu.FindItemByPosition(9).Enable(True) |
434 self.EditMenu.FindItemByPosition(9).Enable(False) |
437 else: |
435 bodytype = self.Controler.GetCurrentElementEditingBodyType() |
438 self.EditMenu.FindItemByPosition(0).Enable(False) |
436 if bodytype in ["IL","ST"]: |
439 self.EditMenu.FindItemByPosition(8).Enable(False) |
437 self.EditMenu.FindItemByPosition(4).Enable(True) |
440 self.EditMenu.FindItemByPosition(9).Enable(False) |
438 self.EditMenu.FindItemByPosition(5).Enable(True) |
441 bodytype = self.Controler.GetCurrentElementEditingBodyType() |
439 self.EditMenu.FindItemByPosition(6).Enable(True) |
442 if bodytype in ["IL","ST"]: |
440 else: |
443 self.EditMenu.FindItemByPosition(4).Enable(True) |
441 self.EditMenu.FindItemByPosition(4).Enable(False) |
444 self.EditMenu.FindItemByPosition(5).Enable(True) |
442 self.EditMenu.FindItemByPosition(5).Enable(False) |
445 self.EditMenu.FindItemByPosition(6).Enable(True) |
|
446 else: |
|
447 self.EditMenu.FindItemByPosition(4).Enable(False) |
|
448 self.EditMenu.FindItemByPosition(5).Enable(False) |
|
449 self.EditMenu.FindItemByPosition(6).Enable(False) |
443 self.EditMenu.FindItemByPosition(6).Enable(False) |
450 |
444 |
451 def OnNewProjectMenu(self, event): |
445 def OnNewProjectMenu(self, event): |
452 dialog = ProjectDialog(self) |
446 dialog = ProjectDialog(self) |
453 if dialog.ShowModal() == wxID_OK: |
447 if dialog.ShowModal() == wxID_OK: |
1003 if root.IsOk(): |
997 if root.IsOk(): |
1004 self.ProjectTree.SetItemText(root, infos["name"]) |
998 self.ProjectTree.SetItemText(root, infos["name"]) |
1005 else: |
999 else: |
1006 root = self.ProjectTree.AddRoot(infos["name"]) |
1000 root = self.ProjectTree.AddRoot(infos["name"]) |
1007 self.ProjectTree.SetPyData(root, infos["type"]) |
1001 self.ProjectTree.SetPyData(root, infos["type"]) |
|
1002 if infos["type"] == ITEM_POU: |
|
1003 self.ProjectTree.SetItemImage(root, LANGUAGES.index(self.Controler.GetPouBodyType(infos["name"]))) |
1008 item, root_cookie = self.ProjectTree.GetFirstChild(root) |
1004 item, root_cookie = self.ProjectTree.GetFirstChild(root) |
1009 if len(infos["values"]) > 0: |
1005 if len(infos["values"]) > 0: |
1010 for values in infos["values"]: |
1006 for values in infos["values"]: |
1011 if not item.IsOk(): |
1007 if not item.IsOk(): |
1012 item = self.ProjectTree.AppendItem(root, "") |
1008 item = self.ProjectTree.AppendItem(root, "") |
2026 |
2022 |
2027 self._init_sizers() |
2023 self._init_sizers() |
2028 |
2024 |
2029 def __init__(self, parent, name, pou_type, filter = "All"): |
2025 def __init__(self, parent, name, pou_type, filter = "All"): |
2030 self._init_ctrls(parent, name) |
2026 self._init_ctrls(parent, name) |
2031 self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL) |
2027 self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
2032 self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
2028 self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
2033 self.Filter = filter |
2029 self.Filter = filter |
2034 self.FilterChoices = [] |
2030 self.FilterChoices = [] |
2035 self.FilterChoiceTransfer = {"All" : "All", "Interface" : "Interface", |
2031 self.FilterChoiceTransfer = {"All" : "All", "Interface" : "Interface", |
2036 "Input" : " Input", "Output" : " Output", "InOut" : " InOut", |
2032 "Input" : " Input", "Output" : " Output", "InOut" : " InOut", |