ProjectNodeEditor.py
author Edouard Tisserant
Thu, 07 Jun 2012 01:14:58 +0200
changeset 761 7788545f4137
parent 756 35cd28825be7
child 762 aaacc83aa86b
permissions -rw-r--r--
(none)
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"
413946c04c87 refactoring
laurent
parents:
diff changeset
    10
    
413946c04c87 refactoring
laurent
parents:
diff changeset
    11
    def _init_Editor(self, prnt):
413946c04c87 refactoring
laurent
parents:
diff changeset
    12
        self.Editor = wx.ScrolledWindow(prnt, -1, size=wx.Size(-1, -1),
413946c04c87 refactoring
laurent
parents:
diff changeset
    13
                style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL)
413946c04c87 refactoring
laurent
parents:
diff changeset
    14
        self.Editor.SetBackgroundColour(WINDOW_COLOUR)
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
    15
        self.Editor.Bind(wx.EVT_SIZE, self.OnWindowResize)
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
    16
        self.Editor.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    17
        self.ParamsEditor = self.Editor
413946c04c87 refactoring
laurent
parents:
diff changeset
    18
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    19
        # Variable allowing disabling of Editor scroll when Popup shown 
413946c04c87 refactoring
laurent
parents:
diff changeset
    20
        self.ScrollingEnabled = True
413946c04c87 refactoring
laurent
parents:
diff changeset
    21
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    22
        self.ParamsEditorSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
413946c04c87 refactoring
laurent
parents:
diff changeset
    23
        self.ParamsEditorSizer.AddGrowableCol(0)
413946c04c87 refactoring
laurent
parents:
diff changeset
    24
        self.ParamsEditorSizer.AddGrowableRow(1)
413946c04c87 refactoring
laurent
parents:
diff changeset
    25
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    26
        self.Editor.SetSizer(self.ParamsEditorSizer)
413946c04c87 refactoring
laurent
parents:
diff changeset
    27
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    28
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    29
        buttons_sizer = self.GenerateMethodButtonSizer()
413946c04c87 refactoring
laurent
parents:
diff changeset
    30
        self.ParamsEditorSizer.AddSizer(buttons_sizer, 0, border=5, 
413946c04c87 refactoring
laurent
parents:
diff changeset
    31
                                        flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.TOP)
413946c04c87 refactoring
laurent
parents:
diff changeset
    32
        
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    33
        projectproperties_sizer = wx.BoxSizer(wx.HORIZONTAL)
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    34
        self.ParamsEditorSizer.AddSizer(projectproperties_sizer, 0, border=5, 
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    35
                                        flag=wx.LEFT|wx.RIGHT|wx.BOTTOM)
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    36
        
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    37
        self.ConfNodeParamsSizer = wx.BoxSizer(wx.VERTICAL)
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    38
        projectproperties_sizer.AddSizer(self.ConfNodeParamsSizer, 0, border=5, 
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    39
                                         flag=wx.RIGHT)
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    40
        
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    41
        self.ProjectProperties = ProjectPropertiesPanel(self.Editor, self.Controler, self.ParentWindow)
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    42
        projectproperties_sizer.AddWindow(self.ProjectProperties, 0, border=0, flag=0)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    43
        
413946c04c87 refactoring
laurent
parents:
diff changeset
    44
    def __init__(self, parent, controler, window):
413946c04c87 refactoring
laurent
parents:
diff changeset
    45
        configuration = controler.GetProjectMainConfigurationName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    46
        if configuration is not None:
413946c04c87 refactoring
laurent
parents:
diff changeset
    47
            tagname = controler.ComputeConfigurationName(configuration)
413946c04c87 refactoring
laurent
parents:
diff changeset
    48
        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
    49
            tagname = ""
413946c04c87 refactoring
laurent
parents:
diff changeset
    50
        
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
    51
        ConfTreeNodeEditor.__init__(self, parent, controler, window, tagname)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    52
413946c04c87 refactoring
laurent
parents:
diff changeset
    53
    def GetTagName(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
    54
        return self.Controler.CTNName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    55
    
413946c04c87 refactoring
laurent
parents:
diff changeset
    56
    def GetTitle(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
    57
        fullname = self.Controler.CTNName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    58
        if self.Controler.CTNTestModified():
413946c04c87 refactoring
laurent
parents:
diff changeset
    59
            return "~%s~" % fullname
413946c04c87 refactoring
laurent
parents:
diff changeset
    60
        return fullname
746
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 743
diff changeset
    61
    
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 743
diff changeset
    62
    def RefreshView(self):
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 743
diff changeset
    63
        EditorPanel.RefreshView(self)
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 743
diff changeset
    64
        self.RefreshConfNodeParamsSizer()
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    65
        self.ProjectProperties.RefreshView()
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    66
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    67
    def GetBufferState(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    68
        return self.Controler.GetBufferState()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    69
        
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    70
    def Undo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    71
        self.Controler.LoadPrevious()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    72
        self.ParentWindow.CloseTabsWithoutModel()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    73
            
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    74
    def Redo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    75
        self.Controler.LoadNext()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    76
        self.ParentWindow.CloseTabsWithoutModel()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    77