def OnUpdateTree(self, msg=None): """Update the tree when an action message is sent @param keyword: Message Object """ # Don't update when this window is not Active if self._mw != wx.GetApp().GetActiveWindow(): return page = self._GetCurrentCtrl() genfun = TagLoader.GetGenerator(page.GetLangId()) self._cjob += 1 # increment job Id if genfun is not None and self._ShouldUpdate(): ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_SHOW, (self._mw.GetId(), True)) # Start progress indicator in pulse mode ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_STATE, (self._mw.GetId(), -1, -1)) thread = TagGenThread(self, self._cjob, genfun, StringIO.StringIO(page.GetText())) wx.CallLater(75, thread.start) else: self._cdoc = None self.DeleteChildren(self.root) ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_SHOW, (self._mw.GetId(), False)) return
def OnUpdateTree(self, msg=None, force=False): """Update the tree when an action message is sent @keyword msg: Message Object @keyword force: Force update """ # Don't update when this window is not Active if not force and not self._mw.IsActive(): return page = self._GetCurrentCtrl() cfname = page.GetFileName() # If its a blank document just clear out if not len(cfname): self._cdoc = None self.DeleteChildren(self.root) return # If document job is same as current don't start a new one if not force and self._lastjob == cfname: return else: self._lastjob = cfname # Get the generator method genfun = TagLoader.GetGenerator(page.GetLangId()) self._cjob += 1 # increment job Id # Check if we need to do updates if genfun is not None and (force or self._ShouldUpdate()): ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_SHOW, (self._mw.GetId(), True)) # Start progress indicator in pulse mode ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_STATE, (self._mw.GetId(), -1, -1)) thread = TagGenThread(self, self._cjob, genfun, StringIO.StringIO(page.GetText())) wx.CallLater(75, thread.start) else: self._cdoc = None self.DeleteChildren(self.root) ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_SHOW, (self._mw.GetId(), False)) return
def OnStartJob(self, evt): """Start the tree update job @param evt: wxTimerEvent """ if self._cpage is None or not isinstance(self._cpage, wx.Window): self._cpage = None return else: # Check if its still the current page parent = self._cpage.GetParent() if self._cpage != parent.GetCurrentPage(): return # Get the generator method genfun = TagLoader.GetGenerator(self._cpage.GetLangId()) self._cjob += 1 # increment job Id # Check if we need to do updates if genfun is not None and (self._force or self._ShouldUpdate()): self._force = False # Start progress indicator in pulse mode ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_SHOW, (self._mw.GetId(), True)) ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_STATE, (self._mw.GetId(), -1, -1)) # Create and start the worker thread thread = TagGenThread(self, self._cjob, genfun, StringIO.StringIO(self._cpage.GetText())) wx.CallLater(75, thread.start) else: self._cdoc = None self.DeleteChildren(self.root) ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_SHOW, (self._mw.GetId(), False)) return