[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9526 - in trunk/gnue-forms/src/uidrivers/html: . widgets
From: |
jan |
Subject: |
[gnue] r9526 - in trunk/gnue-forms/src/uidrivers/html: . widgets |
Date: |
Thu, 26 Apr 2007 05:51:25 -0500 (CDT) |
Author: jan
Date: 2007-04-26 05:51:24 -0500 (Thu, 26 Apr 2007)
New Revision: 9526
Modified:
trunk/gnue-forms/src/uidrivers/html/GFController.py
trunk/gnue-forms/src/uidrivers/html/widgets/_base.py
trunk/gnue-forms/src/uidrivers/html/widgets/entry.py
trunk/gnue-forms/src/uidrivers/html/widgets/form.py
Log:
update html frontend for uiForm location and event system changes
implement page change command
Modified: trunk/gnue-forms/src/uidrivers/html/GFController.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/GFController.py 2007-04-26 08:27:10 UTC
(rev 9525)
+++ trunk/gnue-forms/src/uidrivers/html/GFController.py 2007-04-26 10:51:24 UTC
(rev 9526)
@@ -100,7 +100,7 @@
# disable standart html drivers mainloop
gfclient._ui.GFhtmlApp.GFhtmlApp._mainLoop = 1
- self.instance.run_from_file(baseform, None)
+ self.form=self.instance.run_from_file(baseform, parameters=None)
self._setState(self.IDLE_STATE)
print "GNUe Forms Session %s setup" % self._id
@@ -121,6 +121,7 @@
try:
if cmd == "event":
+ # TODO: directly call event functions
# id = int(args["id"])
event = args["event"]
e = events.Event(event, \
@@ -130,18 +131,19 @@
elif cmd == "onChange":
id = int(args["id"])
text = args["text"]
+ if hasattr(args,"pos"):
+ position = args["pos"]
+ else:
+ position = 0
- gfObject = self.instance._uiinstance._WidgetToGFObj [id]
- e = events.Event('requestREPLACEVALUE', text = text, \
- _form=self.instance._main_form)
- self.instance.dispatchEvent(e)
+ UIObject = self.instance._uiinstance._WidgetToUIObj [id]
+ # FIXME: take care that id matches the current index
+ UIObject._on_text_changed (text, position)
-
elif cmd == "onFocus":
id = int(args["id"])
UIObject = self.instance._uiinstance._WidgetToUIObj [id]
- widget = self.instance._uiinstance._IdToWidget [id]
- UIObject._focusInHandler (id)
+ UIObject._on_focus_in (id)
elif cmd == "btn":
id = int(args["id"])
@@ -149,13 +151,28 @@
gfObject = self.instance._uiinstance._WidgetToGFObj [id]
gfObject._event_fire ()
+ elif cmd == "pagechange":
+ page = args["page"]
+ id = int(args["id"][5:]) # convert "page_1" to 1
+ self.form.uiWidget._on_switch_page(id)
+
else:
- updates = [["status","","This session is invalid. Please
restart!"]]
+ updates = [["status","","Unknown command '%s' was called!" %
cmd]]
except Exception, e:
- updates = [["alert","","Error %s" % e]]
+ try:
+ if hasattr(e,"getDetail"):
+ detail = e.getDetail()
+ else:
+ import sys, traceback, string
+ detail = u"Non GNUE Traceback:"
+ detail += u"%s" % string.join(traceback.format_exception
(*sys.exc_info ()))
+ updates = [["alert","",u"Error %s \n\n %s" % (e,detail)]]
+ except Exception, e:
+ updates = [["alert","",u"Error in Exception handling %s" % e]]
+
# refresh updates
- updates.extend(self.instance._uiinstance._UIform.get_updates())
+ updates.extend(self.form.uiWidget.get_updates())
print "pushing updates %s" % updates
self._pushUpdates(updates)
self.updates_available.set() # inform listeners, that new updates are
available
@@ -163,12 +180,13 @@
self._usageCounter.release()
def getHtml(self, form):
+ print "getHtml was called for form '%s'." % form
if self._state==self.LOADING_STATE:
return Generator.build_loading_page("Please wait until loaded")
else:
# FIXME: do we need to acquire a semaphore here?
self._usageCounter.acquire()
- html = self.instance._uiinstance._UIform.get_html()
+ html = self.form.uiWidget.get_html()
self._usageCounter.release()
return html
@@ -281,6 +299,7 @@
def handleRequest(self, session_id, command, arguments):
if not self.sessions.has_key(session_id):
+ print "Request for invalid session '%s'!" % session_id
return [["status","","This session is invalid. Please restart!"]]
# TODO: check for health of thread pool, and if necessary startup new
threads or print warning
Modified: trunk/gnue-forms/src/uidrivers/html/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/widgets/_base.py 2007-04-26
08:27:10 UTC (rev 9525)
+++ trunk/gnue-forms/src/uidrivers/html/widgets/_base.py 2007-04-26
10:51:24 UTC (rev 9526)
@@ -110,7 +110,7 @@
# Handle focus signals from widgets
#
---------------------------------------------------------------------------
- def _focusInHandler (self, widget_id):
+ def _on_focus_in (self, widget_id):
assert gDebug (6, "FOCUS-IN-EVENT: %s" % (widget_id))
gfObject = self._uiDriver._WidgetToGFObj [widget_id]
gfObject._event_set_focus(self._index_for_id (widget_id))
@@ -212,9 +212,9 @@
for child in self._children:
dhtml += child.get_html()
return dhtml
-
- elif self._type == "FORM": # DIALOG
- pno=1
+
+ elif self._type == "FORM": # DIALOG
+ pno=0
pages=u""
header=u""
footer=u""
@@ -230,17 +230,17 @@
pages+=build_page(u"page_%s" % pno, pagename,
child.get_html())
pno+=1
- if hasattr(self,"MenuBar"):
+ if hasattr(self,"MenuBar"):
header = header + self.MenuBar.get_html()
-
- if hasattr(self,"ToolBar"):
+
+ if hasattr(self,"ToolBar"):
header = header + self.ToolBar.get_html()
-
+
if hasattr(self,"StatusBar"):
footer = footer + self.ToolBar.get_html()
-
+
return build_form("GNUe Forms", header, pages, footer)
-
+
else:
return self.dhtml
@@ -252,16 +252,16 @@
self.value = value
else:
self.value = u""
-
+
self._send_update(["set","%s" % self._id,self.value])
def set_sensitive(self, enabled):
self._send_update(["disable","%s" % self._id,not(enabled)])
self._disabled = not(enabled)
-
+
def set_active(self, active):
self._send_update(["activate","%s" % self._id, active])
- self._active = active
+ self._active = active
def grab_focus(self):
self._send_update(["grab_focus","%s" % self._id,""])
Modified: trunk/gnue-forms/src/uidrivers/html/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/widgets/entry.py 2007-04-26
08:27:10 UTC (rev 9525)
+++ trunk/gnue-forms/src/uidrivers/html/widgets/entry.py 2007-04-26
10:51:24 UTC (rev 9526)
@@ -50,8 +50,8 @@
dhtml=build_entry_combobox(id, "%s", choices,
object.Char__height,
object.Char__x*event.widgetWidth,\
self.itemY, self.itemWidth, \
- self.itemHeight)
-
+ self.itemHeight)
+
elif object.style == 'label':
dhtml = build_entry_label(id, "%s",
object.Char__x*event.widgetWidth, \
self.itemY, self.itemWidth,
self.itemHeight)
@@ -59,7 +59,7 @@
elif object.style == 'checkbox':
dhtml = build_entry_checkbox(id, "%s", object.label, \
object.Char__x*event.widgetWidth,
self.itemY)
-
+
# multiline edit
elif hasattr(object,'Char__height') and object.Char__height > 1:
dhtml = build_entry_multiline(id, "%s", object.Char__height, \
@@ -71,12 +71,12 @@
textbox_style = "Textbox"
# Textbox", IntegerTextbox, DateTextbox, TimeTextbox
dhtml = build_entry_default(id, "%s",
object.Char__x*event.widgetWidth,\
- self.itemY, self.itemWidth,
self.itemHeight,
+ self.itemY, self.itemWidth,
self.itemHeight,
textbox_style)
# ["set_cursor", "141", 0], ["select_region", "141", [0, 0]]]
-
-
-
+
+
+
newWidget = HtmlEntryWidget(event.container, self._uiDriver, 'ENTRY',
dhtml, id)
newWidget.style=object.style
@@ -169,47 +169,55 @@
widget = self.widgets [index]
widget.select_region (selection1, selection2)
-
-
+
+
#
---------------------------------------------------------------------------
# Update the list of allowed values on a combo or list widget
#
---------------------------------------------------------------------------
-
+
def _ui_set_choices_(self, index, choices):
widget = self.widgets[index]
-
+
# update HTML template
if self._gfObject.style=="listbox":
- widget.dhtml=build_entry_listbox(widget._id, "%s", choices,
+ widget.dhtml=build_entry_listbox(widget._id, "%s", choices,
self._gfObject.Char__height,
self.itemX, self.itemY,
self.itemWidth, \
self.itemHeight)
else:
- widget.dhtml=build_entry_combobox(widget._id, "%s", choices,
+ widget.dhtml=build_entry_combobox(widget._id, "%s", choices,
self._gfObject.Char__height,
self.itemX, self.itemY,
self.itemWidth, \
self.itemHeight)
-
+
# send update to form
widget.update_choices(choices)
-
+ # -------------------------------------------------------------------------
+ # Event handlers (called by GFController)
+ # -------------------------------------------------------------------------
+
+ def _on_text_changed(self, text, position=0):
+
+ self._request('REPLACEVALUE', text=text, position=position)
+
+
class HtmlEntryWidget(HtmlWidget):
def __repr__(self):
return "Html Widget: %s" % self._type
def set_cursor_pos(self, pos):
- self._send_update(["set_cursor","%s" % self._id, pos])
+ self._send_update(["set_cursor","%s" % self._id, pos])
def select_region(self, selection1, selection2):
self._send_update(["select_region","%s" % self._id, \
- [selection1, selection2]])
+ [selection1, selection2]])
def update_choices(self, choices):
self._send_update(["update_choices","%s" % self._id, \
- choices])
+ choices])
def get_html(self):
if self._type == "ENTRY":
@@ -222,7 +230,7 @@
return (self.dhtml % u"")
else:
return (self.dhtml % self.value)
-
+
except Exception,e:
print e
print self.dhtml,self.value
Modified: trunk/gnue-forms/src/uidrivers/html/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/widgets/form.py 2007-04-26 08:27:10 UTC
(rev 9525)
+++ trunk/gnue-forms/src/uidrivers/html/widgets/form.py 2007-04-26 10:51:24 UTC
(rev 9526)
@@ -212,7 +212,24 @@
self.mainWindow.updates.append(["close","",""])
#FIXME: implement close dialog
+ #
---------------------------------------------------------------------------
+ # Event handlers
+ #
---------------------------------------------------------------------------
+ def _on_switch_page(self, page_number):
+
+ assert gDebug(6, "switch-page to %r" % page_number)
+ self._form._event_page_changed(page_number)
+
+ #
---------------------------------------------------------------------------
+
+ def _on_focus_in_event(self):
+ # called if window is changed back to this form
+
+ assert gDebug(6, "focus-in-event %s" % (self.form))
+ self._form._event_focus_changed(None, 0)
+
+
configuration = {
'baseClass' : UIForm,
'provides' : 'GFForm',
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9526 - in trunk/gnue-forms/src/uidrivers/html: . widgets,
jan <=