def _createWidgets(self): self.summary = ZLinkSummaryPanel(self) self.blogPostListView = ZWhereFoundBlogPostListView(self, self.model)
class ZInfoLinkDetailsPanel(ZAbstractDetailsPanel, IZURLFetchListener): def __init__(self, parent): self.model = ZInfoLinkDetailsModel() self.fetcher = None ZAbstractDetailsPanel.__init__(self, parent) # end __init__() def _createWidgets(self): self.summary = ZLinkSummaryPanel(self) self.blogPostListView = ZWhereFoundBlogPostListView(self, self.model) # end _createWidgets() def _bindWidgetEvents(self): pass # end _bindWidgetEvents() def _layoutWidgets(self): vBox = wx.BoxSizer(wx.VERTICAL) vBox.Add(self.summary, 0, wx.EXPAND | wx.BOTTOM, 5) vBox.Add(self.blogPostListView, 1, wx.EXPAND) box = wx.BoxSizer(wx.VERTICAL) box.AddSizer(vBox, 1, wx.EXPAND | wx.ALL, 5) self.SetAutoLayout(True) self.SetSizer(box) # end _layoutWidgets() def destroy(self): # Cancel any Link fetching that might be going on if self.fetcher is not None and not self.fetcher.isDone(): self.fetcher.cancel() # end destroy() def onSelectionChanged(self, data): (blog, linkIDO) = data #@UnusedVariable # Cancel any Link fetching that might be going on if self.fetcher is not None and not self.fetcher.isDone(): self.fetcher.cancel() # Set the current linkIDO in the model self.model.setLinkIDO(linkIDO) # Reset the UI for the widgets self.summary.reset() self.Layout() # Refresh the list of blog posts self.blogPostListView.refresh() # Start fetching the link in the background - events will update the UI url = linkIDO.getUrl() self.fetcher = self.model.getUrlFetchService().fetch(url, self) # end onSelectionChanged() def updateFromConnectionError(self, error): self.summary.updateFromError(error) self.Layout() # end updateFromConnectionRespInfo() def updateFromConnectionRespInfo(self, connectionRespInfo): self.summary.updateFromConnectionRespInfo(connectionRespInfo) self.Layout() # end updateFromConnectionRespInfo() def updateFromDownloadError(self, error): self.summary.updateFromError(error) self.Layout() # end updateFromDownloadError() def updateFromConnectionResp(self, connectionResp): self.summary.updateFromConnectionResp(connectionResp) self.Layout() # end updateFromConnectionResp() def onCancel(self, fetcher): if self.fetcher == fetcher: self.fetcher = None # end onCancel() def onConnect(self, fetcher, connectionRespInfo): #@UnusedVariable updater = ZInfoLinkDetailsPanelUIUpdater(self, connectionRespInfo, ZInfoLinkDetailsPanelUIUpdater.MODE_CONNECT) fireUIExecEvent(updater, self) # end onConnect() def onConnectError(self, fetcher, error): #@UnusedVariable updater = ZInfoLinkDetailsPanelUIUpdater(self, error, ZInfoLinkDetailsPanelUIUpdater.MODE_CONNECT_ERROR) fireUIExecEvent(updater, self) # end onConnectError() def onContentDownloadStart(self, fetcher, contentLength): #@UnusedVariable updater = ZInfoLinkDetailsPanelUIUpdater(self, contentLength, ZInfoLinkDetailsPanelUIUpdater.MODE_DOWNLOAD_START) fireUIExecEvent(updater, self) # end onContentDownloadStart() def onContentDownload(self, fetcher, numBytes): #@UnusedVariable updater = ZInfoLinkDetailsPanelUIUpdater(self, numBytes, ZInfoLinkDetailsPanelUIUpdater.MODE_DOWNLOAD) fireUIExecEvent(updater, self) # end onContentDownload() def onContentDownloadComplete(self, fetcher, connectionResp): #@UnusedVariable updater = ZInfoLinkDetailsPanelUIUpdater(self, connectionResp, ZInfoLinkDetailsPanelUIUpdater.MODE_DOWNLOAD_COMPLETE) fireUIExecEvent(updater, self) # end onContentDownloadComplete() def onContentDownloadError(self, fetcher, error): #@UnusedVariable updater = ZInfoLinkDetailsPanelUIUpdater(self, error, ZInfoLinkDetailsPanelUIUpdater.MODE_DOWNLOAD_ERROR) fireUIExecEvent(updater, self)