class ZLinkDialog(ZValidatingHeaderDialog, ZPersistentDialogMixin): def __init__(self, parent, model): self.model = model ZValidatingHeaderDialog.__init__(self, parent, wx.ID_ANY, _extstr(u"linkdialog.EnterLinkInfo"), style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, name = u"ZLinkDialog") #$NON-NLS-2$ #$NON-NLS-1$ bestHeight = self.GetBestSizeTuple()[1] self.SetMinSize(wx.Size(-1, bestHeight)) ZPersistentDialogMixin.__init__(self, IZBlogAppUserPrefsKeys.LINK_DIALOG, True, True) # end __init__() def _createNonHeaderWidgets(self): wildcard = u"all files|*.*" #$NON-NLS-1$ self.filePicker = wx.FilePickerCtrl(self, wildcard=wildcard,style=wx.FLP_OPEN|wx.FLP_FILE_MUST_EXIST )#|wx.FLP_USE_TEXTCTRL) self.urlLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"linkdialog.URL")) #$NON-NLS-1$ #$NON-NLS-2$ self.titleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"linkdialog.Title")) #$NON-NLS-1$ #$NON-NLS-2$ self.targetLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"linkdialog.Target")) #$NON-NLS-1$ #$NON-NLS-2$ self.classLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"linkdialog.Class")) #$NON-NLS-1$ #$NON-NLS-2$ self.relLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"linkdialog.Rel")) #$NON-NLS-1$ #$NON-NLS-2$ self.urlText = ZValidatingTextCtrl(ZFileUrlSelectionValidator(_extstr(u"linkdialog.InvalidURLError")), self, wx.ID_ANY) #$NON-NLS-1$ self.titleText = wx.TextCtrl(self, wx.ID_ANY) self.newWindowCB = wx.CheckBox(self, wx.ID_ANY, _extstr(u"linkdialog.OpenInNewWindow")) #$NON-NLS-1$ self.targetText = wx.TextCtrl(self, wx.ID_ANY) self.classText = wx.TextCtrl(self, wx.ID_ANY) self.relText = wx.TextCtrl(self, wx.ID_ANY) # end _createNonHeaderWidgets() def _populateNonHeaderWidgets(self): self.urlText.SetValue( getSafeString( self.model.getAttribute(u"href") ) ) #$NON-NLS-1$ self.titleText.SetValue( getSafeString( self.model.getAttribute(u"title") ) ) #$NON-NLS-1$ self.targetText.SetValue( getSafeString( self.model.getAttribute(u"target") ) ) #$NON-NLS-1$ self.newWindowCB.SetValue( self.model.isOpenInNewWindow() ) self.classText.SetValue( getSafeString( self.model.getAttribute(u"class") ) ) #$NON-NLS-1$ self.relText.SetValue( getSafeString( self.model.getAttribute(u"rel") ) ) #$NON-NLS-1$ if not self.model.isEditMode() and not self.urlText.GetValue(): self.urlText.SetValue(u'http://') #$NON-NLS-1$ # end _populateNonHeaderWidgets() def _updateModel(self): self.model.setAttribute(u"href", self.urlText.GetValue().strip()) #$NON-NLS-1$ self.model.setAttribute(u"title", self.titleText.GetValue().strip() ) #$NON-NLS-1$ self.model.setAttribute(u"class", self.classText.GetValue().strip() ) #$NON-NLS-1$ self.model.setAttribute(u"rel", self.relText.GetValue().strip()) #$NON-NLS-1$ if self.newWindowCB.IsChecked(): target = self.targetText.GetValue().strip() if target == u"": #$NON-NLS-1$ target = u"_blank" #$NON-NLS-1$ self.model.setAttribute(u"target", target) #$NON-NLS-1$ elif self.model.isOpenInNewWindow(): # remove target attr. self.model.setAttribute(u"target", None) #$NON-NLS-1$ # end _updateModel() def _layoutNonHeaderWidgets(self): hrefAndFileSizer = wx.BoxSizer(wx.HORIZONTAL) hrefAndFileSizer.Add(self.urlText, 1, wx.EXPAND | wx.ALL, 1) hrefAndFileSizer.Add(self.filePicker, 0, wx.ALL, 1) flexGridSizer = wx.FlexGridSizer(6, 2, 2, 2) flexGridSizer.AddGrowableCol(1) flexGridSizer.Add(self.urlLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2) flexGridSizer.AddSizer(hrefAndFileSizer, 1, wx.EXPAND | wx.ALL, 2) flexGridSizer.Add(self.titleLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2) flexGridSizer.Add(self.titleText, 1, wx.EXPAND | wx.ALL, 2) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY, u""), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2) #$NON-NLS-1$ flexGridSizer.Add(self.newWindowCB, 1, wx.EXPAND | wx.ALL, 2) flexGridSizer.Add(self.targetLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2) flexGridSizer.Add(self.targetText, 1, wx.EXPAND | wx.ALL, 2) flexGridSizer.Add(self.classLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2) flexGridSizer.Add(self.classText, 1, wx.EXPAND | wx.ALL, 2) flexGridSizer.Add(self.relLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 2) flexGridSizer.Add(self.relText, 1, wx.EXPAND | wx.ALL, 2) staticBoxSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, _extstr(u"linkdialog.LinkProperties")), wx.VERTICAL) #$NON-NLS-1$ staticBoxSizer.AddSizer(flexGridSizer, 1, wx.EXPAND | wx.ALL, 5) self.targetText.Enable(False) return staticBoxSizer # end _layoutNonHeaderWidgets() def _setInitialFocus(self): self.urlText.SetFocus() if not self.model.isEditMode() and self.urlText.GetValue() and u"http://" != self.urlText.GetValue(): #$NON-NLS-1$ self.urlText.SetSelection(-1, -1) else: self.urlText.SetInsertionPointEnd() # end _setInitialFocus() def _bindWidgetEvents(self): self._bindValidatingWidget(self.urlText) self.Bind(wx.EVT_CHECKBOX, self.onNewWindowCB, self.newWindowCB) self.Bind(wx.EVT_BUTTON, self.onOK, self.FindWindowById(wx.ID_OK)) self.Bind(wx.EVT_FILEPICKER_CHANGED, self.onFilePickerChanged, self.filePicker) # end _bindWidgetEvents() def onOK(self, event): # persist settings to model. self._updateModel() event.Skip() # end onOK() def onFilePickerChanged(self, event): path = getNoneString( event.GetPath()) if path: self.urlText.SetValue(path) event.Skip() # end onFilePickerChanged def onNewWindowCB(self, event): self.targetText.Enable(event.IsChecked()) # end onNewWindowCB() def _getHeaderTitle(self): if self.model.isEditMode(): return _extstr(u"linkdialog.EditHyperlink") #$NON-NLS-1$ else: return _extstr(u"linkdialog.CreateHyperlink") #$NON-NLS-1$ # end _getHeaderTitle() def _getHeaderMessage(self): return _extstr(u"linkdialog.LinkDialogDescription") #$NON-NLS-1$ # end _getHeaderMessage() def _getHeaderImagePath(self): return u"images/dialogs/link/header_image.png" #$NON-NLS-1$ # end _getHeaderImagePath() def _getButtonTypes(self): return ZBaseDialog.OK_BUTTON | ZBaseDialog.CANCEL_BUTTON
class ZNewProfileDialog(ZValidatingHeaderDialog): def __init__(self, parent, profilesModel): self.profilesModel = profilesModel ZValidatingHeaderDialog.__init__( self, parent, wx.ID_ANY, _extstr(u"newprofile.CreateNewProfile")) #$NON-NLS-1$ # Tell the dialog to resize itself to best-fit its children. self.Fit() # end __init__() def getProfileInfo(self): return (self.profileNameText.GetValue(), self.profilePathCtrl.getPath()) # end getProfileInfo() def _createNonHeaderWidgets(self): self.profileInfoStaticBox = wx.StaticBox( self, label=_extstr(u"newprofile.ProfileInfo")) #$NON-NLS-1$ self.profileNameLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"newprofile.Name:")) #$NON-NLS-1$ self.profileNameText = ZValidatingTextCtrl(ZProfileNameValidator( self.profilesModel), self, wx.ID_ANY, size=wx.Size(325, -1)) self.profileNameText.SetToolTipString( _extstr(u"newprofile.ProfileNameTooltip")) #$NON-NLS-1$ self.profilePathLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"newprofile.Path:")) #$NON-NLS-1$ self.profilePathCtrl = ZValidatingFileChooserCtrl( ZProfilePathValidator(), self, ZFCC_DIRECTORY_TYPE, _extstr(u"newprofile.ChooseAProfileLocation")) #$NON-NLS-1$ self.profilePathCtrl.SetToolTipString( _extstr(u"newprofile.ProfilePathTooltip")) #$NON-NLS-1$ # end _createNonHeaderWidgets() def _populateNonHeaderWidgets(self): # populate with something? pass # end _populateNonHeaderWidgets() def _layoutNonHeaderWidgets(self): # Flexible grid sizer where all of the label->text ctrl pairs will live flexGridSizer = wx.FlexGridSizer(3, 2, 5, 5) flexGridSizer.AddGrowableCol(1) # NOTE: Called so that the import profile dialog can add widgets. self._layoutAdditionalNonHeaderWidgets(flexGridSizer) flexGridSizer.Add(self.profileNameLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.profileNameText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(self.profilePathLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.profilePathCtrl, 0, wx.EXPAND | wx.RIGHT, 5) # Static box sizer that has a label of "Profile Info" staticBoxSizer = wx.StaticBoxSizer(self.profileInfoStaticBox, wx.VERTICAL) staticBoxSizer.AddSizer(flexGridSizer, 0, wx.EXPAND | wx.ALL, 5) return staticBoxSizer # end _layoutNonHeaderWidgets() def _layoutAdditionalNonHeaderWidgets(self, sizer): #@UnusedVariable pass # end _layoutAdditionalNonHeaderWidgets() def _bindWidgetEvents(self): self._bindValidatingWidget(self.profileNameText) self._bindValidatingWidget(self.profilePathCtrl) # end _bindWidgetEvents() def _setInitialFocus(self): self.profileNameText.SetFocus() # end _setInitialFocus() def _getHeaderTitle(self): return _extstr(u"newprofile.NewProfile") #$NON-NLS-1$ # end _getHeaderTitle() def _getHeaderMessage(self): return _extstr(u"newprofile.DialogUseMsg") #$NON-NLS-1$ # end _getHeaderMessage() def _getHeaderImagePath(self): return u"images/profile/new_dialog/header_image.png" #$NON-NLS-1$ # end _getHeaderImagePath() def setProfilePath(self, path): self.profilePathCtrl.setPath(path) # end setProfilePath() def setProfileName(self, name): self.profileNameText.SetValue(name)
class ZNewPublisherSiteUrlPage(ZNewPublisherSiteWizardPageBase): def __init__(self, model, parent): ZNewPublisherSiteWizardPageBase.__init__(self, model, parent) # end __init__() def _createWidgets(self): self.description1 = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.WelcomeMessage")) #$NON-NLS-1$ self.description1.SetFont(getDefaultFontBold()) self.description2 = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.WizardDescription"), size=wx.Size(-1, 80)) #$NON-NLS-1$ self.urlLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.BlogUrlLabel")) #$NON-NLS-1$ urlValidator = ZUrlSelectionValidator( _extstr(u"publishersitewizard.BlogUrlInvalid"), nonEmpty=False) #$NON-NLS-1$ self.urlText = ZValidatingTextCtrl(urlValidator, self, wx.ID_ANY) self.urlText.SetToolTipString( _extstr(u"publishersitewizard.BlogUrlTooltip")) #$NON-NLS-1$ self.animateControl = ZProgressLabelCtrl(self) self.clickHereHyperlink = wx.HyperlinkCtrl( self, wx.ID_ANY, _extstr(u"publishersitewizard.NoBlogYet"), u"http://www.blogger.com/?ref=ZoundryRaven" ) #$NON-NLS-2$ #$NON-NLS-1$ # end _createWidgets() def _populateWidgets(self): self._showBusy(False) # end _populateWidgets() def _bindWidgetEvents(self): self._bindValidatingWidget(self.urlText) # end _bindWidgetEvents() def _layoutWidgets(self): flexGridSizer = wx.FlexGridSizer(1, 2, 5, 5) flexGridSizer.AddGrowableCol(1) flexGridSizer.Add(self.urlLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.urlText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.animateControl, 0, wx.EXPAND | wx.ALIGN_LEFT | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.clickHereHyperlink, 0, wx.ALL, 5) box = wx.BoxSizer(wx.VERTICAL) box.Add(self.description1, 0, wx.EXPAND | wx.ALL, 10) box.Add(self.description2, 0, wx.EXPAND | wx.ALL, 10) box.AddSizer(flexGridSizer, 0, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(box) # end _layoutWidgets() def _showBusy(self, enable, text=u""): #$NON-NLS-1$ if getNoneString(text): self.animateControl.setLabel(text) self.animateControl.Show(enable) # end _showBusy() def _getSiteUrl(self): return self.urlText.GetValue().strip() # end _getSiteUrl() def getDataProperties(self): rval = {} rval[u"siteurl-page.url"] = self._getSiteUrl() #$NON-NLS-1$ return rval # end getDataProperties() def _refresh(self, eventType, eventData): if eventType == u"begin-autodiscover": #$NON-NLS-1$ self.urlText.Enable(False) self._showBusy(True, u"Checking... %s" % self._getSiteUrl()) #$NON-NLS-1$ elif eventType == u"end-autodiscover": #$NON-NLS-1$ self.urlText.Enable(True) self._showBusy(False) elif eventType == u"error-autodiscover": #$NON-NLS-1$ (errMsg, errDetails, err) = eventData #@UnusedVariable ZShowErrorMessage(self, errMsg, errDetails) # end _refresh() def onEnter(self, session, eventDirection): #@UnusedVariable self.urlText.SetFocus() # end onEnter() def onExit(self, session, eventDirection): if eventDirection == ZWizardPage.NEXT: oldValue = session.getProperty(u"siteurl-page.url") #$NON-NLS-1$ newValue = self._getSiteUrl() # auto discover if there is a new value and it not empty if newValue and newValue != oldValue: # check for cached discover data cacheMap = session.getProperty( u"siteurl-page.discover-info-cache") #$NON-NLS-1$ if cacheMap and cacheMap.has_key(newValue): discoverInfo = cacheMap[newValue] session.setProperty(u"siteurl-page.discover-info", discoverInfo) #$NON-NLS-1$ else: task = ZAutodiscoverTask(self, session) self._fireBeginBackgroundTaskEvent(task) return False elif oldValue and not newValue: # new value does not exist. reset auto-disc. session.setProperty(u"siteurl-page.discover-info", None) #$NON-NLS-1$ return True
class ZNewPublisherSiteApiInfoPage(ZNewPublisherSiteWizardPageBase): def __init__(self, model, parent): ZNewPublisherSiteWizardPageBase.__init__(self, model, parent) # end __init__() def _createWidgets(self): self.description1 = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.ApiInfo")) #$NON-NLS-1$ self.description1.SetFont(getDefaultFontBold()) self.description2 = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.ApiInfoDescription"), size=wx.Size(-1, 40)) #$NON-NLS-1$ self.accLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.AccountNameLabel")) #$NON-NLS-1$ accNameValidator = ZPublisherAccountNameValidator(self._getModel()) self.accText = ZValidatingTextCtrl(accNameValidator, self, wx.ID_ANY) self.accText.SetToolTipString( _extstr(u"publishersitewizard.AccountNameTooltip")) #$NON-NLS-1$ self.siteLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.SiteTypeLabel")) #$NON-NLS-1$ comboValidator = ZNonEmptySelectionValidator( _extstr(u"publishersitewizard.EmptySiteTypeSelectionError") ) #$NON-NLS-1$ self.siteCombo = ZValidatingBitmapComboBox(comboValidator, self, wx.ID_ANY, style=wx.CB_READONLY) self.siteCombo.SetToolTipString( _extstr(u"publishersitewizard.SiteTypeTooltip")) #$NON-NLS-1$ self.Bind(wx.EVT_COMBOBOX, self.onComboEvent, self.siteCombo.widget) self.autodiscoveryHint = wx.StaticText(self, wx.ID_ANY, u"") #$NON-NLS-1$ self.usernameLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.UsernameLabel")) #$NON-NLS-1$ usernameValidator = ZNonEmptySelectionValidator( _extstr(u"publishersitewizard.EmptyUsername")) #$NON-NLS-1$ self.usernameText = ZValidatingTextCtrl(usernameValidator, self, wx.ID_ANY) self.usernameText.SetToolTipString( _extstr(u"publishersitewizard.UsernameTooltip")) #$NON-NLS-1$ self.passwordLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.PasswordLabel")) #$NON-NLS-1$ passwordValidator = ZNonEmptySelectionValidator( _extstr(u"publishersitewizard.EmptyPassword")) #$NON-NLS-1$ self.passwordText = ZValidatingTextCtrl(passwordValidator, self, wx.ID_ANY, style=wx.TE_PASSWORD) self.passwordText.SetToolTipString( _extstr(u"publishersitewizard.PasswordTooltip")) #$NON-NLS-1$ self.apiUrlLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.ApiUrlLabel")) #$NON-NLS-1$ apiUrlValidator = ZUrlSelectionValidator( _extstr(u"publishersitewizard.ApiUrlInvalid")) #$NON-NLS-1$ self.apiUrlText = ZValidatingTextCtrl(apiUrlValidator, self, wx.ID_ANY) self.apiUrlText.SetToolTipString( _extstr(u"publishersitewizard.ApiUrlTooltip")) #$NON-NLS-1$ self.apiUrlHint = wx.StaticText(self, wx.ID_ANY, u"Api Url hints") #$NON-NLS-1$ self.animateControl = ZProgressLabelCtrl(self) # end _createWidgets() def _populateWidgets(self): self._showBusy(False) siteDefList = [] siteDefList.extend(self._getModel().listPublisherSites()) siteDefList.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) for siteDef in siteDefList: bitmap = siteDef.getIconAsBitmap() self.siteCombo.Append(siteDef.getName(), siteDef, bitmap) # end _populateWidgets() def _bindWidgetEvents(self): self._bindValidatingWidget(self.accText) self._bindValidatingWidget(self.siteCombo) self._bindValidatingWidget(self.usernameText) self._bindValidatingWidget(self.passwordText) self._bindValidatingWidget(self.apiUrlText) # end _bindWidgetEvents() def _layoutWidgets(self): flexGridSizer = wx.FlexGridSizer(7, 2, 5, 5) flexGridSizer.AddGrowableCol(1) flexGridSizer.Add(self.accLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.accText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(self.siteLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.siteCombo, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.autodiscoveryHint, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(self.usernameLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.usernameText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(self.passwordLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.passwordText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(self.apiUrlLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.apiUrlText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.apiUrlHint, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.animateControl, 0, wx.EXPAND | wx.ALIGN_LEFT | wx.RIGHT, 5) box = wx.BoxSizer(wx.VERTICAL) box.Add(self.description1, 0, wx.EXPAND | wx.ALL, 10) box.Add(self.description2, 0, wx.EXPAND | wx.ALL, 10) box.AddSizer(flexGridSizer, 0, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(box) # end _layoutWidgets() def getDataProperties(self): rval = {} rval[u"apiinfo-page.accname"] = self.accText.GetValue().strip( ) #$NON-NLS-1$ site = self._getSelectedSite() id = None if site: id = site.getId() rval[u"apiinfo-page.siteid"] = id #$NON-NLS-1$ rval[u"apiinfo-page.username"] = self.usernameText.GetValue().strip( ) #$NON-NLS-1$ rval[u"apiinfo-page.password"] = self.passwordText.GetValue().strip( ) #$NON-NLS-1$ rval[u"apiinfo-page.apiurl"] = self.apiUrlText.GetValue().strip( ) #$NON-NLS-1$ return rval # end getDataProperties() def _enableControls(self, enable): self.accText.Enable(enable) self.siteCombo.Enable(enable) self.usernameText.Enable(enable) self.passwordText.Enable(enable) self.apiUrlText.Enable(enable) def _showBusy(self, enable, text=u""): #$NON-NLS-1$ if getNoneString(text): self.animateControl.setLabel(text) self.animateControl.Show(enable) def _updateDiscoverInfo(self, discoverInfo): hint = u"" #$NON-NLS-1$ if discoverInfo: if discoverInfo.engineName: hint = u"Autodiscovered %s" % discoverInfo.engineName #$NON-NLS-1$ else: hint = u"Autodiscover information not available." #$NON-NLS-1$ if discoverInfo.username and not self.usernameText.GetValue(): self.usernameText.SetValue(discoverInfo.username) if discoverInfo.siteId: self._selectSiteId(discoverInfo.siteId) apiUrl = None if getNoneString(discoverInfo.apiUrl): apiUrl = discoverInfo.apiUrl else: # find api url from site def apiUrl = self._getDefaultUrlForSelectedSite() if apiUrl: self.apiUrlText.SetValue(apiUrl) self.autodiscoveryHint.SetLabel(hint) def _refresh(self, eventType, eventData): if eventType == u"begin-listblogs": #$NON-NLS-1$ self._enableControls(False) self._showBusy(True, u"Getting blog list...") #$NON-NLS-1$ elif eventType == u"end-listblogs": #$NON-NLS-1$ self._enableControls(True) self._showBusy(False) elif eventType == u"error-listblogs": #$NON-NLS-1$ (errMsg, errDetails, err) = eventData #@UnusedVariable ZShowErrorMessage(self, errMsg, errDetails) def onEnter(self, session, eventDirection): self.accText.SetFocus() if eventDirection == ZWizardPage.NEXT: discoverInfo = session.getProperty( u"siteurl-page.discover-info") #$NON-NLS-1$ #print u"ApiInfoPageinfo-Enter discinfo=", discoverInfo # FIXME (PJ) delete this #$NON-NLS-1$ self._updateDiscoverInfo(discoverInfo) def onExit(self, session, eventDirection): # look up blog list if data has changed if eventDirection == ZWizardPage.NEXT: siteId = self._getSelectedSite().getId() username = self.usernameText.GetValue().strip() password = self.passwordText.GetValue().strip() apiUrl = self.apiUrlText.GetValue().strip() key = siteId + username + password + apiUrl oldKey = session.getProperty( u"apiinfo-page.modifykey") #$NON-NLS-1$ if not oldKey or oldKey != key: task = ZListBlogsTask(self, session, siteId, username, password, apiUrl, key) self._fireBeginBackgroundTaskEvent(task) return False return True def onComboEvent(self, event): #@UnusedVariable defUrl = self._getDefaultUrlForSelectedSite() if defUrl: self.apiUrlText.SetValue(defUrl) def _getDefaultUrlForSelectedSite(self): # Attempts to get the default or predefined url for the currenly selected site. siteDef = self._getSelectedSite() defUrl = self._getModel().getDefaultApiUrl(siteDef) return defUrl def _selectSiteId(self, siteId): n = self.siteCombo.GetCount() for idx in range(n): data = self.siteCombo.GetClientData(idx) if data and data.getId() == siteId: self.siteCombo.SetSelection(idx) self.siteCombo.validate() break def _getSelectedSite(self): data = None idx = self.siteCombo.GetSelection() if idx != -1: data = self.siteCombo.GetClientData(idx) # print "SELSITE %s %s" % (data.getName(),data.getId()) return data
class ZNewMediaStorageWizardSitePage(ZNewMediaStorageWizardPage): def __init__(self, model, parent): ZNewMediaStorageWizardPage.__init__(self, model, parent) self.customPages = None self.site = None # end __init__() def _createWidgets(self): self.description1 = wx.StaticText( self, wx.ID_ANY, _extstr(u"mediastoragewizard.WelcomeMessage")) #$NON-NLS-1$ self.description1.SetFont(getDefaultFontBold()) self.description2 = wx.StaticText( self, wx.ID_ANY, _extstr(u"mediastoragewizard.WizardDescription"), size=wx.Size(-1, 80)) #$NON-NLS-1$ self.siteLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"mediastoragewizard.MediaStorageType")) #$NON-NLS-1$ comboValidator = ZNonEmptySelectionValidator( _extstr(u"mediastoragewizard.EmptyStoreTypeSelectionError") ) #$NON-NLS-1$ self.siteCombo = ZValidatingBitmapComboBox(comboValidator, self, wx.ID_ANY, style=wx.CB_READONLY) self.siteCombo.SetToolTipString( _extstr(u"mediastoragewizard.StoreTypeComboTooltip")) #$NON-NLS-1$ self.nameLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"mediastoragewizard.MediaStorageName")) #$NON-NLS-1$ nameValidator = ZMediaStorageNameValidator(self._getModel()) self.nameText = ZValidatingTextCtrl(nameValidator, self, wx.ID_ANY) self.nameText.SetToolTipString( _extstr( u"mediastoragewizard.MediaStorageNameTooltip")) #$NON-NLS-1$ self.clickHereHyperlink = wx.HyperlinkCtrl( self, wx.ID_ANY, _extstr(u"mediastoragewizard.NoStorageLink"), u"http://picasaweb.google.com/?ref=ZoundryRaven" ) #$NON-NLS-2$ #$NON-NLS-1$ # end _createWidgets() def _populateWidgets(self): mediaSites = self._getModel().getMediaSites() for site in mediaSites: iconPath = site.getIconPath() bitmap = getResourceRegistry().getBitmap(iconPath) self.siteCombo.Append(site.getDisplayName(), None, bitmap) # end _populateWidgets() def _bindWidgetEvents(self): self._bindValidatingWidget(self.siteCombo) self._bindValidatingWidget(self.nameText) # end _bindWidgetEvents() def _layoutWidgets(self): flexGridSizer = wx.FlexGridSizer(2, 2, 5, 5) flexGridSizer.AddGrowableCol(1) flexGridSizer.Add(self.siteLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.siteCombo, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(self.nameLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.nameText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY, u""), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) #$NON-NLS-1$ flexGridSizer.Add(self.clickHereHyperlink, 0, wx.EXPAND | wx.RIGHT, 5) box = wx.BoxSizer(wx.VERTICAL) box.Add(self.description1, 0, wx.EXPAND | wx.ALL, 10) box.Add(self.description2, 0, wx.EXPAND | wx.ALL, 10) box.AddSizer(flexGridSizer, 0, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(box) # end _layoutWidgets() def getDataProperties(self): rval = {} rval[u"type-page.site"] = self._getSelectedSite() #$NON-NLS-1$ rval[u"type-page.name"] = self.nameText.GetValue() #$NON-NLS-1$ return rval # end getDataProperties() def onEnter(self, session, eventDirection): #@UnusedVariable if eventDirection == ZWizardPage.NEXT: mediaSites = self._getModel().getMediaSites() idx = 0 for site in mediaSites: if site.getId( ) == u"zoundry.blogapp.mediastorage.site.picasa": #$NON-NLS-1$ self.siteCombo.Select(idx) self.siteCombo.validate() self.nameText.SetFocus() return idx = idx + 1 self.siteCombo.SetFocus() # end onEnter() def onExit(self, session, eventDirection): #@UnusedVariable if eventDirection == ZWizardPage.NEXT: site = self._getSelectedSite() if site != self.site: self.site = site # Remove any old custom pages we may have had if self.customPages: for page in self.customPages: # magic number - the position of the first custom # page and the position of all custom pages as they # are removed self.wizard.removePage(2) self.customPages = None # Now add in new pages pages = [] wizardPageClasses = self.site.createContributedWizardPages() insertionPoint = 2 for wizardPageClass in wizardPageClasses: page = wizardPageClass(self.model, self.wizard) pages.append(page) self.wizard.addPage(page, insertionPoint) insertionPoint = insertionPoint + 1 self.customPages = pages return True # end onExit() def _getSelectedSite(self): idx = self.siteCombo.GetSelection() return self._getModel().getMediaSites()[idx]