Beispiel #1
0
    def _createHeaderWidgets(self, parent, widgetList):
        choices = self._getSearchBoxChoices()
        bitmap = getResourceRegistry().getBitmap(u"images/perspectives/standard/contextinfo/linksview/search.png") #$NON-NLS-1$
        self.searchTextBox = ZAdvancedTextBox(parent, bitmap, choices, False)
        self.searchTextBox.setCurrentChoice(SEARCH_TAG)
        self.searchTextBox.SetSizeHints(220, -1)

        widgetList.append(self.searchTextBox)
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
class ZTagsView(ZBoxedView, IZDocumentIndexListener):

    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()
    # end __init__()

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

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

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

    def _createHeaderWidgets(self, parent, widgetList):
        choices = self._getSearchBoxChoices()
        bitmap = getResourceRegistry().getBitmap(u"images/perspectives/standard/contextinfo/linksview/search.png") #$NON-NLS-1$
        self.searchTextBox = ZAdvancedTextBox(parent, bitmap, choices, False)
        self.searchTextBox.setCurrentChoice(SEARCH_TAG)
        self.searchTextBox.SetSizeHints(220, -1)

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

    def _createContentWidgets(self, parent):
        self.tagCloudsView = ZInfoTagCloudPanel(parent, self.model)
    # end _createContentWidgets()

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

    def _bindWidgetEvents(self):
        ZBoxedView._bindWidgetEvents(self)
        self.Bind(ZEVT_REFRESH, self.onZoundryRefresh, self)
        self.Bind(wx.EVT_TEXT_ENTER, self.onSearchText, self.searchTextBox)
        self.Bind(ZEVT_VIEW_SELECTION_CHANGED, self.onViewSelectionChanged)
    # end _bindWidgetEvents()

    def _getSearchBoxChoices(self):
        return [
                (u"Tag", None, SEARCH_TAG), #$NON-NLS-1$
        ]
    # end _getSearchBoxChoices()

    def onSearchText(self, event):
        self.model.setTagCriteria(event.GetString())
        self.model.refresh()
        self.tagCloudsView.refresh()
        self.onInvalidSelection()

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

    def _updateModel(self, refreshData):
        (eventType, tagIDO) = refreshData
        shouldRefresh = False
        if eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_ADD:
            shouldRefresh = self.model.addTag(tagIDO)
        elif eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_REMOVE:
            shouldRefresh = self.model.removeTag(tagIDO)
        elif eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_UPDATE:
            shouldRefresh = self.model.updateTag(tagIDO)
        return shouldRefresh
    # end _updateModel()

    def onIndexChange(self, event):
        if event.getDataType() == IZDocIndexEvent.DOCINDEX_DATATYPE_TAG:
            refreshData = (event.getEventType(), event.getTagIDO())
            fireRefreshEvent(self, refreshData)
    # end onIndexChange()

    def onZoundryRefresh(self, event): #@UnusedVariable
        if self._updateModel(event.getData()):
            self.tagCloudsView.refresh()
        event.Skip()
    # end onZoundryRefresh()

    def onInvalidSelection(self):
        pass
    # end onInvalidSelection()

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

    def refreshContent(self, selection):
        (accountId, blogId) = selection.getData()

        filter = ZTagSearchFilter()
        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(IZTagSearchFilter.UNPUBLISHED_ACCOUNT_ID)
            filter.setBlogIdCriteria(IZTagSearchFilter.UNPUBLISHED_BLOG_ID)

        self.model = ZContextInfoTagsModel(filter)
        self.tagCloudsView.setBlog(self.blog)
        self.tagCloudsView.setModel(self.model)
        self.tagCloudsView.refresh()
        fireViewUnselectionEvent()
    # end refreshContent()

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

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

    def _unregisterAsIndexListener(self):
        self.indexService.removeListener(self)
Beispiel #5
0
class ZLinksView(ZBoxedView, IZDocumentIndexListener):
    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

    # end __init__()

    def getViewId(self):
        return IZViewIds.LINKS_LIST_VIEW

    # end getViewId()

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

    # end _getHeaderBitmap()

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

    # end _getHeaderLabel()

    def _createHeaderWidgets(self, parent, widgetList):
        choices = self._getSearchBoxChoices()
        bitmap = getResourceRegistry().getBitmap(
            u"images/perspectives/standard/contextinfo/linksview/search.png"
        )  #$NON-NLS-1$
        self.searchTextBox = ZAdvancedTextBox(parent, bitmap, choices, False)
        self.searchTextBox.setCurrentChoice(SEARCH_HOST)
        self.searchTextBox.SetSizeHints(220, -1)

        widgetList.append(self.searchTextBox)

    # end _createHeaderWidgets()

    def _createContentWidgets(self, parent):
        treeStyle = wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT | wx.TR_SINGLE | wx.TR_HAS_BUTTONS | wx.NO_BORDER
        provider = ZLinkTreeContentProvider(self.model)
        self.linksTreeView = ZTreeView(provider, parent, style=treeStyle)

    # end _createContentWidgets()

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

    # end _layoutContentWidgets()

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

        self.Bind(ZEVT_REFRESH, self.onZoundryRefresh, self)
        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.onLinkActivated,
                  self.linksTreeView)
        self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.onLinkRightClick,
                  self.linksTreeView)
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.onLinkSelected,
                  self.linksTreeView)
        #        self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.onEntryBeginDrag, self.linksTreeView)
        self.Bind(wx.EVT_TEXT_ENTER, self.onSearchText, self.searchTextBox)
        self.Bind(ZEVT_VIEW_SELECTION_CHANGED, self.onViewSelectionChanged)
        wx.EVT_SET_FOCUS(self.linksTreeView, self.onFocus)
        wx.EVT_KILL_FOCUS(self.linksTreeView, self.onUnFocus)

    # end _bindWidgetEvents()

    def refreshContent(self, selection):
        (accountId, blogId) = selection.getData()

        filter = ZLinkSearchFilter()
        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(
                IZLinkSearchFilter.UNPUBLISHED_ACCOUNT_ID)
            filter.setBlogIdCriteria(IZLinkSearchFilter.UNPUBLISHED_BLOG_ID)

        self.model = ZContextInfoLinksModel(filter)
        self.linksTreeView.setContentProvider(
            ZLinkTreeContentProvider(self.model))
        self.linksTreeView.refresh()
        self.linksTreeView.deselectAll()
        self.onInvalidSelection()
        fireViewUnselectionEvent()

    # end refreshContent()

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

    # end onViewSelectionChanged()

    def onFocus(self, event):
        if self.link:
            fireViewSelectionEvent(ZLinkSelection(self.link, self.blog), self)
        else:
            fireViewUnselectionEvent()
        event.Skip()

    # end onFocus()

    def onUnFocus(self, event):
        fireViewUnselectionEvent()
        event.Skip()

    # end onUnFocus()

    def onSearchText(self, event):
        self.model.setHostCriteria(event.GetString())
        self.model.refresh()
        self.linksTreeView.clear()
        self.linksTreeView.refresh()
        self.linksTreeView.deselectAll()
        self.onInvalidSelection()

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

    # end onSearchText()
#
#    def onEntryBeginDrag(self, event):
#        index = event.GetIndex()
#        docIDO = self.model.getEntry(index)
#        docId = docIDO.getId()
#
#        # FIXME also add some sort of custom format for dragging to the Explorer/TextPad (use a composite data object)
#        data = ZBlogPostDataObjectInternal(docId)
#        dragSource = wx.DropSource(self)
#        dragSource.SetData(data)
#        dragSource.DoDragDrop(wx.Drag_CopyOnly)
#        event.Skip()
#    # end onEntryBeginDrag()

    def _updateModel(self, refreshData):
        (eventType, linkIDO) = refreshData
        shouldRefresh = False
        if eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_ADD:
            shouldRefresh = self.model.addLink(linkIDO)
        elif eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_REMOVE:
            shouldRefresh = self.model.removeLink(linkIDO)
        elif eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_UPDATE:
            shouldRefresh = self.model.updateLink(linkIDO)
        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_LINK:
            refreshData = (event.getEventType(), event.getLinkIDO())
            fireRefreshEvent(self, refreshData)

    # end onIndexChange()

    def onZoundryRefresh(self, event):
        if self._updateModel(event.getData()):
            self.linksTreeView.refresh()
        event.Skip()

    # end onZoundryRefresh()

    def onLinkActivated(self, event):
        node = self.linksTreeView.GetPyData(event.GetItem())
        if isinstance(node, ZLinkIDONode):
            link = node.getLinkIDO()
            context = ZLinkIDOActionContext(self, link)
            self.openLinkAction.runAction(context)
        event.Skip

    # end onLinkActivated()

    def onLinkRightClick(self, event):
        node = self.linksTreeView.GetPyData(event.GetItem())
        if isinstance(node, ZLinkIDONode):
            link = node.getLinkIDO()
            context = ZLinkIDOActionContext(self, link)
            menuModel = ZLinkMenuModel()
            menu = ZModelBasedMenu(menuModel, context, self)
            self.PopupMenu(menu)
            menu.Destroy()
        event.Skip()

    # end onLinkRightClick()

    def onLinkSelected(self, event):
        node = self.linksTreeView.GetPyData(event.GetItem())
        if isinstance(node, ZLinkIDONode):
            self.link = node.getLinkIDO()

            if self.link:
                fireViewSelectionEvent(ZLinkSelection(self.link, self.blog),
                                       self)
            else:
                fireViewUnselectionEvent()
        event.Skip()

    # end onLinkSelected()

    def onInvalidSelection(self):
        self.link = None

    # end onInvalidSelection()

    def destroy(self):
        self._unregisterAsIndexListener()

    # end destroy()

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

    # end _registerAsIndexListener()

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

    # end _unregisterAsIndexListener()

    def _getSearchBoxChoices(self):
        return [
            (u"Host", None, SEARCH_HOST),  #$NON-NLS-1$
        ]
Beispiel #6
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)
Beispiel #7
0
class ZLinksView(ZBoxedView, IZDocumentIndexListener):

    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
    # end __init__()

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

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

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

    def _createHeaderWidgets(self, parent, widgetList):
        choices = self._getSearchBoxChoices()
        bitmap = getResourceRegistry().getBitmap(u"images/perspectives/standard/contextinfo/linksview/search.png") #$NON-NLS-1$
        self.searchTextBox = ZAdvancedTextBox(parent, bitmap, choices, False)
        self.searchTextBox.setCurrentChoice(SEARCH_HOST)
        self.searchTextBox.SetSizeHints(220, -1)

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

    def _createContentWidgets(self, parent):
        treeStyle = wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT | wx.TR_SINGLE | wx.TR_HAS_BUTTONS | wx.NO_BORDER
        provider = ZLinkTreeContentProvider(self.model)
        self.linksTreeView = ZTreeView(provider, parent, style = treeStyle)
    # end _createContentWidgets()

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

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

        self.Bind(ZEVT_REFRESH, self.onZoundryRefresh, self)
        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.onLinkActivated, self.linksTreeView)
        self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.onLinkRightClick, self.linksTreeView)
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.onLinkSelected, self.linksTreeView)
#        self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.onEntryBeginDrag, self.linksTreeView)
        self.Bind(wx.EVT_TEXT_ENTER, self.onSearchText, self.searchTextBox)
        self.Bind(ZEVT_VIEW_SELECTION_CHANGED, self.onViewSelectionChanged)
        wx.EVT_SET_FOCUS(self.linksTreeView, self.onFocus)
        wx.EVT_KILL_FOCUS(self.linksTreeView, self.onUnFocus)
    # end _bindWidgetEvents()

    def refreshContent(self, selection):
        (accountId, blogId) = selection.getData()

        filter = ZLinkSearchFilter()
        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(IZLinkSearchFilter.UNPUBLISHED_ACCOUNT_ID)
            filter.setBlogIdCriteria(IZLinkSearchFilter.UNPUBLISHED_BLOG_ID)

        self.model = ZContextInfoLinksModel(filter)
        self.linksTreeView.setContentProvider(ZLinkTreeContentProvider(self.model))
        self.linksTreeView.refresh()
        self.linksTreeView.deselectAll()
        self.onInvalidSelection()
        fireViewUnselectionEvent()
    # end refreshContent()

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

    def onFocus(self, event):
        if self.link:
            fireViewSelectionEvent(ZLinkSelection(self.link, self.blog), self)
        else:
            fireViewUnselectionEvent()
        event.Skip()
    # end onFocus()

    def onUnFocus(self, event):
        fireViewUnselectionEvent()
        event.Skip()
    # end onUnFocus()

    def onSearchText(self, event):
        self.model.setHostCriteria(event.GetString())
        self.model.refresh()
        self.linksTreeView.clear()
        self.linksTreeView.refresh()
        self.linksTreeView.deselectAll()
        self.onInvalidSelection()
        
        fireViewEvent(ZViewEvent(VIEWLINKSFILTERCHANGEDEVENT, self))
        event.Skip()
    # end onSearchText()
#
#    def onEntryBeginDrag(self, event):
#        index = event.GetIndex()
#        docIDO = self.model.getEntry(index)
#        docId = docIDO.getId()
#
#        # FIXME also add some sort of custom format for dragging to the Explorer/TextPad (use a composite data object)
#        data = ZBlogPostDataObjectInternal(docId)
#        dragSource = wx.DropSource(self)
#        dragSource.SetData(data)
#        dragSource.DoDragDrop(wx.Drag_CopyOnly)
#        event.Skip()
#    # end onEntryBeginDrag()

    def _updateModel(self, refreshData):
        (eventType, linkIDO) = refreshData
        shouldRefresh = False
        if eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_ADD:
            shouldRefresh = self.model.addLink(linkIDO)
        elif eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_REMOVE:
            shouldRefresh = self.model.removeLink(linkIDO)
        elif eventType == IZDocIndexEvent.DOCINDEX_EVENTTYPE_UPDATE:
            shouldRefresh = self.model.updateLink(linkIDO)
        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_LINK:
            refreshData = (event.getEventType(), event.getLinkIDO())
            fireRefreshEvent(self, refreshData)
    # end onIndexChange()

    def onZoundryRefresh(self, event):
        if self._updateModel(event.getData()):
            self.linksTreeView.refresh()
        event.Skip()
    # end onZoundryRefresh()

    def onLinkActivated(self, event):
        node = self.linksTreeView.GetPyData(event.GetItem())
        if isinstance(node, ZLinkIDONode):
            link = node.getLinkIDO()
            context = ZLinkIDOActionContext(self, link)
            self.openLinkAction.runAction(context)
        event.Skip
    # end onLinkActivated()

    def onLinkRightClick(self, event):
        node = self.linksTreeView.GetPyData(event.GetItem())
        if isinstance(node, ZLinkIDONode):
            link = node.getLinkIDO()
            context = ZLinkIDOActionContext(self, link)
            menuModel = ZLinkMenuModel()
            menu = ZModelBasedMenu(menuModel, context, self)
            self.PopupMenu(menu)
            menu.Destroy()
        event.Skip()
    # end onLinkRightClick()

    def onLinkSelected(self, event):
        node = self.linksTreeView.GetPyData(event.GetItem())
        if isinstance(node, ZLinkIDONode):
            self.link = node.getLinkIDO()

            if self.link:
                fireViewSelectionEvent(ZLinkSelection(self.link, self.blog), self)
            else:
                fireViewUnselectionEvent()
        event.Skip()
    # end onLinkSelected()

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

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

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

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

    def _getSearchBoxChoices(self):
        return [
                (u"Host", None, SEARCH_HOST), #$NON-NLS-1$
        ]
Beispiel #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)