def start(self, listener = _NULL_STARTUP_LISTENER): listener.engineStarting() # Get the list of service extension points. extensionPoints = self._getServiceExtensionPoints() listener.engineCreatingServices(len(extensionPoints)) # Create all of the IZService objects. createdServices = [] numFailed = 0 for extensionPoint in extensionPoints: extPointId = extensionPoint.getId() try: theClass = extensionPoint.loadClass() if not issubclass(theClass, IZService): raise ZEngineException(_extstr(u"engine.ErrorCreatingService") % extensionPoint.getClass()) #$NON-NLS-1$ theService = theClass() if not isinstance(theService, IZService): raise ZEngineException(_extstr(u"engine.ErrorCreatingService") % extensionPoint.getClass()) #$NON-NLS-1$ listener.engineServiceCreated(extPointId) createdServices.append( (extPointId, theService) ) except ZException, ze: listener.engineServiceCreationFailed(extPointId, ze.getStackTrace()) numFailed += 1 except Exception, e: listener.engineServiceCreationFailed(extPointId, ZException(rootCause = e).getStackTrace()) numFailed += 1
def _enableSpellCheck(self): if self.model.enableSpellCheck(self.selectedLanguage): ZShowInfoMessage( self, _extstr(u"spellingprefpage.AppMustBeRestartedMessage"), _extstr(u"spellingprefpage.RestartNeeded" )) #$NON-NLS-2$ #$NON-NLS-1$ self.populateWidgets()
def generateThumbnail(self, sourceFile, tnParams, destFile = None): if destFile is None: destFile = self._createDestFile() if os.path.exists(destFile): os.remove(destFile) if not os.path.isfile(sourceFile): raise ZAppFrameworkException(_extstr(u"imaging.PathDoesNotExistError") % sourceFile) #$NON-NLS-1$ width = tnParams.width height = tnParams.height inputFilePath = sourceFile outputFilePath = destFile try: image = Image.open(inputFilePath) image = image.convert(u"RGB") #$NON-NLS-1$ image.thumbnail((width, height), Image.ANTIALIAS) if tnParams.dropShadow: bgcolor = (tnParams.backgroundColor[2] << 16) + (tnParams.backgroundColor[1] << 8) + tnParams.backgroundColor[0] image = self._addDropShadow(image, background = bgcolor) image.save(outputFilePath) (rWidth, rHeight) = image.size return (outputFilePath, rWidth, rHeight) except Exception, e: raise ZAppFrameworkException(_extstr(u"imaging.ErrorCreatingThumbnailError") % sourceFile, e) #$NON-NLS-1$
def generateThumbnail(self, sourceFile, tnParams, destFile=None): if destFile is None: destFile = self._createDestFile() if os.path.exists(destFile): os.remove(destFile) if not os.path.isfile(sourceFile): raise ZAppFrameworkException( _extstr(u"imaging.PathDoesNotExistError") % sourceFile) #$NON-NLS-1$ width = tnParams.width height = tnParams.height inputFilePath = sourceFile outputFilePath = destFile try: image = Image.open(inputFilePath) image = image.convert(u"RGB") #$NON-NLS-1$ image.thumbnail((width, height), Image.ANTIALIAS) if tnParams.dropShadow: bgcolor = (tnParams.backgroundColor[2] << 16) + ( tnParams.backgroundColor[1] << 8) + tnParams.backgroundColor[0] image = self._addDropShadow(image, background=bgcolor) image.save(outputFilePath) (rWidth, rHeight) = image.size return (outputFilePath, rWidth, rHeight) except Exception, e: raise ZAppFrameworkException( _extstr(u"imaging.ErrorCreatingThumbnailError") % sourceFile, e) #$NON-NLS-1$
def _populateNonHeaderWidgets(self): self.feedbackType.AppendItems([ _extstr(u"feedbackdialog.Bug"), _extstr(u"feedbackdialog.Enhancement"), _extstr(u"feedbackdialog.Praise") ]) #$NON-NLS-3$ #$NON-NLS-2$ #$NON-NLS-1$ self.feedbackType.SetValue(_extstr(u"feedbackdialog.Bug")) #$NON-NLS-1$ if self.userPrefs: emailValue = self.userPrefs.getUserPreference(self.feedbackEmailUserPrefsKey, u"") #$NON-NLS-1$ self.email.SetValue(emailValue)
def _createNonHeaderWidgets(self): self.feedbackTypeLabel = wx.StaticText( self, wx.ID_ANY, u"%s:" % _extstr(u"feedbackdialog.FeedbackType")) #$NON-NLS-1$ #$NON-NLS-2$ self.emailLabel = wx.StaticText( self, wx.ID_ANY, u"%s:" % _extstr(u"feedbackdialog.Email_optional") ) #$NON-NLS-1$ #$NON-NLS-2$ self.subjectLabel = wx.StaticText( self, wx.ID_ANY, u"%s:" % _extstr(u"feedbackdialog.Subject")) #$NON-NLS-1$ #$NON-NLS-2$ self.feedbackLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"feedbackdialog.Feedback")) #$NON-NLS-1$ self.feedbackType = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_DROPDOWN | wx.CB_READONLY) self.email = wx.TextCtrl(self, wx.ID_ANY) self.subject = wx.TextCtrl(self, wx.ID_ANY) self.feedback = wx.TextCtrl(self, wx.ID_ANY, style=wx.TE_PROCESS_TAB | wx.TE_MULTILINE) self.feedback.SetSizeHints(-1, 100) self.staticLine = wx.StaticLine(self, wx.HORIZONTAL)
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()
def _createPanelWidgets(self): self.titleText = wx.StaticText(self, wx.ID_ANY, self.task.getName()) self.titleText.SetFont(getDefaultFontBold()) startTime = u" %s %s" % (_extstr(u"bgtaskpanel.StartedOn"), self.task.getStartTime().toString(u"%c", True)) #$NON-NLS-2$ #$NON-NLS-1$ #$NON-NLS-3$ self.startTimeText = wx.StaticText(self, wx.ID_ANY, startTime) errorBmp = getResourceRegistry().getBitmap(u"images/dialogs/bgtasks/manager/error-glyph.png") #$NON-NLS-1$ self.errorGlyph = ZImageButton(self, errorBmp, True) infoBmp = getResourceRegistry().getBitmap(u"images/dialogs/bgtasks/manager/info-glyph.png") #$NON-NLS-1$ self.infoGlyph = ZImageButton(self, infoBmp, True) stopBmp = getResourceRegistry().getBitmap(u"images/dialogs/bgtasks/manager/stop-glyph.png") #$NON-NLS-1$ self.stopGlyph = ZImageButton(self, stopBmp, True) # Progress widgets - only visible while task is running. self.progressGauge = wx.Gauge(self, wx.ID_ANY, self.task.getNumWorkUnits()) self.progressGauge.SetSizeHints(-1, 14) self.progressText = wx.StaticText(self, wx.ID_ANY, u"") #$NON-NLS-1$ self.statusText = wx.StaticText(self, wx.ID_ANY, u"") #$NON-NLS-1$ self.cancelButton = ZImageButton(self, getResourceRegistry().getBitmap(u"images/dialogs/bgtasks/manager/cancel.png")) #$NON-NLS-1$ self.cancelButton.SetToolTipString(_extstr(u"bgtaskpanel.CancelTask")) #$NON-NLS-1$ self.pauseButton = ZImageButton(self, getResourceRegistry().getBitmap(u"images/dialogs/bgtasks/manager/pause.png")) #$NON-NLS-1$ self.pauseButton.SetToolTipString(_extstr(u"bgtaskpanel.PauseTask")) #$NON-NLS-1$ # Widgets that are only shown when the task is complete self.endTimeText = wx.StaticText(self, wx.ID_ANY, u"") #$NON-NLS-1$ self.removeButton = ZImageButton(self, getResourceRegistry().getBitmap(u"images/dialogs/bgtasks/manager/remove.png")) #$NON-NLS-1$ self.removeButton.SetToolTipString(_extstr(u"bgtaskpanel.RemoveTask")) #$NON-NLS-1$ self.staticLine = wx.StaticLine(self)
def resumeTask(self, taskId, listener=None): task = self.getTask(taskId) if task is None: raise ZAppFrameworkException( _extstr(u"backgroundtaskimpl.FailedToResumeTaskNotFound") % taskId) #$NON-NLS-1$ if task.isRunning(): raise ZAppFrameworkException( _extstr(u"backgroundtaskimpl.FailedToResumeTaskAlreadyRunning") % taskId) #$NON-NLS-1$ if task.isComplete(): raise ZAppFrameworkException( _extstr(u"backgroundtaskimpl.FailedToResumeTaskComplete") % taskId) #$NON-NLS-1$ if not task.isResumable(): raise ZAppFrameworkException( _extstr(u"backgroundtaskimpl.FailedToResumeTaskNotResumable") % taskId) #$NON-NLS-1$ if listener is not None: task.attachListener(listener) self._resumeTask(task) self.listeners.doCallback(u"onTaskResumed", [task]) #$NON-NLS-1$ return task
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()
def createWidgets(self): self.staticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"zoundrysvcprefpage.Zoundry_Service_Settings")) #$NON-NLS-1$ self.zoundryIdLabel = wx.StaticText(self, wx.ID_ANY, _extstr(u"zoundrysvcprefpage.Zoundry_ID")) #$NON-NLS-1$ self.zoundryId = wx.TextCtrl(self, wx.ID_ANY) descPart1 = _extstr(u"zoundrysvcprefpage.ZoundryServiceDescriptionPart1") #$NON-NLS-1$ descPart2 = _extstr(u"zoundrysvcprefpage.ZoundryServiceDescriptionPart2") #$NON-NLS-1$ descPart3 = _extstr(u"zoundrysvcprefpage.ZoundryServiceDescriptionPart3") #$NON-NLS-1$ self.descriptionLabel = wx.StaticText(self, wx.ID_ANY, u"\n%s\n\n%s\n\n%s" % (descPart1, descPart2, descPart3)) #$NON-NLS-1$
def _enableButtons(self, enabled = True): self._enableOkButton(enabled) self._enableApplyButton(enabled) cancelButton = self.FindWindowById(wx.ID_CANCEL) if enabled: cancelButton.SetLabel(_extstr(u"Cancel")) #$NON-NLS-1$ else: cancelButton.SetLabel(_extstr(u"Close")) #$NON-NLS-1$
def __init__(self, model): self.model = model self.imageList = self._createImageList() self.columnInfo = [ (_extstr(u"spellingprefpage.Language"), None, wx.ALIGN_CENTER_VERTICAL, 250), #$NON-NLS-1$ (_extstr(u"spellingprefpage.Ready"), None, 0, 50), #$NON-NLS-1$ ]
def createBackgroundTaskInfoMenuNode(task): rootNode = ZMenuNode() openLogAction = ZOpenBackgroundTaskLogFileAction(task) openLogFileNode = ZActiveMenuNode(_extstr(u"bgtaskmenus.OpenLogFile"), _extstr(u"bgtaskmenus.OpenLogFileTooltip"), action = openLogAction) #$NON-NLS-2$ #$NON-NLS-1$ rootNode.addChild(openLogFileNode) return rootNode
def createSystemProfile(self, type, data): c = self.typeRegistry[type] if not c: raise ZAppFrameworkException(_extstr(u"system.CouldNotCreateSysProfile") % type) #$NON-NLS-1$ try: return c(data) except Exception, ex: raise ZAppFrameworkException(_extstr(u"system.CouldNotCreateSysProfile") % type, ex) #$NON-NLS-1$
def _enableButtons(self, enabled=True): self._enableOkButton(enabled) self._enableApplyButton(enabled) cancelButton = self.FindWindowById(wx.ID_CANCEL) if enabled: cancelButton.SetLabel(_extstr(u"Cancel")) #$NON-NLS-1$ else: cancelButton.SetLabel(_extstr(u"Close")) #$NON-NLS-1$
def _createWidgets(self): self.checkBoxListView = ZCheckBoxListView(self.contentProvider, self, style=self.style, validator=self.validator) self.checkAllButton = wx.Button( self, wx.ID_ANY, _extstr(u"listex.CheckAll")) #$NON-NLS-1$ self.uncheckAllButton = wx.Button( self, wx.ID_ANY, _extstr(u"listex.UncheckAll")) #$NON-NLS-1$
def __init__(self, model): self.model = model self.imageList = self._createImageList() self.columnInfo = [ (_extstr(u"spellingprefpage.Language"), None, wx.ALIGN_CENTER_VERTICAL, 250), #$NON-NLS-1$ (_extstr(u"spellingprefpage.Ready"), None, 0, 50), #$NON-NLS-1$ ]
def getRowText(self, rowIndex, columnIndex): language = self.model.getLanguages()[rowIndex] if columnIndex == 0: return language.getDisplayName() elif columnIndex == 1: if self.model.isDictionaryDownloaded(language): return _extstr(u"spellingprefpage.yes") #$NON-NLS-1$ else: return _extstr(u"spellingprefpage.no") #$NON-NLS-1$
def createWidgets(self): self.localeDetailsStaticBox = wx.StaticBox(self, wx.ID_ANY) self.defaultLocaleLabel = wx.StaticText(self, wx.ID_ANY, _extstr(u"localeprefpage.DefaultLocale")) #$NON-NLS-1$ self.defaultLocaleLabel.SetFont(getDefaultFontBold()) self.defaultLocale = wx.StaticText(self, wx.ID_ANY, u"") #$NON-NLS-1$ self.defaultLocaleBitmap = wx.StaticBitmap(self, wx.ID_ANY, wx.NullBitmap) self.overrideCB = wx.CheckBox(self, wx.ID_ANY, _extstr(u"localeprefpage.OverrideDefaultLocale")) #$NON-NLS-1$ provider = self._createLocaleListProvider() self.localeList = ZListView(provider, self, style = wx.LC_VIRTUAL | wx.LC_REPORT | wx.LC_SINGLE_SEL)
def createWidgets(self): self.warningMsg = wx.StaticText(self, wx.ID_ANY, _extstr(u"personaldictprefpage.SpellCheckingMustBeEnabled")) #$NON-NLS-1$ self.warningMsg.SetFont(getDefaultFontBold()) self.staticBox = wx.StaticBox(self, wx.ID_ANY) provider = ZPersonalDictionaryContentProvider(self.model) self.personalDictionaryListView = ZListViewEx(provider, self) self.addButton = wx.Button(self, wx.ID_ANY, _extstr(u"personaldictprefpage.Add")) #$NON-NLS-1$ self.removeButton = wx.Button(self, wx.ID_ANY, _extstr(u"personaldictprefpage.Remove")) #$NON-NLS-1$ self.clearButton = wx.Button(self, wx.ID_ANY, _extstr(u"personaldictprefpage.Clear")) #$NON-NLS-1$
def _createButtons(self): self.prevButton = wx.Button( self, ZID_PREVIOUS, u"< " + _extstr(u"Back")) #$NON-NLS-1$ #$NON-NLS-2$ self.nextButton = wx.Button(self, ZID_NEXT, _extstr(u"Next") + u" >") #$NON-NLS-2$ #$NON-NLS-1$ self.cancelButton = wx.Button(self, wx.ID_CANCEL, _extstr(u"Cancel")) #$NON-NLS-1$
def getRowText(self, rowIndex, columnIndex): language = self.model.getLanguages()[rowIndex] if columnIndex == 0: return language.getDisplayName() elif columnIndex == 1: if self.model.isDictionaryDownloaded(language): return _extstr(u"spellingprefpage.yes") #$NON-NLS-1$ else: return _extstr(u"spellingprefpage.no") #$NON-NLS-1$
def onAddWord(self, event): word = ZShowDataEntryDialog( self, _extstr(u"personaldictprefpage.AddPersonalDictionaryWord"), _extstr(u"personaldictprefpage.Word")) #$NON-NLS-2$ #$NON-NLS-1$ if word is not None: self.model.addWord(word) self.personalDictionaryListView.refresh() self._refreshButtonStates() self.getPrefsDialog().onPrefPageChange() event.Skip()
def removeTask(self, taskId): task = self.getTask(taskId) if task is None: raise ZAppFrameworkException(_extstr(u"backgroundtaskimpl.FailedToRemoveDoesNotExist") % taskId) #$NON-NLS-1$ if task.isRunning(): raise ZAppFrameworkException(_extstr(u"backgroundtaskimpl.FailedToRemoveStillRunning") % taskId) #$NON-NLS-1$ self.tasks.remove(task) self._removeTask(task) self.listeners.doCallback(u"onTaskRemoved", [task]) #$NON-NLS-1$
def createBackgroundTaskInfoMenuNode(task): rootNode = ZMenuNode() openLogAction = ZOpenBackgroundTaskLogFileAction(task) openLogFileNode = ZActiveMenuNode( _extstr(u"bgtaskmenus.OpenLogFile"), _extstr(u"bgtaskmenus.OpenLogFileTooltip"), action=openLogAction) #$NON-NLS-2$ #$NON-NLS-1$ rootNode.addChild(openLogFileNode) return rootNode
def _doHandleError(self, url, dndContext): ZShowInfoMessage( dndContext.getWindow(), _extstr(u"commonvideo.ErrorDiscoveringVideoEmbedInfoMsg"), _extstr(u"commonvideo.ErrorDiscoveringVideoEmbedInfoTitle" )) #$NON-NLS-2$ #$NON-NLS-1$ dom = ZDom() dom.loadXML(u"<a href='' />") #$NON-NLS-1$ dom.documentElement.setAttribute(u"href", url) #$NON-NLS-1$ dom.documentElement.setText(url) return dom.serialize()
def createWidgets(self): self.staticBox = wx.StaticBox( self, wx.ID_ANY, _extstr(u"loggerprefpage.LoggerSettings")) #$NON-NLS-1$ self.logErrorsCB = wx.CheckBox( self, wx.ID_ANY, _extstr(u"loggerprefpage.LogErrors")) #$NON-NLS-1$ self.logWarningsCB = wx.CheckBox( self, wx.ID_ANY, _extstr(u"loggerprefpage.LogWarnings")) #$NON-NLS-1$ self.logDebugCB = wx.CheckBox( self, wx.ID_ANY, _extstr(u"loggerprefpage.LogDebuggingMessages")) #$NON-NLS-1$
def _createButtons(self): detailsButtonName = _extstr(u"error_dialog.Details") + u" >>" #$NON-NLS-2$ #$NON-NLS-1$ self._createExpandedWidgets() # The details/ok buttons. self.detailsButton = wx.Button(self, wx.ID_ANY, detailsButtonName) self.okButton = wx.Button(self, wx.ID_OK, _extstr(u"Close")) #$NON-NLS-1$ # Wrap them in a sizer. buttonSizer = wx.BoxSizer(wx.HORIZONTAL) buttonSizer.Add(self.detailsButton, 0, wx.ALL, 1) buttonSizer.Add(self.okButton, 0, wx.ALL, 1) return buttonSizer
def onTreeItemChanging(self, event): if self.currentPage is not None: if self.currentPage.isDirty(): # FIXME (EPW) provide override for this message and title if not ZShowYesNoMessage( self, _extstr(u"prefsdialog.PrefPageSwitchMessage"), _extstr(u"prefsdialog.DiscardChanges") ): #$NON-NLS-2$ #$NON-NLS-1$ event.Veto() return else: self.currentPage.rollback() event.Skip()
def _createWidgets(self): wxDt = self._wxDateFromDateTuple(self.dateTuple) self.calendar = wx.calendar.CalendarCtrl( self, wx.ID_ANY, wxDt, style=wx.calendar.CAL_SHOW_HOLIDAYS | wx.calendar.CAL_SUNDAY_FIRST | wx.calendar.CAL_BORDER_ROUND | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION | wx.SIMPLE_BORDER) self.nowButton = wx.Button(self, wx.ID_ANY, _extstr(u"datectrl.Now")) #$NON-NLS-1$ self.resetButton = wx.Button(self, wx.ID_ANY, _extstr(u"datectrl.Reset")) #$NON-NLS-1$
def _populateNonHeaderWidgets(self): self.feedbackType.AppendItems([ _extstr(u"feedbackdialog.Bug"), _extstr(u"feedbackdialog.Enhancement"), _extstr(u"feedbackdialog.Praise") ]) #$NON-NLS-3$ #$NON-NLS-2$ #$NON-NLS-1$ self.feedbackType.SetValue( _extstr(u"feedbackdialog.Bug")) #$NON-NLS-1$ if self.userPrefs: emailValue = self.userPrefs.getUserPreference( self.feedbackEmailUserPrefsKey, u"") #$NON-NLS-1$ self.email.SetValue(emailValue)
def createBackgroundTaskErrorMenuNode(task): rootNode = ZMenuNode() openLogAction = ZOpenBackgroundTaskLogFileAction(task) openLogFileNode = ZActiveMenuNode(_extstr(u"bgtaskmenus.OpenLogFile"), _extstr(u"bgtaskmenus.OpenLogFileTooltip"), action = openLogAction) #$NON-NLS-2$ #$NON-NLS-1$ showErrorAction = ZShowTaskErrorAction(task) showErrorNode = ZActiveMenuNode(_extstr(u"bgtaskmenus.ShowError"), _extstr(u"bgtaskmenus.ShowErrorTooltip"), action = showErrorAction) #$NON-NLS-2$ #$NON-NLS-1$ rootNode.addChild(showErrorNode) rootNode.addChild(openLogFileNode) return rootNode
def _createPanelWidgets(self): self.titleText = wx.StaticText(self, wx.ID_ANY, self.task.getName()) self.titleText.SetFont(getDefaultFontBold()) startTime = u" %s %s" % (_extstr(u"bgtaskpanel.StartedOn"), self.task.getStartTime().toString( u"%c", True) ) #$NON-NLS-2$ #$NON-NLS-1$ #$NON-NLS-3$ self.startTimeText = wx.StaticText(self, wx.ID_ANY, startTime) errorBmp = getResourceRegistry().getBitmap( u"images/dialogs/bgtasks/manager/error-glyph.png") #$NON-NLS-1$ self.errorGlyph = ZImageButton(self, errorBmp, True) infoBmp = getResourceRegistry().getBitmap( u"images/dialogs/bgtasks/manager/info-glyph.png") #$NON-NLS-1$ self.infoGlyph = ZImageButton(self, infoBmp, True) stopBmp = getResourceRegistry().getBitmap( u"images/dialogs/bgtasks/manager/stop-glyph.png") #$NON-NLS-1$ self.stopGlyph = ZImageButton(self, stopBmp, True) # Progress widgets - only visible while task is running. self.progressGauge = wx.Gauge(self, wx.ID_ANY, self.task.getNumWorkUnits()) self.progressGauge.SetSizeHints(-1, 14) self.progressText = wx.StaticText(self, wx.ID_ANY, u"") #$NON-NLS-1$ self.statusText = wx.StaticText(self, wx.ID_ANY, u"") #$NON-NLS-1$ self.cancelButton = ZImageButton( self, getResourceRegistry().getBitmap( u"images/dialogs/bgtasks/manager/cancel.png")) #$NON-NLS-1$ self.cancelButton.SetToolTipString( _extstr(u"bgtaskpanel.CancelTask")) #$NON-NLS-1$ self.pauseButton = ZImageButton( self, getResourceRegistry().getBitmap( u"images/dialogs/bgtasks/manager/pause.png")) #$NON-NLS-1$ self.pauseButton.SetToolTipString( _extstr(u"bgtaskpanel.PauseTask")) #$NON-NLS-1$ # Widgets that are only shown when the task is complete self.endTimeText = wx.StaticText(self, wx.ID_ANY, u"") #$NON-NLS-1$ self.removeButton = ZImageButton( self, getResourceRegistry().getBitmap( u"images/dialogs/bgtasks/manager/remove.png")) #$NON-NLS-1$ self.removeButton.SetToolTipString( _extstr(u"bgtaskpanel.RemoveTask")) #$NON-NLS-1$ self.staticLine = wx.StaticLine(self)
def onDetails(self, event): #@UnusedVariable detailsButtonName = _extstr(u"error_dialog.Details") + u" >>" #$NON-NLS-2$ #$NON-NLS-1$ if self.mode == MODE_COMPACT: self.mode = MODE_EXPANDED self.errorDetailPanel.Show(True) self.SetSize(wx.Size(DIALOG_WIDTH, EXPANDED_DIALOG_HEIGHT)) detailsButtonName = u"<< " + _extstr(u"error_dialog.Details") #$NON-NLS-2$ #$NON-NLS-1$ else: self.mode = MODE_COMPACT self.errorDetailPanel.Show(False) self.SetSize(wx.Size(DIALOG_WIDTH, COMPACT_DIALOG_HEIGHT)) self.detailsButton.SetLabel(detailsButtonName) self.Layout()
def _createNonHeaderWidgets(self): self.feedbackTypeLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"feedbackdialog.FeedbackType")) #$NON-NLS-1$ #$NON-NLS-2$ self.emailLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"feedbackdialog.Email_optional")) #$NON-NLS-1$ #$NON-NLS-2$ self.subjectLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"feedbackdialog.Subject")) #$NON-NLS-1$ #$NON-NLS-2$ self.feedbackLabel = wx.StaticText(self, wx.ID_ANY, _extstr(u"feedbackdialog.Feedback")) #$NON-NLS-1$ self.feedbackType = wx.ComboBox(self, wx.ID_ANY, style = wx.CB_DROPDOWN | wx.CB_READONLY) self.email = wx.TextCtrl(self, wx.ID_ANY) self.subject = wx.TextCtrl(self, wx.ID_ANY) self.feedback = wx.TextCtrl(self, wx.ID_ANY, style = wx.TE_PROCESS_TAB | wx.TE_MULTILINE) self.feedback.SetSizeHints(-1, 100) self.staticLine = wx.StaticLine(self, wx.HORIZONTAL)
def refresh(self): self.progressCtrl.setLabel(self._formatProgressText()) self.progressGauge.SetValue(self.model.getCurrentWorkAmount()) if self.model.isCanceling(): self.workTextCtrl.SetLabel(_extstr(u"bgtaskprogressdialog.Cancelling")) #$NON-NLS-1$ else: self.workTextCtrl.SetLabel(self.model.getCurrentWorkText()) if self.model.isRunning() and not self.progressCtrl.isRunning(): self.progressCtrl.start() if not self.model.isRunning() and self.progressCtrl.isRunning(): self.progressCtrl.stop() if not self.model.isRunning(): self._getOkButton().Show(False) self._getCancelButton().SetLabel(_extstr(u"Close")) #$NON-NLS-1$
def removeTask(self, taskId): task = self.getTask(taskId) if task is None: raise ZAppFrameworkException( _extstr(u"backgroundtaskimpl.FailedToRemoveDoesNotExist") % taskId) #$NON-NLS-1$ if task.isRunning(): raise ZAppFrameworkException( _extstr(u"backgroundtaskimpl.FailedToRemoveStillRunning") % taskId) #$NON-NLS-1$ self.tasks.remove(task) self._removeTask(task) self.listeners.doCallback(u"onTaskRemoved", [task]) #$NON-NLS-1$
def _doCheckForUpdate(self, onlyPromptWhenNewVersionIsAvailable = True): appModel = getApplicationModel() appVersion = appModel.getVersion() latestVersion = self.getLatestVersionInfo() if latestVersion and appVersion.getBuild() < latestVersion.getBuild(): currVer = appVersion.getFullVersionString() latestVer = latestVersion.getFullVersionString() msg = _extstr(u"autoupdateimpl.NewVersionMessage") % (currVer, latestVer) #$NON-NLS-1$ title = _extstr(u"autoupdateimpl.NewVersionAvailable") #$NON-NLS-1$ fireUIExecEvent(ZAutoUpdateMessageRunner(title, msg, False), appModel.getTopWindow()) elif not onlyPromptWhenNewVersionIsAvailable: msg = _extstr(u"autoupdateimpl.AlreadyUpToDateMsg") #$NON-NLS-1$ title = _extstr(u"autoupdateimpl.AlreadyUpToDateTitle") #$NON-NLS-1$ fireUIExecEvent(ZAutoUpdateMessageRunner(title, msg, True), appModel.getTopWindow())
def refresh(self): self.progressCtrl.setLabel(self._formatProgressText()) self.progressGauge.SetValue(self.model.getCurrentWorkAmount()) if self.model.isCanceling(): self.workTextCtrl.SetLabel( _extstr(u"bgtaskprogressdialog.Cancelling")) #$NON-NLS-1$ else: self.workTextCtrl.SetLabel(self.model.getCurrentWorkText()) if self.model.isRunning() and not self.progressCtrl.isRunning(): self.progressCtrl.start() if not self.model.isRunning() and self.progressCtrl.isRunning(): self.progressCtrl.stop() if not self.model.isRunning(): self._getOkButton().Show(False) self._getCancelButton().SetLabel(_extstr(u"Close")) #$NON-NLS-1$
def __init__(self, errorMessage=None, flags=0): self.errorMessage = errorMessage self.setFlags(flags) if self.errorMessage is None: self.errorMessage = _extstr( u"validatingctrl.CssLengthErrorMessage") #$NON-NLS-1$ ZBaseControlValidator.__init__(self)
def _loadErrorHTML(self): global RESOURCE_REGISTRY return ERROR_HTML % { u"error_header" : _extstr(u"error_dialog.Error"), #$NON-NLS-1$ #$NON-NLS-2$ u"error_message" : self.errorMessage, #$NON-NLS-1$ u"error_image" : getResourceRegistry().getImagePath(u"images/widgets/error_dialog/error.png") #$NON-NLS-1$ #$NON-NLS-2$ }
def getDeserializer(self, namespace): if namespace in self.deserializerMap: return self.deserializerMap[namespace] else: raise ZAppFrameworkException( _extstr(u"factory.NoTaskDeserializerFound") % namespace) #$NON-NLS-1$
def _formatProgressText(self): # Avoid possible divide by 0 error if self.bgTask.getNumWorkUnits() == 0: perc = 0 else: perc = (self.bgTask.getNumCompletedWorkUnits() * 100) / self.bgTask.getNumWorkUnits() return _extstr(u"bgtaskpanel.RunningPercent") % perc #$NON-NLS-1$
def getName(self): name = self._getExtensionText(u"plg:menu-group/plg:name") #$NON-NLS-1$ if not name: raise ZAppFrameworkException( _extstr(u"menudefs.NameMissingInMenuItemError") % self.extensionPoint.getId()) #$NON-NLS-1$ return name
def _doHandleError(self, url, dndContext): ZShowInfoMessage(dndContext.getWindow(), _extstr(u"commonvideo.ErrorDiscoveringVideoEmbedInfoMsg"), _extstr(u"commonvideo.ErrorDiscoveringVideoEmbedInfoTitle")) #$NON-NLS-2$ #$NON-NLS-1$ dom = ZDom() dom.loadXML(u"<a href='' />") #$NON-NLS-1$ dom.documentElement.setAttribute(u"href", url) #$NON-NLS-1$ dom.documentElement.setText(url) return dom.serialize()
def saveBackgroundTask(task, taskXmlPath): try: serializer = getBackgroundTaskSerializerFactory().getSerializer() dom = serializer.serialize(task) dom.save(taskXmlPath, True) except Exception, e: raise ZAppFrameworkException(_extstr(u"backgroundtaskio.FailedToSaveTask") % task.getId(), e) #$NON-NLS-1$
def onAddWord(self, event): word = ZShowDataEntryDialog(self, _extstr(u"personaldictprefpage.AddPersonalDictionaryWord"), _extstr(u"personaldictprefpage.Word")) #$NON-NLS-2$ #$NON-NLS-1$ if word is not None: self.model.addWord(word) self.personalDictionaryListView.refresh() self._refreshButtonStates() self.getPrefsDialog().onPrefPageChange() event.Skip()
def resumeTask(self, taskId, listener = None): task = self.getTask(taskId) if task is None: raise ZAppFrameworkException(_extstr(u"backgroundtaskimpl.FailedToResumeTaskNotFound") % taskId) #$NON-NLS-1$ if task.isRunning(): raise ZAppFrameworkException(_extstr(u"backgroundtaskimpl.FailedToResumeTaskAlreadyRunning") % taskId) #$NON-NLS-1$ if task.isComplete(): raise ZAppFrameworkException(_extstr(u"backgroundtaskimpl.FailedToResumeTaskComplete") % taskId) #$NON-NLS-1$ if not task.isResumable(): raise ZAppFrameworkException(_extstr(u"backgroundtaskimpl.FailedToResumeTaskNotResumable") % taskId) #$NON-NLS-1$ if listener is not None: task.attachListener(listener) self._resumeTask(task) self.listeners.doCallback(u"onTaskResumed", [task]) #$NON-NLS-1$ return task
def _loadPluginSchemaXML(self): schemaPath = self._getPluginSchemaPath() try: f = open(schemaPath, u"r") #$NON-NLS-1$ xml = f.read() f.close() return xml except Exception, e: raise ZAppFrameworkException(_extstr(u"plugin.FailedToLoadSchema"), e) #$NON-NLS-1$
def __init__(self, parent): self.model = ZBackgroundTaskManagerModel() ZBaseWindow.__init__(self, parent, _extstr(u"bgtaskmanager.BackgroundTaskManager"), name = u"ZBackgroundTaskManager") #$NON-NLS-2$ #$NON-NLS-1$ ZPersistentDialogMixin.__init__(self, IZAppUserPrefsKeys.BGTASK_WINDOW) self.Layout() self.model.getService().addListener(self)
def cancelTask(self, taskId, removeFlag = False): task = self.getTask(taskId) if task is None: raise ZAppFrameworkException(_extstr(u"backgroundtaskimpl.FailedToCancelDoesNotExist") % taskId) #$NON-NLS-1$ task.cancel() task.detachListener(self) self.listeners.doCallback(u"onTaskCancelled", [task]) #$NON-NLS-1$ if removeFlag: self.removeTask(taskId)
def _raiseError(self, errorMessage, errorDetails): self.logger.error(errorMessage) self.error = (errorMessage, errorDetails) self.listeners.doCallback(u"onError", [self, errorMessage, errorDetails]) #$NON-NLS-1$ self._writeToLog(_extstr(u"backgroundtaskimpl.ErrorInTask") % errorMessage) #$NON-NLS-1$ self._writeToLog(errorDetails) self.endTime = ZSchemaDateTime() self.stopped = True self.cancelled = True