Mercurial > libervia-web
diff browser_side/list_manager.py @ 396:a71fcc27f231
browser_side: small improvements for ListManager
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 11 Mar 2014 10:45:52 +0100 |
parents | 83454ba70a9c |
children | 63f8469b4ad3 |
line wrap: on
line diff
--- a/browser_side/list_manager.py Mon Mar 10 22:39:26 2014 +0100 +++ b/browser_side/list_manager.py Tue Mar 11 10:45:52 2014 +0100 @@ -30,12 +30,11 @@ from pyjamas.ui.MouseListener import MouseHandler from pyjamas.ui.FocusListener import FocusHandler from pyjamas.ui.DropWidget import DropWidget -from pyjamas.ui.DragWidget import DragWidget from pyjamas.Timer import Timer from pyjamas import DOM from base_panels import PopupMenuPanel - +from base_widget import DragLabel # HTML content for the removal button (image or text) REMOVE_BUTTON = '<span class="recipientRemoveIcon">x</span>' @@ -243,7 +242,7 @@ self.popup_menu = PopupMenuPanel(entries=entries, hide=hide, callback=callback, style={"item": self.style["popupMenuItem"]}) -class DragAutoCompleteTextBox(AutoCompleteTextBox, DragWidget, MouseHandler, FocusHandler): +class DragAutoCompleteTextBox(AutoCompleteTextBox, DragLabel, MouseHandler, FocusHandler): """A draggable AutoCompleteTextBox which is used for representing a contact. This class is NOT generic because of the onDragEnd method which call methods from ListPanel. It's probably not reusable for another scenario. @@ -251,7 +250,7 @@ def __init__(self, parent, event_cbs, style): AutoCompleteTextBox.__init__(self) - DragWidget.__init__(self) + DragLabel.__init__(self, '', 'CONTACT_TEXTBOX') # The group prefix "@" is already in text so we use only the "CONTACT_TEXTBOX" type self._parent = parent self.event_cbs = event_cbs self.style = style @@ -275,15 +274,15 @@ self.valid = valid def onDragStart(self, event): - dt = event.dataTransfer - # The group prefix "@" is already in text so we use only the "CONTACT" type - dt.setData('text/plain', "%s\n%s" % (self.getText(), "CONTACT_TEXTBOX")) + self._text = self.getText() + DragLabel.onDragStart(self, event) + self._parent.setTargetDropCell(None) self.setSelectionRange(len(self.getText()), 0) def onDragEnd(self, event): - if self.getText() == "": + target = self._parent.target_drop_cell # parent or another ListPanel + if self.getText() == "" or target is None: return - target = self._parent.target_drop_cell # parent or another ListPanel self.event_cbs["drop"](self, target) def setRemoveButton(self): @@ -392,6 +391,7 @@ FlowPanel.__init__(self, Visible=(False if entry["optional"] else True)) drop_cbs = {"GROUP": lambda panel, item: self.addContact("@%s" % item), "CONTACT": lambda panel, item: self.addContact(item), + "CONTACT_TITLE": lambda panel, item: self.addContact('@@'), "CONTACT_TEXTBOX": lambda panel, item: self.setTargetDropCell(panel) } DropCell.__init__(self, drop_cbs) @@ -531,12 +531,10 @@ """@return: the panel where something has been dropped.""" return self._parent.target_drop_cell - @target_drop_cell.setter - def target_drop_cell(self, target_drop_cell): - """@param target_drop_cell: the panel where something has been dropped.""" - self.setTargetDropCell(target_drop_cell) - def setTargetDropCell(self, target_drop_cell): + """ + XXX: Property setter here would not make it, you need a proper method! + @param target_drop_cell: the panel where something has been dropped.""" self._parent.target_drop_cell = target_drop_cell