示例#1
0
    def setValue(self, newValue):
        # Gets the IProperty set
        propertySet = self._container._items.get(self._itemId)

        # Support null values on all types
        if newValue is None:
            del propertySet[self._propertyId]
        elif issubclass(newValue.__class__, self.getType()):
            propertySet[self._propertyId] = newValue
        else:
            try:
                # Gets the string constructor
                #constr = self.getType().getConstructor([str])
                constr = self.getType().__init__  # FIXME: getConstructor
                # Creates new object from the string
                propertySet[self._propertyId] = constr(*[str(newValue)])
            except Exception:
                raise prop.ConversionException, ('Conversion for value \''
                        + newValue + '\' of class ' + fullname(newValue)
                        + ' to ' + self.getType().__name__ + ' failed')

        # update the container filtering if this property is being filtered
        if self._container.isPropertyFiltered(self._propertyId):
            self.filterAll()

        self._container.firePropertyValueChange(self)
示例#2
0
    def setValue(self, newValue):
        # Gets the IProperty set
        propertySet = self._container._items.get(self._itemId)

        # Support null values on all types
        if newValue is None:
            if self._propertyId in propertySet:
                del propertySet[self._propertyId]
        elif issubclass(newValue.__class__, self.getType()):
            propertySet[self._propertyId] = newValue
        else:
            try:
                # Gets the string constructor
                #constr = self.getType().getConstructor([str])
                constr = self.getType().__init__  # FIXME: getConstructor
                # Creates new object from the string
                propertySet[self._propertyId] = constr(*[str(newValue)])
            except Exception:
                raise prop.ConversionException, ('Conversion for value \'' +
                                                 newValue + '\' of class ' +
                                                 fullname(newValue) + ' to ' +
                                                 self.getType().__name__ +
                                                 ' failed')

        # update the container filtering if this property is being filtered
        if self._container.isPropertyFiltered(self._propertyId):
            self._container.filterAll()

        self._container.firePropertyValueChange(self)
示例#3
0
 def getExample(self):
     """Get the example instance. Override if instantiation needs
     parameters.
     """
     pkgName, className = fullname(self).rsplit('.', 1)
     canonicalName = pkgName + 'Example' + '.' + className + 'Example'
     #        try:
     classObject = loadClass(canonicalName)
     return classObject()
示例#4
0
    def paintContent(self, target):
        if self._root is None:
            raise ValueError, ('Composition root must be set to' +
                               ' non-null value before the ' + fullname(self) +
                               ' can be painted')

        if self.getComponentType() is not None:
            target.addAttribute('type', self.getComponentType())

        self._root.paint(target)
示例#5
0
    def paintContent(self, target):
        if self._root is None:
            raise ValueError, ('Composition root must be set to'
                    + ' non-null value before the ' + fullname(self)
                    + ' can be painted')

        if self.getComponentType() is not None:
            target.addAttribute('type', self.getComponentType())

        self._root.paint(target)
示例#6
0
    def paintContent(self, target):
        if self._root is None:
            raise ValueError, (
                "Composition root must be set to" + " non-null value before the " + fullname(self) + " can be painted"
            )

        if self.getComponentType() is not None:
            target.addAttribute("type", self.getComponentType())

        self._root.paint(target)
示例#7
0
    def setParent(self, parent):
        # Sets the parent component.

        # If the parent is not changed, don't do anything
        if parent == self._parent:
            return

        if parent is not None and self._parent is not None:
            raise ValueError, fullname(self) + ' already has a parent.'

        # Send detach event if the component have been connected to a window
        if self.getApplication() is not None:
            self.detach()

        # Connect to new parent
        self._parent = parent

        # Send attach event if connected to a window
        if self.getApplication() is not None:
            self.attach()
示例#8
0
    def setParent(self, parent):
        # Sets the parent component.

        # If the parent is not changed, don't do anything
        if parent == self._parent:
            return

        if parent is not None and self._parent is not None:
            raise ValueError, fullname(self) + ' already has a parent.'

        # Send detach event if the component have been connected to a window
        if self.getApplication() is not None:
            self.detach()

        # Connect to new parent
        self._parent = parent

        # Send attach event if connected to a window
        if self.getApplication() is not None:
            self.attach()
示例#9
0
 def getExample(self):
     """Get the example instance. Override if instantiation needs
     parameters.
     """
     pkgName, className = fullname(self).rsplit('.', 1)
     canonicalName = pkgName + 'Example' + '.' + className + 'Example'
     try:
         classObject = loadClass(canonicalName)
         return classObject()
     except Exception:
         return None
示例#10
0
 def layoutClick(self, event):
     # Get the child component which was clicked
     child = event.getChildComponent()
     if child is None:
         # Not over any child component
         self._c.getWindow().showNotification('The click '
                 'was not over any component.')
     else:
         # Over a child component
         self._c.getWindow().showNotification(
                 'The click was over a ' + fullname(child))
 def layoutClick(self, event):
     # Get the child component which was clicked
     child = event.getChildComponent()
     if child is None:
         # Not over any child component
         self._c.getWindow().showNotification('The click '
                                              'was not over any component.')
     else:
         # Over a child component
         self._c.getWindow().showNotification('The click was over a ' +
                                              fullname(child))