Mercurial > libervia-web
changeset 396:a71fcc27f231
browser_side: small improvements for ListManager
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 11 Mar 2014 10:45:52 +0100 |
parents | 98cd5387d291 |
children | 6148e9063069 |
files | browser_side/base_widget.py browser_side/list_manager.py |
diffstat | 2 files changed, 13 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/browser_side/base_widget.py Mon Mar 10 22:39:26 2014 +0100 +++ b/browser_side/base_widget.py Tue Mar 11 10:45:52 2014 +0100 @@ -107,6 +107,7 @@ return (row.rowIndex, cell.cellIndex) def onDrop(self, event): + self.removeStyleName('dragover') DOM.eventPreventDefault(event) dt = event.dataTransfer # 'text', 'text/plain', and 'Text' are equivalent. @@ -135,14 +136,10 @@ if len(row_wids) == 1 and wid_row == widgets_panel.getWidgetCoords(self)[0]: # the dropped widget is the only one in the same row # as the target widget (self), we don't do anything - self.removeStyleName('dragover') return widgets_panel.removeWidget(_new_panel) elif item_type in self.drop_keys: _new_panel = self.drop_keys[item_type](self.host, item) - elif item_type == "CONTACT_TEXTBOX": - # eventually open a window? - pass else: print "WARNING: unmanaged item type" return @@ -677,9 +674,6 @@ _new_panel.getWidgetsPanel().removeWidget(_new_panel) elif item_type in DropCell.drop_keys: _new_panel = DropCell.drop_keys[item_type](self.tab_panel.host, item) - elif item_type == "CONTACT_TEXTBOX": - # eventually open a window? - pass else: print "WARNING: unmanaged item type" return
--- 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