class NotificationSettingEntityDeco(BaseListEntryCustomColumns): default_name = 'NotificationSettingEntry' VISIBILITY_CHECKED_KEY = 'visibilityChecked' VISIBILITY_CHANGED_CALLBACK_KEY = 'onVisibilityChanged' POPUP_CHECKED_KEY = 'popupChecked' POPUP_CHANGED_CALLBACK_KEY = 'onPopupChanged' GETMENU_CALLBACK = 'menuCallBack' def ApplyAttributes(self, attributes): BaseListEntryCustomColumns.ApplyAttributes(self, attributes) self.AddColumnText(' ' + attributes.node.label) self.node = attributes.node visibilityChecked = self.node.get(self.VISIBILITY_CHECKED_KEY) popupChecked = self.node.get(self.POPUP_CHECKED_KEY) self.visibilityCallBack = self.node.get(self.VISIBILITY_CHANGED_CALLBACK_KEY) self.popupChangedCallback = self.node.get(self.POPUP_CHANGED_CALLBACK_KEY) self.getMenuCallBack = self.node.get(self.GETMENU_CALLBACK) visibiltyColumn = self.AddColumnContainer() self.visibilityCheckbox = Checkbox(name='visibiltyCheckbox', parent=visibiltyColumn, text='', checked=visibilityChecked, callback=self.OnVisibiltyCheckbox) containerColumn = self.AddColumnContainer() self.popupCheckBox = Checkbox(name='showPopupCheckBox', parent=containerColumn, text='', checked=popupChecked, callback=self.OnPopupChangedCheckbox) def forceSetPopupState(self, status): if not self.destroyed: self.popupCheckBox.SetChecked(status, report=False) def OnPopupChangedCheckbox(self, *args): self.popupChangedCallback(self.node) def OnVisibiltyCheckbox(self, *args): self.visibilityCallBack(self.node) def GetMenu(self): return self.getMenuCallBack(self.node)
class TreeViewSettingsItem(TreeViewEntry): default_name = 'TreeViewEntrySettings' def ApplyAttributes(self, attributes): TreeViewEntry.ApplyAttributes(self, attributes) if hasattr(self.data, 'settings'): self.settings = self.data.settings if self.settings: self.GetMenuCallback = self.settings[NotificationSettingEntityDeco.GETMENU_CALLBACK] visibilityChecked = self.settings[NotificationSettingEntityDeco.VISIBILITY_CHECKED_KEY] showPopupChecked = self.settings[NotificationSettingEntityDeco.POPUP_CHECKED_KEY] self.visibilityCallBack = self.settings[NotificationSettingEntityDeco.VISIBILITY_CHANGED_CALLBACK_KEY] self.showPopupCallBack = self.settings[NotificationSettingEntityDeco.POPUP_CHANGED_CALLBACK_KEY] self.popupCheckBox = Checkbox(name='UsepopupNotifications', text='', parent=self.topRightCont, align=uiconst.TORIGHT, checked=showPopupChecked, callback=self.OnPopupNotificationToggle, hint=localization.GetByLabel('Notifications/NotificationSettings/PopupVisibilityCheckboxTooltip')) self.visibilityChckbox = Checkbox(name='visibilityNotification', text='', parent=self.topRightCont, align=uiconst.TORIGHT, checked=visibilityChecked, callback=self.OnVisibiltyToggle, hint=localization.GetByLabel('Notifications/NotificationSettings/HistoryVisibilityCheckboxTooltip')) self.isGroup = self.settings['isGroup'] self.id = self.settings['id'] def OnPopupNotificationToggle(self, checkbox): if self.isGroup: for child in self.childCont.children: child.UpdatePopupCheckBox(checkbox._checked, report=True) self.showPopupCallBack(self.isGroup, self.id, checkbox._checked) def OnVisibiltyToggle(self, checkbox): if self.isGroup: for child in self.childCont.children: child.UpdateVisibilitySetting(checkbox._checked, report=True) self.visibilityCallBack(self.isGroup, self.id, checkbox._checked) def OnOneClick(self, *args): print 'click' def GetMenu(self): return self.GetMenuCallback(self.isGroup, self.id) def GetTreeViewEntryClassByTreeData(self, treeData): return TreeViewSettingsItem def UpdateVisibilitySetting(self, on, report = False): self.visibilityChckbox.SetChecked(onoff=on, report=report) def UpdatePopupCheckBox(self, on, report = False): self.popupCheckBox.SetChecked(onoff=on, report=report)