def changeVariables(self, source, variables): """Invoked when the value of a variable has changed. Button listeners are notified if the button is clicked. """ super(Button, self).changeVariables(source, variables) if "disabledOnClick" in variables: # Could be optimized so the button is not repainted because # of this (client side has already disabled the button) self.setEnabled(False) if not self.isReadOnly() and ('state' in variables): # Gets the new and old button states newValue = bool(variables.get('state')) oldValue = bool(self.getValue()) if self.isSwitchMode(): # For switch button, the event is only sent if the # switch state is changed if ((newValue is not None) and (newValue != oldValue) and not self.isReadOnly()): self.setValue(newValue) if 'mousedetails' in variables: self.fireClick( MouseEventDetails.deSerialize( variables.get('mousedetails'))) else: # for compatibility with custom implementations # which don't send mouse details self.fireClick() else: # Only send click event if the button is pushed if newValue: if 'mousedetails' in variables: self.fireClick( MouseEventDetails.deSerialize( variables.get('mousedetails'))) else: # for compatibility with custom implementations # which don't send mouse details self.fireClick() # If the button is true for some reason, release it if (oldValue is None) or oldValue: self.setValue(False) if FocusEvent.EVENT_ID in variables: self.fireEvent(FocusEvent(self)) if BlurEvent.EVENT_ID in variables: self.fireEvent(BlurEvent(self))
def changeVariables(self, source, variables): """Invoked when the value of a variable has changed. Button listeners are notified if the button is clicked. """ super(Button, self).changeVariables(source, variables) if "disabledOnClick" in variables: # Could be optimized so the button is not repainted because # of this (client side has already disabled the button) self.setEnabled(False) if not self.isReadOnly() and ('state' in variables): # Gets the new and old button states newValue = bool( variables.get('state') ) oldValue = bool( self.getValue() ) if self.isSwitchMode(): # For switch button, the event is only sent if the # switch state is changed if ((newValue is not None) and (newValue != oldValue) and not self.isReadOnly()): self.setValue(newValue) if 'mousedetails' in variables: self.fireClick(MouseEventDetails.deSerialize( variables.get('mousedetails'))) else: # for compatibility with custom implementations # which don't send mouse details self.fireClick() else: # Only send click event if the button is pushed if newValue: if 'mousedetails' in variables: self.fireClick(MouseEventDetails.deSerialize( variables.get('mousedetails'))) else: # for compatibility with custom implementations # which don't send mouse details self.fireClick() # If the button is true for some reason, release it if (oldValue is None) or oldValue: self.setValue(False) if FocusEvent.EVENT_ID in variables: self.fireEvent( FocusEvent(self) ) if BlurEvent.EVENT_ID in variables: self.fireEvent( BlurEvent(self) )
def fireClick(self, parameters): """Fire a click event to all click listeners. @param parameters: The raw "value" of the variable change from the client side """ mouseDetails = MouseEventDetails.deSerialize(parameters.get("mouseDetails")) self.fireEvent(ClickEvent(self, mouseDetails))
def fireClick(self, parameters): """Fire a click event to all click listeners. @param parameters: The raw "value" of the variable change from the client side """ params = parameters.get('mouseDetails') mouseDetails = MouseEventDetails.deSerialize(params) self.fireEvent( ClickEvent(self, mouseDetails) )
def changeVariables(self, source, variables): """Invoked when the value of a variable has changed. Button listeners are notified if the button is clicked. """ super(Button, self).changeVariables(source, variables) if not self.isReadOnly() and 'state' in variables: # Gets the new and old button states newValue = variables.get('state') oldValue = self.getValue() if self.isSwitchMode(): # For switch button, the event is only sent if the # switch state is changed if (newValue is not None and newValue != oldValue and not self.isReadOnly()): self.setValue(newValue) if 'mousedetails' in variables: self.fireClick(MouseEventDetails.deSerialize( variables.get('mousedetails'))) else: # for compatibility with custom implementations # which don't send mouse details self.fireClick() else: # Only send click event if the button is pushed if bool(newValue): if 'mousedetails' in variables: self.fireClick(MouseEventDetails.deSerialize( variables.get('mousedetails'))) else: # for compatibility with custom implementations # which don't send mouse details self.fireClick() # If the button is true for some reason, release it if oldValue is None or bool(oldValue): self.setValue(False) if FocusEvent.EVENT_ID in variables: self.fireEvent( FocusEvent(self) ) if BlurEvent.EVENT_ID in variables: self.fireEvent( BlurEvent(self) )
def fireClick(self, parameters): """Fire a layout click event. Note that this method is only used by the subclasses that implement L{LayoutClickNotifier}, and can be overridden for custom click event firing. @param parameters: The parameters received from the client side implementation """ mouseDetails = MouseEventDetails.deSerialize(parameters.get("mouseDetails")) clickedComponent = parameters.get("component") childComponent = clickedComponent while childComponent is not None and childComponent.getParent() != self: childComponent = childComponent.getParent() self.fireEvent(LayoutClickEvent(self, mouseDetails, clickedComponent, childComponent))
def fireClick(self, parameters): """Fire a layout click event. Note that this method is only used by the subclasses that implement L{LayoutClickNotifier}, and can be overridden for custom click event firing. @param parameters: The parameters received from the client side implementation """ mouseDetails = MouseEventDetails.deSerialize( parameters.get('mouseDetails')) clickedComponent = parameters.get('component') childComponent = clickedComponent while (childComponent is not None and childComponent.getParent() != self): childComponent = childComponent.getParent() self.fireEvent( LayoutClickEvent(self, mouseDetails, clickedComponent, childComponent))
def fireClick(self, parameters): mouseDetails = \ MouseEventDetails.deSerialize(parameters.get('mouseDetails')) self.fireEvent( SplitterClickEvent(self, mouseDetails) )
def fireClick(self, parameters): """Notifies click-listeners that a mouse click event has occurred. """ mouseDetails = \ MouseEventDetails.deSerialize(parameters['mouseDetails']) self.fireEvent( ClickEvent(self, mouseDetails) )
def changeVariables(self, source, variables): if 'clickedKey' in variables: key = variables.get('clickedKey') idd = self.itemIdMapper.get(key) evt = variables.get('clickEvent') details = MouseEventDetails.deSerialize(evt) item = self.getItem(idd) if item is not None: event = ItemClickEvent(self, item, idd, None, details) self.fireEvent(event) if not self.isSelectable() and 'selected' in variables: # Not-selectable is a special case, AbstractSelect does not # support. TODO: could be optimized. variables = dict(variables) del variables['selected'] # Collapses the nodes if 'collapse' in variables: keys = variables.get('collapse') for key in keys: idd = self.itemIdMapper.get(key) if idd is not None and self.isExpanded(idd): self._expanded.remove(idd) self.fireCollapseEvent(idd) # Expands the nodes if 'expand' in variables: sendChildTree = False if 'requestChildTree' in variables: sendChildTree = True keys = variables.get('expand') for key in keys: idd = self.itemIdMapper.get(key) if idd is not None: self.expandItem(idd, sendChildTree) # AbstractSelect cannot handle multiselection so we # handle it ourself if ('selected' in variables and self.isMultiSelect() and self._multiSelectMode == MultiSelectMode.DEFAULT): self.handleSelectedItems(variables) variables = dict(variables) del variables['selected'] # Selections are handled by the select component super(Tree, self).changeVariables(source, variables) # Actions if 'action' in variables: st = variables.get('action').split(',') # FIXME: StringTokenizer if len(st) == 2: itemId = self.itemIdMapper.get(st[0].strip()) action = self._actionMapper.get(st[1].strip()) if (action is not None and ((itemId is None) or self.containsId(itemId)) and self._actionHandlers is not None): for ah in self._actionHandlers: ah.handleAction(action, self, itemId)
def changeVariables(self, source, variables): if 'clickedKey' in variables: key = variables.get('clickedKey') idd = self.itemIdMapper.get(key) evt = variables.get('clickEvent') details = MouseEventDetails.deSerialize(evt) item = self.getItem(idd) if item is not None: event = ItemClickEvent(self, item, idd, None, details) self.fireEvent(event) if not self.isSelectable() and 'selected' in variables: # Not-selectable is a special case, AbstractSelect does not # support. TODO: could be optimized. variables = dict(variables) del variables['selected'] # Collapses the nodes if 'collapse' in variables: keys = variables.get('collapse') for key in keys: idd = self.itemIdMapper.get(key) if idd is not None and self.isExpanded(idd): self._expanded.remove(idd) self.fireCollapseEvent(idd) # Expands the nodes if 'expand' in variables: sendChildTree = False if 'requestChildTree' in variables: sendChildTree = True keys = variables.get('expand') for key in keys: idd = self.itemIdMapper.get(key) if idd is not None: self.expandItem(idd, sendChildTree) # AbstractSelect cannot handle multiselection so we # handle it ourself if ('selected' in variables and self.isMultiSelect() and self._multiSelectMode == MultiSelectMode.DEFAULT): self.handleSelectedItems(variables) variables = dict(variables) del variables['selected'] # Selections are handled by the select component super(Tree, self).changeVariables(source, variables) # Actions if 'action' in variables: st = variables.get('action').split(',') # FIXME: StringTokenizer if len(st) == 2: itemId = self.itemIdMapper.get(st[0].strip()) action = self._actionMapper.get(st[1].strip()) if (action is not None and (itemId is None) or self.containsId(itemId) and self._actionHandlers is not None): for ah in self._actionHandlers: ah.handleAction(action, self, itemId)
def fireClick(self, parameters): mouseDetails = \ MouseEventDetails.deSerialize(parameters.get('mouseDetails')) self.fireEvent(SplitterClickEvent(self, mouseDetails))
def getMouseEvent(self): """@return: details about the actual event that caused the event details. Practically mouse move or mouse up. """ return MouseEventDetails.deSerialize(self.getData('mouseEvent'))
def getMouseDownEvent(self): """@return: the mouse down event that started the drag and drop operation """ return MouseEventDetails.deSerialize(self.getData('mouseDown'))
def fireClick(self, parameters): """Notifies click-listeners that a mouse click event has occurred. """ mouseDetails = \ MouseEventDetails.deSerialize(parameters['mouseDetails']) self.fireEvent(ClickEvent(self, mouseDetails))