Share via


ExtenderInfo Class

Methods | This Package | All Packages

Defines an extender property of a component.

MemberInfo
  |
  +--ExtenderInfo

package com.ms.wfc.core

public class ExtenderInfo
extends
MemberInfo****

Remarks

An extender property allows a component to provide properties to other components. An example is the toolTip property of the ToolTip component. When this component is present, all other controls on the form appear to have an extra toolTip property.

Note   In order to provide extender properties, a component must implement the IExtenderProvider interface.

The ExtenderInfo class is used within a component's ClassInfo inner class. When you create an ExtenderInfo object, you specify the component class that is providing the extender, the name of the extender, the component class that is receiving the extender, the type of the extender, and the various attributes of the extender. (Attributes can be specified using the classes that extend MemberAttribute.)

The following example shows a portion of the ClassInfo of the ToolTip class:

public static class ClassInfo extends Component.ClassInfo {
   public static final ExtenderInfo toolTip = new ExtenderInfo(
      ToolTip.class, "toolTip", Control.class, String.class,
      LocalizableAttribute.YES,
      new DefaultValueAttribute.NULL,
      new DescriptionAttribute(
    "Determines the tool tip shown when the mouse hovers over the control."));

   public void getExtenders(IExtenders iexts) {
      super.getExtenders(iexts);
      iexts.add(toolTip);
   }
}

For a read-only extender property defined through ExtenderInfo, the component class providing the extender must implement the following method:

public <extenderType> get<ExtenderName>( Object extendee )

For a read/write extender property, the component class must implement get<ExtenderName> as well as the following method:

public void set<ExtenderName>( Object extendee**,** <extenderType>****value )

In the syntax for these methods, the extendee parameter is the object that receives the extender. These methods return and set the value of the extender for the extendee object.

Note   An extender name typically begins with a lowercase letter, while the case of the associated methods is mixed. For example, a read/write extender property named toolTip is associated with getToolTip and setToolTip methods.

The following example shows how to set an extender property:

Button button1 = new Button();
Button button2 = new Button();
ToolTip toolTip1 = new ToolTip();

toolTip1.setToolTip(button1, "button1's tooltip");
toolTip1.setToolTip(button2, "button2's tooltip");

In addition to the get<ExtenderName> and set<ExtenderName> methods, the component class providing the extender can optionally implement the following two methods:

public boolean shouldPersist<ExtenderName>( Object extendee )

public void reset<ExtenderName>( Object extendee )

These methods involve the extender's default value, which is specified using DefaultValueAttribute. The shouldPersist<ExtenderName> method returns true if the current value of the extender is different than its default value, indicating that the value should be persisted. The reset<ExtenderName> method resets the extender to its default value.

If the ExtenderInfo definition specifies a value editor (using ValueEditorAttribute), this value editor is used to edit the extender. Otherwise, a system-provided value editor is used.

An ExtenderInfo object can be obtained programmatically through the ComponentManager class.

See Also   PropertyInfo, EventInfo, Attribute Classes