dialogs/ConnectionDialog.py
changeset 856 b64e436f000e
parent 814 5743cbdff669
child 1245 d34ba528346b
--- a/dialogs/ConnectionDialog.py	Thu Oct 18 01:22:52 2012 +0200
+++ b/dialogs/ConnectionDialog.py	Thu Oct 18 12:05:45 2012 +0200
@@ -32,7 +32,7 @@
 
 class ConnectionDialog(wx.Dialog):
     
-    def __init__(self, parent, controller):
+    def __init__(self, parent, controller, apply_button=False):
         wx.Dialog.__init__(self, parent,
               size=wx.Size(350, 220), title=_('Connection Properties'))
         
@@ -92,6 +92,13 @@
         main_sizer.AddSizer(button_sizer, border=20, 
               flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
         
+        if apply_button:
+            self.ApplyToAllButton = wx.Button(self, label=_("Propagate Name"))
+            self.ApplyToAllButton.SetToolTipString(
+                _("Apply name modification to all continuations with the same name"))
+            self.Bind(wx.EVT_BUTTON, self.OnApplyToAll, self.ApplyToAllButton)
+            button_sizer.AddWindow(self.ApplyToAllButton)
+        
         self.SetSizer(main_sizer)
         
         self.Connection = None
@@ -135,7 +142,7 @@
     def SetPouElementNames(self, element_names):
         self.PouElementNames = [element_name.upper() for element_name in element_names]
     
-    def OnOK(self, event):
+    def TestName(self):
         message = None
         connection_name = self.ConnectionName.GetValue()
         if connection_name == "":
@@ -152,9 +159,17 @@
             dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
             dialog.ShowModal()
             dialog.Destroy()
-        else:
+            return False
+        return True
+        
+    def OnOK(self, event):
+        if self.TestName():
             self.EndModal(wx.ID_OK)
 
+    def OnApplyToAll(self, event):
+        if self.TestName():
+            self.EndModal(wx.ID_YESTOALL)
+
     def OnTypeChanged(self, event):
         self.RefreshPreview()
         event.Skip()