author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Wed, 07 Dec 2016 19:28:13 +0300 | |
changeset 1598 | 1445457547f7 |
parent 1571 | 486f94a8032c |
child 1730 | 64d8f52bc8c8 |
permissions | -rw-r--r-- |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
1 |
#!/usr/bin/env python |
814 | 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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
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:
1347
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 24 |
|
25 |
import wx |
|
26 |
||
27 |
#------------------------------------------------------------------------------- |
|
28 |
# Edit Step Name Dialog |
|
29 |
#------------------------------------------------------------------------------- |
|
30 |
||
31 |
class SFCStepNameDialog(wx.TextEntryDialog): |
|
32 |
||
33 |
def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", |
|
34 |
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition): |
|
35 |
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos) |
|
36 |
||
37 |
self.PouNames = [] |
|
38 |
self.Variables = [] |
|
39 |
self.StepNames = [] |
|
40 |
||
41 |
self.Bind(wx.EVT_BUTTON, self.OnOK, |
|
42 |
self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton()) |
|
43 |
||
44 |
def OnOK(self, event): |
|
45 |
message = None |
|
46 |
step_name = self.GetSizer().GetItem(1).GetWindow().GetValue() |
|
47 |
if step_name == "": |
|
48 |
message = _("You must type a name!") |
|
49 |
elif not TestIdentifier(step_name): |
|
50 |
message = _("\"%s\" is not a valid identifier!") % step_name |
|
51 |
elif step_name.upper() in IEC_KEYWORDS: |
|
52 |
message = _("\"%s\" is a keyword. It can't be used!") % step_name |
|
53 |
elif step_name.upper() in self.PouNames: |
|
54 |
message = _("A POU named \"%s\" already exists!") % step_name |
|
55 |
elif step_name.upper() in self.Variables: |
|
56 |
message = _("A variable with \"%s\" as name already exists in this pou!") % step_name |
|
57 |
elif step_name.upper() in self.StepNames: |
|
58 |
message = _("\"%s\" step already exists!") % step_name |
|
59 |
if message is not None: |
|
60 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) |
|
61 |
dialog.ShowModal() |
|
62 |
dialog.Destroy() |
|
63 |
else: |
|
64 |
self.EndModal(wx.ID_OK) |
|
65 |
event.Skip() |
|
66 |
||
67 |
def SetPouNames(self, pou_names): |
|
68 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
69 |
||
70 |
def SetVariables(self, variables): |
|
1347
533741e5075c
Fixed pou variables information loading stylesheet
Laurent Bessard
parents:
814
diff
changeset
|
71 |
self.Variables = [var.Name.upper() for var in variables] |
814 | 72 |
|
73 |
def SetStepNames(self, step_names): |
|
74 |
self.StepNames = [step_name.upper() for step_name in step_names] |