def _createNonHeaderWidgets(self): self.staticBox = wx.StaticBox( self, wx.ID_ANY, _extstr(u"accountblogs.BlogList")) #$NON-NLS-1$ self.blogListProvider = ZBlogCheckboxListContentProvider() self.blogListControl = ZCheckBoxListViewWithButtons( self.blogListProvider, self) self.blogListControl.SetSizeHints(-1, 150) self.refreshButton = wx.Button( self, wx.ID_ANY, _extstr(u"synchronizeaccountdialog.RefreshBlogList")) #$NON-NLS-1$ self.animateControl = ZProgressLabelCtrl(self)
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)
def _createNonHeaderWidgets(self): self.staticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"accountblogs.BlogList")) #$NON-NLS-1$ self.blogListProvider = ZBlogCheckboxListContentProvider() self.blogListControl = ZCheckBoxListViewWithButtons(self.blogListProvider, self) self.blogListControl.SetSizeHints(-1, 150) self.refreshButton = wx.Button(self, wx.ID_ANY, _extstr(u"synchronizeaccountdialog.RefreshBlogList")) #$NON-NLS-1$ self.animateControl = ZProgressLabelCtrl(self)
def _createNonHeaderWidgets(self): self.progressCtrl = ZProgressLabelCtrl(self, u"") #$NON-NLS-1$ self.progressGauge = wx.Gauge(self, wx.ID_ANY, self.bgTask.getNumWorkUnits()) self.progressGauge.SetSizeHints(-1, 16) self.workTextCtrl = wx.StaticText(self, wx.ID_ANY, u"") #$NON-NLS-1$ self.staticLine = wx.StaticLine(self, wx.HORIZONTAL)
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$
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$
def _createCustomWidgets(self): self.progressCtrl = ZProgressLabelCtrl(self, u"", True) #$NON-NLS-1$ self._debugMsg(u"Done _createCustomWidgets") #$NON-NLS-1$
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)
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 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 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 ZSynchronizeAccountBlogsDialog(ZHeaderDialog, ZPersistentDialogMixin): def __init__(self, parent, account): self.account = account self.model = ZAccountSynchModel(self.account) ZHeaderDialog.__init__( self, parent, wx.ID_ANY, _extstr(u"synchronizeaccountdialog.DialogTitle"), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, name=u"ZSynchronizeAccountBlogsDialog") #$NON-NLS-2$ #$NON-NLS-1$ ZPersistentDialogMixin.__init__(self, IZBlogAppUserPrefsKeys.SYNCH_DIALOG) self.Layout() # end __init__() def _getAccount(self): return self.account # end _getAccount() def _createNonHeaderWidgets(self): self.staticBox = wx.StaticBox( self, wx.ID_ANY, _extstr(u"accountblogs.BlogList")) #$NON-NLS-1$ self.blogListProvider = ZBlogCheckboxListContentProvider() self.blogListControl = ZCheckBoxListViewWithButtons( self.blogListProvider, self) self.blogListControl.SetSizeHints(-1, 150) self.refreshButton = wx.Button( self, wx.ID_ANY, _extstr(u"synchronizeaccountdialog.RefreshBlogList")) #$NON-NLS-1$ self.animateControl = ZProgressLabelCtrl(self) # end _createNonHeaderWidgets() def _populateNonHeaderWidgets(self): self._showBusy(False) blogs = [] blogs.extend(self._getAccount().getBlogs()) self._populateProvider(blogs) # end _populateNonHeaderWidgets() def _populateProvider(self, blogs): self.animateControl.setLabel( _extstr( u"synchronizeaccountdialog.FetchingBlogList")) #$NON-NLS-1$ self.blogListProvider.setBlogList(blogs) self.blogListControl.checkBoxListView.refreshItems() # end _populateProvider() def _layoutNonHeaderWidgets(self): box = wx.BoxSizer(wx.HORIZONTAL) box.Add(self.refreshButton, 0, wx.LEFT | wx.ALL, 5) box.Add(self.animateControl, 1, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.ALL, 5) sizer = wx.StaticBoxSizer(self.staticBox, wx.VERTICAL) sizer.Add(self.blogListControl, 1, wx.EXPAND | wx.ALL, 5) sizer.AddSizer(box, 0, wx.LEFT | wx.BOTTOM, 5) return sizer # end _layoutNonHeaderWidgets() def _bindWidgetEvents(self): self.Bind(wx.EVT_BUTTON, self.onRefreshBlogList, self.refreshButton) self.Bind(ZEVT_CHECKBOX_LIST_CHANGE, self.onBlogCheckedEvent, self.blogListControl) self.Bind(ZEVT_REFRESH, self.onRefreshEvent, self) # end _bindWidgetEvents() def _getHeaderTitle(self): return _extstr(u"synchronizeaccountdialog.HeaderTitle") #$NON-NLS-1$ # end _getHeaderTitle() def _getHeaderMessage(self): return _extstr(u"synchronizeaccountdialog.HeaderMessage") #$NON-NLS-1$ # end _getHeaderMessage() def _getHeaderImagePath(self): return u"images/dialogs/mediastorage/manage/header_image.png" #$NON-NLS-1$ # end _getHeaderImagePath() def _showBusy(self, enable): #$NON-NLS-1$ self.animateControl.Show(enable) # _showBusy() def onRefreshEvent(self, event): data = event.getData() if u"begin-list-blogs" == data: #$NON-NLS-1$ self._showBusy(True) elif u"end-list-blogs" == data: #$NON-NLS-1$ self._showBusy(False) # onRefreshEvent() def _refreshBlogList(self): # called via runnable ZListBlogsTasks fireRefreshEvent(self, u"begin-list-blogs") #$NON-NLS-1$ blogs = self.model.listAllBlogs() self._populateProvider(blogs) fireRefreshEvent(self, u"end-list-blogs") #$NON-NLS-1$ # _refreshBlogList() def onRefreshBlogList(self, event): #@UnusedVariable thread = ZThread(ZListBlogsTasks(self), u"ZSynchronizeAccountBlogsDialog.ZListBlogsTasks", True) #$NON-NLS-1$ thread.start() # end onRefreshBlogList() def _getButtonTypes(self): return ZBaseDialog.OK_BUTTON | ZBaseDialog.CANCEL_BUTTON # end _getButtonTypes() def getSelectedBlogList(self): rval = self.blogListProvider.getSelectedBlogList() return rval # end _getSelectedBlogList def onBlogCheckedEvent(self, event): #@UnusedVariable pass
def _createWidgets(self): self.staticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"infodetailswidgets.Preview")) #$NON-NLS-1$ self.generatingMsg = ZProgressLabelCtrl(self, _extstr(u"infodetailswidgets.GeneratingPreview")) #$NON-NLS-1$ self.previewUnavailableMsg = wx.StaticText(self, wx.ID_ANY, _extstr(u"infodetailswidgets.PreviewUnavailable")) #$NON-NLS-1$ self.previewBmp = ZStaticBitmap(self, None)
class ZImagePreviewPanel(ZTransparentPanel): def __init__(self, parent): wx.Panel.__init__(self, parent, wx.ID_ANY) self._createWidgets() self._layoutWidgets() # end __init__() def _createWidgets(self): self.staticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"infodetailswidgets.Preview")) #$NON-NLS-1$ self.generatingMsg = ZProgressLabelCtrl(self, _extstr(u"infodetailswidgets.GeneratingPreview")) #$NON-NLS-1$ self.previewUnavailableMsg = wx.StaticText(self, wx.ID_ANY, _extstr(u"infodetailswidgets.PreviewUnavailable")) #$NON-NLS-1$ self.previewBmp = ZStaticBitmap(self, None) # end _createWidgets() def _layoutWidgets(self): staticBoxSizer = wx.StaticBoxSizer(self.staticBox, wx.HORIZONTAL) staticBoxSizer.Add(self.generatingMsg, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3) staticBoxSizer.Add(self.previewUnavailableMsg, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3) staticBoxSizer.Add(self.previewBmp, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3) self.SetAutoLayout(True) self.SetSizer(staticBoxSizer) # end _layoutWidgets() def reset(self): self.generatingMsg.Show(True) self.generatingMsg.start() self.previewUnavailableMsg.Show(False) self.previewBmp.Show(False) # end reset() def updateFromError(self, error): # Log the error getLoggerService().exception(error) self.generatingMsg.Show(False) self.generatingMsg.stop() self.previewUnavailableMsg.Show(True) self.previewBmp.Show(False) # end updateFromError() def updateFromConnectionRespInfo(self, connectionRespInfo): #@UnusedVariable # Do nothing... pass # end updateFromConnectionRespInfo() def updateFromConnectionResp(self, connectionResp): imagingService = getApplicationModel().getService(IZAppServiceIDs.IMAGING_SERVICE_ID) bgColor = self.GetBackgroundColour() tnParams = ZThumbnailParams(backgroundColor = (bgColor.Red(), bgColor.Green(), bgColor.Blue()), dropShadow = True) tnFile = os.path.join(getApplicationModel().getUserProfile().getTempDirectory(), u"_ZImagePreviewPanel_tn.png") #$NON-NLS-1$ try: imagingService.generateThumbnail(connectionResp.getContentFilename(), tnParams, tnFile) image = wx.Image(tnFile, getImageType(tnFile)) if image is None: raise ZException() bitmap = image.ConvertToBitmap() self.previewBmp.setBitmap(bitmap) deleteFile(tnFile) self.generatingMsg.Show(False) self.generatingMsg.stop() self.previewUnavailableMsg.Show(False) self.previewBmp.Show(True) except Exception, e: getLoggerService().exception(e) self.updateFromError(e)
class ZRavenApplicationStatusBar(ZStatusBar, IZBackgroundTaskServiceListener, IZBackgroundTaskListener): def __init__(self, parent): applicationModel = getApplicationModel() userProfile = applicationModel.getUserProfile() debugFilePath = os.path.join(userProfile.getLogDirectory(), u"ZRavenApplicationStatusBar.log") #$NON-NLS-1$ self.debugFile = open(debugFilePath, u"wa") #$NON-NLS-1$ self._debugMsg(u"== New Debug Session ==") #$NON-NLS-1$ self.progressCtrl = None self.model = ZRavenApplicationStatusBarModel() self.mutex = ZMutex(u"ZAppStatusBarMTX") #$NON-NLS-1$ self._debugMsg(u"Begin Call Super ZStatusBar.__init__") #$NON-NLS-1$ ZStatusBar.__init__(self, parent, self.model.createStatusBarProvider()) self._debugMsg(u"Done Call Super ZStatusBar.__init__") #$NON-NLS-1$ # Attach to any already-running tasks. for task in self.model.getTaskService().getTasks(): if task.isRunning(): self._debugMsg(u"Attaching self as listner to task %s - %s" % (task.getId(), task.getName()) ) #$NON-NLS-1$ task.attachListener(self) # Listen for new tasks that may show up. self._debugMsg(u"Attaching self as listner to task service") #$NON-NLS-1$ self.model.getTaskService().addListener(self) self._debugMsg(u"End ZRavenApplicationStatusBar.__init__") #$NON-NLS-1$ # end __init__() def _debugMsg(self, msg): try: self.debugFile.write(u"*****>>>>> %s\n" % msg) #$NON-NLS-1$ self.debugFile.flush() except: pass # end _debugMsg() def _debugProgressCtrl(self): if not self.progressCtrl: stack = traceback.extract_stack() self._debugMsg( unicode(stack) ) return self.progressCtrl is not None # end _debugProgressCtrl() def _createCustomWidgets(self): self.progressCtrl = ZProgressLabelCtrl(self, u"", True) #$NON-NLS-1$ self._debugMsg(u"Done _createCustomWidgets") #$NON-NLS-1$ # end _createCustomWidgets() def _bindCustomWidgets(self): self.Bind(ZEVT_REFRESH, self.onRefresh, self) self._debugMsg(u"Done _bindCustomWidgets") #$NON-NLS-1$ # end _bindCustomWidgets() def _refreshPane(self, paneIdx): if not self._debugProgressCtrl(): return if paneIdx == 0: numTasks = self.model.getNumRunningTasks() progressText = u"%d %s" % (numTasks, _extstr(u"appstatusbar.RunningTasks")) #$NON-NLS-1$ #$NON-NLS-2$ if numTasks == 0: progressText = _extstr(u"appstatusbar.NoRunningTasks") #$NON-NLS-1$ self.progressCtrl.setLabel(progressText) # end _refreshPane() def _repositionPane(self, paneIdx, rect): if not self._debugProgressCtrl(): return if paneIdx == 0: self.progressCtrl.SetPosition( (rect.x + 4, rect.y + 1) ) self.progressCtrl.SetSize( (rect.width - 5, rect.height - 2) ) # end _repositionPane() def onRefresh(self, event): self.mutex.acquire() try: if self._debugProgressCtrl() and self.model.isDirty(): if self.model.isRunning(): self.progressCtrl.start() else: self.progressCtrl.stop() self.refresh() self.model.setDirty(False) finally: self.mutex.release() event.Skip() # end onRefresh() def onTaskAdded(self, task): self.mutex.acquire() try: task.attachListener(self) finally: self.mutex.release() fireRefreshEvent(self) # end onTaskAdded() def onTaskRemoved(self, task): self.mutex.acquire() try: self.model.removeTask(task) task.detachListener(self) finally: self.mutex.release() fireRefreshEvent(self) # end onTaskRemoved() def onAttached(self, task, numCompletedWorkUnits): #@UnusedVariable self.mutex.acquire() try: if task.isRunning(): self.model.addTask(task) finally: self.mutex.release() fireRefreshEvent(self) # end onAttached() def onStarted(self, task, workAmount): #@UnusedVariable self.mutex.acquire() try: self.model.addTask(task) finally: self.mutex.release() fireRefreshEvent(self) # end onStarted() def onComplete(self, task): self.mutex.acquire() try: self.model.removeTask(task) finally: self.mutex.release() fireRefreshEvent(self) # end onComplete() def onStop(self, task): self.mutex.acquire() try: self.model.removeTask(task) finally: self.mutex.release() fireRefreshEvent(self) # end onStop() def onCancel(self, task): self.mutex.acquire() try: self.model.removeTask(task) finally: self.mutex.release() fireRefreshEvent(self) # end onCancel() def onError(self, task, errorMessage, errorDetails): #@UnusedVariable self.mutex.acquire() try: self.model.removeTask(task) finally: self.mutex.release() fireRefreshEvent(self) # end onError() def reposition(self): self._debugMsg(u"start 'reposition()'") #$NON-NLS-1$ try: ZStatusBar.reposition(self) finally: self._debugMsg(u"end 'reposition()'") #$NON-NLS-1$
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 ZSynchronizeAccountBlogsDialog(ZHeaderDialog, ZPersistentDialogMixin): def __init__(self, parent, account): self.account = account self.model = ZAccountSynchModel(self.account) ZHeaderDialog.__init__(self, parent, wx.ID_ANY, _extstr(u"synchronizeaccountdialog.DialogTitle"), style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, name = u"ZSynchronizeAccountBlogsDialog") #$NON-NLS-2$ #$NON-NLS-1$ ZPersistentDialogMixin.__init__(self, IZBlogAppUserPrefsKeys.SYNCH_DIALOG) self.Layout() # end __init__() def _getAccount(self): return self.account # end _getAccount() def _createNonHeaderWidgets(self): self.staticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"accountblogs.BlogList")) #$NON-NLS-1$ self.blogListProvider = ZBlogCheckboxListContentProvider() self.blogListControl = ZCheckBoxListViewWithButtons(self.blogListProvider, self) self.blogListControl.SetSizeHints(-1, 150) self.refreshButton = wx.Button(self, wx.ID_ANY, _extstr(u"synchronizeaccountdialog.RefreshBlogList")) #$NON-NLS-1$ self.animateControl = ZProgressLabelCtrl(self) # end _createNonHeaderWidgets() def _populateNonHeaderWidgets(self): self._showBusy(False) blogs = [] blogs.extend(self._getAccount().getBlogs()) self._populateProvider(blogs) # end _populateNonHeaderWidgets() def _populateProvider(self, blogs): self.animateControl.setLabel(_extstr(u"synchronizeaccountdialog.FetchingBlogList")) #$NON-NLS-1$ self.blogListProvider.setBlogList(blogs) self.blogListControl.checkBoxListView.refreshItems() # end _populateProvider() def _layoutNonHeaderWidgets(self): box = wx.BoxSizer(wx.HORIZONTAL) box.Add(self.refreshButton, 0 , wx.LEFT | wx.ALL, 5) box.Add(self.animateControl, 1, wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.ALL, 5) sizer = wx.StaticBoxSizer(self.staticBox, wx.VERTICAL) sizer.Add(self.blogListControl, 1, wx.EXPAND | wx.ALL, 5) sizer.AddSizer(box, 0, wx.LEFT | wx.BOTTOM, 5) return sizer # end _layoutNonHeaderWidgets() def _bindWidgetEvents(self): self.Bind(wx.EVT_BUTTON, self.onRefreshBlogList, self.refreshButton) self.Bind(ZEVT_CHECKBOX_LIST_CHANGE, self.onBlogCheckedEvent, self.blogListControl) self.Bind(ZEVT_REFRESH, self.onRefreshEvent, self) # end _bindWidgetEvents() def _getHeaderTitle(self): return _extstr(u"synchronizeaccountdialog.HeaderTitle") #$NON-NLS-1$ # end _getHeaderTitle() def _getHeaderMessage(self): return _extstr(u"synchronizeaccountdialog.HeaderMessage") #$NON-NLS-1$ # end _getHeaderMessage() def _getHeaderImagePath(self): return u"images/dialogs/mediastorage/manage/header_image.png" #$NON-NLS-1$ # end _getHeaderImagePath() def _showBusy(self, enable): #$NON-NLS-1$ self.animateControl.Show(enable) # _showBusy() def onRefreshEvent(self, event): data = event.getData() if u"begin-list-blogs" == data: #$NON-NLS-1$ self._showBusy(True) elif u"end-list-blogs" == data: #$NON-NLS-1$ self._showBusy(False) # onRefreshEvent() def _refreshBlogList(self): # called via runnable ZListBlogsTasks fireRefreshEvent(self, u"begin-list-blogs") #$NON-NLS-1$ blogs = self.model.listAllBlogs() self._populateProvider(blogs) fireRefreshEvent(self, u"end-list-blogs") #$NON-NLS-1$ # _refreshBlogList() def onRefreshBlogList(self, event): #@UnusedVariable thread = ZThread(ZListBlogsTasks(self), u"ZSynchronizeAccountBlogsDialog.ZListBlogsTasks", True) #$NON-NLS-1$ thread.start() # end onRefreshBlogList() def _getButtonTypes(self): return ZBaseDialog.OK_BUTTON | ZBaseDialog.CANCEL_BUTTON # end _getButtonTypes() def getSelectedBlogList(self): rval = self.blogListProvider.getSelectedBlogList() return rval # end _getSelectedBlogList def onBlogCheckedEvent(self, event): #@UnusedVariable pass