def initializeAspellDirectory(self): spellingDir = getApplicationModel().getUserProfile().getDirectory(u"spellcheck") #$NON-NLS-1$ aspellDir = os.path.join(spellingDir, u"aspell") #$NON-NLS-1$ keyFilePath = os.path.join(aspellDir, u"data", u"ASCII.dat") #$NON-NLS-2$ #$NON-NLS-1$ if not os.path.isfile(keyFilePath): aspellBaseZip = getApplicationModel().getResourceRegistry().getResourcePath(u"spellcheck/aspell/aspell-base.zip") #$NON-NLS-1$ unpackZip(aspellBaseZip, aspellDir)
def _run(self): publisherService = getApplicationModel().getService( IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) dataStoreService = getApplicationModel().getService( IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) publisher = None self.commands = [] if self.blogs: for blog in self.blogs: account = blog.getAccount() publisher = createBlogPublisherFromAccount( account, publisherService) command = ZDeleteEntryCommand(publisher, dataStoreService, account, blog, self.document, False) command.addListener(self) self.commands.append(command) else: command = ZDeleteEntryCommand(None, dataStoreService, None, None, self.document, True) command.addListener(self) self.commands.append(command) if self.deleteLocal and self.commands: self.commands[len(self.commands) - 1].setDeleteLocalEntry(True) # Now run all of the commands. for command in self.commands: self.currentCommand = command if self.isCancelled(): return else: self.currentCommand.doCommand()
def _saveTreeLayout(self): visitor = ZTreeLayoutSaveVisitor() self.treeView.accept(visitor) self._saveTreeSelection() # Save the properties getApplicationModel().getUserProfile().getProperties().save()
def __init__(self, parent, tabInfo, selected = False): self.parent = parent self.tabInfo = tabInfo self.selected = selected self.firstTab = False self.wingmanTab = False self.hovering = False # is the user hovering the mouse over the control self.clicking = False # is the user clicking the control self.middleClicking = False # is the user middle-clicking the control self.borderColor = TAB_BORDER_INNER_COLOR self.selBGColorStart = wx.Color(157, 185, 235) self.selBGColorEnd = wx.Color(157, 185, 235) wx.Panel.__init__(self, parent, wx.ID_ANY) self.preferredWidth = self._calculatePreferredWidth() self.SetFont(getDefaultFont()) self.closeButtonBitmap = getApplicationModel().getResourceRegistry().getBitmap(u"images/widgets/tabcontainer/close.png") #$NON-NLS-1$ self.closeHoverButtonBitmap = getApplicationModel().getResourceRegistry().getBitmap(u"images/widgets/tabcontainer/close.png") #$NON-NLS-1$ self.SetSize(wx.Size(self.preferredWidth, -1)) self.Bind(wx.EVT_PAINT, self.onPaint, self) self.Bind(wx.EVT_ERASE_BACKGROUND, self.onEraseBackground, self) self.Bind(wx.EVT_ENTER_WINDOW, self.onEnter, self) self.Bind(wx.EVT_LEAVE_WINDOW, self.onLeave, self) self.Bind(wx.EVT_LEFT_DOWN, self.onLeftClickDown, self) self.Bind(wx.EVT_LEFT_UP, self.onLeftClickUp, self) self.Bind(wx.EVT_MIDDLE_DOWN, self.onMiddleClickDown, self) self.Bind(wx.EVT_MIDDLE_UP, self.onMiddleClickUp, self) self.Bind(wx.EVT_RIGHT_UP, self.onRightClick, self) # FIXME (EPW) show the tooltip string only if the title is truncated self.SetToolTipString(self.tabInfo.getTitle())
def _run(self): publisherService = getApplicationModel().getService(IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) dataStoreService = getApplicationModel().getService(IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) publisher = None self.commands = [] if self.blogs: for blog in self.blogs: account = blog.getAccount() publisher = createBlogPublisherFromAccount(account, publisherService) command = ZDeleteEntryCommand(publisher, dataStoreService, account, blog, self.document, False) command.addListener( self ) self.commands.append(command) else: command = ZDeleteEntryCommand(None, dataStoreService, None, None, self.document, True) command.addListener( self ) self.commands.append(command) if self.deleteLocal and self.commands: self.commands[len(self.commands) - 1].setDeleteLocalEntry(True) # Now run all of the commands. for command in self.commands: self.currentCommand = command if self.isCancelled(): return else: self.currentCommand.doCommand()
def __init__(self): self.publisherService = getApplicationModel().getService( IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) self.accStoreService = getApplicationModel().getService( IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) self.mediaStoreService = getApplicationModel().getService( (IZBlogAppServiceIDs.MEDIA_STORAGE_SERVICE_ID))
def _loadStringFromFile(self, html): # MSHTML control requires a <head> and <title> element title = getNoneString( extractTitle(html) ) if not title or html.find(u"<html") == -1: #$NON-NLS-1$ # case where only the body content is given or the content did not have non-empty <head> and <title> elems. # try and create wrapper around the body. Eg: <html><head><title>ZoundryDocument</title></head><body> CONTENT </body> </html> html = wrapHtmlBody(html, u"ZoundryDocument") #$NON-NLS-1$ # note: \r\n must be replace with \n. Otherwise, in <pre> blocks, the \r' will show up as an extra line. html = html.replace(u"\r\n", u"\n") #$NON-NLS-1$ #$NON-NLS-2$ # For the test-harness to work, hard code temp dir tmpDir = u"c:/temp" #$NON-NLS-1$ if getApplicationModel(): userProfile = getApplicationModel().getUserProfile() tmpDir = userProfile.getTempDirectory() d = str(time.time()) fname = os.path.join(tmpDir, u"_z_raven_mshtml_%s_tmp.xhtml" % d) #$NON-NLS-1$ tmpFile = codecs.open(fname, u"w") #$NON-NLS-1$ try: # write the utf-8 byte order marker for wintel platforms. tmpFile.write(codecs.BOM_UTF8) tmpFile.write( convertToUtf8(html) ) tmpFile.close() self._loadFile(fname) finally: tmpFile.close()
def _saveTreeLayout(self): visitor = ZTreeLayoutSaveVisitor() self.treeView.accept(visitor) self._saveTreeSelection() # Save the properties getApplicationModel().getUserProfile().getProperties().save()
def _loadStringFromFile(self, html): # MSHTML control requires a <head> and <title> element title = getNoneString(extractTitle(html)) if not title or html.find(u"<html") == -1: #$NON-NLS-1$ # case where only the body content is given or the content did not have non-empty <head> and <title> elems. # try and create wrapper around the body. Eg: <html><head><title>ZoundryDocument</title></head><body> CONTENT </body> </html> html = wrapHtmlBody(html, u"ZoundryDocument") #$NON-NLS-1$ # note: \r\n must be replace with \n. Otherwise, in <pre> blocks, the \r' will show up as an extra line. html = html.replace(u"\r\n", u"\n") #$NON-NLS-1$ #$NON-NLS-2$ # For the test-harness to work, hard code temp dir tmpDir = u"c:/temp" #$NON-NLS-1$ if getApplicationModel(): userProfile = getApplicationModel().getUserProfile() tmpDir = userProfile.getTempDirectory() d = str(time.time()) fname = os.path.join(tmpDir, u"_z_raven_mshtml_%s_tmp.xhtml" % d) #$NON-NLS-1$ tmpFile = codecs.open(fname, u"w") #$NON-NLS-1$ try: # write the utf-8 byte order marker for wintel platforms. tmpFile.write(codecs.BOM_UTF8) tmpFile.write(convertToUtf8(html)) tmpFile.close() self._loadFile(fname) finally: tmpFile.close()
def _doRun(self): service = getApplicationModel().getService( IZBlogAppServiceIDs.PRODUCTS_SERVICE_ID) userPrefs = getApplicationModel().getUserProfile().getPreferences() zoundryId = userPrefs.getUserPreference( IZBlogAppUserPrefsKeys.ZOUNDRY_ID, None) if not zoundryId: zoundryId = u"*****@*****.**" #$NON-NLS-1$ self.logger.debug( u"Converting link %s using zoundry id %s." % (unicode(self.url), unicode(zoundryId))) #$NON-NLS-1$ self._fireWorkDoneEvent( 1, _extstr( u"blogeditoractions.Invoking_Zoundry_Service")) #$NON-NLS-1$ newUrl = service.convertProductLink(self.url, zoundryId) if newUrl: self.logger.debug(u"Link successfully converted to %s" % unicode(newUrl)) #$NON-NLS-1$ self._fireWorkDoneEvent( 1, _extstr(u"blogeditoractions.SuccessfullyConvertedLink" )) #$NON-NLS-1$ if not self.isCancelled(): self.zoundryProductUrl = newUrl else: raise ZException(_extstr( u"blogeditoractions.FailedToConvertLink")) #$NON-NLS-1$
def _createWidgets(self): tabSelBitmap = getApplicationModel().getResourceRegistry().getBitmap( u"images/widgets/tabcontainer/tabselection.png") #$NON-NLS-1$ tabSelHoverBitmap = getApplicationModel().getResourceRegistry( ).getBitmap(u"images/widgets/tabcontainer/tabselection_hover.png" ) #$NON-NLS-1$ self.tabSelMenuButton = ZImageButton(self, tabSelBitmap, False, tabSelHoverBitmap, False)
def __init__(self): systemProfile = getApplicationModel().getSystemProfile() self.bundleDirectory = systemProfile.getBundleDirectory() self.i18nService = getApplicationModel().getService(IZBlogAppServiceIDs.I18N_SERVICE_ID) self.defaultTranslation = self._loadDefaultTranslation(self.bundleDirectory) self.defaultTranslation.load() self.translations = self._loadTranslations(self.bundleDirectory)
def updateCategories(self, account, blogList, izcommandActivityListener): accStoreService = getApplicationModel().getService(IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) publisherService = getApplicationModel().getService(IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) publisher = createBlogPublisherFromAccount(account, publisherService) blogList = self._getFilteredAccBlogList(account, blogList) cmd = ZListCategoriesCommand(publisher, account, blogList) cmd.addListener(izcommandActivityListener) cmd.doCommand() accStoreService.saveAccount(account)
def _registerAsListener(self): # Register as a data store listener service = getApplicationModel().getService(IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) service.addListener(self) # Register as a user prefs listener appModel = getApplicationModel() userProfile = appModel.getUserProfile() userPrefs = userProfile.getPreferences() userPrefs.addListener(self)
def createMediaStorages(self, account, izcommandActivityListener): accStoreService = getApplicationModel().getService(IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) publisherService = getApplicationModel().getService(IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) mediaStoreService = getApplicationModel().getService(IZBlogAppServiceIDs.MEDIA_STORAGE_SERVICE_ID) # create publisher publisher = createBlogPublisherFromAccount(account, publisherService) cmd = ZCreateOrUpdateBlogMediaStoragesCommand(publisher, mediaStoreService, account) cmd.addListener(izcommandActivityListener) cmd.doCommand() accStoreService.saveAccount(account)
def downloadPosts(self, account, blogList, maxDocs, izcommandActivityListener): docIndexService = getApplicationModel().getService(IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID) publisherService = getApplicationModel().getService(IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) dataStoreService = getApplicationModel().getService(IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) publisher = createBlogPublisherFromAccount(account, publisherService) blogList = self._getFilteredAccBlogList(account, blogList) cmd = ZDownloadEntriesCommand(dataStoreService, docIndexService, publisher, account, blogList, maxDocs) cmd.addListener(izcommandActivityListener) cmd.doCommand()
def updateCategories(self, account, blogList, izcommandActivityListener): accStoreService = getApplicationModel().getService( IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) publisherService = getApplicationModel().getService( IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) publisher = createBlogPublisherFromAccount(account, publisherService) blogList = self._getFilteredAccBlogList(account, blogList) cmd = ZListCategoriesCommand(publisher, account, blogList) cmd.addListener(izcommandActivityListener) cmd.doCommand() accStoreService.saveAccount(account)
def _unregisterAsListener(self): # Unregister from the data store service = getApplicationModel().getService(IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) service.removeListener(self) # Unregister from the user prefs object # Register as a user prefs listener appModel = getApplicationModel() userProfile = appModel.getUserProfile() userPrefs = userProfile.getPreferences() userPrefs.removeListener(self)
def _createCommand(self, account, blog, pubMetaData): publisherService = getApplicationModel().getService(IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) dataStoreService = getApplicationModel().getService(IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) publisher = createBlogPublisherFromAccount(account, publisherService) # create update or publish command and execute command = None if self.document.isPublishedToBlog( blog.getId() ): command = ZUpdateEntryCommand(publisher, dataStoreService, account, blog, self.document, pubMetaData) else: command = ZPublishEntryCommand(publisher, dataStoreService, account, blog, self.document, pubMetaData) return command
def initializeAspellDirectory(self): spellingDir = getApplicationModel().getUserProfile().getDirectory( u"spellcheck") #$NON-NLS-1$ aspellDir = os.path.join(spellingDir, u"aspell") #$NON-NLS-1$ keyFilePath = os.path.join(aspellDir, u"data", u"ASCII.dat") #$NON-NLS-2$ #$NON-NLS-1$ if not os.path.isfile(keyFilePath): aspellBaseZip = getApplicationModel().getResourceRegistry( ).getResourcePath( u"spellcheck/aspell/aspell-base.zip") #$NON-NLS-1$ unpackZip(aspellBaseZip, aspellDir)
def __init__(self, parent): self.indexService = getApplicationModel().getService(IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID) self.accountStore = getApplicationModel().getService(IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) self.model = ZContextInfoTagsModel(ZTagSearchFilter()) self.tagCloudsView = None self.searchTextBox = None ZBoxedView.__init__(self, parent) self._registerAsIndexListener()
def _registerAsListener(self): # Register as a data store listener service = getApplicationModel().getService( IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) service.addListener(self) # Register as a user prefs listener appModel = getApplicationModel() userProfile = appModel.getUserProfile() userPrefs = userProfile.getPreferences() userPrefs.addListener(self)
def _unregisterAsListener(self): # Unregister from the data store service = getApplicationModel().getService( IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) service.removeListener(self) # Unregister from the user prefs object # Register as a user prefs listener appModel = getApplicationModel() userProfile = appModel.getUserProfile() userPrefs = userProfile.getPreferences() userPrefs.removeListener(self)
def updateBlogList(self, account, selectedBlogList, izcommandActivityListener): #@UnusedVariable accStoreService = getApplicationModel().getService(IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) publisherService = getApplicationModel().getService(IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) # create publisher publisher = createBlogPublisherFromAccount(account, publisherService) # update account's blog list from server cmd = ZListBlogsCommand(publisher, account, selectedBlogList) cmd.addListener(izcommandActivityListener) cmd.listBlogs(); # save account with the new blog lists. accStoreService.saveAccount(account)
def _run(self): template = self.grabber.grab(self) if template is not None and not self.cancelled: template.setName(self.templateName) template.setSource(u"Blog [%s]" % getSafeString(self.blog.getName())) #$NON-NLS-1$ service = getApplicationModel().getService(IZBlogAppServiceIDs.TEMPLATE_SERVICE_ID) service.saveTemplate(template) if self.bMakeDefaultTemplate: self.blog.setTemplateId(template.getId()) self.blog.getPreferences().setUserPreference(IZBlogAppUserPrefsKeys.BLOG_OVERRIDE_TEMPLATE, True) accountService = getApplicationModel().getService(IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) accountService.saveAccount(self.blog.getAccount())
def _recoverCrashSnapshots(self): crashRecoveryService = getApplicationModel().getService(IZBlogAppServiceIDs.CRASH_RECOVERY_SERVICE_ID) snapshots = crashRecoveryService.getRecoverySnapshots() if snapshots: title = _extstr(u"startup.RecoverTitle") #$NON-NLS-1$ msg = _extstr(u"startup.RecoverMessage") % len(snapshots) #$NON-NLS-1$ if ZShowYesNoMessage(getApplicationModel().getTopWindow(), msg, title): for document in snapshots: editorWindow = getEditorWindow() editorWindow.openDocument(document) editorWindow.Show() crashRecoveryService.clearRecoverySnapshot()
def __init__(self, parent): self.link = None self.blog = None self.indexService = getApplicationModel().getService(IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID) self.accountStore = getApplicationModel().getService(IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) self.model = ZContextInfoLinksModel(ZLinkSearchFilter()) self.openLinkAction = getApplicationModel().getActionRegistry().findAction(IZAppActionIDs.OPEN_LINK_ACTION) ZBoxedView.__init__(self, parent) self._registerAsIndexListener() self.validSelection = False
def downloadPosts(self, account, blogList, maxDocs, izcommandActivityListener): docIndexService = getApplicationModel().getService( IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID) publisherService = getApplicationModel().getService( IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) dataStoreService = getApplicationModel().getService( IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) publisher = createBlogPublisherFromAccount(account, publisherService) blogList = self._getFilteredAccBlogList(account, blogList) cmd = ZDownloadEntriesCommand(dataStoreService, docIndexService, publisher, account, blogList, maxDocs) cmd.addListener(izcommandActivityListener) cmd.doCommand()
def _recoverCrashSnapshots(self): crashRecoveryService = getApplicationModel().getService( IZBlogAppServiceIDs.CRASH_RECOVERY_SERVICE_ID) snapshots = crashRecoveryService.getRecoverySnapshots() if snapshots: title = _extstr(u"startup.RecoverTitle") #$NON-NLS-1$ msg = _extstr(u"startup.RecoverMessage") % len( snapshots) #$NON-NLS-1$ if ZShowYesNoMessage(getApplicationModel().getTopWindow(), msg, title): for document in snapshots: editorWindow = getEditorWindow() editorWindow.openDocument(document) editorWindow.Show() crashRecoveryService.clearRecoverySnapshot()
def createMediaStorages(self, account, izcommandActivityListener): accStoreService = getApplicationModel().getService( IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) publisherService = getApplicationModel().getService( IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) mediaStoreService = getApplicationModel().getService( IZBlogAppServiceIDs.MEDIA_STORAGE_SERVICE_ID) # create publisher publisher = createBlogPublisherFromAccount(account, publisherService) cmd = ZCreateOrUpdateBlogMediaStoragesCommand(publisher, mediaStoreService, account) cmd.addListener(izcommandActivityListener) cmd.doCommand() accStoreService.saveAccount(account)
def updateBlogList(self, account, selectedBlogList, izcommandActivityListener): #@UnusedVariable accStoreService = getApplicationModel().getService( IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) publisherService = getApplicationModel().getService( IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) # create publisher publisher = createBlogPublisherFromAccount(account, publisherService) # update account's blog list from server cmd = ZListBlogsCommand(publisher, account, selectedBlogList) cmd.addListener(izcommandActivityListener) cmd.listBlogs() # save account with the new blog lists. accStoreService.saveAccount(account)
def getBlogFromIds(accountId, blogId): accountStore = getApplicationModel().getService( IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) account = accountStore.getAccountById(accountId) if account is not None: return account.getBlogById(blogId) return None
def _createAccountMediaStores(self): # assigm media stores if needed to accounts that do not have any (e.g via WLW imports) try: accStore = getApplicationModel().getService(IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) ZAccountUtil().autoAssignMediaStores(accStore) except: pass
def _getMediaStorage(self): mediaStoreId = self._getMediaStoreId() mediastorage = None if mediaStoreId: mediaStoreService = getApplicationModel().getService(IZBlogAppServiceIDs.MEDIA_STORAGE_SERVICE_ID) mediastorage = mediaStoreService.getMediaStorageById(mediaStoreId) return mediastorage
def onTemplateToggleButton(self, event): appModel = getApplicationModel() userProfile = appModel.getUserProfile() userPrefs = userProfile.getPreferences() useTemplateInPreview = self.templateToggleButton.IsToggled() userPrefs.setUserPreference(IZBlogAppUserPrefsKeys.POST_PREVIEW_VIEW_USE_TEMPLATE, useTemplateInPreview) event.Skip()
def _showDashboardOrWelcomeView(self): accountStore = getApplicationModel().getService(IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) accounts = accountStore.getAccounts() if accounts is None or len(accounts) == 0: self._showWelcomePage() else: self._showDashboardView()
def _restoreLayout(self): userPrefs = getApplicationModel().getUserProfile().getPreferences() width = userPrefs.getUserPreferenceInt(self.persistentId + u".width", -1) #$NON-NLS-1$ height = userPrefs.getUserPreferenceInt(self.persistentId + u".height", -1) #$NON-NLS-1$ posX = userPrefs.getUserPreferenceInt(self.persistentId + u".x", -1) #$NON-NLS-1$ posY = userPrefs.getUserPreferenceInt(self.persistentId + u".y", -1) #$NON-NLS-1$ # Bound the size if width < 100: width = -1 if height < 100: width = -1 # Bound the window position if posX < 0: posX = -1 if posY < 0: posY = -1 displaySize = wx.GetDisplaySize() if posX >= displaySize.GetWidth() - 50: posX = -1 if posY >= displaySize.GetHeight() - 50: posY = -1 if width != -1 and height != -1: self.SetSize(wx.Size(width, height)) elif self.defaultToBestSize: self.SetSize(self.GetBestSize()) if posX != -1 and posY != -1: self.SetPosition(wx.Point(posX, posY)) elif self.defaultToCentreOnParent: self.CentreOnParent() else: # FIXME (EPW) this might be problematic for multi-screen setups self.CentreOnScreen()
def __init__(self): self.blogPosts = None self.accountIdCriteria = None self.blogIdCriteria = None self.blogEntryIdCriteria = None self.indexService = getApplicationModel().getService( IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID)
def _restoreTreeSelection(self): userPrefs = getApplicationModel().getUserProfile().getPreferences() hashValue = userPrefs.getUserPreferenceInt( IZBlogAppUserPrefsKeys.NAVIGATOR_VIEW_SELECTION, 0) if hashValue != 0: visitor = ZTreeSelectionRestoreVisitor(self, hashValue) self.treeView.accept(visitor)
def _createTemplate(self): templateSvc = getApplicationModel().getService(IZBlogAppServiceIDs.TEMPLATE_SERVICE_ID) # FIXME (EPW) add createTemplate() variant that takes a bool - add/noadd. then 'add' the template to the service at the end template = templateSvc.createTemplate() if template is None: template = ZTemplate() return template
def _loadAdditionalEntries(self): return [ ZAcceleratorEntry( wx.ACCEL_NORMAL, wx.WXK_DELETE, getApplicationModel().getActionRegistry().findAction( IZBlogAppActionIDs.DELETE_BLOG_POST_ACTION)) ]
def __init__(self, filter): self.currentFilter = filter self.entries = None self.engine = getApplicationModel().getEngine() self.indexService = self.engine.getService( IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID)
def _getImageSizeFromFile(self, imgPath): imgService = getApplicationModel().getService(IZAppServiceIDs.IMAGING_SERVICE_ID) (width, height) = imgService.getImageSize(imgPath) return (width, height) # end _getImageSize # end ZBlogDocumentUploadContent
def onActivated(self, event): url = self.linkListView.GetItemText(event.GetIndex()) if url: context = ZLinkActionContext(self, url) openLinkAction = getApplicationModel().getActionRegistry().findAction(IZAppActionIDs.OPEN_LINK_ACTION) openLinkAction.runAction(context) event.Skip
def _restoreLayout(self): ZPersistentDialogMixin._restoreLayout(self) userPrefs = getApplicationModel().getUserProfile().getPreferences() sashPos = userPrefs.getUserPreferenceInt(self.persistentId + u".sash-pos", -1) #$NON-NLS-1$ if sashPos != -1: self.splitterWindow.SetSashPosition(sashPos)
def __init__(self, parent): self.link = None self.blog = None self.indexService = getApplicationModel().getService( IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID) self.accountStore = getApplicationModel().getService( IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID) self.model = ZContextInfoLinksModel(ZLinkSearchFilter()) self.openLinkAction = getApplicationModel().getActionRegistry( ).findAction(IZAppActionIDs.OPEN_LINK_ACTION) ZBoxedView.__init__(self, parent) self._registerAsIndexListener() self.validSelection = False
def saveDocument(self): u"""saveDocument() -> void Invoked by the editor framework when document needs to be saved. """ #$NON-NLS-1$ if self.getDocument(): dataStore = getApplicationModel().getService(IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) dataStore.saveDocument(self.getDocument())
def onActivated(self, event): url = self.imageListView.GetItemText(event.GetIndex()) if url: context = ZImageActionContext(self, url) openAction = getApplicationModel().getActionRegistry().findAction(IZAppActionIDs.OPEN_IMAGE_ACTION) openAction.runAction(context) event.Skip
def _deleteMultiPublishedPost(self, parent, zblogDocument, blogInfos, blog): blogs = [] for blogInfo in blogInfos: b = getBlogFromBlogInfo(blogInfo) blogs.append(b) (rBool, alsoDeleteLocal, blogsToDeleteFrom) = ZShowConfirmDeletePostFromMultipleBlogsDialog( parent, zblogDocument, blog, blogs) if rBool: if not ZPublisherUiValidator().validateBlogs( parent, blogsToDeleteFrom): return if alsoDeleteLocal and not blogsToDeleteFrom: docStore = getApplicationModel().getService( IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) docStore.removeDocument(zblogDocument.getId()) else: task = ZDeletePostBackgroundTask() task.initialize(blogsToDeleteFrom, zblogDocument, alsoDeleteLocal) title = _extstr( u"publisherutil.DeletingOnlinePost") #$NON-NLS-1$ desc = _extstr(u"publisherutil.DeletingPostFromBlogs") % ( zblogDocument.getTitle(), len(blogsToDeleteFrom) ) #$NON-NLS-1$ self._addBackgroundTask(task, parent, title, desc, None)
def __init__(self): self.appModel = getApplicationModel() self.spellcheckService = self.appModel.getService( IZAppServiceIDs.SPELLCHECK_SERVICE_ID) self.i18nService = self.appModel.getService( IZAppServiceIDs.I18N_SERVICE_ID) self.userProfile = self.appModel.getUserProfile()
def __init__(self, ztest): self.ztest = ztest registry = getApplicationModel().getResourceRegistry() self.pendingImagePath = registry.getImagePath(u"images/common/ztest/pending.png") #$NON-NLS-1$ self.currentImagePath = registry.getImagePath(u"images/common/ztest/current.png") #$NON-NLS-1$ self.passImagePath = registry.getImagePath(u"images/common/ztest/pass.png") #$NON-NLS-1$ self.failImagePath = registry.getImagePath(u"images/common/ztest/fail.png") #$NON-NLS-1$
def __init__(self): self.serializer = ZUsagePacketSerializer() self.logger = None self.running = False self.version = ZVersion() self.profileGuid = getApplicationModel().getUserProfile().getGuid() self.usageDir = None
def getActiveSpellcheckerLocale(self): u"""getActiveSpellcheckerLocale() -> string Gets the locale for the currently active spell checker.""" #$NON-NLS-1$ userPrefs = getApplicationModel().getUserProfile().getPreferences() return userPrefs.getUserPreference( IZAppUserPrefsKeys.SPELLCHECKER_LANGUAGE, None)
def isVisible(self, context): #@UnusedVariable url = self._getLinkUrl(context) if url: service = getApplicationModel().getService(IZBlogAppServiceIDs.PRODUCTS_SERVICE_ID) productMD = service.findProductByUrl(url) return productMD is not None return False
def _createCommand(self, account, blog, pubMetaData): publisherService = getApplicationModel().getService( IZBlogAppServiceIDs.PUBLISHING_SERVICE_ID) dataStoreService = getApplicationModel().getService( IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID) publisher = createBlogPublisherFromAccount(account, publisherService) # create update or publish command and execute command = None if self.document.isPublishedToBlog(blog.getId()): command = ZUpdateEntryCommand(publisher, dataStoreService, account, blog, self.document, pubMetaData) else: command = ZPublishEntryCommand(publisher, dataStoreService, account, blog, self.document, pubMetaData) return command
def doFeedback(self, parent, subject=None, details=None): feedback = None # Open the feedback dialog dialog = ZFeedbackDialog(parent) if subject is not None: dialog.setSubject(subject) if details is not None: dialog.setDetails(details) if dialog.ShowModal() == wx.ID_OK: feedback = dialog.getFeedback() dialog.Destroy() # If the resulting feedback is not None, then initiate the # feedback (hit the Zoundry endpoint) and display the result # as a background task in the bg task dialog. if feedback is not None: feedbackService = getApplicationModel().getService( IZAppServiceIDs.FEEDBACK_SERVICE_ID) bgTask = feedbackService.sendFeedback(feedback) if bgTask is not None: title = _extstr(u"feedbackutil.SendingFeedback") #$NON-NLS-1$ description = _extstr( u"feedbackutil.SendingFeedbackMsg") #$NON-NLS-1$ imagePath = u"images/dialogs/bgtask/header_image.png" #$NON-NLS-1$ dialog = ZBackgroundTaskProgressDialog(parent, bgTask, title, description, imagePath) dialog.ShowModal() dialog.Destroy()