author | Edouard Tisserant 7BB06627 <edouard.tisserant@gmail.com> |
Tue, 24 Jan 2017 01:09:54 +0100 | |
branch | 1.2 |
changeset 1641 | 24168e52fc2b |
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
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:
814
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 24 |
|
25 |
import wx |
|
26 |
||
27 |
#------------------------------------------------------------------------------- |
|
28 |
# POU Name Dialog |
|
29 |
#------------------------------------------------------------------------------- |
|
30 |
||
31 |
class PouNameDialog(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 |
||
39 |
self.Bind(wx.EVT_BUTTON, self.OnOK, |
|
40 |
self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton()) |
|
41 |
||
42 |
def OnOK(self, event): |
|
43 |
message = None |
|
44 |
step_name = self.GetSizer().GetItem(1).GetWindow().GetValue() |
|
45 |
if step_name == "": |
|
46 |
message = _("You must type a name!") |
|
47 |
elif not TestIdentifier(step_name): |
|
48 |
message = _("\"%s\" is not a valid identifier!") % step_name |
|
49 |
elif step_name.upper() in IEC_KEYWORDS: |
|
50 |
message = _("\"%s\" is a keyword. It can't be used!") % step_name |
|
51 |
elif step_name.upper() in self.PouNames: |
|
52 |
message = _("A POU named \"%s\" already exists!") % step_name |
|
53 |
if message is not None: |
|
54 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) |
|
55 |
dialog.ShowModal() |
|
56 |
dialog.Destroy() |
|
57 |
else: |
|
58 |
self.EndModal(wx.ID_OK) |
|
59 |
event.Skip() |
|
60 |
||
61 |
def SetPouNames(self, pou_names): |
|
62 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
63 |