editors/ProjectNodeEditor.py
author Laurent Bessard
Thu, 18 Apr 2013 10:19:21 +0200
changeset 1036 a6718197caf2
parent 920 1499a4d225db
child 1055 da483f620668
permissions -rw-r--r--
Fixed bug in ProjectNodeEditor when base params panel is not shown
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
        
1036
a6718197caf2 Fixed bug in ProjectNodeEditor when base params panel is not shown
Laurent Bessard
parents: 920
diff changeset
    36
        if self.SHOW_BASE_PARAMS:
a6718197caf2 Fixed bug in ProjectNodeEditor when base params panel is not shown
Laurent Bessard
parents: 920
diff changeset
    37
            buttons_sizer = self.GenerateMethodButtonSizer()
a6718197caf2 Fixed bug in ProjectNodeEditor when base params panel is not shown
Laurent Bessard
parents: 920
diff changeset
    38
            self.ParamsEditorSizer.InsertSizer(0, buttons_sizer, 0, border=5, 
a6718197caf2 Fixed bug in ProjectNodeEditor when base params panel is not shown
Laurent Bessard
parents: 920
diff changeset
    39
                    flag=wx.LEFT|wx.RIGHT|wx.TOP)
a6718197caf2 Fixed bug in ProjectNodeEditor when base params panel is not shown
Laurent Bessard
parents: 920
diff changeset
    40
            self.ParamsEditorSizer.Layout()
a6718197caf2 Fixed bug in ProjectNodeEditor when base params panel is not shown
Laurent Bessard
parents: 920
diff changeset
    41
            
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    42
        self.VariableEditor = self.VariableEditorPanel
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    43
413946c04c87 refactoring
laurent
parents:
diff changeset
    44
    def GetTagName(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
    45
        return self.Controler.CTNName()
413946c04c87 refactoring
laurent
parents:
diff changeset
    46
    
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    47
    def SetTagName(self, tagname):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    48
        self.TagName = tagname
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    49
        if self.VariableEditor is not None:
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    50
            self.VariableEditor.SetTagName(tagname)
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    51
    
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    52
    def GetTitle(self):
815
e4f24593a758 Adding support for extending internationalization to extensions
laurent
parents: 814
diff changeset
    53
        fullname = _(self.Controler.CTNName())
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    54
        if self.Controler.CTNTestModified():
413946c04c87 refactoring
laurent
parents:
diff changeset
    55
            return "~%s~" % fullname
413946c04c87 refactoring
laurent
parents:
diff changeset
    56
        return fullname
746
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 743
diff changeset
    57
    
800
e9406586bb14 Fix bug when modifying configuration global variable in ProjectNodeEditor
laurent
parents: 762
diff changeset
    58
    def RefreshView(self, variablepanel=True):
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    59
        ConfTreeNodeEditor.RefreshView(self)
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    60
        if variablepanel:
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    61
            self.VariableEditor.RefreshView()
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 815
diff changeset
    62
        #self.ProjectProperties.RefreshView()
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    63
756
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    64
    def GetBufferState(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    65
        return self.Controler.GetBufferState()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    66
        
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    67
    def Undo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    68
        self.Controler.LoadPrevious()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    69
        self.ParentWindow.CloseTabsWithoutModel()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    70
            
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    71
    def Redo(self):
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    72
        self.Controler.LoadNext()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    73
        self.ParentWindow.CloseTabsWithoutModel()
35cd28825be7 Integrating project properties panel into project window
laurent
parents: 746
diff changeset
    74