Example #1
0
    def __init__(self, parent, blogPostsListQueryModel=None, provider=None):
        if not blogPostsListQueryModel:
            blogPostsListQueryModel = ZBlogPostsListQueryModel()
        self.blogPostsListQueryModel = blogPostsListQueryModel
        if provider is None:
            provider = ZBlogPostListProvider(self.blogPostsListQueryModel)
        self.openAction = ZOpenBlogPostAction()
        self.blogPostContextMenu = ZBlogPostMenuModel()

        ZListViewEx.__init__(self, provider, parent)

        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onEntryActivated, self)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.onEntryRightClick, self)
Example #2
0
    def __init__(self, parent, blogPostsListQueryModel = None, provider = None):
        if not blogPostsListQueryModel:
            blogPostsListQueryModel = ZBlogPostsListQueryModel()
        self.blogPostsListQueryModel = blogPostsListQueryModel
        if provider is None:
            provider = ZBlogPostListProvider(self.blogPostsListQueryModel)
        self.openAction = ZOpenBlogPostAction()
        self.blogPostContextMenu = ZBlogPostMenuModel()

        ZListViewEx.__init__(self, provider, parent)

        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onEntryActivated, self)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.onEntryRightClick, self)
Example #3
0
    def __init__(self, parent):
        filter = ZDocumentSearchFilter()
        filter.setAccountIdCriteria(
            IZDocumentSearchFilter.UNPUBLISHED_ACCOUNT_ID)
        filter.setBlogIdCriteria(IZDocumentSearchFilter.UNPUBLISHED_BLOG_ID)
        self.model = ZContextInfoPostsModel(filter)
        self.openAction = getApplicationModel().getActionRegistry().findAction(
            IZBlogAppActionIDs.OPEN_BLOG_POST_ACTION)
        self.blogPostContextMenu = ZBlogPostMenuModel()
        self.postsAccelTable = ZBlogPostsListAcceleratorTable(self)
        self.document = None
        self.blog = None
        self.hasFocus = False

        self.indexService = getApplicationModel().getService(
            IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID)
        self.docStore = getApplicationModel().getService(
            IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID)
        self.accountStore = getApplicationModel().getService(
            IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID)

        ZBoxedView.__init__(self, parent)

        self._registerAsIndexListener()
Example #4
0
    def __init__(self, parent):
        filter = ZDocumentSearchFilter()
        filter.setAccountIdCriteria(IZDocumentSearchFilter.UNPUBLISHED_ACCOUNT_ID)
        filter.setBlogIdCriteria(IZDocumentSearchFilter.UNPUBLISHED_BLOG_ID)
        self.model = ZContextInfoPostsModel(filter)
        self.openAction = getApplicationModel().getActionRegistry().findAction(IZBlogAppActionIDs.OPEN_BLOG_POST_ACTION)
        self.blogPostContextMenu = ZBlogPostMenuModel()
        self.postsAccelTable = ZBlogPostsListAcceleratorTable(self)
        self.document = None
        self.blog = None
        self.hasFocus = False

        self.indexService = getApplicationModel().getService(IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID)
        self.docStore = getApplicationModel().getService(IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID)
        self.accountStore = getApplicationModel().getService(IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID)

        ZBoxedView.__init__(self, parent)

        self._registerAsIndexListener()
Example #5
0
class ZBlogPostListView(ZListViewEx):
    def __init__(self, parent, blogPostsListQueryModel=None, provider=None):
        if not blogPostsListQueryModel:
            blogPostsListQueryModel = ZBlogPostsListQueryModel()
        self.blogPostsListQueryModel = blogPostsListQueryModel
        if provider is None:
            provider = ZBlogPostListProvider(self.blogPostsListQueryModel)
        self.openAction = ZOpenBlogPostAction()
        self.blogPostContextMenu = ZBlogPostMenuModel()

        ZListViewEx.__init__(self, provider, parent)

        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onEntryActivated, self)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.onEntryRightClick, self)

    # end __init__()

    def getModel(self):
        return self.blogPostsListQueryModel

    # end getModel()

    def onEntryActivated(self, event):
        index = event.GetIndex()
        docIDO = self.blogPostsListQueryModel.getDocumentIDO(index)
        actionContext = ZBlogPostActionContext(self, docIDO)
        self.openAction.runAction(actionContext)

    # end onEntryActivated()

    def onEntryRightClick(self, event):
        index = event.GetIndex()
        docIDO = self.blogPostsListQueryModel.getDocumentIDO(index)
        actionContext = ZBlogPostActionContext(self, docIDO)
        provider = ZModelBasedMenuContentProvider(self.blogPostContextMenu,
                                                  actionContext)
        handler = ZModelBasedMenuEventHandler(self.blogPostContextMenu,
                                              actionContext)
        menu = ZMenu(self, self.blogPostContextMenu.getRootNode(), provider,
                     handler)
        self.PopupMenu(menu)
        event.Skip()
Example #6
0
class ZBlogPostListView(ZListViewEx):

    def __init__(self, parent, blogPostsListQueryModel = None, provider = None):
        if not blogPostsListQueryModel:
            blogPostsListQueryModel = ZBlogPostsListQueryModel()
        self.blogPostsListQueryModel = blogPostsListQueryModel
        if provider is None:
            provider = ZBlogPostListProvider(self.blogPostsListQueryModel)
        self.openAction = ZOpenBlogPostAction()
        self.blogPostContextMenu = ZBlogPostMenuModel()

        ZListViewEx.__init__(self, provider, parent)

        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onEntryActivated, self)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.onEntryRightClick, self)
    # end __init__()

    def getModel(self):
        return self.blogPostsListQueryModel
    # end getModel()

    def onEntryActivated(self, event):
        index = event.GetIndex()
        docIDO = self.blogPostsListQueryModel.getDocumentIDO(index)
        actionContext = ZBlogPostActionContext(self, docIDO)
        self.openAction.runAction(actionContext)
    # end onEntryActivated()

    def onEntryRightClick(self, event):
        index = event.GetIndex()
        docIDO = self.blogPostsListQueryModel.getDocumentIDO(index)
        actionContext = ZBlogPostActionContext(self, docIDO)
        provider = ZModelBasedMenuContentProvider(self.blogPostContextMenu, actionContext)
        handler = ZModelBasedMenuEventHandler(self.blogPostContextMenu, actionContext)
        menu = ZMenu(self, self.blogPostContextMenu.getRootNode(), provider, handler)
        self.PopupMenu(menu)
        event.Skip()
Example #7
0
class ZBlogPostsView(ZBoxedView, IZDocumentIndexListener):
    def __init__(self, parent):
        filter = ZDocumentSearchFilter()
        filter.setAccountIdCriteria(
            IZDocumentSearchFilter.UNPUBLISHED_ACCOUNT_ID)
        filter.setBlogIdCriteria(IZDocumentSearchFilter.UNPUBLISHED_BLOG_ID)
        self.model = ZContextInfoPostsModel(filter)
        self.openAction = getApplicationModel().getActionRegistry().findAction(
            IZBlogAppActionIDs.OPEN_BLOG_POST_ACTION)
        self.blogPostContextMenu = ZBlogPostMenuModel()
        self.postsAccelTable = ZBlogPostsListAcceleratorTable(self)
        self.document = None
        self.blog = None
        self.hasFocus = False

        self.indexService = getApplicationModel().getService(
            IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID)
        self.docStore = getApplicationModel().getService(
            IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID)
        self.accountStore = getApplicationModel().getService(
            IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID)

        ZBoxedView.__init__(self, parent)

        self._registerAsIndexListener()

    # end __init__()

    def getViewId(self):
        return IZViewIds.POSTS_LIST_VIEW

    # end getViewId()

    def _getHeaderBitmap(self):
        return getResourceRegistry().getBitmap(
            u"images/perspectives/standard/posts.png")  #$NON-NLS-1$

    # end _getHeaderBitmap()

    def _getHeaderLabel(self):
        return _extstr(u"postsview.BlogPosts")  #$NON-NLS-1$

    # end _getHeaderLabel()

    def _createHeaderWidgets(self, parent, widgetList):
        self.viewLabel = wx.StaticText(
            parent, wx.ID_ANY, _extstr(u"postsview.Filter"))  #$NON-NLS-1$
        choices = self._getViewChoices()
        self.viewCombo = wx.ComboBox(parent,
                                     wx.ID_ANY,
                                     _extstr(u"postsview.All"),
                                     style=wx.CB_READONLY,
                                     choices=choices)  #$NON-NLS-1$
        choices = self._getSearchBoxChoices()
        bitmap = getResourceRegistry().getBitmap(
            u"images/perspectives/standard/contextinfo/postsview/search.png"
        )  #$NON-NLS-1$
        self.searchTextBox = ZAdvancedTextBox(parent, bitmap, choices, False)
        self.searchTextBox.setCurrentChoice(SEARCH_TB_TITLE)
        self.searchTextBox.SetSizeHints(220, -1)

        widgetList.append(self.viewLabel)
        widgetList.append(self.viewCombo)
        widgetList.append(self.searchTextBox)

    # end _createHeaderWidgets()

    def _createContentWidgets(self, parent):
        provider = ZBlogEntryListContentProvider(self.model)
        style = wx.LC_VIRTUAL | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.NO_BORDER
        self.entriesListView = ZListViewEx(provider, parent, style=style)
        self.entriesListView.SetAcceleratorTable(self.postsAccelTable)

    # end _createContentWidgets()

    def _layoutContentWidgets(self):
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.entriesListView, 1, wx.EXPAND)
        return box

    # end _layoutContentWidgets()

    def _bindWidgetEvents(self):
        ZBoxedView._bindWidgetEvents(self)

        self.postsAccelTable.bindTo(self.entriesListView)

        self.Bind(ZEVT_REFRESH, self.onZoundryRefresh, self)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onEntryActivated,
                  self.entriesListView)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onEntrySelected,
                  self.entriesListView)
        self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.onEntryBeginDrag,
                  self.entriesListView)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.onEntryRightClick,
                  self.entriesListView)
        self.Bind(wx.EVT_COMBOBOX, self.onViewCombo, self.viewCombo)
        self.Bind(wx.EVT_TEXT_ENTER, self.onSearchText, self.searchTextBox)
        self.Bind(ZEVT_VIEW_SELECTION_CHANGED, self.onViewSelectionChanged)
        wx.EVT_SET_FOCUS(self.entriesListView, self.onFocus)
        wx.EVT_KILL_FOCUS(self.entriesListView, self.onUnFocus)

    # end _bindWidgetEvents()

    def refreshContent(self, selection):
        isUnselecting = False
        if self.entriesListView.getSelection():
            isUnselecting = True

        (accountId, blogId) = selection.getData()

        filter = ZDocumentSearchFilter()
        if blogId is not None:
            account = self.accountStore.getAccountById(accountId)
            self.blog = account.getBlogById(blogId)
            filter.setAccountIdCriteria(accountId)
            filter.setBlogIdCriteria(blogId)
        else:
            self.blog = None
            filter.setAccountIdCriteria(
                IZDocumentSearchFilter.UNPUBLISHED_ACCOUNT_ID)
            filter.setBlogIdCriteria(
                IZDocumentSearchFilter.UNPUBLISHED_BLOG_ID)

        self.model = ZContextInfoPostsModel(filter)
        self.entriesListView.setContentProvider(
            ZBlogEntryListContentProvider(self.model))
        self.entriesListView.refresh()
        self.entriesListView.deselectAll()
        self.onInvalidSelection()
        if isUnselecting:
            fireViewUnselectionEvent()

    # end refreshContent()

    def onViewSelectionChanged(self, event):
        if event.getSelection().getType(
        ) == IZViewSelectionTypes.BLOG_POSTS_SELECTION:
            self.refreshContent(event.getSelection())
        event.Skip()

    # end onViewSelectionChanged()

    def onFocus(self, event):
        if not self.hasFocus:
            if self.document:
                fireViewSelectionEvent(
                    ZDocumentSelection(self.document, self.blog), self)
            else:
                fireViewUnselectionEvent()
            self.hasFocus = True
        event.Skip()

    # end onFocus()

    def onUnFocus(self, event):
        if self.hasFocus:
            fireViewUnselectionEvent()
            self.hasFocus = False
        event.Skip()

    # end onUnFocus()

    def onViewCombo(self, event):
        choice = event.GetSelection()
        self.model.clearDraftCriteria()
        self.model.clearDateRangeCriteria()
        if choice == VIEW_CHOICE_DRAFTS:
            self.model.setDraftCriteria()
        elif choice == VIEW_CHOICE_PUBLISHED:
            self.model.setDraftCriteria(False)
        elif choice == VIEW_CHOICE_TODAY:
            dateRange = getRangeForToday()
            self.model.setDateRangeCriteria(dateRange.getStartDate(),
                                            dateRange.getEndDate())
        elif choice == VIEW_CHOICE_YESTERDAY:
            dateRange = getRangeForYesterday()
            self.model.setDateRangeCriteria(dateRange.getStartDate(),
                                            dateRange.getEndDate())
        elif choice == VIEW_CHOICE_THISWEEK:
            dateRange = getRangeForThisWeek()
            self.model.setDateRangeCriteria(dateRange.getStartDate(),
                                            dateRange.getEndDate())
        elif choice == VIEW_CHOICE_THISMONTH:
            dateRange = getRangeForThisMonth()
            self.model.setDateRangeCriteria(dateRange.getStartDate(),
                                            dateRange.getEndDate())
        self.model.refresh()
        self.entriesListView.refresh()
        self.entriesListView.deselectAll()
        self.onInvalidSelection()

        fireViewEvent(ZViewEvent(VIEWBLOGPOSTSFILTERCHANGEDEVENT, self))
        event.Skip()

    # end onViewCombo()

    def onSearchText(self, event):
        self.model.setTitleCriteria(event.GetString())
        self.model.refresh()
        self.entriesListView.refresh()
        self.entriesListView.deselectAll()
        self.onInvalidSelection()

        fireViewEvent(ZViewEvent(VIEWBLOGPOSTSFILTERCHANGEDEVENT, self))
        event.Skip()

    # end onSearchText()

    def onEntryBeginDrag(self, event):
        index = event.GetIndex()
        docIDO = self.model.getEntry(index)
        docId = docIDO.getId()

        # FIXME (EPW) also add some sort of custom format for dragging to the Explorer/TextPad (use a composite data object)
        data = wx.DataObjectComposite()
        #        url = self._getUrlFromDocIDO(docIDO)
        #        if url is not None:
        #            data.Add(ZURLDataObject(url))
        data.Add(ZBlogPostDataObjectInternal(docId))
        #        data.Add(wx.TextDataObject(str(convertToUtf8(u"Hello World"))))

        dragSource = wx.DropSource(self)
        dragSource.SetData(data)
        dragSource.DoDragDrop(wx.Drag_CopyOnly)
        event.Skip()

    # end onEntryBeginDrag()

    def _updateModel(self, refreshData):
        (eventType, documentIDO) = refreshData
        shouldRefresh = False
        if eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_ADD:
            shouldRefresh = self.model.addEntry(documentIDO)
        elif eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_REMOVE:
            shouldRefresh = self.model.removeEntry(documentIDO)
        elif eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_UPDATE:
            shouldRefresh = self.model.updateEntry(documentIDO)
        return shouldRefresh

    # end _updateModel()

    # This is the only method that can happen on a non-UI thread.  It will
    # gather up the needed data, then fire a "refresh ui" event.  That event
    # will get picked up by the UI thread and the view will refresh.
    def onIndexChange(self, event):
        if event.getDataType() == IZDocIndexEvent.DOCINDEX_DATATYPE_DOCUMENT:
            refreshData = (event.getEventType(), event.getDocumentIDO())
            fireRefreshEvent(self, refreshData)

    # end onIndexChange()

    def onZoundryRefresh(self, event):  #@UnusedVariable
        if self._updateModel(event.getData()):
            self.entriesListView.refresh()
            selection = self.entriesListView.getSelection()
            if not selection:
                self.onInvalidSelection()
                fireViewUnselectionEvent()
            else:
                selIdx = selection[0]
                newDocIDO = self.model.getEntry(selIdx)
                newDoc = self.docStore.getDocument(newDocIDO.getId())
                self.document = newDoc
                fireViewSelectionEvent(
                    ZDocumentSelection(self.document, self.blog), self)
        event.Skip()

    # end onZoundryRefresh()

    def onEntryRightClick(self, event):
        index = event.GetIndex()
        docIDO = self.model.getEntry(index)
        blogId = None
        if self.blog is not None:
            blogId = self.blog.getId()
        actionContext = ZBlogPostActionContext(self, docIDO, blogId)
        provider = ZModelBasedMenuContentProvider(self.blogPostContextMenu,
                                                  actionContext)
        handler = ZModelBasedMenuEventHandler(self.blogPostContextMenu,
                                              actionContext)
        menu = ZMenu(self, self.blogPostContextMenu.getRootNode(), provider,
                     handler)
        self.PopupMenu(menu)
        event.Skip()

    # end onEntryRightClick()

    def onEntryActivated(self, event):
        index = event.GetIndex()
        docIDO = self.model.getEntry(index)
        blogId = None
        if self.blog is not None:
            blogId = self.blog.getId()
        actionContext = ZBlogPostActionContext(self, docIDO, blogId)
        self.openAction.runAction(actionContext)
        event.Skip()

    # end onEntryActivated()

    def onEntrySelected(self, event):
        index = event.GetIndex()
        docIDO = self.model.getEntry(index)
        docId = docIDO.getId()
        self.document = self.docStore.getDocument(docId)

        if self.document:
            fireViewSelectionEvent(
                ZDocumentSelection(self.document, self.blog), self)
        else:
            fireViewUnselectionEvent()

        event.Skip()

    # end onEntrySelected()

    def onInvalidSelection(self):
        self.document = None

    # end onInvalidSelection()

    def createActionContext(self):
        docIDO = None
        blogId = None
        selection = self.entriesListView.getSelection()
        if selection:
            index = selection[0]
            docIDO = self.model.getEntry(index)
            if self.blog is not None:
                blogId = self.blog.getId()
        return ZBlogPostActionContext(self, docIDO, blogId)

    # end createActionContext()

    def destroy(self):
        self._unregisterAsIndexListener()

    # end destroy()

    def _getViewChoices(self):
        return [
            _extstr(u"postsview.All"),  #$NON-NLS-1$
            _extstr(u"postsview.Drafts"),  #$NON-NLS-1$
            _extstr(u"postsview.Published"),  #$NON-NLS-1$
            _extstr(u"postsview.Today"),  #$NON-NLS-1$
            u"-----------",  #$NON-NLS-1$
            _extstr(u"postsview.Yesterday"),  #$NON-NLS-1$
            _extstr(u"postsview.ThisWeek"),  #$NON-NLS-1$
            _extstr(u"postsview.ThisMonth")  #$NON-NLS-1$
        ]

    # end _getViewChoices()

    def _getSearchBoxChoices(self):
        return [
            (_extstr(u"postsview.Title"), None, SEARCH_TB_TITLE),  #$NON-NLS-1$
        ]

    # end _getSearchBoxChoices()

    def _getUrlFromDocIDO(self, docIDO):
        url = None
        if self.blog is not None:
            pdIDO = docIDO.getPubDataIDO(self.blog.getId())
            if pdIDO is not None:
                url = pdIDO.getUrl()
        return url

    # end _getUrlFromDocIDO()

    def _registerAsIndexListener(self):
        self.indexService.addListener(self)

    # end _registerAsIndexListener()

    def _unregisterAsIndexListener(self):
        self.indexService.removeListener(self)
Example #8
0
class ZBlogPostsView(ZBoxedView, IZDocumentIndexListener):

    def __init__(self, parent):
        filter = ZDocumentSearchFilter()
        filter.setAccountIdCriteria(IZDocumentSearchFilter.UNPUBLISHED_ACCOUNT_ID)
        filter.setBlogIdCriteria(IZDocumentSearchFilter.UNPUBLISHED_BLOG_ID)
        self.model = ZContextInfoPostsModel(filter)
        self.openAction = getApplicationModel().getActionRegistry().findAction(IZBlogAppActionIDs.OPEN_BLOG_POST_ACTION)
        self.blogPostContextMenu = ZBlogPostMenuModel()
        self.postsAccelTable = ZBlogPostsListAcceleratorTable(self)
        self.document = None
        self.blog = None
        self.hasFocus = False

        self.indexService = getApplicationModel().getService(IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID)
        self.docStore = getApplicationModel().getService(IZBlogAppServiceIDs.DATA_STORE_SERVICE_ID)
        self.accountStore = getApplicationModel().getService(IZBlogAppServiceIDs.ACCOUNT_STORE_SERVICE_ID)

        ZBoxedView.__init__(self, parent)

        self._registerAsIndexListener()
    # end __init__()

    def getViewId(self):
        return IZViewIds.POSTS_LIST_VIEW
    # end getViewId()

    def _getHeaderBitmap(self):
        return getResourceRegistry().getBitmap(u"images/perspectives/standard/posts.png") #$NON-NLS-1$
    # end _getHeaderBitmap()

    def _getHeaderLabel(self):
        return _extstr(u"postsview.BlogPosts") #$NON-NLS-1$
    # end _getHeaderLabel()

    def _createHeaderWidgets(self, parent, widgetList):
        self.viewLabel = wx.StaticText(parent, wx.ID_ANY, _extstr(u"postsview.Filter")) #$NON-NLS-1$
        choices = self._getViewChoices()
        self.viewCombo = wx.ComboBox(parent, wx.ID_ANY, _extstr(u"postsview.All"), style = wx.CB_READONLY, choices = choices) #$NON-NLS-1$
        choices = self._getSearchBoxChoices()
        bitmap = getResourceRegistry().getBitmap(u"images/perspectives/standard/contextinfo/postsview/search.png") #$NON-NLS-1$
        self.searchTextBox = ZAdvancedTextBox(parent, bitmap, choices, False)
        self.searchTextBox.setCurrentChoice(SEARCH_TB_TITLE)
        self.searchTextBox.SetSizeHints(220, -1)

        widgetList.append(self.viewLabel)
        widgetList.append(self.viewCombo)
        widgetList.append(self.searchTextBox)
    # end _createHeaderWidgets()

    def _createContentWidgets(self, parent):
        provider = ZBlogEntryListContentProvider(self.model)
        style = wx.LC_VIRTUAL | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.NO_BORDER
        self.entriesListView = ZListViewEx(provider, parent, style = style)
        self.entriesListView.SetAcceleratorTable(self.postsAccelTable)
    # end _createContentWidgets()

    def _layoutContentWidgets(self):
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.entriesListView, 1, wx.EXPAND)
        return box
    # end _layoutContentWidgets()

    def _bindWidgetEvents(self):
        ZBoxedView._bindWidgetEvents(self)

        self.postsAccelTable.bindTo(self.entriesListView)

        self.Bind(ZEVT_REFRESH, self.onZoundryRefresh, self)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onEntryActivated, self.entriesListView)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onEntrySelected, self.entriesListView)
        self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.onEntryBeginDrag, self.entriesListView)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.onEntryRightClick, self.entriesListView)
        self.Bind(wx.EVT_COMBOBOX, self.onViewCombo, self.viewCombo)
        self.Bind(wx.EVT_TEXT_ENTER, self.onSearchText, self.searchTextBox)
        self.Bind(ZEVT_VIEW_SELECTION_CHANGED, self.onViewSelectionChanged)
        wx.EVT_SET_FOCUS(self.entriesListView, self.onFocus)
        wx.EVT_KILL_FOCUS(self.entriesListView, self.onUnFocus)
    # end _bindWidgetEvents()

    def refreshContent(self, selection):
        isUnselecting = False
        if self.entriesListView.getSelection():
            isUnselecting = True

        (accountId, blogId) = selection.getData()

        filter = ZDocumentSearchFilter()
        if blogId is not None:
            account = self.accountStore.getAccountById(accountId)
            self.blog = account.getBlogById(blogId)
            filter.setAccountIdCriteria(accountId)
            filter.setBlogIdCriteria(blogId)
        else:
            self.blog = None
            filter.setAccountIdCriteria(IZDocumentSearchFilter.UNPUBLISHED_ACCOUNT_ID)
            filter.setBlogIdCriteria(IZDocumentSearchFilter.UNPUBLISHED_BLOG_ID)

        self.model = ZContextInfoPostsModel(filter)
        self.entriesListView.setContentProvider(ZBlogEntryListContentProvider(self.model))
        self.entriesListView.refresh()
        self.entriesListView.deselectAll()
        self.onInvalidSelection()
        if isUnselecting:
            fireViewUnselectionEvent()
    # end refreshContent()

    def onViewSelectionChanged(self, event):
        if event.getSelection().getType() == IZViewSelectionTypes.BLOG_POSTS_SELECTION:
            self.refreshContent(event.getSelection())
        event.Skip()
    # end onViewSelectionChanged()

    def onFocus(self, event):
        if not self.hasFocus:
            if self.document:
                fireViewSelectionEvent(ZDocumentSelection(self.document, self.blog), self)
            else:
                fireViewUnselectionEvent()
            self.hasFocus = True
        event.Skip()
    # end onFocus()

    def onUnFocus(self, event):
        if self.hasFocus:
            fireViewUnselectionEvent()
            self.hasFocus = False
        event.Skip()
    # end onUnFocus()

    def onViewCombo(self, event):
        choice = event.GetSelection()
        self.model.clearDraftCriteria()
        self.model.clearDateRangeCriteria()
        if choice == VIEW_CHOICE_DRAFTS:
            self.model.setDraftCriteria()
        elif choice == VIEW_CHOICE_PUBLISHED:
            self.model.setDraftCriteria(False)
        elif choice == VIEW_CHOICE_TODAY:
            dateRange = getRangeForToday()
            self.model.setDateRangeCriteria(dateRange.getStartDate(), dateRange.getEndDate())
        elif choice == VIEW_CHOICE_YESTERDAY:
            dateRange = getRangeForYesterday()
            self.model.setDateRangeCriteria(dateRange.getStartDate(), dateRange.getEndDate())
        elif choice == VIEW_CHOICE_THISWEEK:
            dateRange = getRangeForThisWeek()
            self.model.setDateRangeCriteria(dateRange.getStartDate(), dateRange.getEndDate())
        elif choice == VIEW_CHOICE_THISMONTH:
            dateRange = getRangeForThisMonth()
            self.model.setDateRangeCriteria(dateRange.getStartDate(), dateRange.getEndDate())
        self.model.refresh()
        self.entriesListView.refresh()
        self.entriesListView.deselectAll()
        self.onInvalidSelection()

        fireViewEvent(ZViewEvent(VIEWBLOGPOSTSFILTERCHANGEDEVENT, self))
        event.Skip()
    # end onViewCombo()

    def onSearchText(self, event):
        self.model.setTitleCriteria(event.GetString())
        self.model.refresh()
        self.entriesListView.refresh()
        self.entriesListView.deselectAll()
        self.onInvalidSelection()

        fireViewEvent(ZViewEvent(VIEWBLOGPOSTSFILTERCHANGEDEVENT, self))
        event.Skip()
    # end onSearchText()

    def onEntryBeginDrag(self, event):
        index = event.GetIndex()
        docIDO = self.model.getEntry(index)
        docId = docIDO.getId()

        # FIXME (EPW) also add some sort of custom format for dragging to the Explorer/TextPad (use a composite data object)
        data = wx.DataObjectComposite()
#        url = self._getUrlFromDocIDO(docIDO)
#        if url is not None:
#            data.Add(ZURLDataObject(url))
        data.Add(ZBlogPostDataObjectInternal(docId))
#        data.Add(wx.TextDataObject(str(convertToUtf8(u"Hello World"))))

        dragSource = wx.DropSource(self)
        dragSource.SetData(data)
        dragSource.DoDragDrop(wx.Drag_CopyOnly)
        event.Skip()
    # end onEntryBeginDrag()

    def _updateModel(self, refreshData):
        (eventType, documentIDO) = refreshData
        shouldRefresh = False
        if eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_ADD:
            shouldRefresh = self.model.addEntry(documentIDO)
        elif eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_REMOVE:
            shouldRefresh = self.model.removeEntry(documentIDO)
        elif eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_UPDATE:
            shouldRefresh = self.model.updateEntry(documentIDO)
        return shouldRefresh
    # end _updateModel()

    # This is the only method that can happen on a non-UI thread.  It will
    # gather up the needed data, then fire a "refresh ui" event.  That event
    # will get picked up by the UI thread and the view will refresh.
    def onIndexChange(self, event):
        if event.getDataType() == IZDocIndexEvent.DOCINDEX_DATATYPE_DOCUMENT:
            refreshData = (event.getEventType(), event.getDocumentIDO())
            fireRefreshEvent(self, refreshData)
    # end onIndexChange()

    def onZoundryRefresh(self, event): #@UnusedVariable
        if self._updateModel(event.getData()):
            self.entriesListView.refresh()
            selection = self.entriesListView.getSelection()
            if not selection:
                self.onInvalidSelection()
                fireViewUnselectionEvent()
            else:
                selIdx = selection[0]
                newDocIDO = self.model.getEntry(selIdx)
                newDoc = self.docStore.getDocument(newDocIDO.getId())
                self.document = newDoc
                fireViewSelectionEvent(ZDocumentSelection(self.document, self.blog), self)
        event.Skip()
    # end onZoundryRefresh()

    def onEntryRightClick(self, event):
        index = event.GetIndex()
        docIDO = self.model.getEntry(index)
        blogId = None
        if self.blog is not None:
            blogId = self.blog.getId()
        actionContext = ZBlogPostActionContext(self, docIDO, blogId)
        provider = ZModelBasedMenuContentProvider(self.blogPostContextMenu, actionContext)
        handler = ZModelBasedMenuEventHandler(self.blogPostContextMenu, actionContext)
        menu = ZMenu(self, self.blogPostContextMenu.getRootNode(), provider, handler)
        self.PopupMenu(menu)
        event.Skip()
    # end onEntryRightClick()

    def onEntryActivated(self, event):
        index = event.GetIndex()
        docIDO = self.model.getEntry(index)
        blogId = None
        if self.blog is not None:
            blogId = self.blog.getId()
        actionContext = ZBlogPostActionContext(self, docIDO, blogId)
        self.openAction.runAction(actionContext)
        event.Skip()
    # end onEntryActivated()

    def onEntrySelected(self, event):
        index = event.GetIndex()
        docIDO = self.model.getEntry(index)
        docId = docIDO.getId()
        self.document = self.docStore.getDocument(docId)

        if self.document:
            fireViewSelectionEvent(ZDocumentSelection(self.document, self.blog), self)
        else:
            fireViewUnselectionEvent()

        event.Skip()
    # end onEntrySelected()

    def onInvalidSelection(self):
        self.document = None
    # end onInvalidSelection()

    def createActionContext(self):
        docIDO = None
        blogId = None
        selection = self.entriesListView.getSelection()
        if selection:
            index = selection[0]
            docIDO = self.model.getEntry(index)
            if self.blog is not None:
                blogId = self.blog.getId()
        return ZBlogPostActionContext(self, docIDO, blogId)
    # end createActionContext()

    def destroy(self):
        self._unregisterAsIndexListener()
    # end destroy()

    def _getViewChoices(self):
        return [
                _extstr(u"postsview.All"), #$NON-NLS-1$
                _extstr(u"postsview.Drafts"), #$NON-NLS-1$
                _extstr(u"postsview.Published"), #$NON-NLS-1$
                _extstr(u"postsview.Today"), #$NON-NLS-1$
                u"-----------", #$NON-NLS-1$
                _extstr(u"postsview.Yesterday"), #$NON-NLS-1$
                _extstr(u"postsview.ThisWeek"), #$NON-NLS-1$
                _extstr(u"postsview.ThisMonth") #$NON-NLS-1$
        ]
    # end _getViewChoices()

    def _getSearchBoxChoices(self):
        return [
                (_extstr(u"postsview.Title"), None, SEARCH_TB_TITLE), #$NON-NLS-1$
        ]
    # end _getSearchBoxChoices()

    def _getUrlFromDocIDO(self, docIDO):
        url = None
        if self.blog is not None:
            pdIDO = docIDO.getPubDataIDO(self.blog.getId())
            if pdIDO is not None:
                url = pdIDO.getUrl()
        return url
    # end _getUrlFromDocIDO()

    def _registerAsIndexListener(self):
        self.indexService.addListener(self)
    # end _registerAsIndexListener()

    def _unregisterAsIndexListener(self):
        self.indexService.removeListener(self)