PLCOpenEditor.py
changeset 555 b6f9d08fd69f
parent 540 82fa901a2160
child 559 984c51d1bf6b
--- a/PLCOpenEditor.py	Fri Sep 09 17:19:35 2011 +0200
+++ b/PLCOpenEditor.py	Tue Sep 13 13:01:04 2011 +0200
@@ -2194,8 +2194,10 @@
         dialog = DataTypeDialog(self, _("Add a new data type"), _("Please enter data type name"), "", wx.OK|wx.CANCEL)
         dialog.SetDataTypeNames(self.Controler.GetProjectDataTypeNames())
         if dialog.ShowModal() == wx.ID_OK:
-            self.Controler.ProjectAddDataType(dialog.GetValue())
-            self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE)
+            tagname = self.Controler.ProjectAddDataType(dialog.GetValue())
+            if tagname is not None:
+                self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE)
+                self.EditProjectElement(ITEM_DATATYPE, tagname)
         dialog.Destroy()
 
     def GenerateAddPouFunction(self, pou_type):
@@ -2205,8 +2207,10 @@
             dialog.SetPouElementNames(self.Controler.GetProjectPouVariables())
             if dialog.ShowModal() == wx.ID_OK:
                 values = dialog.GetValues()
-                self.Controler.ProjectAddPou(values["pouName"], values["pouType"], values["language"])
-                self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE, LIBRARYTREE)
+                tagname = self.Controler.ProjectAddPou(values["pouName"], values["pouType"], values["language"])
+                if tagname is not None:
+                    self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE, LIBRARYTREE)
+                    self.EditProjectElement(ITEM_POU, tagname)
             dialog.Destroy()
         return OnAddPouMenu
 
@@ -2217,9 +2221,11 @@
             dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(pou_name))
             if dialog.ShowModal() == wx.ID_OK: 
                 values = dialog.GetValues()
-                self.Controler.ProjectAddPouTransition(pou_name, values["transitionName"], values["language"])
-                self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE)
-                dialog.Destroy()
+                tagname = self.Controler.ProjectAddPouTransition(pou_name, values["transitionName"], values["language"])
+                if tagname is not None:
+                    self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE)
+                    self.EditProjectElement(ITEM_TRANSITION, tagname)
+            dialog.Destroy()
         return OnAddTransitionMenu
 
     def GenerateAddActionFunction(self, pou_name):
@@ -2229,8 +2235,10 @@
             dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(pou_name))
             if dialog.ShowModal() == wx.ID_OK:
                 values = dialog.GetValues()
-                self.Controler.ProjectAddPouAction(pou_name, values["actionName"], values["language"])
-                self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE)
+                tagname = self.Controler.ProjectAddPouAction(pou_name, values["actionName"], values["language"])
+                if tagname is not None:
+                    self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE)
+                    self.EditProjectElement(ITEM_ACTION, tagname)
             dialog.Destroy()
         return OnAddActionMenu
 
@@ -2240,8 +2248,10 @@
         dialog.SetPouElementNames(self.Controler.GetProjectPouVariables())
         if dialog.ShowModal() == wx.ID_OK:
             value = dialog.GetValue()
-            self.Controler.ProjectAddConfiguration(value)
-            self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE, INSTANCESTREE)
+            tagname = self.Controler.ProjectAddConfiguration(value)
+            if tagname is not None:
+                self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE, INSTANCESTREE)
+                self.EditProjectElement(ITEM_CONFIGURATION, tagname)
         dialog.Destroy()
 
     def GenerateAddResourceFunction(self, config_name):
@@ -2251,8 +2261,10 @@
             dialog.SetPouElementNames(self.Controler.GetProjectPouVariables())
             if dialog.ShowModal() == wx.ID_OK:
                 value = dialog.GetValue()
-                self.Controler.ProjectAddConfigurationResource(config_name, value)
-                self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE, INSTANCESTREE)
+                tagname = self.Controler.ProjectAddConfigurationResource(config_name, value)
+                if tagname is not None:
+                    self._Refresh(TITLE, FILEMENU, EDITMENU, TYPESTREE, INSTANCESTREE)
+                    self.EditProjectElement(ITEM_RESOURCE, tagname)
             dialog.Destroy()
         return OnAddResourceMenu
 
@@ -2264,15 +2276,6 @@
                 self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, TYPESTREE, LIBRARYTREE)
         return OnChangePouTypeMenu
 
-    def OnCreatePouFromMenu(self, event):
-        selected = self.TypesTree.GetSelection()
-        if self.TypesTree.GetPyData(selected) == ITEM_POU: 
-            dialog = PouNameDialog(self, _("Please enter POU name"), _("Create a new POU from"), "", wx.OK|wx.CANCEL)
-            dialog.SetPouNames(self.Controler.GetProjectPouNames())
-            if dialog.ShowModal() == wx.ID_OK:
-                self.Controler.ProjectCreatePouFrom(dialog.GetValue(), self.TypesTree.GetItemText(selected))
-                self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, TYPESTREE, LIBRARYTREE)
-
     def OnCopyPou(self, event):
         selected = self.TypesTree.GetSelection()
         pou_name = self.TypesTree.GetItemText(selected)
@@ -2735,7 +2738,7 @@
               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
         
         self.staticText1 = wx.StaticText(id=ID_SCALINGPANELSTATICTEXT1,
-              label=_('X Scale:'), name='staticText1', parent=self,
+              label=_('Horizontal:'), name='staticText1', parent=self,
               pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
         
         self.XScale = wx.SpinCtrl(id=ID_SCALINGPANELXSCALE,
@@ -2743,7 +2746,7 @@
               size=wx.Size(0, 24), style=0, min=0, max=2**16)
         
         self.staticText2 = wx.StaticText(id=ID_SCALINGPANELSTATICTEXT2,
-              label=_('Y Scale:'), name='staticText2', parent=self,
+              label=_('Vertical:'), name='staticText2', parent=self,
               pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
         
         self.YScale = wx.SpinCtrl(id=ID_SCALINGPANELYSCALE,
@@ -3008,7 +3011,7 @@
               size=wx.Size(0, 24), style=0, min=0, max=2**16)
         
         self.staticText15 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT15,
-              label=_('Scaling:'), name='staticText15', parent=self.GraphicsPanel,
+              label=_('Grid Resolution:'), name='staticText15', parent=self.GraphicsPanel,
               pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
         
         self.ScalingNotebook = wx.Notebook(id=ID_PROJECTDIALOGSCALINGNOTEBOOK,