Basic Customization > User Interface Customization > Presenting Information in the UI > Icon Delegates > Solution > Procedure – Authoring Custom IconDelegate > Authoring the custom IconDelegate
  
Authoring the custom IconDelegate
1. You can extend either wt.fc.IconDelegate or an existing subclass of wt.fc.IconDelegate.
2. There are few API’s that you need to over-ride, where you have to put your icon determining logic.
a. These two API’s returns an IconSelector object, which holds the information of the icon for the specific Windchill object.
API Signature
Description
public IconSelector getStandardIconSelector() throws WTException, IllegalAccessException, InvocationTargetException;
Get the standard selector for the icon
public IconSelector getOpenIconSelector() throws WTException, IllegalAccessException, InvocationTargetException;
Get a selector for when the object is opened (for example when a folder is opened)
b. This API returns the localized tooltip value that need to be shown for the icon.
API Signature
Description
public String getToolTip()
The tooltip to be shown with the icon.
c. This API is needed to handle TypeInstances. In the method, you have to check whether the available TypeInstance has all the minimum required attribute values to determine icon and tool tip. If not there is a need to inflate the TypeInstance.
API Signature
Description
protected Boolean inflateRequired()
Inflate Required, if TypeInstance doesn't have required attributes to calculate the icon/tool tip.
@Override
protected boolean inflateRequired() {
boolean need = super.inflateRequired();
TypeInstance ti = getTypeInstanceObject();
if(ti != null && !need){
//check you necessary attributes in TypeInstance
// to determine to inflate it or not.
}
}
return need;
}
d. This API is needed to handle TypeInstances. In the method, you have to add all the attributes that drive icon/tool tip determination. This will make sure that they are properly populated when you invoke getStandardIconSelector() or getOpenIconSelector().
API Signature
Description
protected void initAttributes(Set<AttributeTypeIdentifier> attributes)
Update <AttributeTypeIdentifier> with attributes that drive-determining icon/tool tip.
@Override
protected void initAttributes(Set<AttributeTypeIdentifier>
attributes) {
super.initAttributes(attributes);
//add your attributes here
}
3. IconDelegate defines a static helper method to create AttributeTypeIdentifier and TypeIdentifier objects that your subclass can use. e.g.
AttributeTypeIdentifier NAME_ATI = getIdentifier("name",
"wt.part.WTPart");
TypeIdentifier WTPART_TI = getIdentifier("wt.part.WTPart",
null);
4. The getObject() API will convert the current TypeInstance to a Persistable, if not available. Hence its usage should be avoided in favor of getObject(false).