]> gerrit.simantics Code Review - simantics/platform.git/blob
8876960a22b704714529817fd4dde42fb595855d
[simantics/platform.git] /
1 package org.simantics.document.linking.report.evaluator;
2
3 import org.eclipse.jface.resource.ImageDescriptor;
4 import org.simantics.document.linking.Activator;
5 import org.simantics.document.linking.ontology.DocumentLink;
6 import org.simantics.document.linking.report.TableColumn.Alignment;
7 import org.simantics.objmap.graph.annotations.OrderedSetType;
8 import org.simantics.objmap.graph.annotations.RelatedGetValue;
9 import org.simantics.objmap.graph.annotations.RelatedSetValue;
10
11 @OrderedSetType(DocumentLink.URIs.EvaluatorTree_AligmentHint)
12 public class AlignmentHint extends HintNode implements EnumEditableNode{
13         
14         
15         Alignment alignment;
16         
17         public AlignmentHint() {
18                 alignment = Alignment.LEFT;
19         }
20         
21         public AlignmentHint(Alignment alignment) {
22                 this.alignment = alignment;
23         }
24         
25         @Override
26         public String toString() {
27                 return alignment.toString();
28         }
29         
30         @RelatedGetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
31         @Override
32         public String getValue() {
33                 return alignment.toString();
34         }
35         
36         public AlignmentHint setAlignment(Alignment alignment) {
37                 this.alignment = alignment;
38                 return this;
39         }
40         
41         @RelatedSetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
42         @Override
43         public void setValue(String value) {
44                 alignment = Alignment.valueOf(value);
45         }
46         
47         @Override
48         public String[] getEnumearation() {
49                 String values[] = new String[Alignment.values().length];
50                 for (int i = 0; i < values.length; i++)
51                         values[i] = Alignment.values()[i].toString();
52                 return values;
53         }
54         
55         @Override
56         public Object getHintValue() {
57                 return alignment;
58         }
59         
60         @Override
61         public Object getHintClass() {
62                 return Alignment.class;
63         }
64         
65         @Override
66         public EvaluatorItem copy() {
67                 AlignmentHint a = new AlignmentHint(alignment);
68                 copyChildren(a);
69                 return a;
70         }
71         
72         @Override
73         public ImageDescriptor getImage() {
74                 if (alignment == Alignment.LEFT) {
75                         return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_align_left.png");
76                 } else if (alignment == Alignment.CENTER) {
77                         return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_align_center.png");
78                 } else {
79                         return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_align_right.png");
80                 }
81         }
82         
83         
84 }