author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Sat, 29 Sep 2018 17:52:33 +0300 | |
changeset 2405 | af050469fc5c |
parent 1881 | 091005ec69c4 |
child 3750 | f62625418bff |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
814 | 6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
814 | 8 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
814 | 10 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
814 | 15 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
19 |
# GNU General Public License for more details. |
814 | 20 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1085
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 24 |
|
1881
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1836
diff
changeset
|
25 |
|
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1836
diff
changeset
|
26 |
from __future__ import absolute_import |
814 | 27 |
import wx |
28 |
||
29 |
from controls import VariablePanel |
|
30 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1735
diff
changeset
|
31 |
|
814 | 32 |
class EditorPanel(wx.SplitterWindow): |
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
33 |
|
814 | 34 |
VARIABLE_PANEL_TYPE = None |
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
35 |
|
814 | 36 |
def _init_Editor(self, prnt): |
37 |
self.Editor = None |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
38 |
|
814 | 39 |
def _init_MenuItems(self): |
40 |
self.MenuItems = [] |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
41 |
|
814 | 42 |
def _init_ctrls(self, parent): |
43 |
self.SetMinimumPaneSize(1) |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
44 |
|
814 | 45 |
self._init_MenuItems() |
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
46 |
|
814 | 47 |
if self.VARIABLE_PANEL_TYPE is not None: |
48 |
self.VariableEditor = VariablePanel(self, self, self.Controler, self.VARIABLE_PANEL_TYPE, self.Debug) |
|
49 |
self.VariableEditor.SetTagName(self.TagName) |
|
50 |
else: |
|
51 |
self.VariableEditor = None |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
52 |
|
814 | 53 |
self._init_Editor(self) |
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
54 |
|
814 | 55 |
if self.Editor is not None and self.VariableEditor is not None: |
56 |
self.SplitHorizontally(self.VariableEditor, self.Editor, 200) |
|
57 |
elif self.VariableEditor is not None: |
|
58 |
self.Initialize(self.VariableEditor) |
|
59 |
elif self.Editor is not None: |
|
60 |
self.Initialize(self.Editor) |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
61 |
|
814 | 62 |
def __init__(self, parent, tagname, window, controler, debug=False): |
1836
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
63 |
wx.SplitterWindow.__init__(self, parent, |
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
64 |
style=wx.SUNKEN_BORDER | wx.SP_3D) |
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
65 |
|
814 | 66 |
self.ParentWindow = window |
67 |
self.Controler = controler |
|
68 |
self.TagName = tagname |
|
69 |
self.Icon = None |
|
70 |
self.Debug = debug |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
71 |
|
814 | 72 |
self._init_ctrls(parent) |
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
73 |
|
814 | 74 |
def SetTagName(self, tagname): |
75 |
self.TagName = tagname |
|
76 |
if self.VARIABLE_PANEL_TYPE is not None: |
|
77 |
self.VariableEditor.SetTagName(tagname) |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
78 |
|
814 | 79 |
def GetTagName(self): |
80 |
return self.TagName |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
81 |
|
814 | 82 |
def Select(self): |
83 |
self.ParentWindow.EditProjectElement(None, self.GetTagName(), True) |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
84 |
|
814 | 85 |
def GetTitle(self): |
1615
af9b0ccb418e
replace '-' with '.' in resource tab and transition/action SFC code
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
86 |
return ".".join(self.TagName.split("::")[1:]) |
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
87 |
|
814 | 88 |
def GetIcon(self): |
89 |
return self.Icon |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
90 |
|
814 | 91 |
def SetIcon(self, icon): |
92 |
self.Icon = icon |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
93 |
|
814 | 94 |
def IsViewing(self, tagname): |
95 |
return self.GetTagName() == tagname |
|
96 |
||
97 |
def IsDebugging(self): |
|
98 |
return self.Debug |
|
99 |
||
100 |
def SetMode(self, mode): |
|
101 |
pass |
|
102 |
||
103 |
def ResetBuffer(self): |
|
104 |
pass |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
105 |
|
814 | 106 |
def IsModified(self): |
107 |
return False |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
108 |
|
814 | 109 |
def CheckSaveBeforeClosing(self): |
110 |
return True |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
111 |
|
814 | 112 |
def Save(self): |
113 |
pass |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
114 |
|
814 | 115 |
def SaveAs(self): |
116 |
pass |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
117 |
|
814 | 118 |
def GetBufferState(self): |
119 |
if self.Controler is not None: |
|
120 |
return self.Controler.GetBufferState() |
|
121 |
return False, False |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
122 |
|
814 | 123 |
def Undo(self): |
124 |
if self.Controler is not None: |
|
125 |
self.Controler.LoadPrevious() |
|
126 |
self.RefreshView() |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
127 |
|
814 | 128 |
def Redo(self): |
129 |
if self.Controler is not None: |
|
130 |
self.Controler.LoadNext() |
|
131 |
self.RefreshView() |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
132 |
|
814 | 133 |
def Find(self, direction, search_params): |
134 |
pass |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
135 |
|
814 | 136 |
def HasNoModel(self): |
137 |
return False |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
138 |
|
814 | 139 |
def RefreshView(self, variablepanel=True): |
140 |
if variablepanel: |
|
141 |
self.RefreshVariablePanel() |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
142 |
|
814 | 143 |
def RefreshVariablePanel(self): |
144 |
if self.VariableEditor is not None: |
|
145 |
self.VariableEditor.RefreshView() |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
146 |
|
814 | 147 |
def GetConfNodeMenuItems(self): |
148 |
return self.MenuItems |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
149 |
|
814 | 150 |
def RefreshConfNodeMenu(self, confnode_menu): |
151 |
pass |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
152 |
|
814 | 153 |
def _Refresh(self, *args): |
154 |
self.ParentWindow._Refresh(*args) |
|
155 |
||
156 |
def RefreshScaling(self, refresh=True): |
|
157 |
pass |
|
158 |
||
159 |
def AddHighlight(self, infos, start, end, highlight_type): |
|
160 |
if self.VariableEditor is not None and infos[0] in ["var_local", "var_input", "var_output", "var_inout"]: |
|
161 |
self.VariableEditor.AddVariableHighlight(infos[1:], highlight_type) |
|
162 |
||
163 |
def RemoveHighlight(self, infos, start, end, highlight_type): |
|
164 |
if self.VariableEditor is not None and infos[0] in ["var_local", "var_input", "var_output", "var_inout"]: |
|
165 |
self.VariableEditor.RemoveVariableHighlight(infos[1:], highlight_type) |
|
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1615
diff
changeset
|
166 |
|
814 | 167 |
def ClearHighlights(self, highlight_type=None): |
168 |
if self.VariableEditor is not None: |
|
169 |
self.VariableEditor.ClearHighlights(highlight_type) |