Advanced Customization > Business Logic Customization > Windchill ProjectLink Customization > Writing Custom Windchill ProjectLink Algorithms > Customizing Health Status Icon Display
  
Customizing Health Status Icon Display
Creating a Handler Class
An interface HealthStatusIconHandler.java is designed to extend the capability of providing custom class for health status icon display. This interface is defined as follows:
public HashMap<Object, Object> getHealthStatusImageIcon(List objects);

public Object getIcon(HealthStatusType healthStatusType, boolean isComplete, boolean isCancelled,
AbstractPlanActivity activity) throws WTException, WTPropertyVetoException;

public String getIconForCompletedLate();

public String getIconForCompletedPlannables();

public String getIconForCancelledPlannables();

There is an ‘Out of the box’ Icon handler provided named PlannableHealthStatusIconHandler. For any customization, a custom class should be created implementing above interface and extending this OOTB handler and corresponding methods should be overridden for specific purposes.
The following table describes the customization and the method that needs to be overridden:
Customization
Method that needs overriding
Activities or sublans that are completed after their deadline
getIconForCompletedLate()
Activities or subplans that are completed on or before their deadline
getIconForCompletedPlannables()
Cancelled Activities or Cancelled Subplans
getIconForCancelledPlannables()
Health Status Red
getIcon()
Health Status Yellow
getIcon()
Health Status Green
getIcon()
Health Status UnAvailable
getIcon()
These overridden methods should return a string containing the image path as follows - return netmarkets/images/xxxxx.png
For example, below code could be a possible custom algorithm which would configure health status icon for Activity having health status as ‘RED’:
package com.ptc.projectmanagement.plan;

public class CustomHealthStatusCalculation extends PlannableHealthStatusIconHandler {
@Override
public Object getIcon(HealthStatusType healthStatusType, boolean isComplete, boolean isCancelled, AbstractPlanActivity activity) throws WTException, WTPropertyVetoException {

Object statusIcon = "";
Locale locale = SessionHelper.getLocale();
if(healthStatusType != null){
if(HealthStatusType.RED.equals(healthStatusType)){
statusIcon = getStatusIcon("netmarkets/images/red.gif", healthStatusType.getDisplay(locale));
}
else{
super.getIcon(healthStatusType, isComplete, isCancelled, activity);
}
}
}
}

Configuring the Handler Class
Once the custom algorithm for configuring the graphical health status icons is authored, configure the following in the xconf file.
Copy the Internal name from Type and Attribute Management utility and insert the below entry in file projectmanagement.service.properties.xconf. The location is ${WT_HOME}/Windchill/codebase/com/ptc/projectmanagement/projectmanagement.service.properties.xconf and run the xconfmanager -p in the windchill shell.
<Service context="default"
name="com.ptc.projectmanagement.plan.HealthStatusIconHandler">
<Option cardinality="singleton" requestor= "null"
selector = "<internal type name>"
serviceClass="<fully qualified handler class name>"/>
</Service>
The sample code entry could be:
<Service context="default"
name="com.ptc.projectmanagement.plan.HealthStatusIconHandler">
<Option cardinality="singleton" requestor= "null"
selector = " org.rnd.VW_AutoHealthAutoDeadline " serviceClass= "com.ptc.projectmanagement.plan.HealthStatusIconForRed"/>
</Service>
For type ‘PlanActivity’, there is out of the box handler defined as follows:
<Service context="default" name="com.ptc.projectmanagement.plan. HealthStatusIconHandler ">
<Option cardinality="singleton" requestor= "null"
selector = "com.ptc.projectmanagement.plan.Plannable" serviceClass="com.ptc.projectmanagement.plan.PlannableHealthStatusIconHandler"/>
</Service>