editors/ProjectNodeEditor.py
author laurent
Fri, 07 Sep 2012 18:28:45 +0200
changeset 815 e4f24593a758
parent 814 5743cbdff669
child 920 1499a4d225db
permissions -rw-r--r--
Adding support for extending internationalization to extensions
738
413946c04c87 refactoring
laurent
parents:
diff changeset
     1
413946c04c87 refactoring
laurent
parents:
diff changeset
     2
import wx
413946c04c87 refactoring
laurent
parents:
diff changeset
     3
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 800
diff changeset
     4
from controls import ProjectPropertiesPanel
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 800
diff changeset
     5
from EditorPanel import EditorPanel
738
413946c04c87 refactoring
laurent
parents:
diff changeset
     6
from ConfTreeNodeEditor import ConfTreeNodeEditor, WINDOW_COLOUR
413946c04c87 refactoring
laurent
parents:
diff changeset
     7
413946c04c87 refactoring
laurent
parents:
diff changeset
     8
class ProjectNodeEditor(ConfTreeNodeEditor):
413946c04c87 refactoring
laurent
parents:
diff changeset
     9
    
413946c04c87 refactoring
laurent
parents:
diff changeset
    10
    VARIABLE_PANEL_TYPE = "config"
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    11
    ENABLE_REQUIRED = True
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    12
    
413946c04c87 refactoring
laurent
parents:
diff changeset
    13
    def _init_Editor(self, prnt):
413946c04c87 refactoring
laurent
parents:
diff changeset
    14
        self.Editor = wx.ScrolledWindow(prnt, -1, size=wx.Size(-1, -1),
413946c04c87 refactoring
laurent
parents:
diff changeset
    15
                style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL)
413946c04c87 refactoring
laurent
parents:
diff changeset
    16
        self.Editor.SetBackgroundColour(WINDOW_COLOUR)
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
    17
        self.Editor.Bind(wx.EVT_SIZE, self.OnWindowResize)
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
    18
        self.Editor.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    19
        self.ParamsEditor = self.Editor
413946c04c87 refactoring
laurent
parents:
diff changeset
    20
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    21
        # Variable allowing disabling of Editor scroll when Popup shown 
413946c04c87 refactoring
laurent
parents:
diff changeset
    22
        self.ScrollingEnabled = True
413946c04c87 refactoring
laurent
parents:
diff changeset
    23
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    24
        self.ParamsEditorSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
413946c04c87 refactoring
laurent
parents:
diff changeset
    25
        self.ParamsEditorSizer.AddGrowableCol(0)
413946c04c87 refactoring
laurent
parents:
diff changeset
    26
        self.ParamsEditorSizer.AddGrowableRow(1)
413946c04c87 refactoring
laurent
parents:
diff changeset
    27
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    28
        self.Editor.SetSizer(self.ParamsEditorSizer)
413946c04c87 refactoring
laurent
parents:
diff changeset
    29
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    30
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    31
        buttons_sizer = self.GenerateMethodButtonSizer()
413946c04c87 refactoring
laurent
parents:
diff changeset
    32
        self.ParamsEditorSizer.AddSizer(buttons_sizer, 0, border=5, 
413946c04c87 refactoring
laurent
parents:
diff changeset
    33
                                        flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.TOP)
413946c04c87 refactoring
laurent
parents:
diff changeset
    34
        
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    35
        projectproperties_sizer = wx.BoxSizer(wx.HORIZONTAL)
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    36
        self.ParamsEditorSizer.AddSizer(projectproperties_sizer, 0, border=5, 
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    37
                                        flag=wx.LEFT|wx.RIGHT|wx.BOTTOM)
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    38
        
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    39
        if self.SHOW_PARAMS:
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    40
            self.ConfNodeParamsSizer = wx.BoxSizer(wx.VERTICAL)
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    41
            projectproperties_sizer.AddSizer(self.ConfNodeParamsSizer, 0, border=5, 
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    42
                                             flag=wx.RIGHT)
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    43
        else:
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    44
            self.ConfNodeParamsSizer = None
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    45
        
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    46
        self.ProjectProperties = ProjectPropertiesPanel(self.Editor, self.Controler, self.ParentWindow, self.ENABLE_REQUIRED)
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    47
        projectproperties_sizer.AddWindow(self.ProjectProperties, 0, border=0, flag=0)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    48
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    49
    def __init__(self, parent, controler, window):
413946c04c87 refactoring
laurent
parents:
diff changeset
    50
        configuration = controler.GetProjectMainConfigurationName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    51
        if configuration is not None:
413946c04c87 refactoring
laurent
parents:
diff changeset
    52
            tagname = controler.ComputeConfigurationName(configuration)
413946c04c87 refactoring
laurent
parents:
diff changeset
    53
        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
    54
            tagname = ""
413946c04c87 refactoring
laurent
parents:
diff changeset
    55
        
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
    56
        ConfTreeNodeEditor.__init__(self, parent, controler, window, tagname)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    57
413946c04c87 refactoring
laurent
parents:
diff changeset
    58
    def GetTagName(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
    59
        return self.Controler.CTNName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    60
    
413946c04c87 refactoring
laurent
parents:
diff changeset
    61
    def GetTitle(self):
815
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 814
diff changeset
    62
        fullname = _(self.Controler.CTNName())
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    63
        if self.Controler.CTNTestModified():
413946c04c87 refactoring
laurent
parents:
diff changeset
    64
            return "~%s~" % fullname
413946c04c87 refactoring
laurent
parents:
diff changeset
    65
        return fullname
746
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 743
diff changeset
    66
    
800
e9406586bb14 Fix bug when modifying configuration global variable in ProjectNodeEditor
laurent
parents: 762
diff changeset
    67
    def RefreshView(self, variablepanel=True):
e9406586bb14 Fix bug when modifying configuration global variable in ProjectNodeEditor
laurent
parents: 762
diff changeset
    68
        EditorPanel.RefreshView(self, variablepanel)
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    69
        if self.ConfNodeParamsSizer is not None:
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 756
diff changeset
    70
            self.RefreshConfNodeParamsSizer()
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    71
        self.ProjectProperties.RefreshView()
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    72
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    73
    def GetBufferState(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    74
        return self.Controler.GetBufferState()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    75
        
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    76
    def Undo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    77
        self.Controler.LoadPrevious()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    78
        self.ParentWindow.CloseTabsWithoutModel()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    79
            
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    80
    def Redo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    81
        self.Controler.LoadNext()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    82
        self.ParentWindow.CloseTabsWithoutModel()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    83