editors/ProjectNodeEditor.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Mon, 14 Aug 2017 23:27:15 +0300
changeset 1736 7e61baa047f0
parent 1735 c02818d7e29f
child 1850 614396cbffbf
permissions -rw-r--r--
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
     1
#!/usr/bin/env python
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
     2
# -*- coding: utf-8 -*-
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
     3
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
     6
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
     7
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
     8
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
     9
# See COPYING file for copyrights details.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    10
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    11
# This program is free software; you can redistribute it and/or
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    12
# modify it under the terms of the GNU General Public License
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    13
# as published by the Free Software Foundation; either version 2
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    14
# of the License, or (at your option) any later version.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    15
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    16
# This program is distributed in the hope that it will be useful,
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    19
# GNU General Public License for more details.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    20
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    21
# You should have received a copy of the GNU General Public License
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    22
# along with this program; if not, write to the Free Software
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    24
413946c04c87 refactoring
laurent
parents:
diff changeset
    25
import wx
413946c04c87 refactoring
laurent
parents:
diff changeset
    26
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    27
from controls import ProjectPropertiesPanel, VariablePanel
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 800
diff changeset
    28
from EditorPanel import EditorPanel
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    29
from ConfTreeNodeEditor import ConfTreeNodeEditor
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    30
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1735
diff changeset
    31
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    32
class ProjectNodeEditor(ConfTreeNodeEditor):
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    33
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    34
    SHOW_BASE_PARAMS = False
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    35
    ENABLE_REQUIRED = True
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    36
    CONFNODEEDITOR_TABS = [
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    37
        (_("Config variables"), "_create_VariablePanel"),
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    38
        (_("Project properties"), "_create_ProjectPropertiesPanel")]
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    39
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    40
    def _create_VariablePanel(self, prnt):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    41
        self.VariableEditorPanel = VariablePanel(prnt, self, self.Controler, "config", self.Debug)
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    42
        self.VariableEditorPanel.SetTagName(self.TagName)
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    43
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    44
        return self.VariableEditorPanel
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    45
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    46
    def _create_ProjectPropertiesPanel(self, prnt):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    47
        self.ProjectProperties = ProjectPropertiesPanel(prnt, self.Controler, self.ParentWindow, self.ENABLE_REQUIRED)
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    48
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    49
        return self.ProjectProperties
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    50
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    51
    def __init__(self, parent, controler, window):
413946c04c87 refactoring
laurent
parents:
diff changeset
    52
        configuration = controler.GetProjectMainConfigurationName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    53
        if configuration is not None:
413946c04c87 refactoring
laurent
parents:
diff changeset
    54
            tagname = controler.ComputeConfigurationName(configuration)
413946c04c87 refactoring
laurent
parents:
diff changeset
    55
        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
    56
            tagname = ""
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    57
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
    58
        ConfTreeNodeEditor.__init__(self, parent, controler, window, tagname)
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    59
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    60
        buttons_sizer = self.GenerateMethodButtonSizer()
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    61
        self.MainSizer.InsertSizer(0, buttons_sizer, 0, border=5, flag=wx.ALL)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    62
        self.MainSizer.Layout()
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    63
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    64
        self.VariableEditor = self.VariableEditorPanel
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    65
413946c04c87 refactoring
laurent
parents:
diff changeset
    66
    def GetTagName(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
    67
        return self.Controler.CTNName()
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    68
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    69
    def SetTagName(self, tagname):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    70
        self.TagName = tagname
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    71
        if self.VariableEditor is not None:
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    72
            self.VariableEditor.SetTagName(tagname)
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    73
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    74
    def GetTitle(self):
815
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 814
diff changeset
    75
        fullname = _(self.Controler.CTNName())
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    76
        if self.Controler.CTNTestModified():
413946c04c87 refactoring
laurent
parents:
diff changeset
    77
            return "~%s~" % fullname
413946c04c87 refactoring
laurent
parents:
diff changeset
    78
        return fullname
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    79
800
e9406586bb14 Fix bug when modifying configuration global variable in ProjectNodeEditor
laurent
parents: 762
diff changeset
    80
    def RefreshView(self, variablepanel=True):
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    81
        ConfTreeNodeEditor.RefreshView(self)
1257
4b7ef7ea318f Fixed bug VariablePanel and ProjectProperties not refreshed in ProjectNodeEditor
Laurent Bessard
parents: 1055
diff changeset
    82
        self.VariableEditorPanel.RefreshView()
4b7ef7ea318f Fixed bug VariablePanel and ProjectProperties not refreshed in ProjectNodeEditor
Laurent Bessard
parents: 1055
diff changeset
    83
        self.ProjectProperties.RefreshView()
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    84
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    85
    def GetBufferState(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    86
        return self.Controler.GetBufferState()
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    87
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    88
    def Undo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    89
        self.Controler.LoadPrevious()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    90
        self.ParentWindow.CloseTabsWithoutModel()
1735
c02818d7e29f clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1511
diff changeset
    91
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    92
    def Redo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    93
        self.Controler.LoadNext()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    94
        self.ParentWindow.CloseTabsWithoutModel()