equal
deleted
inserted
replaced
30 # Create New Connection Dialog |
30 # Create New Connection Dialog |
31 #------------------------------------------------------------------------------- |
31 #------------------------------------------------------------------------------- |
32 |
32 |
33 class ConnectionDialog(wx.Dialog): |
33 class ConnectionDialog(wx.Dialog): |
34 |
34 |
35 def __init__(self, parent, controller): |
35 def __init__(self, parent, controller, apply_button=False): |
36 wx.Dialog.__init__(self, parent, |
36 wx.Dialog.__init__(self, parent, |
37 size=wx.Size(350, 220), title=_('Connection Properties')) |
37 size=wx.Size(350, 220), title=_('Connection Properties')) |
38 |
38 |
39 main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
39 main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
40 main_sizer.AddGrowableCol(0) |
40 main_sizer.AddGrowableCol(0) |
89 |
89 |
90 button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
90 button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
91 self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) |
91 self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) |
92 main_sizer.AddSizer(button_sizer, border=20, |
92 main_sizer.AddSizer(button_sizer, border=20, |
93 flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
93 flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
|
94 |
|
95 if apply_button: |
|
96 self.ApplyToAllButton = wx.Button(self, label=_("Propagate Name")) |
|
97 self.ApplyToAllButton.SetToolTipString( |
|
98 _("Apply name modification to all continuations with the same name")) |
|
99 self.Bind(wx.EVT_BUTTON, self.OnApplyToAll, self.ApplyToAllButton) |
|
100 button_sizer.AddWindow(self.ApplyToAllButton) |
94 |
101 |
95 self.SetSizer(main_sizer) |
102 self.SetSizer(main_sizer) |
96 |
103 |
97 self.Connection = None |
104 self.Connection = None |
98 self.MinConnectionSize = None |
105 self.MinConnectionSize = None |
133 self.PouNames = [pou_name.upper() for pou_name in pou_names] |
140 self.PouNames = [pou_name.upper() for pou_name in pou_names] |
134 |
141 |
135 def SetPouElementNames(self, element_names): |
142 def SetPouElementNames(self, element_names): |
136 self.PouElementNames = [element_name.upper() for element_name in element_names] |
143 self.PouElementNames = [element_name.upper() for element_name in element_names] |
137 |
144 |
138 def OnOK(self, event): |
145 def TestName(self): |
139 message = None |
146 message = None |
140 connection_name = self.ConnectionName.GetValue() |
147 connection_name = self.ConnectionName.GetValue() |
141 if connection_name == "": |
148 if connection_name == "": |
142 message = _("Form isn't complete. Name must be filled!") |
149 message = _("Form isn't complete. Name must be filled!") |
143 elif not TestIdentifier(connection_name): |
150 elif not TestIdentifier(connection_name): |
150 message = _("\"%s\" element for this pou already exists!") % connection_name |
157 message = _("\"%s\" element for this pou already exists!") % connection_name |
151 if message is not None: |
158 if message is not None: |
152 dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) |
159 dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) |
153 dialog.ShowModal() |
160 dialog.ShowModal() |
154 dialog.Destroy() |
161 dialog.Destroy() |
155 else: |
162 return False |
|
163 return True |
|
164 |
|
165 def OnOK(self, event): |
|
166 if self.TestName(): |
156 self.EndModal(wx.ID_OK) |
167 self.EndModal(wx.ID_OK) |
|
168 |
|
169 def OnApplyToAll(self, event): |
|
170 if self.TestName(): |
|
171 self.EndModal(wx.ID_YESTOALL) |
157 |
172 |
158 def OnTypeChanged(self, event): |
173 def OnTypeChanged(self, event): |
159 self.RefreshPreview() |
174 self.RefreshPreview() |
160 event.Skip() |
175 event.Skip() |
161 |
176 |