]> gerrit.simantics Code Review - simantics/platform.git/blob
d1fa4486747011948c27f4058bef47c17eba05b4
[simantics/platform.git] /
1 package org.simantics.document.linking.report.evaluator;
2
3 import java.text.DateFormat;
4 import java.util.Map;
5
6 import org.eclipse.jface.resource.ImageDescriptor;
7 import org.simantics.db.ReadGraph;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.layer0.variable.Variable;
10 import org.simantics.document.linking.Activator;
11 import org.simantics.document.linking.ontology.DocumentLink;
12 import org.simantics.objmap.graph.annotations.GraphType;
13
14
15 @GraphType(DocumentLink.URIs.EvaluatorTree_Date)
16 public class Date extends EvaluatorLeaf {
17         
18         
19         @Override
20         public String getValue(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {
21                 return getDate();
22         }
23         
24
25         @Override
26         public String toString() {
27                 return getDate();
28         }
29
30         private String getDate() {
31                 java.util.Date date = new java.util.Date(System.currentTimeMillis());
32                 String dateString = DateFormat.getDateTimeInstance().format(date);
33                 return dateString;
34         }
35         
36         @Override
37         public EvaluatorItem copy() {
38                 return new Date();
39         }
40         
41         @Override
42         public ImageDescriptor getImage() {
43                 return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/date.png");
44         }
45
46 }