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