]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/decorators/ResultFailedDecorator.java
Update licence headers
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui / src / main / java / org / argeo / slc / client / ui / decorators / ResultFailedDecorator.java
index 1d021e2a3ddd3be1b4e8be4cab0fc17bc1d5ca0c..e6f7a96c10af34596ef36d2846867a7beff043ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2012 Mathieu Baudier
+ * Copyright (C) 2007-2012 Argeo GmbH
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package org.argeo.slc.client.ui.decorators;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.ClientUiPlugin;
 import org.argeo.slc.client.ui.model.ResultParent;
+import org.argeo.slc.client.ui.model.SingleResultNode;
+import org.argeo.slc.jcr.SlcNames;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.DecorationOverlayIcon;
 import org.eclipse.jface.viewers.IDecoration;
@@ -30,8 +37,11 @@ import org.eclipse.ui.ISharedImages;
 public class ResultFailedDecorator extends LabelProvider implements
                ILabelDecorator {
 
-       private final static Log log = LogFactory
-                       .getLog(ResultFailedDecorator.class);
+       // private final static Log log = LogFactory
+       // .getLog(ResultFailedDecorator.class);
+
+       private final static DateFormat dateFormat = new SimpleDateFormat(
+                       "yyyy-MM-dd HH:mm");
 
        public ResultFailedDecorator() {
                super();
@@ -45,8 +55,6 @@ public class ResultFailedDecorator extends LabelProvider implements
                // decorates resource icon with basic decorations provided
                // by Eclipse
                if (object instanceof ResultParent) {
-                       log.debug("decorate : " + ((ResultParent) object).getName()
-                                       + " - passed : " + ((ResultParent) object).isPassed());
                        if (!((ResultParent) object).isPassed()) {
                                ImageDescriptor desc = ClientUiPlugin.getDefault()
                                                .getWorkbench().getSharedImages()
@@ -62,6 +70,22 @@ public class ResultFailedDecorator extends LabelProvider implements
 
        // Method to decorate Text
        public String decorateText(String label, Object object) {
-               return null;
+               if (object instanceof SingleResultNode) {
+                       SingleResultNode srNode = (SingleResultNode) object;
+                       Node node = srNode.getNode();
+                       String decoration = null;
+                       try {
+                               if (node.hasProperty(SlcNames.SLC_COMPLETED))
+                                       decoration = dateFormat.format(node
+                                                       .getProperty(SlcNames.SLC_COMPLETED).getDate()
+                                                       .getTime());
+                       } catch (RepositoryException re) {
+                               throw new SlcException(
+                                               "Unexpected error defining text decoration for result", re);
+                       }
+                       return label + " [" + decoration + "]";
+               } else
+                       return null;
        }
+
 }