frontends: some modifications to ease the the use of the new sat_frontends.tools.xmlui.XMLUI class in Libervia
This commit is contained in:
parent
c6aaaaa297
commit
d5b255e437
1 changed files with 18 additions and 11 deletions
|
|
@ -242,7 +242,7 @@ class XMLUI(object):
|
|||
self._parseChilds(cont, node, ('widget', 'container'))
|
||||
try:
|
||||
parent._xmluiAppend(cont)
|
||||
except AttributeError:
|
||||
except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError
|
||||
if parent is self:
|
||||
self.main_cont = cont
|
||||
else:
|
||||
|
|
@ -279,7 +279,8 @@ class XMLUI(object):
|
|||
try:
|
||||
value = node.childNodes[0].wholeText
|
||||
except IndexError:
|
||||
warning (_("text node has no child !"))
|
||||
# warning (_("text node has no child !"))
|
||||
pass # FIXME proper warning (this one is not OK with Libervia)
|
||||
ctrl = self.widget_factory.createTextWidget(parent, value)
|
||||
elif type_=="label":
|
||||
ctrl = self.widget_factory.createLabelWidget(parent, value)
|
||||
|
|
@ -318,8 +319,8 @@ class XMLUI(object):
|
|||
try:
|
||||
ctrl._xmluiOnChange(self.onParamChange)
|
||||
ctrl._param_category = self._current_category
|
||||
except AttributeError:
|
||||
if not isinstance(ctrl, (EmptyWidget, TextWidget)):
|
||||
except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError
|
||||
if not isinstance(ctrl, (EmptyWidget, TextWidget, LabelWidget, JidWidget)):
|
||||
warning(_("No change listener on [%s]" % ctrl))
|
||||
|
||||
ctrl._xmlui_name = name
|
||||
|
|
@ -360,6 +361,12 @@ class XMLUI(object):
|
|||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def _xmluiLaunchAction(self, action_id, data):
|
||||
self.host.launchAction(action_id, data, profile_key = self.host.profile)
|
||||
|
||||
def _xmluiSetParam(self, name, value, category):
|
||||
self.host.bridge.setParam(name, value, category, profile_key=self.host.profile)
|
||||
|
||||
##EVENTS##
|
||||
|
||||
def onParamChange(self, ctrl):
|
||||
|
|
@ -378,7 +385,7 @@ class XMLUI(object):
|
|||
name = self.escape(wid._xmlui_name)
|
||||
value = wid._xmluiGetValue()
|
||||
ret[name] = value
|
||||
except AttributeError:
|
||||
except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError
|
||||
pass
|
||||
idx = ctrl._xmluiGetSelectedIndex()
|
||||
if idx is not None:
|
||||
|
|
@ -387,7 +394,7 @@ class XMLUI(object):
|
|||
if callback_id is None:
|
||||
warning(_("No callback_id found"))
|
||||
return
|
||||
self.host.launchAction(callback_id, data, profile_key = self.host.profile)
|
||||
self._xmluiLaunchAction(callback_id, data)
|
||||
|
||||
def onButtonPress(self, button):
|
||||
""" Called when an XMLUI button is clicked
|
||||
|
|
@ -404,7 +411,7 @@ class XMLUI(object):
|
|||
data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelected())
|
||||
else:
|
||||
data[escaped] = ctrl['control']._xmluiGetValue()
|
||||
self.host.launchAction(callback_id, data, profile_key = self.host.profile)
|
||||
self._xmluiLaunchAction(callback_id, data)
|
||||
|
||||
def onFormSubmitted(self, ignore=None):
|
||||
""" An XMLUI form has been submited
|
||||
|
|
@ -423,7 +430,7 @@ class XMLUI(object):
|
|||
data = dict(selected_values)
|
||||
if self.session_id is not None:
|
||||
data["session_id"] = self.session_id
|
||||
self.host.launchAction(self.submit_id, data, profile_key=self.host.profile)
|
||||
self._xmluiLaunchAction(self.submit_id, data)
|
||||
|
||||
else:
|
||||
warning (_("The form data is not sent back, the type is not managed properly"))
|
||||
|
|
@ -446,7 +453,7 @@ class XMLUI(object):
|
|||
value = u'\t'.join(ctrl._xmluiGetSelectedValues())
|
||||
else:
|
||||
value = ctrl._xmluiGetValue()
|
||||
param_name = ctr._xmlui_name.split(Const.SAT_PARAM_SEPARATOR)[1]
|
||||
self.host.bridge.setParam(param_name, value, ctrl._param_category,
|
||||
profile_key=self.host.profile)
|
||||
param_name = ctrl._xmlui_name.split(Const.SAT_PARAM_SEPARATOR)[1]
|
||||
self._xmluiSetParam(param_name, value, ctrl._param_category)
|
||||
|
||||
self._xmluiClose()
|
||||
|
|
|
|||
Loading…
Reference in a new issue