class ZRavenApplicationStatusBarModel: def __init__(self): self.runningTasks = ZSortedSet() self.dirty = True self.statusBarModel = self._createStatusBarModel() # end __init__() def isDirty(self): return self.dirty # end isDirty() def setDirty(self, dirty): self.dirty = dirty # end setDirty() def _createStatusBarModel(self): sbModel = ZStatusBarModel() sbModel.addPane(u"bgTaskSummaryPane") #$NON-NLS-1$ sbModel.setPaneWidth(u"bgTaskSummaryPane", -1) #$NON-NLS-1$ return sbModel # end _createStatusBarModel() def getTaskService(self): return getApplicationModel().getService(IZAppServiceIDs.BACKGROUND_TASK_SERVICE_ID) # end getTaskService() def getStatusBarModel(self): return self.statusBarModel # end getStatusBarModel() def createStatusBarProvider(self): return ZStatusBarModelBasedContentProvider(self.statusBarModel) # end createStatusBarProvider() def isRunning(self): return len(self.runningTasks) > 0 # end isRunning() def addTask(self, task): self.runningTasks.append(task) self.dirty = True # end addTask() def removeTask(self, task): self.runningTasks.remove(task) self.dirty = True # end removeTask() def getNumRunningTasks(self): return len(self.runningTasks)
class ZHostNode(IZTreeNodeModel): def __init__(self, host): self.host = host self.children = ZSortedSet(ZImageIDONodeComparator()) # end __init__() def addImageIDO(self, imageIDO): return self.children.add(ZImageIDONode(imageIDO)) # end addImageIDO() def removeImageIDO(self, imageIDO): return self.children.remove(ZImageIDONode(imageIDO)) # end removeImageIDO() def getHost(self): return self.host # end getHost() def getLabel(self): host = self.getHost() if host is None or host.strip() == u"": #$NON-NLS-1$ host = u"(%s)" % _extstr( u"imgsviewmodel.local") #$NON-NLS-1$ #$NON-NLS-2$ return host # end getLabel() def getChildren(self): return self.children # end getChildren() def getImageLabel(self): return u"site" #$NON-NLS-1$ # end getImageLabel() def getSelectedImageLabel(self): return u"site" #$NON-NLS-1$ # end getSelectedImageLabel() def isBold(self): return True # end isBold() def isExpanded(self): # FIXME (EPW) it would be nice if this remembered its state, at least when refreshing return False # end isExpanded() def isEmpty(self): return self.children.isEmpty()
class ZHostNode(IZTreeNodeModel): def __init__(self, host): self.host = host self.children = ZSortedSet(ZLinkIDONodeComparator()) # end __init__() def addLinkIDO(self, linkIDO): return self.children.add(ZLinkIDONode(linkIDO)) # end addLinkIDO() def removeLinkIDO(self, linkIDO): return self.children.remove(ZLinkIDONode(linkIDO)) # end removeLinkIDO() def getHost(self): return self.host # end getHost() def getLabel(self): host = self.getHost() if host is None or host.strip() == u"": #$NON-NLS-1$ host = u"(%s)" % _extstr(u"imgsviewmodel.local") #$NON-NLS-1$ #$NON-NLS-2$ return host # end getLabel() def getChildren(self): return self.children # end getChildren() def getImageLabel(self): return u"site" #$NON-NLS-1$ # end getImageLabel() def getSelectedImageLabel(self): return u"site" #$NON-NLS-1$ # end getSelectedImageLabel() def isBold(self): return True # end isBold() def isExpanded(self): # FIXME (EPW) it would be nice if this remembered its state, at least when refreshing return False # end isExpanded() def isEmpty(self): return self.children.isEmpty()
class ZTranslationEditorModel: def __init__(self, translation, defaultTranslation): self.translation = translation self.defaultTranslation = defaultTranslation self.showOnlyUntranslated = False self.dirty = False self.allKeys = ZSortedSet() self.untranslatedKeys = ZSortedSet() self._initKeys() # end __init__() def _initKeys(self): translationBundleStrings = self.translation.getBundleStrings() defaultBundleStrings = self.defaultTranslation.getBundleStrings() for key in defaultBundleStrings.keys(): self.allKeys.add(key) if not key in translationBundleStrings: self.untranslatedKeys.add(key) # end _initKeys() def save(self): self.translation.save(self.defaultTranslation) # end save() def isDirty(self): return self.dirty # end isDirty() def setDirty(self, dirty): self.dirty = dirty # end setDirty() def getTranslation(self): return self.translation # end getTranslation() def getDefaultTranslation(self): return self.defaultTranslation # end getDefaultTranslation() def setShowOnlyUntranslated(self, value): self.showOnlyUntranslated = value # end setShowOnlyUntranslated() def getAllKeys(self): return self.allKeys # end getAllKeys() def getUntranslatedKeys(self): return self.untranslatedKeys # end getUntranslatedKeys() def getKeys(self): if self.showOnlyUntranslated: return self.untranslatedKeys else: return self.allKeys # end getKeys() def getNumStrings(self): return len(self.getKeys()) # end getNumStrings() def getTranslationValue(self, key): translationBundleStrings = self.translation.getBundleStrings() if key in translationBundleStrings: return translationBundleStrings[key] return u"" #$NON-NLS-1$ # end getTranslationValue() def getDefaultValue(self, key): defaultBundleStrings = self.defaultTranslation.getBundleStrings() if key in defaultBundleStrings: return defaultBundleStrings[key] return u"" #$NON-NLS-1$ # end getDefaultValue() def setTranslationValue(self, key, value): self.dirty = True if not value: self.translation.clearBundleString(key) self.untranslatedKeys.add(key) else: self.translation.setBundleString(key, value) if key in self.untranslatedKeys: self.untranslatedKeys.remove(key)
class ZTranslationEditorModel: def __init__(self, translation, defaultTranslation): self.translation = translation self.defaultTranslation = defaultTranslation self.showOnlyUntranslated = False self.dirty = False self.allKeys = ZSortedSet() self.untranslatedKeys = ZSortedSet() self._initKeys() # end __init__() def _initKeys(self): translationBundleStrings = self.translation.getBundleStrings() defaultBundleStrings = self.defaultTranslation.getBundleStrings() for key in defaultBundleStrings.keys(): self.allKeys.add(key) if not key in translationBundleStrings: self.untranslatedKeys.add(key) # end _initKeys() def save(self): self.translation.save(self.defaultTranslation) # end save() def isDirty(self): return self.dirty # end isDirty() def setDirty(self, dirty): self.dirty = dirty # end setDirty() def getTranslation(self): return self.translation # end getTranslation() def getDefaultTranslation(self): return self.defaultTranslation # end getDefaultTranslation() def setShowOnlyUntranslated(self, value): self.showOnlyUntranslated = value # end setShowOnlyUntranslated() def getAllKeys(self): return self.allKeys # end getAllKeys() def getUntranslatedKeys(self): return self.untranslatedKeys # end getUntranslatedKeys() def getKeys(self): if self.showOnlyUntranslated: return self.untranslatedKeys else: return self.allKeys # end getKeys() def getNumStrings(self): return len(self.getKeys()) # end getNumStrings() def getTranslationValue(self, key): translationBundleStrings = self.translation.getBundleStrings() if key in translationBundleStrings: return translationBundleStrings[key] return u"" #$NON-NLS-1$ # end getTranslationValue() def getDefaultValue(self, key): defaultBundleStrings = self.defaultTranslation.getBundleStrings() if key in defaultBundleStrings: return defaultBundleStrings[key] return u"" #$NON-NLS-1$ # end getDefaultValue() def setTranslationValue(self, key, value): self.dirty = True if not value: self.translation.clearBundleString(key) self.untranslatedKeys.add(key) else: self.translation.setBundleString(key, value) if key in self.untranslatedKeys: self.untranslatedKeys.remove(key)