editors/ProjectNodeEditor.py
author mjsousa
Wed, 21 Oct 2015 15:00:32 +0100
changeset 1475 de4ee16f7c6c
parent 1257 4b7ef7ea318f
child 1511 91538d0c242c
permissions -rw-r--r--
merge
738
413946c04c87 refactoring
laurent
parents:
diff changeset
     1
413946c04c87 refactoring
laurent
parents:
diff changeset
     2
import wx
413946c04c87 refactoring
laurent
parents:
diff changeset
     3
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
     4
from controls import ProjectPropertiesPanel, VariablePanel
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 800
diff changeset
     5
from EditorPanel import EditorPanel
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
     6
from ConfTreeNodeEditor import ConfTreeNodeEditor
738
413946c04c87 refactoring
laurent
parents:
diff changeset
     7
413946c04c87 refactoring
laurent
parents:
diff changeset
     8
class ProjectNodeEditor(ConfTreeNodeEditor):
413946c04c87 refactoring
laurent
parents:
diff changeset
     9
    
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    10
    SHOW_BASE_PARAMS = False
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    11
    ENABLE_REQUIRED = True
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    12
    CONFNODEEDITOR_TABS = [
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    13
        (_("Config variables"), "_create_VariablePanel"),
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    14
        (_("Project properties"), "_create_ProjectPropertiesPanel")]
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    15
    
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    16
    def _create_VariablePanel(self, prnt):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    17
        self.VariableEditorPanel = VariablePanel(prnt, self, self.Controler, "config", self.Debug)
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    18
        self.VariableEditorPanel.SetTagName(self.TagName)
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    19
    
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    20
        return self.VariableEditorPanel
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    21
    
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    22
    def _create_ProjectPropertiesPanel(self, prnt):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    23
        self.ProjectProperties = ProjectPropertiesPanel(prnt, self.Controler, self.ParentWindow, self.ENABLE_REQUIRED)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    24
        
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    25
        return self.ProjectProperties
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    26
    
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    27
    def __init__(self, parent, controler, window):
413946c04c87 refactoring
laurent
parents:
diff changeset
    28
        configuration = controler.GetProjectMainConfigurationName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    29
        if configuration is not None:
413946c04c87 refactoring
laurent
parents:
diff changeset
    30
            tagname = controler.ComputeConfigurationName(configuration)
413946c04c87 refactoring
laurent
parents:
diff changeset
    31
        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
    32
            tagname = ""
413946c04c87 refactoring
laurent
parents:
diff changeset
    33
        
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
    34
        ConfTreeNodeEditor.__init__(self, parent, controler, window, tagname)
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    35
        
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    36
        buttons_sizer = self.GenerateMethodButtonSizer()
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    37
        self.MainSizer.InsertSizer(0, buttons_sizer, 0, border=5, flag=wx.ALL)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    38
        self.MainSizer.Layout()
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 1036
diff changeset
    39
        
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    40
        self.VariableEditor = self.VariableEditorPanel
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    41
413946c04c87 refactoring
laurent
parents:
diff changeset
    42
    def GetTagName(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
    43
        return self.Controler.CTNName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    44
    
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    45
    def SetTagName(self, tagname):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    46
        self.TagName = tagname
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    47
        if self.VariableEditor is not None:
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    48
            self.VariableEditor.SetTagName(tagname)
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    49
    
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    50
    def GetTitle(self):
815
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 814
diff changeset
    51
        fullname = _(self.Controler.CTNName())
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    52
        if self.Controler.CTNTestModified():
413946c04c87 refactoring
laurent
parents:
diff changeset
    53
            return "~%s~" % fullname
413946c04c87 refactoring
laurent
parents:
diff changeset
    54
        return fullname
746
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 743
diff changeset
    55
    
800
e9406586bb14 Fix bug when modifying configuration global variable in ProjectNodeEditor
laurent
parents: 762
diff changeset
    56
    def RefreshView(self, variablepanel=True):
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    57
        ConfTreeNodeEditor.RefreshView(self)
1257
4b7ef7ea318f Fixed bug VariablePanel and ProjectProperties not refreshed in ProjectNodeEditor
Laurent Bessard
parents: 1055
diff changeset
    58
        self.VariableEditorPanel.RefreshView()
4b7ef7ea318f Fixed bug VariablePanel and ProjectProperties not refreshed in ProjectNodeEditor
Laurent Bessard
parents: 1055
diff changeset
    59
        self.ProjectProperties.RefreshView()
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    60
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    61
    def GetBufferState(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    62
        return self.Controler.GetBufferState()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    63
        
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    64
    def Undo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    65
        self.Controler.LoadPrevious()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    66
        self.ParentWindow.CloseTabsWithoutModel()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    67
            
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    68
    def Redo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    69
        self.Controler.LoadNext()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    70
        self.ParentWindow.CloseTabsWithoutModel()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    71