Mercurial > libervia-backend
diff frontends/src/tools/xmlui.py @ 1367:f71a0fc26886
merged branch frontends_multi_profiles
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 18 Mar 2015 10:52:28 +0100 |
parents | 35f99c90b736 |
children | 069ad98b360d |
line wrap: on
line diff
--- a/frontends/src/tools/xmlui.py Thu Feb 05 11:59:26 2015 +0100 +++ b/frontends/src/tools/xmlui.py Wed Mar 18 10:52:28 2015 +0100 @@ -20,7 +20,7 @@ from sat.core.i18n import _ from sat.core.log import getLogger log = getLogger(__name__) -from sat_frontends.constants import Const as C +from sat_frontends.quick_frontend.constants import Const as C from sat.core.exceptions import DataError @@ -202,7 +202,7 @@ This class must not be instancied directly """ - def __init__(self, host, parsed_dom, title = None, flags = None): + def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, profile=C.PROF_KEY_NONE): """Initialise the XMLUI instance @param host: %(doc_host)s @@ -210,15 +210,18 @@ @param title: force the title, or use XMLUI one if None @param flags: list of string which can be: - NO_CANCEL: the UI can't be cancelled + @param callback: if present, will be used with launchAction """ self.host = host top=parsed_dom.documentElement self.session_id = top.getAttribute("session_id") or None self.submit_id = top.getAttribute("submit") or None - self.title = title or top.getAttribute("title") or u"" + self.xmlui_title = title or top.getAttribute("title") or u"" if flags is None: flags = [] self.flags = flags + self.callback = callback + self.profile = profile def _isAttrSet(self, name, node): """Returnw widget boolean attribute status @@ -253,7 +256,7 @@ self._xmluiLaunchAction(self.submit_id, data) def _xmluiLaunchAction(self, action_id, data): - self.host.launchAction(action_id, data, profile_key = self.host.profile) + self.host.launchAction(action_id, data, callback=self.callback, profile=self.profile) class XMLUIPanel(XMLUIBase): @@ -265,8 +268,8 @@ """ widget_factory = None - def __init__(self, host, parsed_dom, title = None, flags = None): - super(XMLUIPanel, self).__init__(host, parsed_dom, title = None, flags = None) + def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, profile=C.PROF_KEY_NONE): + super(XMLUIPanel, self).__init__(host, parsed_dom, title=title, flags=flags, callback=callback, profile=profile) self.ctrl_list = {} # usefull to access ctrl self._main_cont = None self.constructUI(parsed_dom) @@ -286,7 +289,7 @@ self._main_cont = value def _parseChilds(self, _xmlui_parent, current_node, wanted = ('container',), data = None): - """Recursively parse childNodes of an elemen + """Recursively parse childNodes of an element @param _xmlui_parent: widget container with '_xmluiAppend' method @param current_node: element from which childs will be parsed @@ -462,7 +465,7 @@ raise NotImplementedError def _xmluiSetParam(self, name, value, category): - self.host.bridge.setParam(name, value, category, profile_key=self.host.profile) + self.host.bridge.setParam(name, value, category, profile_key=self.profile) ##EVENTS## @@ -639,8 +642,8 @@ class XMLUIDialog(XMLUIBase): dialog_factory = None - def __init__(self, host, parsed_dom, title = None, flags = None): - super(XMLUIDialog, self).__init__(host, parsed_dom, title = None, flags = None) + def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, profile=C.PROF_KEY_NONE): + super(XMLUIDialog, self).__init__(host, parsed_dom, title=None, flags=None, callback=callback, profile=C.PROF_KEY_NONE) top=parsed_dom.documentElement dlg_elt = self._getChildNode(top, "dialog") if dlg_elt is None: @@ -654,23 +657,23 @@ level = dlg_elt.getAttribute(C.XMLUI_DATA_LVL) or C.XMLUI_DATA_LVL_INFO if dlg_type == C.XMLUI_DIALOG_MESSAGE: - self.dlg = self.dialog_factory.createMessageDialog(self, self.title, message, level) + self.dlg = self.dialog_factory.createMessageDialog(self, self.xmlui_title, message, level) elif dlg_type == C.XMLUI_DIALOG_NOTE: - self.dlg = self.dialog_factory.createNoteDialog(self, self.title, message, level) + self.dlg = self.dialog_factory.createNoteDialog(self, self.xmlui_title, message, level) elif dlg_type == C.XMLUI_DIALOG_CONFIRM: try: buttons_elt = self._getChildNode(dlg_elt, "buttons") buttons_set = buttons_elt.getAttribute("set") or C.XMLUI_DATA_BTNS_SET_DEFAULT except (TypeError, AttributeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError buttons_set = C.XMLUI_DATA_BTNS_SET_DEFAULT - self.dlg = self.dialog_factory.createConfirmDialog(self, self.title, message, level, buttons_set) + self.dlg = self.dialog_factory.createConfirmDialog(self, self.xmlui_title, message, level, buttons_set) elif dlg_type == C.XMLUI_DIALOG_FILE: try: file_elt = self._getChildNode(dlg_elt, "file") filetype = file_elt.getAttribute("type") or C.XMLUI_DATA_FILETYPE_DEFAULT except (TypeError, AttributeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError filetype = C.XMLUI_DATA_FILETYPE_DEFAULT - self.dlg = self.dialog_factory.createFileDialog(self, self.title, message, level, filetype) + self.dlg = self.dialog_factory.createFileDialog(self, self.xmlui_title, message, level, filetype) else: raise ValueError("Unknown dialog type [%s]" % dlg_type) @@ -690,9 +693,9 @@ class_map[type_] = class_ -def create(host, xml_data, title = None, flags = None, dom_parse=None, dom_free=None): +def create(host, xml_data, title=None, flags=None, dom_parse=None, dom_free=None, callback=None, profile=C.PROF_KEY_NONE): """ - @param dom_parse: methode equivalent to minidom.parseString (but which must manage unicode), or None to use default one + @param dom_parse: methode equivalent to minidom.parseString (but which must manage unicode), or None to use default one @param dom_free: method used to free the parsed DOM """ if dom_parse is None: @@ -713,6 +716,6 @@ except KeyError: raise ClassNotRegistedError(_("You must register classes with registerClass before creating a XMLUI")) - xmlui = cls(host, parsed_dom, title, flags) + xmlui = cls(host, parsed_dom, title, flags, callback, profile) dom_free(parsed_dom) return xmlui