andrej@1511: #!/usr/bin/env python
andrej@1511: # -*- coding: utf-8 -*-
andrej@1511: 
andrej@1511: # This file is part of Beremiz, a Integrated Development Environment for
andrej@1511: # programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
andrej@1511: #
andrej@1511: # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
andrej@1511: #
andrej@1511: # See COPYING file for copyrights details.
andrej@1511: #
andrej@1511: # This program is free software; you can redistribute it and/or
andrej@1511: # modify it under the terms of the GNU General Public License
andrej@1511: # as published by the Free Software Foundation; either version 2
andrej@1511: # of the License, or (at your option) any later version.
andrej@1511: #
andrej@1511: # This program is distributed in the hope that it will be useful,
andrej@1511: # but WITHOUT ANY WARRANTY; without even the implied warranty of
andrej@1511: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
andrej@1511: # GNU General Public License for more details.
andrej@1511: #
andrej@1511: # You should have received a copy of the GNU General Public License
andrej@1511: # along with this program; if not, write to the Free Software
andrej@1511: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
laurent@738: 
andrej@1853: 
andrej@1853: from __future__ import absolute_import
laurent@738: import wx
laurent@738: 
Laurent@920: from controls import ProjectPropertiesPanel, VariablePanel
andrej@1853: from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
Edouard@1948: from plcopen.types_enums import ComputeConfigurationName
laurent@738: 
andrej@1736: 
laurent@738: class ProjectNodeEditor(ConfTreeNodeEditor):
andrej@1735: 
Laurent@920:     SHOW_BASE_PARAMS = False
laurent@762:     ENABLE_REQUIRED = True
Laurent@920:     CONFNODEEDITOR_TABS = [
Laurent@920:         (_("Config variables"), "_create_VariablePanel"),
Laurent@920:         (_("Project properties"), "_create_ProjectPropertiesPanel")]
andrej@1735: 
Laurent@920:     def _create_VariablePanel(self, prnt):
Laurent@920:         self.VariableEditorPanel = VariablePanel(prnt, self, self.Controler, "config", self.Debug)
Laurent@920:         self.VariableEditorPanel.SetTagName(self.TagName)
andrej@1735: 
Laurent@920:         return self.VariableEditorPanel
andrej@1735: 
Laurent@920:     def _create_ProjectPropertiesPanel(self, prnt):
Laurent@920:         self.ProjectProperties = ProjectPropertiesPanel(prnt, self.Controler, self.ParentWindow, self.ENABLE_REQUIRED)
andrej@1735: 
Laurent@920:         return self.ProjectProperties
andrej@1735: 
laurent@738:     def __init__(self, parent, controler, window):
Edouard@1958:         configuration = controler.GetProjectMainConfigurationName()
laurent@738:         if configuration is not None:
Edouard@1948:             tagname = ComputeConfigurationName(configuration)
laurent@738:         else:
laurent@738:             tagname = ""
andrej@1735: 
laurent@743:         ConfTreeNodeEditor.__init__(self, parent, controler, window, tagname)
andrej@1735: 
Laurent@1055:         buttons_sizer = self.GenerateMethodButtonSizer()
Laurent@1055:         self.MainSizer.InsertSizer(0, buttons_sizer, 0, border=5, flag=wx.ALL)
Laurent@1055:         self.MainSizer.Layout()
andrej@1735: 
Laurent@920:         self.VariableEditor = self.VariableEditorPanel
laurent@738: 
laurent@738:     def GetTagName(self):
laurent@738:         return self.Controler.CTNName()
andrej@1735: 
Laurent@920:     def SetTagName(self, tagname):
Laurent@920:         self.TagName = tagname
Laurent@920:         if self.VariableEditor is not None:
Laurent@920:             self.VariableEditor.SetTagName(tagname)
andrej@1735: 
laurent@738:     def GetTitle(self):
laurent@815:         fullname = _(self.Controler.CTNName())
laurent@738:         if self.Controler.CTNTestModified():
laurent@738:             return "~%s~" % fullname
laurent@738:         return fullname
andrej@1735: 
laurent@800:     def RefreshView(self, variablepanel=True):
Laurent@920:         ConfTreeNodeEditor.RefreshView(self)
Laurent@1257:         self.VariableEditorPanel.RefreshView()
Laurent@1257:         self.ProjectProperties.RefreshView()
laurent@738: 
laurent@756:     def GetBufferState(self):
laurent@756:         return self.Controler.GetBufferState()
andrej@1735: 
laurent@756:     def Undo(self):
laurent@756:         self.Controler.LoadPrevious()
laurent@756:         self.ParentWindow.CloseTabsWithoutModel()
andrej@1735: 
laurent@756:     def Redo(self):
laurent@756:         self.Controler.LoadNext()
laurent@756:         self.ParentWindow.CloseTabsWithoutModel()