Package muntjac :: Package ui :: Module abstract_component :: Class AbstractComponent
[hide private]
[frames] | no frames]

Class AbstractComponent

source code

                          object --+            
                                   |            
                 util.IEventListener --+        
                                       |        
           terminal.paintable.IPaintable --+    
                                           |    
                              object --+   |    
                                       |   |    
  terminal.variable_owner.IVariableOwner --+    
                                           |    
                              object --+   |    
                                       |   |    
             terminal.sizeable.ISizeable --+    
                                           |    
                        component.IComponent --+
                                               |
                                  object --+   |
                                           |   |
event.method_event_source.IMethodEventSource --+
                                               |
                                              AbstractComponent
Known Subclasses:

An abstract class that defines default implementation for the IComponent interface. Basic UI components that are not derived from an external component can inherit this class to easily qualify as Muntjac components. Most components in Muntjac do just that.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
__init__(self)
Constructs a new IComponent.
source code
 
__getstate__(self) source code
 
__setstate__(self, d) source code
 
setDebugId(self, idd)
Adds an unique id for component that get's transferred to terminal for testing purposes.
source code
 
getDebugId(self)
Get's currently set debug identifier
source code
 
getStyle(self)
Gets style for component.
source code
 
setStyle(self, style)
Sets and replaces all previous style names of the component.
source code
 
getStyleName(self)
Gets all user-defined CSS style names of a component.
source code
 
setStyleName(self, style)
Sets one or more user-defined style names of the component, replacing any previous user-defined styles.
source code
 
addStyleName(self, style)
Adds a style name to component.
source code
 
removeStyleName(self, style)
Removes one or more style names from component.
source code
 
getCaption(self)
Gets the caption of the component.
source code
 
setCaption(self, caption)
Sets the component's caption string.
source code
 
getLocale(self)
Gets the locale of the component.
source code
 
setLocale(self, locale)
Sets the locale of this component:
source code
 
getIcon(self)
Gets the icon resource of the component.
source code
 
setIcon(self, icon)
Sets the component's icon.
source code
 
isEnabled(self)
Tests whether the component is enabled or not.
source code
 
setEnabled(self, enabled)
Enables or disables the component.
source code
 
isImmediate(self)
Tests if the variable owner is in immediate mode or not.
source code
 
setImmediate(self, immediate)
Sets the component's immediate mode to the specified status.
source code
 
isVisible(self)
Tests the visibility property of the component.
source code
 
setVisible(self, visible)
Sets the visibility of the component.
source code
 
getDescription(self)
Gets the component's description, used in tooltips and can be displayed directly in certain other components such as forms.
source code
 
setDescription(self, description)
Sets the component's description.
source code
 
getParent(self)
Gets the parent component of the component.
source code
 
setParent(self, parent)
Sets the parent component of the component.
source code
 
getErrorMessage(self)
Gets the error message for this component.
source code
 
getComponentError(self)
Gets the component's error message.
source code
 
setComponentError(self, componentError)
Sets the component's error message.
source code
 
isReadOnly(self)
Tests whether the component is in the read-only mode.
source code
 
setReadOnly(self, readOnly)
Sets the read-only mode of the component to the specified mode.
source code
 
getWindow(self)
Gets the parent window of the component.
source code
 
attach(self)
Notifies the component that it is connected to an application.
source code
 
detach(self)
Notifies the component that it is detached from the application.
source code
 
focus(self)
Sets the focus for this component if the component is IFocusable.
source code
 
getApplication(self)
Gets the application object to which the component is attached.
source code
 
requestRepaintRequests(self)
Request sending of repaint events on any further visible changes.
source code
 
paint(self, target)
Paints the Paintable into a UIDL stream.
source code
 
getCSSHeight(self)
Build CSS compatible string representation of height.
source code
 
getCSSWidth(self)
Build CSS compatible string representation of width.
source code
 
paintContent(self, target)
Paints any needed component-specific things to the given UIDL stream.
source code
 
requestRepaint(self)
Requests that the paintable should be repainted as soon as possible.
source code
 
childRequestedRepaint(self, alreadyNotified)
The child components of the component must call this method when they need repainting.
source code
 
fireRequestRepaintEvent(self, alreadyNotified)
Fires the repaint request event.
source code
 
addListener(self, listener, iface=None)
Registers a new (generic) component event listener for the component:
source code
 
addCallback(self, callback, eventType=None, *args) source code
 
registerListener(self, *args)
Registers a new listener with the specified activation method to listen events generated by this component.
source code
 
registerCallback(self, eventType, callback, eventId, *args) source code
 
removeListener(self, listener, iface=None)
Removes a previously registered component event listener from this component.
source code
 
removeCallback(self, callback, eventType=None) source code
 
withdrawListener(self, *args)
Removes all registered listeners matching the given parameters.
source code
 
withdrawCallback(self, eventType, callback, eventId=None) source code
 
changeVariables(self, source, variables)
Called when one or more variables handled by the implementing class are changed.
source code
 
hasListeners(self, eventType)
Checks if the given Event type is listened for this component.
source code
 
getListeners(self, eventType)
Returns all listeners that are registered for the given event type or one of its subclasses.
source code
 
fireEvent(self, event)
Sends the event to all listeners.
source code
 
fireComponentEvent(self)
Emits the component event.
source code
 
fireComponentErrorEvent(self)
Emits the component error event.
source code
 
setData(self, data)
Sets the data object, that can be used for any application specific data.
source code
 
getData(self)
Gets the application specific data.
source code
 
getHeight(self)
Gets the height of the object.
source code
 
getHeightUnits(self)
Gets the height property units.
source code
 
getWidth(self)
Gets the width of the object.
source code
 
getWidthUnits(self)
Gets the width property units.
source code
 
setHeight(self, height, unit=None)
Sets the height of the object.
source code
 
setHeightUnits(self, unit)
Sets the height property units.
source code
 
setSizeFull(self)
Sets the size to 100% x 100%.
source code
 
setSizeUndefined(self)
Clears any size settings.
source code
 
setWidth(self, width, unit=None)
Sets the width of the object.
source code
 
setWidthUnits(self, unit)
Sets the width property units.
source code
 
parseStringSize(self, s)
Returns array with size in index 0 unit in index 1.
source code
 
getErrorHandler(self)
Gets the error handler for the component.
source code
 
setErrorHandler(self, errorHandler)
Sets the error handler for the component.
source code
 
handleError(self, error)
Handle the component error event.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  SIZE_PATTERN = '^(-?\\d+(\\.\\d+)?)(%|px|em|ex|in|cm|mm|pt|pc)?$'

Inherited from terminal.sizeable.ISizeable: SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS, UNIT_SYMBOLS

Instance Variables [hide private]
  _styles
Style names.
  _caption
Caption text.
  _applicationData
Application specific data object.
  _icon
Icon to be shown together with caption.
  _enabled
Is the component enabled (its normal usage is allowed).
  _visible
Is the component visible (it is rendered).
  _readOnly
Is the component read-only ?
  _description
Description of the usage (XML).
  _parent
The container this component resides in.
  _eventRouter
The EventRouter used for the event model.
  _eventIdentifiers
A set of event identifiers with registered listeners.
  _componentError
The internal error message of the component.
  _immediate
Immediate mode: if true, all variable changes are required
  _locale
Locale of this component.
  _delayedFocus
The component should receive focus (if IFocusable)
  _repaintRequestListeners
List of repaint request listeners or null if not listened at all.
  _repaintRequestListenersNotified
Are all the repaint listeners notified about recent changes ?
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Constructs a new IComponent.

Overrides: object.__init__

setDebugId(self, idd)

source code 

Adds an unique id for component that get's transferred to terminal for testing purposes. Keeping identifiers unique throughout the Application instance is on programmers responsibility.

Note, that with the current terminal implementation the identifier cannot be changed while the component is visible. This means that the identifier should be set before the component is painted for the first time and kept the same while visible in the client.

Parameters:
  • idd - A short (< 20 chars) alphanumeric id
Overrides: terminal.paintable.IPaintable.setDebugId
(inherited documentation)

getDebugId(self)

source code 

Get's currently set debug identifier

Returns:
current debug id, null if not set
Overrides: terminal.paintable.IPaintable.getDebugId
(inherited documentation)

getStyle(self)

source code 

Gets style for component. Multiple styles are joined with spaces.

Returns:
the component's styleValue of property style.

Deprecated: Use getStyleName() instead; renamed for consistency and to indicate that "style" should not be used to switch client side implementation, only to style the component.

setStyle(self, style)

source code 

Sets and replaces all previous style names of the component. This method will trigger a RepaintRequestEvent.

Parameters:
  • style - the new style of the component.

Deprecated: Use setStyleName() instead; renamed for consistency and to indicate that "style" should not be used to switch client side implementation, only to style the component.

getStyleName(self)

source code 

Gets all user-defined CSS style names of a component. If the component has multiple style names defined, the return string is a space-separated list of style names. Built-in style names defined in Muntjac or GWT are not returned.

The style names are returned only in the basic form in which they were added; each user-defined style name shows as two CSS style class names in the rendered HTML: one as it was given and one prefixed with the component-specific style name. Only the former is returned.

Returns:
the style name or a space-separated list of user-defined style names of the component
Overrides: component.IComponent.getStyleName
(inherited documentation)

setStyleName(self, style)

source code 

Sets one or more user-defined style names of the component, replacing any previous user-defined styles. Multiple styles can be specified as a space-separated list of style names. The style names must be valid CSS class names and should not conflict with any built-in style names in Muntjac or GWT:

 label = new Label("This text has a lot of style")
 label.setStyleName("myonestyle myotherstyle")

Each style name will occur in two versions: one as specified and one that is prefixed with the style name of the component. For example, if you have a Button component and give it "mystyle" style, the component will have both "mystyle" and "v-button-mystyle" styles. You could then style the component either with:

 .myonestyle {background: blue;}

or:

 .v-button-myonestyle {background: blue;}

It is normally a good practice to use addStyleName rather than this setter, as different software abstraction layers can then add their own styles without accidentally removing those defined in other layers.

This method will trigger a RepaintRequestEvent.

Parameters:
  • style - the new style or styles of the component as a space-separated list
Overrides: component.IComponent.setStyleName
(inherited documentation)

addStyleName(self, style)

source code 

Adds a style name to component. The style name will be rendered as a HTML class name, which can be used in a CSS definition:

 label = new Label("This text has style")
 label.addStyleName("mystyle")

Each style name will occur in two versions: one as specified and one that is prefixed wil the style name of the component. For example, if you have a Button component and give it "mystyle" style, the component will have both "mystyle" and "v-button-mystyle" styles. You could then style the component either with:

 .mystyle {font-style: italic;}

or:

 .v-button-mystyle {font-style: italic;}

This method will trigger a RepaintRequestEvent.

Parameters:
  • style - the new style to be added to the component
Overrides: component.IComponent.addStyleName
(inherited documentation)

removeStyleName(self, style)

source code 

Removes one or more style names from component. Multiple styles can be specified as a space-separated list of style names.

The parameter must be a valid CSS style name. Only user-defined style names added with addStyleName or setStyleName can be removed; built-in style names defined in Muntjac or GWT can not be removed.

This method will trigger a RepaintRequestEvent.

Parameters:
  • style - the style name or style names to be removed
Overrides: component.IComponent.removeStyleName
(inherited documentation)

getCaption(self)

source code 

Gets the caption of the component.

See setCaption for a detailed description of the caption.

Returns:
the caption of the component or null if the caption is not set.
Overrides: component.IComponent.getCaption
(inherited documentation)

setCaption(self, caption)

source code 

Sets the component's caption string. Caption is the visible name of the component. This method will trigger a RepaintRequestEvent.

Parameters:
  • caption - the new caption string for the component.
Overrides: component.IComponent.setCaption

getLocale(self)

source code 

Gets the locale of the component.

If a component does not have a locale set, the locale of its parent is returned, and so on. Eventually, if no parent has locale set, the locale of the application is returned. If the application does not have a locale set, it is determined by getDefaultLocale().

As the component must be attached before its locale can be acquired, using this method in the internationalization of component captions, etc. is generally not feasible. For such use case, we recommend using an otherwise acquired reference to the application locale.

Returns:
Locale of this component or null if the component and none of its parents has a locale set and the component is not yet attached to an application.
Overrides: component.IComponent.getLocale
(inherited documentation)

setLocale(self, locale)

source code 

Sets the locale of this component:

 # IComponent for which the locale is meaningful
 date = InlineDateField(&quot;Datum&quot;)

 # German language specified with ISO 639-1 language
 # code and ISO 3166-1 alpha-2 country code.
 date.setLocale(Locale(&quot;de&quot;, &quot;DE&quot;))

 date.setResolution(DateField.RESOLUTION_DAY)
 layout.addComponent(date)
Parameters:
  • locale - the locale to become this component's locale.

getIcon(self)

source code 

Gets the icon resource of the component.

See setIcon for a detailed description of the icon.

Returns:
the icon resource of the component or None if the component has no icon
Overrides: component.IComponent.getIcon
(inherited documentation)

setIcon(self, icon)

source code 

Sets the component's icon. This method will trigger a RepaintRequestEvent.

Parameters:
  • icon - the icon to be shown with the component's caption.
Overrides: component.IComponent.setIcon

isEnabled(self)

source code 

Tests whether the component is enabled or not. A user can not interact with disabled components. Disabled components are rendered in a style that indicates the status, usually in gray color. Children of a disabled component are also disabled. Components are enabled by default.

As a security feature, all variable change events for disabled components are blocked on the server-side.

Returns:
True if the component and its parent are enabled, False otherwise.
Overrides: terminal.variable_owner.IVariableOwner.isEnabled
(inherited documentation)

setEnabled(self, enabled)

source code 

Enables or disables the component. The user can not interact disabled components, which are shown with a style that indicates the status, usually shaded in light gray color. Components are enabled by default. Children of a disabled component are automatically disabled; if a child component is explicitly set as disabled, changes in the disabled status of its parents do not change its status:

 enabled = new Button("Enabled")
 enabled.setEnabled(True)  # the default
 layout.addComponent(enabled)

 disabled = Button("Disabled")
 disabled.setEnabled(False)
 layout.addComponent(disabled)

This method will trigger a RepaintRequestEvent for the component and, if it is a ComponentContainer, for all its children recursively.

Parameters:
  • enabled - a boolean value specifying if the component should be enabled or not
Overrides: component.IComponent.setEnabled
(inherited documentation)

isImmediate(self)

source code 

Tests if the variable owner is in immediate mode or not. Being in immediate mode means that all variable changes are required to be sent back from the terminal immediately when they occur.

Note: IVariableOwner does not include a set-method for the immediateness property. This is because not all VariableOwners wish to offer the functionality. Such VariableOwners are never in the immediate mode, thus they always return False in isImmediate.

Returns:
True if the component is in immediate mode, False if not
Overrides: terminal.variable_owner.IVariableOwner.isImmediate
(inherited documentation)

setImmediate(self, immediate)

source code 

Sets the component's immediate mode to the specified status. This method will trigger a RepaintRequestEvent.

Parameters:
  • immediate - the boolean value specifying if the component should be in the immediate mode after the call.

isVisible(self)

source code 

Tests the visibility property of the component.

Visible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change, but the entire HTML element will be empty. Making a component invisible through this property can alter the positioning of other components.

A component is visible only if all its parents are also visible. Notice that if a child component is explicitly set as invisible, changes in the visibility status of its parents do not change its status.

This method does not check whether the component is attached (see attach). The component and all its parents may be considered "visible", but not necessarily attached to application. To test if component will actually be drawn, check both its visibility and that getApplication does not return None.

Returns:
True if the component is visible in the user interface, False if not
Overrides: component.IComponent.isVisible
(inherited documentation)

setVisible(self, visible)

source code 

Sets the visibility of the component.

Visible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change, but the entire HTML element will be empty:

 readonly = TextField("Read-Only")
 readonly.setValue("You can't see this!")
 readonly.setVisible(False)
 layout.addComponent(readonly)

A component is visible only if all of its parents are also visible. If a component is explicitly set to be invisible, changes in the visibility of its parents will not change the visibility of the component.

Parameters:
  • visible - the boolean value specifying if the component should be visible after the call or not.
Overrides: component.IComponent.setVisible
(inherited documentation)

getDescription(self)

source code 

Gets the component's description, used in tooltips and can be displayed directly in certain other components such as forms. The description can be used to briefly describe the state of the component to the user. The description string may contain certain XML tags:

   <table border=1>
   <tr>
   <td width=120><b>Tag</b></td>
   <td width=120><b>Description</b></td>
   <td width=120><b>Example</b></td>
   </tr>
   <tr>
   <td>&lt;b></td>
   <td>bold</td>
   <td><b>bold text</b></td>
   </tr>
   <tr>
   <td>&lt;i></td>
   <td>italic</td>
   <td><i>italic text</i></td>
   </tr>
   <tr>
   <td>&lt;u></td>
   <td>underlined</td>
   <td><u>underlined text</u></td>
   </tr>
   <tr>
   <td>&lt;br></td>
   <td>linebreak</td>
   <td>N/A</td>
   </tr>
   <tr>
   <td>&lt;ul><br>
   &lt;li>item1<br>
   &lt;li>item1<br>
   &lt;/ul></td>
   <td>item list</td>
   <td>
   <ul>
   <li>item1
   <li>item2
   </ul>
   </td>
   </tr>
   </table>

These tags may be nested.

Returns:
component's description string

setDescription(self, description)

source code 

Sets the component's description. See getDescription for more information on what the description is. This method will trigger a RepaintRequestEvent.

The description is displayed as HTML/XHTML in tooltips or directly in certain components so care should be taken to avoid creating the possibility for HTML injection and possibly XSS vulnerabilities.

Parameters:
  • description - the new description string for the component.

getParent(self)

source code 

Gets the parent component of the component.

Components can be nested but a component can have only one parent. A component that contains other components, that is, can be a parent, should usually inherit the ComponentContainer interface.

Returns:
the parent component
Overrides: component.IComponent.getParent
(inherited documentation)

setParent(self, parent)

source code 

Sets the parent component of the component.

This method automatically calls attach if the parent becomes attached to the application, regardless of whether it was attached previously. Conversely, if the parent is None and the component is attached to the application, detach is called for the component.

This method is rarely called directly. The ComponentContainer.addComponent method is normally used for adding components to a container and it will call this method implicitly.

It is not possible to change the parent without first setting the parent to None.

Parameters:
  • parent - the parent component
Raises:
  • ValueError - if a parent is given even though the component already has a parent
Overrides: component.IComponent.setParent
(inherited documentation)

getErrorMessage(self)

source code 

Gets the error message for this component.

Returns:
ErrorMessage containing the description of the error state of the component or null, if the component contains no errors. Extending classes should override this method if they support other error message types such as validation errors or buffering errors. The returned error message contains information about all the errors.

getComponentError(self)

source code 

Gets the component's error message.

Returns:
the component's error message.

setComponentError(self, componentError)

source code 

Sets the component's error message. The message may contain certain XML tags.

Parameters:
  • componentError - the new ErrorMessage of the component.

isReadOnly(self)

source code 

Tests whether the component is in the read-only mode. The user can not change the value of a read-only component. As only IField components normally have a value that can be input or changed by the user, this is mostly relevant only to field components, though not restricted to them.

Notice that the read-only mode only affects whether the user can change the value of the component; it is possible to, for example, scroll a read-only table.

The read-only status affects only the user; the value can still be changed programmatically, for example, with IProperty.setValue.

The method will return True if the component or any of its parents is in the read-only mode.

Returns:
True if the component or any of its parents is in read-only mode, False if not.
Overrides: component.IComponent.isReadOnly
(inherited documentation)

setReadOnly(self, readOnly)

source code 

Sets the read-only mode of the component to the specified mode. The user can not change the value of a read-only component.

As only IField components normally have a value that can be input or changed by the user, this is mostly relevant only to field components, though not restricted to them.

Notice that the read-only mode only affects whether the user can change the value of the component; it is possible to, for example, scroll a read-only table.

The read-only status affects only the user; the value can still be changed programmatically, for example, with IProperty.setValue.

This method will trigger a RepaintRequestEvent.

Parameters:
  • readOnly - a boolean value specifying whether the component is put read-only mode or not
Overrides: component.IComponent.setReadOnly
(inherited documentation)

getWindow(self)

source code 

Gets the parent window of the component.

If the component is not attached to a window through a component containment hierarchy, None is returned.

The window can be either an application-level window or a sub-window. If the component is itself a window, it returns a reference to itself, not to its containing window (of a sub-window).

Returns:
the parent window of the component or None if it is not attached to a window or is itself a window
Overrides: component.IComponent.getWindow
(inherited documentation)

attach(self)

source code 

Notifies the component that it is connected to an application.

The caller of this method is setParent if the parent is itself already attached to the application. If not, the parent will call the attach for all its children when it is attached to the application. This method is always called before the component is painted for the first time.

Reimplementing the attach() method is useful for tasks that need to get a reference to the parent, window, or application object with the getParent, getWindow, and getApplication methods. A component does not yet know these objects in the constructor, so in such case, the methods will return None. For example, the following is invalid:

 class AttachExample(CustomComponent):
     def __init__(self):
         # ERROR: We can't access the application object yet.
         r = ClassResource("smiley.jpg", getApplication())
         image = Embedded("Image:", r)
         setCompositionRoot(image)

Adding a component to an application triggers calling the attach method for the component. Correspondingly, removing a component from a container triggers calling the detach method. If the parent of an added component is already connected to the application, the attach() is called immediately from setParent:

 class AttachExample(CustomComponent):
     def __init__(self):
         pass

     def attach(self):
         super(AttachExample, self).attach()  # must call

         # Now we know who ultimately owns us.
         r = ClassResource("smiley.jpg", self.getApplication())
         image = Embedded("Image", r)
         self.setCompositionRoot(image)

The attachment logic is implemented in AbstractComponent.

Overrides: component.IComponent.attach
(inherited documentation)

detach(self)

source code 

Notifies the component that it is detached from the application.

The getApplication and getWindow methods might return None after this method is called.

The caller of this method is setParent if the parent is in the application. When the parent is detached from the application it is its response to call detach for all the children and to detach itself from the terminal.

Overrides: component.IComponent.detach
(inherited documentation)

getApplication(self)

source code 

Gets the application object to which the component is attached.

The method will return None if the component is not currently attached to an application. This is often a problem in constructors of regular components and in the initializers of custom composite components. A standard workaround is to move the problematic initialization to attach, as described in the documentation of the method.

This method is not meant to be overridden.

Returns:
the parent application of the component or None.
Overrides: component.IComponent.getApplication

See Also: attach

requestRepaintRequests(self)

source code 

Request sending of repaint events on any further visible changes. Normally the paintable only send up to one repaint request for listeners after paint as the paintable as the paintable assumes that the listeners already know about the repaint need. This method resets the assumtion. Paint implicitly does the assumtion reset functionality implemented by this method.

This method is normally used only by the terminals to note paintables about implicit repaints (painting the component without actually invoking paint method).

Overrides: terminal.paintable.IPaintable.requestRepaintRequests
(inherited documentation)

paint(self, target)

source code 

Paints the Paintable into a UIDL stream. This method creates the UIDL sequence describing it and outputs it to the given UIDL stream.

It is called when the contents of the component should be painted in response to the component first being shown or having been altered so that its visual representation is changed.

Do not override this to paint your component. Override paintContent instead.

Parameters:
  • target - the target UIDL stream where the component should paint itself to.
Raises:
Overrides: terminal.paintable.IPaintable.paint

getCSSHeight(self)

source code 

Build CSS compatible string representation of height.

Returns:
CSS height

getCSSWidth(self)

source code 

Build CSS compatible string representation of width.

Returns:
CSS width

paintContent(self, target)

source code 

Paints any needed component-specific things to the given UIDL stream. The more general paint method handles all general attributes common to all components, and it calls this method to paint any component-specific attributes to the UIDL stream.

Parameters:
  • target - the target UIDL stream where the component should paint itself to
Raises:

requestRepaint(self)

source code 

Requests that the paintable should be repainted as soon as possible.

Overrides: terminal.paintable.IPaintable.requestRepaint
(inherited documentation)

childRequestedRepaint(self, alreadyNotified)

source code 

The child components of the component must call this method when they need repainting. The call must be made even in the case in which the children sent the repaint request themselves.

A repaint request is ignored if the component is invisible.

This method is called automatically by AbstractComponent, which also provides a default implementation of it. As this is a somewhat internal feature, it is rarely necessary to reimplement this or call it explicitly.

Parameters:
  • alreadyNotified - the collection of repaint request listeners that have been already notified by the child. This component should not re-notify the listed listeners again. The container given as parameter must be modifiable as the component might modify it and pass it forward. A None parameter is interpreted as an empty collection.
Overrides: component.IComponent.childRequestedRepaint
(inherited documentation)

addListener(self, listener, iface=None)

source code 

Registers a new (generic) component event listener for the component:

 class Listening(CustomComponent, IListener):

     # Stored for determining the source of an event
     ok = None

     status = None  # For displaying info about the event

     def __init__(self):
         layout = VerticalLayout()

         # Some miscellaneous component
         name = TextField("Say it all here")
         name.addListener(self)
         name.setImmediate(true)
         layout.addComponent(name)

         # Handle button clicks as generic events instead
         # of Button.ClickEvent events
         ok = new Button("OK")
         ok.addListener(self)
         layout.addComponent(ok)

         # For displaying information about an event
         status = new Label("")
         layout.addComponent(status)

         setCompositionRoot(layout)


     def componentEvent(event):
         # Act according to the source of the event
         if (event.getSource() == ok):
             getWindow().showNotification("Click!")

         status.setValue("Event from " +
                 event.getSource().__class__.__name__
                 + ": " + event.__class__.__name__)


 listening = Listening()
 layout.addComponent(listening)
Parameters:
  • listener - the new IListener to be registered.
Raises:
  • ValueError - unless method has a match in object
Overrides: event.method_event_source.IMethodEventSource.addListener
(inherited documentation)

addCallback(self, callback, eventType=None, *args)

source code 
Overrides: terminal.paintable.IPaintable.addCallback

registerListener(self, *args)

source code 

Registers a new listener with the specified activation method to listen events generated by this component. If the activation method does not have any arguments the event object will not be passed to it when it's called.

This method additionally informs the event-api to route events with the given eventIdentifier to the components handleEvent function call.

For more information on the inheritable event mechanism see the muntjac.event package documentation.

Parameters:
  • args - tuple of the form
    • (eventIdentifier, eventType, target, method)
      1. the identifier of the event to listen for
      2. the type of the listened event. Events of this type or its subclasses activate the listener.
      3. the object instance who owns the activation method.
      4. the activation method.
    • (eventType, target, method)
      1. the type of the listened event. Events of this type or its subclasses activate the listener.
      2. the object instance who owns the activation method.
      3. the activation method or the name of the activation method.

removeListener(self, listener, iface=None)

source code 

Removes a previously registered component event listener from this component.

Parameters:
  • listener - the listener to be removed.
Overrides: event.method_event_source.IMethodEventSource.removeListener
(inherited documentation)

removeCallback(self, callback, eventType=None)

source code 
Overrides: terminal.paintable.IPaintable.removeCallback

withdrawListener(self, *args)

source code 

Removes all registered listeners matching the given parameters. Since this method receives the event type and the listener object as parameters, it will unregister all object's methods that are registered to listen to events of type eventType generated by this component.

This method additionally informs the event-api to stop routing events with the given eventIdentifier to the components handleEvent function call.

For more information on the inheritable event mechanism see the muntjac.event package documentation.

Parameters:
  • args - tuple of the form
    • (eventIdentifier, eventType, target)
      1. the identifier of the event to stop listening for
      2. the exact event type the object listens to.
      3. the target object that has registered to listen to events of type eventType with one or more methods.
    • (eventType, target)
      1. the exact event type the object listens to.
      2. the target object that has registered to listen to events of type eventType with one or more methods.
    • (eventType, target, method)
      1. the exact event type the object listens to.
      2. the target object that has registered to listen to events of type eventType with one or more methods.
      3. the method or the name of the method owned by target that's registered to listen to events of type eventType.

changeVariables(self, source, variables)

source code 

Called when one or more variables handled by the implementing class are changed.

Parameters:
  • source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
  • variables - the Mapping from variable names to new variable values.
Overrides: terminal.variable_owner.IVariableOwner.changeVariables
(inherited documentation)

hasListeners(self, eventType)

source code 

Checks if the given Event type is listened for this component.

Parameters:
  • eventType - the event type to be checked
Returns:
true if a listener is registered for the given event type

getListeners(self, eventType)

source code 

Returns all listeners that are registered for the given event type or one of its subclasses.

Parameters:
  • eventType - The type of event to return listeners for.
Returns:
A collection with all registered listeners. Empty if no listeners are found.

fireEvent(self, event)

source code 

Sends the event to all listeners.

Parameters:
  • event - the Event to be sent to all listeners.

fireComponentEvent(self)

source code 

Emits the component event. It is transmitted to all registered listeners interested in such events.

fireComponentErrorEvent(self)

source code 

Emits the component error event. It is transmitted to all registered listeners interested in such events.

setData(self, data)

source code 

Sets the data object, that can be used for any application specific data. The component does not use or modify this data.

Parameters:
  • data - the Application specific data.

getData(self)

source code 

Gets the application specific data. See setData.

Returns:
the Application specific data set with setData function.

getHeight(self)

source code 

Gets the height of the object. Negative number implies unspecified size (terminal is free to set the size).

Returns:
height of the object in units specified by heightUnits property.
Overrides: terminal.sizeable.ISizeable.getHeight
(inherited documentation)

getHeightUnits(self)

source code 

Gets the height property units.

Returns:
units used in height property.
Overrides: terminal.sizeable.ISizeable.getHeightUnits
(inherited documentation)

getWidth(self)

source code 

Gets the width of the object. Negative number implies unspecified size (terminal is free to set the size).

Returns:
width of the object in units specified by widthUnits property.
Overrides: terminal.sizeable.ISizeable.getWidth
(inherited documentation)

getWidthUnits(self)

source code 

Gets the width property units.

Returns:
units used in width property.
Overrides: terminal.sizeable.ISizeable.getWidthUnits
(inherited documentation)

setHeight(self, height, unit=None)

source code 

Sets the height of the object. Negative number implies unspecified size (terminal is free to set the size).

Parameters:
  • args - tuple of the form
    • (height)
      1. the height of the object in units specified by heightUnits property or the height of the component using string presentation. String presentation is similar to what is used in Cascading Style Sheets. Size can be length or percentage of available size.
    • (height, unit)
      1. the height of the object.
      2. the unit used for the width. Possible values include UNITS_PIXELS, UNITS_POINTS, UNITS_PICAS, UNITS_EM, UNITS_EX, UNITS_MM, UNITS_CM, UNITS_INCH, UNITS_PERCENTAGE.
Overrides: terminal.sizeable.ISizeable.setHeight
(inherited documentation)

setHeightUnits(self, unit)

source code 

Sets the height property units.

Parameters:
  • units - the units used in height property.
Overrides: terminal.sizeable.ISizeable.setHeightUnits
(inherited documentation)

setSizeFull(self)

source code 

Sets the size to 100% x 100%.

Overrides: terminal.sizeable.ISizeable.setSizeFull
(inherited documentation)

setSizeUndefined(self)

source code 

Clears any size settings.

Overrides: terminal.sizeable.ISizeable.setSizeUndefined
(inherited documentation)

setWidth(self, width, unit=None)

source code 

Sets the width of the object. Negative number implies unspecified size (terminal is free to set the size).

Parameters:
Overrides: terminal.sizeable.ISizeable.setWidth
(inherited documentation)

setWidthUnits(self, unit)

source code 

Sets the width property units.

Parameters:
  • units - the units used in width property.
Overrides: terminal.sizeable.ISizeable.setWidthUnits
(inherited documentation)

parseStringSize(self, s)

source code 

Returns array with size in index 0 unit in index 1. Null or empty string will produce {-1,UNITS_PIXELS}.

getErrorHandler(self)

source code 

Gets the error handler for the component.

The error handler is dispatched whenever there is an error processing the data coming from the client.

setErrorHandler(self, errorHandler)

source code 

Sets the error handler for the component.

The error handler is dispatched whenever there is an error processing the data coming from the client.

If the error handler is not set, the application error handler is used to handle the exception.

Parameters:
  • errorHandler - AbstractField specific error handler

handleError(self, error)

source code 

Handle the component error event.

Parameters:
  • error - Error event to handle
Returns:
True if the error has been handled False, otherwise. If the error haven't been handled by this component, it will be handled in the application error handler.

Instance Variable Details [hide private]

_applicationData

Application specific data object. The component does not use