editors/ResourceEditor.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 18 Aug 2017 12:36:31 +0300
changeset 1767 c74815729afd
parent 1762 fcc406143e5b
child 1768 691083b5682a
permissions -rw-r--r--
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     1
#!/usr/bin/env python
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     3
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1423
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: 1423
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     6
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1423
diff changeset
     7
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     8
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1423
diff changeset
     9
# See COPYING file for copyrights details.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    10
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1423
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: 1423
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: 1423
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: 1423
diff changeset
    14
# of the License, or (at your option) any later version.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    15
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1423
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: 1423
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: 1423
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: 1423
diff changeset
    19
# GNU General Public License for more details.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    20
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1423
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: 1423
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: 1423
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    24
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    25
import wx
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    26
import wx.lib.buttons
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    27
import wx.grid
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    28
831
dec885ba1f2b Adding support for signaling that a task interval isn't well formatted
laurent
parents: 814
diff changeset
    29
from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD, ERROR_HIGHLIGHT
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    30
from controls import CustomGrid, CustomTable, DurationCellEditor
831
dec885ba1f2b Adding support for signaling that a task interval isn't well formatted
laurent
parents: 814
diff changeset
    31
from dialogs.DurationEditorDialog import IEC_TIME_MODEL
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    32
from EditorPanel import EditorPanel
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    33
from util.BitmapLibrary import GetBitmap
1657
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
    34
from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS, DefaultType
1762
fcc406143e5b clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1749
diff changeset
    35
from util.TranslationCatalogs import NoTranslate
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    36
#-------------------------------------------------------------------------------
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    37
#                          Configuration Editor class
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    38
#-------------------------------------------------------------------------------
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    39
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
    40
[ID_CONFIGURATIONEDITOR,
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    41
] = [wx.NewId() for _init_ctrls in range(1)]
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    42
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1734
diff changeset
    43
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    44
class ConfigurationEditor(EditorPanel):
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
    45
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    46
    ID = ID_CONFIGURATIONEDITOR
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    47
    VARIABLE_PANEL_TYPE = "config"
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
    48
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    49
    def GetBufferState(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    50
        return self.Controler.GetBufferState()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
    51
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    52
    def Undo(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    53
        self.Controler.LoadPrevious()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    54
        self.ParentWindow.CloseTabsWithoutModel()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
    55
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    56
    def Redo(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    57
        self.Controler.LoadNext()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    58
        self.ParentWindow.CloseTabsWithoutModel()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
    59
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    60
    def HasNoModel(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    61
        return self.Controler.GetEditedElement(self.TagName) is None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    62
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    63
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    64
#-------------------------------------------------------------------------------
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    65
#                            Resource Editor class
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    66
#-------------------------------------------------------------------------------
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    67
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    68
def GetTasksTableColnames():
1762
fcc406143e5b clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1749
diff changeset
    69
    _ = NoTranslate
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    70
    return [_("Name"), _("Triggering"), _("Single"), _("Interval"), _("Priority")]
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    71
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1734
diff changeset
    72
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    73
def GetTaskTriggeringOptions():
1762
fcc406143e5b clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1749
diff changeset
    74
    _ = NoTranslate
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    75
    return [_("Interrupt"), _("Cyclic")]
1749
d73b64672238 clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    76
d73b64672238 clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    77
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    78
TASKTRIGGERINGOPTIONS_DICT = dict([(_(option), option) for option in GetTaskTriggeringOptions()])
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    79
1762
fcc406143e5b clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1749
diff changeset
    80
fcc406143e5b clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1749
diff changeset
    81
def SingleCellEditor(*x):
fcc406143e5b clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1749
diff changeset
    82
    return wx.grid.GridCellChoiceEditor()
1423
4e33f644f7cf Added highlighting of wrong SINGLE task trigger
Edouard Tisserant
parents: 1420
diff changeset
    83
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1734
diff changeset
    84
1423
4e33f644f7cf Added highlighting of wrong SINGLE task trigger
Edouard Tisserant
parents: 1420
diff changeset
    85
def CheckSingle(single, varlist):
4e33f644f7cf Added highlighting of wrong SINGLE task trigger
Edouard Tisserant
parents: 1420
diff changeset
    86
    return single in varlist
4e33f644f7cf Added highlighting of wrong SINGLE task trigger
Edouard Tisserant
parents: 1420
diff changeset
    87
4e33f644f7cf Added highlighting of wrong SINGLE task trigger
Edouard Tisserant
parents: 1420
diff changeset
    88
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    89
def GetInstancesTableColnames():
1762
fcc406143e5b clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1749
diff changeset
    90
    _ = NoTranslate
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    91
    return [_("Name"), _("Type"), _("Task")]
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    92
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1734
diff changeset
    93
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    94
class ResourceTable(CustomTable):
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
    95
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    96
    """
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    97
    A custom wx.grid.Grid Table using user supplied data
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    98
    """
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    99
    def __init__(self, parent, data, colnames):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   100
        # The base class must be initialized *first*
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   101
        CustomTable.__init__(self, parent, data, colnames)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   102
        self.ColAlignements = []
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   103
        self.ColSizes = []
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   104
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   105
    def GetColAlignements(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   106
        return self.ColAlignements
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   107
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   108
    def SetColAlignements(self, list):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   109
        self.ColAlignements = list
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   110
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   111
    def GetColSizes(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   112
        return self.ColSizes
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   113
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   114
    def SetColSizes(self, list):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   115
        self.ColSizes = list
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   116
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   117
    def GetValue(self, row, col):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   118
        if row < self.GetNumberRows():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   119
            colname = self.GetColLabelValue(col, False)
1657
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   120
            value = self.data[row].get(colname, "")
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   121
            if colname == "Triggering":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   122
                return _(value)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   123
            return value
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   124
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   125
    def SetValue(self, row, col, value):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   126
        if col < len(self.colnames):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   127
            colname = self.GetColLabelValue(col, False)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   128
            if colname == "Triggering":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   129
                value = TASKTRIGGERINGOPTIONS_DICT[value]
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   130
            self.data[row][colname] = value
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   131
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   132
    def _updateColAttrs(self, grid):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   133
        """
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   134
        wx.grid.Grid -> update the column attributes to add the
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   135
        appropriate renderer given the column name.
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   136
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   137
        Otherwise default to the default renderer.
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   138
        """
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   139
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   140
        for col in range(self.GetNumberCols()):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   141
            attr = wx.grid.GridCellAttr()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   142
            attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   143
            grid.SetColAttr(col, attr)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   144
            grid.SetColSize(col, self.ColSizes[col])
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   145
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   146
        for row in range(self.GetNumberRows()):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   147
            row_highlights = self.Highlights.get(row, {})
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   148
            for col in range(self.GetNumberCols()):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   149
                editor = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   150
                renderer = None
879
55b8a16ead2b Fix resource task interval error highlighting
Laurent Bessard
parents: 831
diff changeset
   151
                error = False
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   152
                colname = self.GetColLabelValue(col, False)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   153
                grid.SetReadOnly(row, col, False)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   154
                if colname == "Name":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   155
                    editor = wx.grid.GridCellTextEditor()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   156
                    renderer = wx.grid.GridCellStringRenderer()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   157
                elif colname == "Interval":
1275
8d4de18c9f29 Fixed DurationCellEditor to make it reusable
Laurent Bessard
parents: 1026
diff changeset
   158
                    editor = DurationCellEditor(self, colname)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   159
                    renderer = wx.grid.GridCellStringRenderer()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   160
                    if self.GetValueByName(row, "Triggering") != "Cyclic":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   161
                        grid.SetReadOnly(row, col, True)
879
55b8a16ead2b Fix resource task interval error highlighting
Laurent Bessard
parents: 831
diff changeset
   162
                    interval = self.GetValueByName(row, colname)
55b8a16ead2b Fix resource task interval error highlighting
Laurent Bessard
parents: 831
diff changeset
   163
                    if interval != "" and IEC_TIME_MODEL.match(interval.upper()) is None:
55b8a16ead2b Fix resource task interval error highlighting
Laurent Bessard
parents: 831
diff changeset
   164
                        error = True
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   165
                elif colname == "Single":
1740
b789b695b5c6 clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1739
diff changeset
   166
                    editor = SingleCellEditor(self, colname)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   167
                    editor.SetParameters(self.Parent.VariableList)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   168
                    if self.GetValueByName(row, "Triggering") != "Interrupt":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   169
                        grid.SetReadOnly(row, col, True)
1423
4e33f644f7cf Added highlighting of wrong SINGLE task trigger
Edouard Tisserant
parents: 1420
diff changeset
   170
                    single = self.GetValueByName(row, colname)
1740
b789b695b5c6 clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1739
diff changeset
   171
                    if single != "" and not CheckSingle(single, self.Parent.VariableList):
1423
4e33f644f7cf Added highlighting of wrong SINGLE task trigger
Edouard Tisserant
parents: 1420
diff changeset
   172
                        error = True
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   173
                elif colname == "Triggering":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   174
                    editor = wx.grid.GridCellChoiceEditor()
1026
96a2dc05651a Fixed Triggering column cell choice editor, removing useless and bugging empty string option
Laurent Bessard
parents: 899
diff changeset
   175
                    editor.SetParameters(",".join(map(_, GetTaskTriggeringOptions())))
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   176
                elif colname == "Type":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   177
                    editor = wx.grid.GridCellChoiceEditor()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   178
                    editor.SetParameters(self.Parent.TypeList)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   179
                elif colname == "Priority":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   180
                    editor = wx.grid.GridCellNumberEditor()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   181
                    editor.SetParameters("0,65535")
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   182
                elif colname == "Task":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   183
                    editor = wx.grid.GridCellChoiceEditor()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   184
                    editor.SetParameters(self.Parent.TaskList)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   185
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   186
                grid.SetCellEditor(row, col, editor)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   187
                grid.SetCellRenderer(row, col, renderer)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   188
879
55b8a16ead2b Fix resource task interval error highlighting
Laurent Bessard
parents: 831
diff changeset
   189
                if error:
831
dec885ba1f2b Adding support for signaling that a task interval isn't well formatted
laurent
parents: 814
diff changeset
   190
                    highlight_colours = ERROR_HIGHLIGHT
dec885ba1f2b Adding support for signaling that a task interval isn't well formatted
laurent
parents: 814
diff changeset
   191
                else:
dec885ba1f2b Adding support for signaling that a task interval isn't well formatted
laurent
parents: 814
diff changeset
   192
                    highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1]
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   193
                grid.SetCellBackgroundColour(row, col, highlight_colours[0])
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   194
                grid.SetCellTextColour(row, col, highlight_colours[1])
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   195
            self.ResizeRow(grid, row)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   196
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   197
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   198
#-------------------------------------------------------------------------------
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   199
#                        Highlights showing functions
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   200
#-------------------------------------------------------------------------------
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   201
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   202
    def AddHighlight(self, infos, highlight_type):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   203
        row_highlights = self.Highlights.setdefault(infos[0], {})
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   204
        col_highlights = row_highlights.setdefault(infos[1], [])
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   205
        col_highlights.append(highlight_type)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   206
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   207
    def ClearHighlights(self, highlight_type=None):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   208
        if highlight_type is None:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   209
            self.Highlights = {}
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   210
        else:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   211
            for row, row_highlights in self.Highlights.iteritems():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   212
                row_items = row_highlights.items()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   213
                for col, col_highlights in row_items:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   214
                    if highlight_type in col_highlights:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   215
                        col_highlights.remove(highlight_type)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   216
                    if len(col_highlights) == 0:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   217
                        row_highlights.pop(col)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   218
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   219
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   220
class ResourceEditor(EditorPanel):
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   221
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   222
    VARIABLE_PANEL_TYPE = "resource"
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   223
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   224
    def _init_Editor(self, parent):
1745
f9d32913bad4 clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
   225
        self.Editor = wx.Panel(parent, style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   226
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   227
        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   228
        main_sizer.AddGrowableCol(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   229
        main_sizer.AddGrowableRow(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   230
        main_sizer.AddGrowableRow(1)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   231
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   232
        tasks_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   233
        tasks_sizer.AddGrowableCol(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   234
        tasks_sizer.AddGrowableRow(1)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   235
        main_sizer.AddSizer(tasks_sizer, border=5,
1745
f9d32913bad4 clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
   236
              flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   237
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   238
        tasks_buttons_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   239
        tasks_buttons_sizer.AddGrowableCol(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   240
        tasks_buttons_sizer.AddGrowableRow(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   241
        tasks_sizer.AddSizer(tasks_buttons_sizer, flag=wx.GROW)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   242
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   243
        tasks_label = wx.StaticText(self.Editor, label=_(u'Tasks:'))
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   244
        tasks_buttons_sizer.AddWindow(tasks_label, flag=wx.ALIGN_BOTTOM)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   245
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   246
        for name, bitmap, help in [
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   247
                ("AddTaskButton", "add_element", _("Add task")),
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   248
                ("DeleteTaskButton", "remove_element", _("Remove task")),
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   249
                ("UpTaskButton", "up", _("Move task up")),
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   250
                ("DownTaskButton", "down", _("Move task down"))]:
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   251
            button = wx.lib.buttons.GenBitmapButton(self.Editor,
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   252
                  bitmap=GetBitmap(bitmap), size=wx.Size(28, 28), style=wx.NO_BORDER)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   253
            button.SetToolTipString(help)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   254
            setattr(self, name, button)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   255
            tasks_buttons_sizer.AddWindow(button)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   256
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   257
        self.TasksGrid = CustomGrid(self.Editor, style=wx.VSCROLL)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   258
        self.TasksGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnTasksGridCellChange)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   259
        tasks_sizer.AddWindow(self.TasksGrid, flag=wx.GROW)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   260
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   261
        instances_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   262
        instances_sizer.AddGrowableCol(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   263
        instances_sizer.AddGrowableRow(1)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   264
        main_sizer.AddSizer(instances_sizer, border=5,
1745
f9d32913bad4 clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
   265
              flag=wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   266
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   267
        instances_buttons_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   268
        instances_buttons_sizer.AddGrowableCol(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   269
        instances_buttons_sizer.AddGrowableRow(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   270
        instances_sizer.AddSizer(instances_buttons_sizer, flag=wx.GROW)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   271
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   272
        instances_label = wx.StaticText(self.Editor, label=_(u'Instances:'))
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   273
        instances_buttons_sizer.AddWindow(instances_label, flag=wx.ALIGN_BOTTOM)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   274
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   275
        for name, bitmap, help in [
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   276
                ("AddInstanceButton", "add_element", _("Add instance")),
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   277
                ("DeleteInstanceButton", "remove_element", _("Remove instance")),
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   278
                ("UpInstanceButton", "up", _("Move instance up")),
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   279
                ("DownInstanceButton", "down", _("Move instance down"))]:
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   280
            button = wx.lib.buttons.GenBitmapButton(self.Editor,
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   281
                  bitmap=GetBitmap(bitmap), size=wx.Size(28, 28), style=wx.NO_BORDER)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   282
            button.SetToolTipString(help)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   283
            setattr(self, name, button)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   284
            instances_buttons_sizer.AddWindow(button)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   285
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   286
        self.InstancesGrid = CustomGrid(self.Editor, style=wx.VSCROLL)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   287
        self.InstancesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   288
              self.OnInstancesGridCellChange)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   289
        instances_sizer.AddWindow(self.InstancesGrid, flag=wx.GROW)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   290
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   291
        self.Editor.SetSizer(main_sizer)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   292
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   293
    def __init__(self, parent, tagname, window, controler):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   294
        EditorPanel.__init__(self, parent, tagname, window, controler)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   295
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   296
        self.RefreshHighlightsTimer = wx.Timer(self, -1)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   297
        self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   298
1739
ec153828ded2 clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
   299
        self.TasksDefaultValue = {"Name": "", "Triggering": "", "Single": "", "Interval": "", "Priority": 0}
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   300
        self.TasksTable = ResourceTable(self, [], GetTasksTableColnames())
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   301
        self.TasksTable.SetColAlignements([wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT])
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   302
        self.TasksTable.SetColSizes([200, 100, 100, 150, 100])
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   303
        self.TasksGrid.SetTable(self.TasksTable)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   304
        self.TasksGrid.SetButtons({"Add": self.AddTaskButton,
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   305
                                   "Delete": self.DeleteTaskButton,
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   306
                                   "Up": self.UpTaskButton,
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   307
                                   "Down": self.DownTaskButton})
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   308
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   309
        def _AddTask(new_row):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   310
            self.TasksTable.InsertRow(new_row, self.TasksDefaultValue.copy())
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   311
            self.RefreshModel()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   312
            self.RefreshView()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   313
            return new_row
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   314
        setattr(self.TasksGrid, "_AddRow", _AddTask)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   315
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   316
        def _DeleteTask(row):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   317
            self.TasksTable.RemoveRow(row)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   318
            self.RefreshModel()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   319
            self.RefreshView()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   320
        setattr(self.TasksGrid, "_DeleteRow", _DeleteTask)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   321
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   322
        def _MoveTask(row, move):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   323
            new_row = self.TasksTable.MoveRow(row, move)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   324
            if new_row != row:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   325
                self.RefreshModel()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   326
                self.RefreshView()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   327
            return new_row
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   328
        setattr(self.TasksGrid, "_MoveRow", _MoveTask)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   329
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   330
        self.TasksGrid.SetRowLabelSize(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   331
        self.TasksTable.ResetView(self.TasksGrid)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   332
        self.TasksGrid.RefreshButtons()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   333
1739
ec153828ded2 clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
   334
        self.InstancesDefaultValue = {"Name": "", "Type": "", "Task": ""}
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   335
        self.InstancesTable = ResourceTable(self, [], GetInstancesTableColnames())
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   336
        self.InstancesTable.SetColAlignements([wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT])
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   337
        self.InstancesTable.SetColSizes([200, 150, 150])
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   338
        self.InstancesGrid.SetTable(self.InstancesTable)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   339
        self.InstancesGrid.SetButtons({"Add": self.AddInstanceButton,
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   340
                                       "Delete": self.DeleteInstanceButton,
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   341
                                       "Up": self.UpInstanceButton,
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   342
                                       "Down": self.DownInstanceButton})
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   343
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   344
        def _AddInstance(new_row):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   345
            self.InstancesTable.InsertRow(new_row, self.InstancesDefaultValue.copy())
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   346
            self.RefreshModel()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   347
            self.RefreshView()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   348
            return new_row
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   349
        setattr(self.InstancesGrid, "_AddRow", _AddInstance)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   350
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   351
        def _DeleteInstance(row):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   352
            self.InstancesTable.RemoveRow(row)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   353
            self.RefreshModel()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   354
            self.RefreshView()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   355
        setattr(self.InstancesGrid, "_DeleteRow", _DeleteInstance)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   356
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   357
        def _MoveInstance(row, move):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   358
            new_row = max(0, min(row + move, self.InstancesTable.GetNumberRows() - 1))
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   359
            if new_row != row:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   360
                if self.InstancesTable.GetValueByName(row, "Task") != self.InstancesTable.GetValueByName(new_row, "Task"):
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   361
                    return row
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   362
                self.InstancesTable.MoveRow(row, move)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   363
                self.RefreshModel()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   364
                self.RefreshView()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   365
            return new_row
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   366
        setattr(self.InstancesGrid, "_MoveRow", _MoveInstance)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   367
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   368
        def _RefreshInstanceButtons():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   369
            if self:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   370
                rows = self.InstancesTable.GetNumberRows()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   371
                row = self.InstancesGrid.GetGridCursorRow()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   372
                self.DeleteInstanceButton.Enable(rows > 0)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   373
                self.UpInstanceButton.Enable(row > 0 and
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   374
                    self.InstancesTable.GetValueByName(row, "Task") == self.InstancesTable.GetValueByName(row - 1, "Task"))
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   375
                self.DownInstanceButton.Enable(0 <= row < rows - 1 and
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   376
                    self.InstancesTable.GetValueByName(row, "Task") == self.InstancesTable.GetValueByName(row + 1, "Task"))
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   377
        setattr(self.InstancesGrid, "RefreshButtons", _RefreshInstanceButtons)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   378
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   379
        self.InstancesGrid.SetRowLabelSize(0)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   380
        self.InstancesTable.ResetView(self.InstancesGrid)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   381
        self.InstancesGrid.RefreshButtons()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   382
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   383
        self.TasksGrid.SetFocus()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   384
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   385
    def __del__(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   386
        self.RefreshHighlightsTimer.Stop()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   387
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   388
    def RefreshTypeList(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   389
        self.TypeList = ""
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   390
        blocktypes = self.Controler.GetBlockResource()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   391
        for blocktype in blocktypes:
1734
750eeb7230a1 clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1657
diff changeset
   392
            self.TypeList += ",%s" % blocktype
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   393
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   394
    def RefreshTaskList(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   395
        self.TaskList = ""
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   396
        for row in xrange(self.TasksTable.GetNumberRows()):
1734
750eeb7230a1 clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1657
diff changeset
   397
            self.TaskList += ",%s" % self.TasksTable.GetValueByName(row, "Name")
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   398
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   399
    def RefreshVariableList(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   400
        self.VariableList = ""
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   401
        for variable in self.Controler.GetEditedResourceVariables(self.TagName):
1734
750eeb7230a1 clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1657
diff changeset
   402
            self.VariableList += ",%s" % variable
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   403
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   404
    def RefreshModel(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   405
        self.Controler.SetEditedResourceInfos(self.TagName, self.TasksTable.GetData(), self.InstancesTable.GetData())
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   406
        self.RefreshBuffer()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   407
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   408
    # Buffer the last model state
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   409
    def RefreshBuffer(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   410
        self.Controler.BufferProject()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   411
        self.ParentWindow.RefreshTitle()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   412
        self.ParentWindow.RefreshFileMenu()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   413
        self.ParentWindow.RefreshEditMenu()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   414
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   415
    def GetBufferState(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   416
        return self.Controler.GetBufferState()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   417
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   418
    def Undo(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   419
        self.Controler.LoadPrevious()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   420
        self.ParentWindow.CloseTabsWithoutModel()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   421
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   422
    def Redo(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   423
        self.Controler.LoadNext()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   424
        self.ParentWindow.CloseTabsWithoutModel()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   425
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   426
    def HasNoModel(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   427
        return self.Controler.GetEditedElement(self.TagName) is None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   428
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   429
    def RefreshView(self, variablepanel=True):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   430
        EditorPanel.RefreshView(self, variablepanel)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   431
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   432
        tasks, instances = self.Controler.GetEditedResourceInfos(self.TagName)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   433
        self.TasksTable.SetData(tasks)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   434
        self.InstancesTable.SetData(instances)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   435
        self.RefreshTypeList()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   436
        self.RefreshTaskList()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   437
        self.RefreshVariableList()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   438
        self.TasksTable.ResetView(self.TasksGrid)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   439
        self.InstancesTable.ResetView(self.InstancesGrid)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   440
        self.TasksGrid.RefreshButtons()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   441
        self.InstancesGrid.RefreshButtons()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   442
1657
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   443
    def ShowErrorMessage(self, message):
1745
f9d32913bad4 clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
   444
        dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
1657
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   445
        dialog.ShowModal()
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   446
        dialog.Destroy()
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   447
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   448
    def OnTasksGridCellChange(self, event):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   449
        row, col = event.GetRow(), event.GetCol()
1604
7f98c091be56 fix issue with task rename if "Name" column label is translated into
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
   450
        if self.TasksTable.GetColLabelValue(col, False) == "Name":
1657
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   451
            value = self.TasksTable.GetValue(row, col)
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   452
            message = None
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   453
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   454
            if not TestIdentifier(value):
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   455
                message = _("\"%s\" is not a valid identifier!") % value
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   456
            elif value.upper() in IEC_KEYWORDS:
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   457
                message = _("\"%s\" is a keyword. It can't be used!") % value
1742
92932cd370a4 clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1741
diff changeset
   458
            elif value.upper() in [var["Name"].upper() for i, var in enumerate(self.TasksTable.data) if i != row]:
1657
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   459
                message = _("A task with the same name already exists!")
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   460
            if message is not None:
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   461
                event.Veto()
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   462
                wx.CallAfter(self.ShowErrorMessage, message)
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   463
                return
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   464
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   465
            tasklist = [name for name in self.TaskList.split(",") if name != ""]
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   466
            for i in xrange(self.TasksTable.GetNumberRows()):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   467
                task = self.TasksTable.GetValueByName(i, "Name")
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   468
                if task in tasklist:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   469
                    tasklist.remove(task)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   470
            if len(tasklist) > 0:
1611
5e64d552b25a make renames caseinsensitive
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1604
diff changeset
   471
                old_name = tasklist[0].upper()
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   472
                new_name = self.TasksTable.GetValue(row, col)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   473
                for i in xrange(self.InstancesTable.GetNumberRows()):
1611
5e64d552b25a make renames caseinsensitive
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1604
diff changeset
   474
                    name = self.InstancesTable.GetValueByName(i, "Task").upper()
5e64d552b25a make renames caseinsensitive
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1604
diff changeset
   475
                    if old_name == name:
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   476
                        self.InstancesTable.SetValueByName(i, "Task", new_name)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   477
        self.RefreshModel()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   478
        colname = self.TasksTable.GetColLabelValue(col, False)
1423
4e33f644f7cf Added highlighting of wrong SINGLE task trigger
Edouard Tisserant
parents: 1420
diff changeset
   479
        if colname in ["Triggering", "Name", "Single", "Interval"]:
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   480
            wx.CallAfter(self.RefreshView, False)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   481
        event.Skip()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   482
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   483
    def OnInstancesGridCellChange(self, event):
1657
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   484
        row, col = event.GetRow(), event.GetCol()
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   485
        if self.InstancesTable.GetColLabelValue(col, False) == "Name":
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   486
            value = self.InstancesTable.GetValue(row, col)
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   487
            message = None
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   488
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   489
            if not TestIdentifier(value):
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   490
                message = _("\"%s\" is not a valid identifier!") % value
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   491
            elif value.upper() in IEC_KEYWORDS:
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   492
                message = _("\"%s\" is a keyword. It can't be used!") % value
1742
92932cd370a4 clean-up: fix PEP8 E225 missing whitespace around operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1741
diff changeset
   493
            elif value.upper() in [var["Name"].upper() for i, var in enumerate(self.InstancesTable.data) if i != row]:
1657
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   494
                message = _("An instance with the same name already exists!")
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   495
            if message is not None:
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   496
                event.Veto()
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   497
                wx.CallAfter(self.ShowErrorMessage, message)
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   498
                return
3a98027ff372 apply constraints to names for tasks and task instances in resource configuration
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1611
diff changeset
   499
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   500
        self.RefreshModel()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   501
        self.ParentWindow.RefreshPouInstanceVariablesPanel()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   502
        self.InstancesGrid.RefreshButtons()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   503
        event.Skip()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   504
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   505
#-------------------------------------------------------------------------------
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   506
#                        Highlights showing functions
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   507
#-------------------------------------------------------------------------------
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   508
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   509
    def OnRefreshHighlightsTimer(self, event):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   510
        self.RefreshView()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   511
        event.Skip()
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   512
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   513
    def AddHighlight(self, infos, start, end, highlight_type):
899
64aa66d481c5 Fix bug in resource search result highlighting
Laurent Bessard
parents: 879
diff changeset
   514
        EditorPanel.AddHighlight(self, infos, start, end, highlight_type)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   515
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   516
        if infos[0] == "task":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   517
            self.TasksTable.AddHighlight(infos[1:], highlight_type)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   518
        elif infos[0] == "instance":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   519
            self.InstancesTable.AddHighlight(infos[1:], highlight_type)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   520
        self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   521
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   522
    def ClearHighlights(self, highlight_type=None):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   523
        EditorPanel.ClearHighlights(self, highlight_type)
1420
71b1545d746f Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
Edouard Tisserant
parents: 1275
diff changeset
   524
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   525
        self.TasksTable.ClearHighlights(highlight_type)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   526
        self.InstancesTable.ClearHighlights(highlight_type)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   527
        self.TasksTable.ResetView(self.TasksGrid)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   528
        self.InstancesTable.ResetView(self.InstancesGrid)