editors/ProjectNodeEditor.py
author Edouard Tisserant 7BB06627 <edouard.tisserant@gmail.com>
Tue, 24 Jan 2017 01:09:54 +0100
branch1.2
changeset 1641 24168e52fc2b
parent 1511 91538d0c242c
child 1735 c02818d7e29f
permissions -rw-r--r--
1.2rc1
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
413946c04c87 refactoring
laurent
parents:
diff changeset
    31
class ProjectNodeEditor(ConfTreeNodeEditor):
413946c04c87 refactoring
laurent
parents:
diff changeset
    32
    
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    33
    SHOW_BASE_PARAMS = False
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    34
    ENABLE_REQUIRED = True
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    35
    CONFNODEEDITOR_TABS = [
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    36
        (_("Config variables"), "_create_VariablePanel"),
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    37
        (_("Project properties"), "_create_ProjectPropertiesPanel")]
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    38
    
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    39
    def _create_VariablePanel(self, prnt):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    40
        self.VariableEditorPanel = VariablePanel(prnt, self, self.Controler, "config", self.Debug)
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    41
        self.VariableEditorPanel.SetTagName(self.TagName)
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    42
    
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    43
        return self.VariableEditorPanel
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    44
    
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    45
    def _create_ProjectPropertiesPanel(self, prnt):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    46
        self.ProjectProperties = ProjectPropertiesPanel(prnt, self.Controler, self.ParentWindow, self.ENABLE_REQUIRED)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    47
        
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    48
        return self.ProjectProperties
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    49
    
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    50
    def __init__(self, parent, controler, window):
413946c04c87 refactoring
laurent
parents:
diff changeset
    51
        configuration = controler.GetProjectMainConfigurationName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    52
        if configuration is not None:
413946c04c87 refactoring
laurent
parents:
diff changeset
    53
            tagname = controler.ComputeConfigurationName(configuration)
413946c04c87 refactoring
laurent
parents:
diff changeset
    54
        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
    55
            tagname = ""
413946c04c87 refactoring
laurent
parents:
diff changeset
    56
        
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
    57
        ConfTreeNodeEditor.__init__(self, parent, controler, window, tagname)
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    58
        
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    59
        buttons_sizer = self.GenerateMethodButtonSizer()
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    60
        self.MainSizer.InsertSizer(0, buttons_sizer, 0, border=5, flag=wx.ALL)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    61
        self.MainSizer.Layout()
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    62
        
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    63
        self.VariableEditor = self.VariableEditorPanel
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    64
413946c04c87 refactoring
laurent
parents:
diff changeset
    65
    def GetTagName(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
    66
        return self.Controler.CTNName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    67
    
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    68
    def SetTagName(self, tagname):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    69
        self.TagName = tagname
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    70
        if self.VariableEditor is not None:
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    71
            self.VariableEditor.SetTagName(tagname)
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    72
    
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    73
    def GetTitle(self):
815
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 814
diff changeset
    74
        fullname = _(self.Controler.CTNName())
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    75
        if self.Controler.CTNTestModified():
413946c04c87 refactoring
laurent
parents:
diff changeset
    76
            return "~%s~" % fullname
413946c04c87 refactoring
laurent
parents:
diff changeset
    77
        return fullname
746
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 743
diff changeset
    78
    
800
e9406586bb14 Fix bug when modifying configuration global variable in ProjectNodeEditor
laurent
parents: 762
diff changeset
    79
    def RefreshView(self, variablepanel=True):
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    80
        ConfTreeNodeEditor.RefreshView(self)
1257
4b7ef7ea318f Fixed bug VariablePanel and ProjectProperties not refreshed in ProjectNodeEditor
Laurent Bessard
parents: 1055
diff changeset
    81
        self.VariableEditorPanel.RefreshView()
4b7ef7ea318f Fixed bug VariablePanel and ProjectProperties not refreshed in ProjectNodeEditor
Laurent Bessard
parents: 1055
diff changeset
    82
        self.ProjectProperties.RefreshView()
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    83
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    84
    def GetBufferState(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    85
        return self.Controler.GetBufferState()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    86
        
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    87
    def Undo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    88
        self.Controler.LoadPrevious()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    89
        self.ParentWindow.CloseTabsWithoutModel()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    90
            
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    91
    def Redo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    92
        self.Controler.LoadNext()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    93
        self.ParentWindow.CloseTabsWithoutModel()
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1257
diff changeset
    94