1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.fosstrak.llrp.commander.editors;
23
24 import org.eclipse.jface.viewers.*;
25
26
27
28
29
30
31
32
33 public class LLRPBinaryContentProvider implements ITreeContentProvider {
34
35 private BinaryMessage message;
36
37 public void inputChanged (Viewer aViewer, Object aOldInput, Object aNewInput) {
38 message = (BinaryMessage) aNewInput;
39 }
40
41 public Object[] getElements(Object aElement) {
42 return getChildren(aElement);
43 }
44
45
46
47
48
49 public Object[] getChildren(Object aElement) {
50 if (aElement instanceof BinaryMessage) {
51 BinaryMessage msg = (BinaryMessage) aElement;
52
53
54
55
56 BinarySingleValue[] arr = msg.getSplitParameters();
57 int len = 5 + arr.length;
58 BinarySingleValue[] values = new BinarySingleValue[len];
59 values[0] = msg.getReserved();
60 values[1] = msg.getVersion();
61 values[2] = msg.getMsgType();
62 values[3] = msg.getMsgID();
63 values[4] = msg.getMsgLength();
64
65
66 for (int i=5; i<len; i++) {
67 values[i] = arr[i-5];
68 }
69
70 return values;
71 }
72
73 return null;
74 }
75
76 public Object getParent(Object aElement) {
77 if (aElement instanceof BinarySingleValue) {
78 BinarySingleValue value = (BinarySingleValue) aElement;
79 return value.getParent();
80 }
81 return null;
82 }
83
84 public boolean hasChildren(Object aElement) {
85 if (aElement instanceof BinaryMessage) {
86 return true;
87 }
88
89 return false;
90 }
91
92 public void dispose() {
93
94 }
95 }