WorkListDecorator Implementation Example

The following example changes the instance reception date, so that if it was received today it shows the word "Today" with an icon, and the relative time. It also shows a red background for those instances that have a high priority.

The following class implements the interface fuego.workspace.model.view.WorkListDecorator.

It implements the method getRowStyle() so that the background color of the row changes to red if the intance has a high priority.

The method getCellStyle() returns null because this example does not change the style for any cell.

It also implements the method getValue so that if the arrival date is today, it displays the word today and an icon. In this case instead of showing the arrival time, it displays how many hours and minutes have passed since its arrival.

The getValue() method checks that the viewId corresponds to the Inbox View to ensure that only those Work List panels that display the information of this view use this display setting. This is useful when you have multiple Work List porlets displaying different views. The other reason to check the view is to ensure that the variable you use to determine the display preferences exists.

Note: When implementing any of these methods make sure that the variable you are using to determine the display properties exists and its value is not null.
      import fuego.lang.Interval;
      import fuego.lang.Time;
      import fuego.papi.InstanceInfo;
      import fuego.papi.Presentation;
      import fuego.papi.Priority;
      import fuego.papi.VarDefinition;
      import fuego.papi.View;
      import fuego.workspace.model.view.WorkListDecorator;

      import java.util.Locale;

      public class CustomWorkListDecorator
              implements WorkListDecorator {

          public String getRowStyle(String viewId, InstanceInfo instanceInfo, int rowIndex) {
              return instanceInfo.getPriority() == Priority.HIGHEST ? "background-color:IndianRed" : null;
          }

          public String getCellStyle(String viewId, InstanceInfo instanceInfo,
                                     Presentation.Column column, int rowIndex) {
              return null;
          }

          public String getValue(String viewId, InstanceInfo instanceInfo, Presentation.Column column,
                                 Locale locale, String currentValue, int rowIndex) {
              String result = currentValue;

              if (View.INBOX_DEFAULT_ID.equals(viewId)) {

                  if (column.getId().equals(VarDefinition.RECEIVED_ID)) {
                      Time receptionTime = instanceInfo.getReceptionTime();
                      Time today = Time.now();
                      if (receptionTime.getDate().equals(today.getDate())) {
                          Interval relativeTime = Time.sub(today, receptionTime);
                          int relativeHours = relativeTime.getHoursOnly();
                          int relativeMinutes = relativeTime.getMinutesOnly();
                          String relativeTimeString = relativeHours > 0 ? relativeHours + " h " + relativeMinutes + " m" :
                                  relativeMinutes + " m";
                          result = "<table><tr><td nowrap class=bpmWorkspaceNormalText>" +
                                  "<img src='/workspace/img/time.gif'/> Today " +
                                  "(" + relativeTimeString + " ago)</td></tr></table>";
                      }
                  }
              }


              return result;
          }
      }