Package arcjobtool :: Module ClientSettingsDialog
[hide private]
[frames] | no frames]

Source Code for Module arcjobtool.ClientSettingsDialog

  1  # -*- coding: iso-8859-15 -*- 
  2  # generated by wxGlade HG on Mon Jul  6 15:48:44 2009 
  3   
  4  # 
  5  # ClientSettingsDialog main window class 
  6  # 
  7   
  8  """ 
  9  Implements the client settings dialog. 
 10  """ 
 11   
 12  import wx 
 13   
 14  # begin wxGlade: dependencies 
 15  # end wxGlade 
 16   
 17  # begin wxGlade: extracode 
 18   
 19  # end wxGlade 
 20   
 21  import os, sys 
 22   
 23  from wx.lib.dialogs import * 
 24   
25 -class ClientSettingsDialog(wx.Dialog):
26 """ 27 Client settings dialog class 28 29 Displays settings for timeout, broker, automatic download and certificate information. 30 """
31 - def __init__(self, *args, **kwds):
32 """ 33 Class constructor 34 """ 35 self.__applicationDir = os.path.dirname(sys.argv[0]) 36 37 if os.environ.has_key("ARCJOBTOOL_SHARE"): 38 self.__imageDir = os.path.join(os.environ["ARCJOBTOOL_SHARE"], "images") 39 else: 40 self.__imageDir = os.path.join(self.__imageDir, "../share/arcjobtool/images") 41 42 ARCGUI_SELECT_PATH = os.path.join(self.__imageDir, "folder-open.png") 43 44 # begin wxGlade: ClientSettingsDialog.__init__ 45 kwds["style"] = wx.DEFAULT_DIALOG_STYLE 46 wx.Dialog.__init__(self, *args, **kwds) 47 self.settingsNotebook = wx.Notebook(self, -1, style=0) 48 self.generalPane = wx.Panel(self.settingsNotebook, -1) 49 self.timeoutLabel = wx.StaticText(self.generalPane, -1, "Timeout (s)") 50 self.timeOutText = wx.TextCtrl(self.generalPane, -1, "40") 51 self.brokerLabel = wx.StaticText(self.generalPane, -1, "Broker") 52 self.brokerCombo = wx.ComboBox(self.generalPane, -1, choices=["Random"], style=wx.CB_DROPDOWN) 53 self.processingPane = wx.Panel(self.settingsNotebook, -1) 54 self.panel_3 = wx.Panel(self.processingPane, -1) 55 self.automaticDownloadCheck = wx.CheckBox(self.panel_3, -1, "Automatic download to definition") 56 self.downloadTimerIntervalLabel = wx.StaticText(self.panel_3, -1, "Download timer interval (s)") 57 self.automaticDownloadIntervalSpin = wx.SpinCtrl(self.panel_3, -1, "120", min=10, max=3600) 58 self.static_line_2 = wx.StaticLine(self.panel_3, -1) 59 self.automaticUpdateCheck = wx.CheckBox(self.panel_3, -1, "Automatic update of job status") 60 self.automaticUpdateIntervalLabel = wx.StaticText(self.panel_3, -1, "Update timer interval (s)") 61 self.automaticUpdateIntervalSpin = wx.SpinCtrl(self.panel_3, -1, "60", min=10, max=3600) 62 self.certificatesPane = wx.Panel(self.settingsNotebook, -1) 63 self.userCertficiateLabel = wx.StaticText(self.certificatesPane, -1, "User certificate") 64 self.userCertificateText = wx.TextCtrl(self.certificatesPane, -1, "") 65 self.selectUserCertButton = wx.BitmapButton(self.certificatesPane, -1, wx.Bitmap(ARCGUI_SELECT_PATH,wx.BITMAP_TYPE_ANY)) 66 self.userKeyLabel = wx.StaticText(self.certificatesPane, -1, "User key") 67 self.userKeyText = wx.TextCtrl(self.certificatesPane, -1, "") 68 self.selectUserKeyButton = wx.BitmapButton(self.certificatesPane, -1, wx.Bitmap(ARCGUI_SELECT_PATH,wx.BITMAP_TYPE_ANY)) 69 self.CACertificateLabel = wx.StaticText(self.certificatesPane, -1, "CA Certificates") 70 self.CACertificatesText = wx.TextCtrl(self.certificatesPane, -1, "") 71 self.selectCACertDir = wx.BitmapButton(self.certificatesPane, -1, wx.Bitmap(ARCGUI_SELECT_PATH,wx.BITMAP_TYPE_ANY)) 72 self.proxyCertificateLabel = wx.StaticText(self.certificatesPane, -1, "Proxy certificate") 73 self.proxyCertificateText = wx.TextCtrl(self.certificatesPane, -1, "") 74 self.selectProxyCertButton = wx.BitmapButton(self.certificatesPane, -1, wx.Bitmap(ARCGUI_SELECT_PATH,wx.BITMAP_TYPE_ANY)) 75 self.okButton = wx.Button(self, -1, "OK") 76 self.cancelButton = wx.Button(self, -1, "Cancel") 77 78 self.__set_properties() 79 self.__do_layout() 80 81 self.Bind(wx.EVT_CHECKBOX, self.onDownloadToDefinition, self.automaticDownloadCheck) 82 self.Bind(wx.EVT_CHECKBOX, self.onUpdateStatus, self.automaticUpdateCheck) 83 self.Bind(wx.EVT_BUTTON, self.onSelectUserCert, self.selectUserCertButton) 84 self.Bind(wx.EVT_BUTTON, self.onSelectUserKey, self.selectUserKeyButton) 85 self.Bind(wx.EVT_BUTTON, self.onSelectCaDir, self.selectCACertDir) 86 self.Bind(wx.EVT_BUTTON, self.onSelectProxyCert, self.selectProxyCertButton) 87 self.Bind(wx.EVT_BUTTON, self.onOK, self.okButton) 88 self.Bind(wx.EVT_BUTTON, self.onCancel, self.cancelButton) 89 # end wxGlade 90 91 self.__initDialog()
92
93 - def __set_properties(self):
94 # begin wxGlade: ClientSettingsDialog.__set_properties 95 self.SetTitle("Client settings") 96 self.SetSize((459, 316)) 97 self.timeoutLabel.SetMinSize((120, -1)) 98 self.brokerLabel.SetMinSize((120, -1)) 99 self.brokerCombo.SetSelection(-1) 100 self.automaticUpdateCheck.SetValue(1) 101 self.userCertficiateLabel.SetMinSize((120, -1)) 102 self.selectUserCertButton.SetSize(self.selectUserCertButton.GetBestSize()) 103 self.userKeyLabel.SetMinSize((120, -1)) 104 self.selectUserKeyButton.SetSize(self.selectUserKeyButton.GetBestSize()) 105 self.CACertificateLabel.SetMinSize((120, -1)) 106 self.selectCACertDir.SetSize(self.selectCACertDir.GetBestSize()) 107 self.proxyCertificateLabel.SetMinSize((120, -1)) 108 self.selectProxyCertButton.SetSize(self.selectProxyCertButton.GetBestSize())
109 # end wxGlade 110
111 - def __do_layout(self):
112 # begin wxGlade: ClientSettingsDialog.__do_layout 113 sizer_1 = wx.BoxSizer(wx.VERTICAL) 114 sizer_14 = wx.BoxSizer(wx.HORIZONTAL) 115 certificatesVertSizer = wx.BoxSizer(wx.VERTICAL) 116 sizer_16_copy_copy_1_copy = wx.BoxSizer(wx.HORIZONTAL) 117 sizer_16_copy_copy_1 = wx.BoxSizer(wx.HORIZONTAL) 118 sizer_16_copy_copy = wx.BoxSizer(wx.HORIZONTAL) 119 sizer_16_copy = wx.BoxSizer(wx.HORIZONTAL) 120 sizer_18 = wx.BoxSizer(wx.HORIZONTAL) 121 sizer_19 = wx.BoxSizer(wx.VERTICAL) 122 sizer_32 = wx.BoxSizer(wx.HORIZONTAL) 123 sizer_25 = wx.BoxSizer(wx.HORIZONTAL) 124 sizer_15 = wx.BoxSizer(wx.VERTICAL) 125 sizer_17 = wx.BoxSizer(wx.HORIZONTAL) 126 sizer_16 = wx.BoxSizer(wx.HORIZONTAL) 127 sizer_16.Add(self.timeoutLabel, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10) 128 sizer_16.Add(self.timeOutText, 0, 0, 0) 129 sizer_15.Add(sizer_16, 0, wx.ALL|wx.EXPAND, 5) 130 sizer_17.Add(self.brokerLabel, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10) 131 sizer_17.Add(self.brokerCombo, 0, 0, 0) 132 sizer_15.Add(sizer_17, 0, wx.ALL|wx.EXPAND, 5) 133 self.generalPane.SetSizer(sizer_15) 134 sizer_19.Add(self.automaticDownloadCheck, 0, 0, 0) 135 sizer_25.Add((20, 20), 0, 0, 0) 136 sizer_25.Add(self.downloadTimerIntervalLabel, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 4) 137 sizer_25.Add(self.automaticDownloadIntervalSpin, 0, 0, 0) 138 sizer_19.Add(sizer_25, 0, wx.EXPAND, 0) 139 sizer_19.Add(self.static_line_2, 0, wx.TOP|wx.BOTTOM|wx.EXPAND, 4) 140 sizer_19.Add(self.automaticUpdateCheck, 0, 0, 0) 141 sizer_32.Add((20, 20), 0, 0, 0) 142 sizer_32.Add(self.automaticUpdateIntervalLabel, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 4) 143 sizer_32.Add(self.automaticUpdateIntervalSpin, 0, 0, 0) 144 sizer_19.Add(sizer_32, 0, wx.EXPAND, 0) 145 self.panel_3.SetSizer(sizer_19) 146 sizer_18.Add(self.panel_3, 1, wx.ALL|wx.EXPAND, 4) 147 self.processingPane.SetSizer(sizer_18) 148 sizer_16_copy.Add(self.userCertficiateLabel, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10) 149 sizer_16_copy.Add(self.userCertificateText, 1, wx.RIGHT|wx.EXPAND, 6) 150 sizer_16_copy.Add(self.selectUserCertButton, 0, 0, 0) 151 certificatesVertSizer.Add(sizer_16_copy, 0, wx.ALL|wx.EXPAND, 5) 152 sizer_16_copy_copy.Add(self.userKeyLabel, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10) 153 sizer_16_copy_copy.Add(self.userKeyText, 1, wx.RIGHT|wx.EXPAND, 6) 154 sizer_16_copy_copy.Add(self.selectUserKeyButton, 0, 0, 0) 155 certificatesVertSizer.Add(sizer_16_copy_copy, 0, wx.ALL|wx.EXPAND, 5) 156 sizer_16_copy_copy_1.Add(self.CACertificateLabel, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10) 157 sizer_16_copy_copy_1.Add(self.CACertificatesText, 1, wx.RIGHT|wx.EXPAND, 6) 158 sizer_16_copy_copy_1.Add(self.selectCACertDir, 0, 0, 0) 159 certificatesVertSizer.Add(sizer_16_copy_copy_1, 0, wx.ALL|wx.EXPAND, 5) 160 sizer_16_copy_copy_1_copy.Add(self.proxyCertificateLabel, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10) 161 sizer_16_copy_copy_1_copy.Add(self.proxyCertificateText, 1, wx.RIGHT|wx.EXPAND, 6) 162 sizer_16_copy_copy_1_copy.Add(self.selectProxyCertButton, 0, 0, 0) 163 certificatesVertSizer.Add(sizer_16_copy_copy_1_copy, 0, wx.ALL|wx.EXPAND, 5) 164 self.certificatesPane.SetSizer(certificatesVertSizer) 165 self.settingsNotebook.AddPage(self.generalPane, "General") 166 self.settingsNotebook.AddPage(self.processingPane, "Processing") 167 self.settingsNotebook.AddPage(self.certificatesPane, "Certificates") 168 sizer_1.Add(self.settingsNotebook, 1, wx.ALL|wx.EXPAND, 5) 169 sizer_14.Add(self.okButton, 0, wx.RIGHT, 5) 170 sizer_14.Add(self.cancelButton, 0, 0, 0) 171 sizer_1.Add(sizer_14, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 3) 172 self.SetSizer(sizer_1) 173 self.Layout() 174 self.Centre()
175 # end wxGlade 176
177 - def __initDialog(self):
178 """ 179 Initialise dialig instance variables. 180 """ 181 self.__arcGuiConfig = None
182
183 - def getArcGuiConfig(self):
184 """ 185 Return ArcGuiConfig instance 186 """ 187 return self.__arcGuiConfig
188
189 - def setArcGuiConfig(self, arcGuiConfig):
190 """ 191 Assign the ArcGuiConfig instance. 192 193 Assigns all controls values from the ArcGuiConfig instance. 194 """ 195 self.__arcGuiConfig = arcGuiConfig 196 197 self.automaticDownloadCheck.SetValue(self.__arcGuiConfig.automaticDownload) 198 self.automaticDownloadIntervalSpin.SetValue(self.__arcGuiConfig.automaticDownloadInterval/1000) 199 200 if self.__arcGuiConfig.automaticDownload: 201 self.automaticDownloadIntervalSpin.Enable() 202 else: 203 self.automaticDownloadIntervalSpin.Disable() 204 205 self.automaticUpdateCheck.SetValue(self.__arcGuiConfig.automaticUpdate) 206 self.automaticUpdateIntervalSpin.SetValue(self.__arcGuiConfig.automaticUpdateInterval/1000) 207 208 if self.__arcGuiConfig.automaticUpdate: 209 self.automaticUpdateIntervalSpin.Enable() 210 else: 211 self.automaticUpdateIntervalSpin.Disable() 212 213 self.brokerCombo.SetValue(str(self.__arcGuiConfig.brokerName)) 214 self.timeOutText.SetValue(str(self.__arcGuiConfig.timeout)) 215 self.userCertificateText.SetValue(str(self.__arcGuiConfig.certificatePath)) 216 self.userKeyText.SetValue(str(self.__arcGuiConfig.keyPath)) 217 self.proxyCertificateText.SetValue(str(self.__arcGuiConfig.proxyPath)) 218 self.CACertificatesText.SetValue(str(self.__arcGuiConfig.cacertificatesDirectory))
219
220 - def onDownloadToDefinition(self, event): # wxGlade: ClientSettingsDialog.<event_handler>
221 """ 222 Event method handling download to definition checkbox. 223 """ 224 if self.automaticDownloadCheck.GetValue() == True: 225 self.automaticDownloadIntervalSpin.Enable() 226 else: 227 self.automaticDownloadIntervalSpin.Disable()
228
229 - def onUpdateStatus(self, event): # wxGlade: ClientSettingsDialog.<event_handler>
230 """ 231 Event method handling automatic update check box. 232 """ 233 if self.automaticUpdateCheck.GetValue() == True: 234 self.automaticUpdateIntervalSpin.Enable() 235 else: 236 self.automaticUpdateIntervalSpin.Disable() 237
238 - def onOK(self, event): # wxGlade: ClientSettingsDialog.<event_handler>
239 """ 240 Event method handling a click on the OK button. 241 242 Assigns the ArcGuiConfig instance the contents of the dialog controls. 243 """ 244 245 self.__arcGuiConfig.timeout = int(self.timeOutText.GetValue()) 246 self.__arcGuiConfig.brokerName = str(self.brokerCombo.GetValue()) 247 self.__arcGuiConfig.certificatePath = self.userCertificateText.GetValue() 248 self.__arcGuiConfig.keyPath = self.userKeyText.GetValue() 249 self.__arcGuiConfig.proxyPath = self.proxyCertificateText.GetValue() 250 self.__arcGuiConfig.cacertificatesDirectory = self.CACertificatesText.GetValue() 251 self.__arcGuiConfig.automaticDownload = bool(self.automaticDownloadCheck.GetValue()) 252 self.__arcGuiConfig.automaticDownloadInterval = int(self.automaticDownloadIntervalSpin.GetValue()*1000) 253 self.__arcGuiConfig.automaticUpdate = bool(self.automaticUpdateCheck.GetValue()) 254 self.__arcGuiConfig.automaticUpdateInterval = int(self.automaticUpdateIntervalSpin.GetValue()*1000) 255 self.__arcGuiConfig.update() 256 self.Close() 257
258 - def onCancel(self, event): # wxGlade: ClientSettingsDialog.<event_handler>
259 """ 260 Event method handling a click on the Cancel button. 261 262 Closes the dialog 263 """ 264 self.Close() 265
266 - def onSelectUserCert(self, event): # wxGlade: ClientSettingsDialog.<event_handler>
267 """ 268 Event method handling the button for selecting a user certificate. 269 """ 270 inputFilename = wx.FileSelector("Select user certificate", default_path=os.getcwd()) 271 if inputFilename != "": 272 self.userCertificateText.SetValue(inputFilename) 273
274 - def onSelectUserKey(self, event): # wxGlade: ClientSettingsDialog.<event_handler>
275 """ 276 Event method handling the button for selecting a user key. 277 """ 278 inputFilename = wx.FileSelector("Select user key", default_path=os.getcwd()) 279 if inputFilename != "": 280 self.userKeyText.SetValue(inputFilename) 281
282 - def onSelectCaDir(self, event): # wxGlade: ClientSettingsDialog.<event_handler>
283 """ 284 Event method handling the button for selecting a CA certificate directory. 285 """ 286 dlg = wx.DirDialog(self, "Choose a CA directory", os.getcwd()) 287 if dlg.ShowModal() == wx.ID_OK: 288 self.CACertificatesText.SetValue(dlg.GetPath()) 289 else: 290 return 291
292 - def onSelectProxyCert(self, event): # wxGlade: ClientSettingsDialog.<event_handler>
293 """ 294 Event method handling the button for selecting proxy certificate location. 295 """ 296 inputFilename = wx.FileSelector("Select user proxy", default_path=os.getcwd()) 297 if inputFilename != "": 298 self.proxyCertificateText.SetValue(inputFilename) 299 300 arcGuiConfig = property(getArcGuiConfig, setArcGuiConfig) 301 302 303 304 305 # end of class ClientSettingsDialog 306