Mercurial > libervia-web
comparison src/browser/sat_browser/list_manager.py @ 648:6d3142b782c3 frontends_multi_profiles
browser_side: classes reorganisation:
- moved widgets in dedicated modules (base, contact, editor, libervia) and a widget module for single classes
- same thing for panels (base, main, contact)
- libervia_widget mix main panels and widget and drag n drop for technical reasons (see comments)
- renamed WebPanel to WebWidget
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Feb 2015 18:10:54 +0100 |
parents | c22b47d63fe2 |
children | 9877607c719a |
comparison
equal
deleted
inserted
replaced
647:e0021d571eef | 648:6d3142b782c3 |
---|---|
24 from pyjamas.ui.AutoComplete import AutoCompleteTextBox | 24 from pyjamas.ui.AutoComplete import AutoCompleteTextBox |
25 from pyjamas.ui.KeyboardListener import KEY_ENTER | 25 from pyjamas.ui.KeyboardListener import KEY_ENTER |
26 from pyjamas.ui.DragWidget import DragWidget | 26 from pyjamas.ui.DragWidget import DragWidget |
27 from pyjamas.Timer import Timer | 27 from pyjamas.Timer import Timer |
28 | 28 |
29 import base_panels | 29 import base_panel |
30 import base_widget | 30 import base_widget |
31 import libervia_widget | |
31 | 32 |
32 from sat_frontends.tools import jid | 33 from sat_frontends.tools import jid |
33 | 34 |
34 | 35 |
35 unicode = str # FIXME: pyjamas workaround | 36 unicode = str # FIXME: pyjamas workaround |
248 should be hidden from the menu. Takes in the button widget and the | 249 should be hidden from the menu. Takes in the button widget and the |
249 item key and returns a boolean. | 250 item key and returns a boolean. |
250 @param callback (callable): common callback for all menu items, takes in | 251 @param callback (callable): common callback for all menu items, takes in |
251 the button widget and the item key. | 252 the button widget and the item key. |
252 """ | 253 """ |
253 self.popup_menu = base_panels.PopupMenuPanel(entries, hide, callback, style={"item": self.style["popupMenuItem"]}) | 254 self.popup_menu = base_panel.PopupMenuPanel(entries, hide, callback, style={"item": self.style["popupMenuItem"]}) |
254 | 255 |
255 | 256 |
256 class DragAutoCompleteTextBox(AutoCompleteTextBox, DragWidget): | 257 class DragAutoCompleteTextBox(AutoCompleteTextBox, DragWidget): |
257 """A draggable AutoCompleteTextBox which is used for representing an item.""" | 258 """A draggable AutoCompleteTextBox which is used for representing an item.""" |
258 | 259 |
375 VALID = 1 | 376 VALID = 1 |
376 INVALID = 2 | 377 INVALID = 2 |
377 DELETE = 3 | 378 DELETE = 3 |
378 | 379 |
379 | 380 |
380 class ListPanel(FlowPanel, base_widget.DropCell): | 381 class ListPanel(FlowPanel, libervia_widget.DropCell): |
381 """Panel used for listing items sharing the same key. The key is showed as | 382 """Panel used for listing items sharing the same key. The key is showed as |
382 a Button to which you can bind a popup menu and the items are represented | 383 a Button to which you can bind a popup menu and the items are represented |
383 with a sequence of DragAutoCompleteTextBox.""" | 384 with a sequence of DragAutoCompleteTextBox.""" |
384 # XXX: beware that pyjamas.ui.FlowPanel is not fully implemented yet and can not be used with pyjamas.ui.Label | 385 # XXX: beware that pyjamas.ui.FlowPanel is not fully implemented yet and can not be used with pyjamas.ui.Label |
385 | 386 |
399 drop_cbs = {"GROUP": lambda host, item: self.addItem("@%s" % item), | 400 drop_cbs = {"GROUP": lambda host, item: self.addItem("@%s" % item), |
400 "CONTACT": lambda host, item: self.addItem(tryJID(item)), | 401 "CONTACT": lambda host, item: self.addItem(tryJID(item)), |
401 "CONTACT_TITLE": lambda host, item: self.addItem('@@'), | 402 "CONTACT_TITLE": lambda host, item: self.addItem('@@'), |
402 "CONTACT_TEXTBOX": setTargetDropCell | 403 "CONTACT_TEXTBOX": setTargetDropCell |
403 } | 404 } |
404 base_widget.DropCell.__init__(self, None) | 405 libervia_widget.DropCell.__init__(self, None) |
405 self.drop_keys = drop_cbs | 406 self.drop_keys = drop_cbs |
406 self.style = style | 407 self.style = style |
407 self.addStyleName(self.style["keyPanel"]) | 408 self.addStyleName(self.style["keyPanel"]) |
408 self.manager = manager | 409 self.manager = manager |
409 self.key = data["title"] | 410 self.key = data["title"] |
410 self._addTextBox() | 411 self._addTextBox() |
411 | 412 |
412 def onDrop(self, event): | 413 def onDrop(self, event): |
413 try: | 414 try: |
414 base_widget.DropCell.onDrop(self, event) | 415 libervia_widget.DropCell.onDrop(self, event) |
415 except base_widget.NoLiberviaWidgetException: | 416 except base_widget.NoLiberviaWidgetException: |
416 pass | 417 pass |
417 | 418 |
418 def _addTextBox(self, switchPrevious=False): | 419 def _addTextBox(self, switchPrevious=False): |
419 """Add an empty text box to the last position. | 420 """Add an empty text box to the last position. |