1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.binding.value.binder;
17
18 import java.util.List;
19
20 import org.eclipse.jface.viewers.ILabelProvider;
21 import org.eclipse.jface.viewers.ILabelProviderListener;
22 import org.eclipse.jface.viewers.TreeNode;
23 import org.eclipse.swt.graphics.Image;
24 import org.eclipse.swt.widgets.Text;
25 import org.seasar.uruma.annotation.EventListener;
26 import org.seasar.uruma.annotation.ExportValue;
27 import org.seasar.uruma.annotation.ImportSelection;
28 import org.seasar.uruma.renderer.impl.AbstractGUITest;
29
30
31
32
33
34
35 public class TreeViewerValueBinderGUITest extends AbstractGUITest {
36 @ExportValue(id = "tree1")
37 public TreeNode[] tparent;
38
39 @ImportSelection(id = "tree1")
40 public List<TreeNode> selected;
41
42 @ImportSelection(id = "tree1")
43 public TreeNode selected2;
44
45 public Text textArea;
46
47
48
49
50
51 public TreeViewerValueBinderGUITest() {
52 tparent = new TreeNode[2];
53 tparent[0] = new TreeNode("親1");
54 tparent[1] = new TreeNode("親2");
55
56 TreeNode[] tchild = new TreeNode[2];
57 tchild[0] = new TreeNode("子1");
58 tchild[1] = new TreeNode("子2");
59 tparent[0].setChildren(tchild);
60
61 TreeNode[] tgrandChild = new TreeNode[2];
62 tgrandChild[0] = new TreeNode("孫1");
63 tgrandChild[1] = new TreeNode("孫2");
64 tchild[0].setChildren(tgrandChild);
65 }
66
67 @EventListener(id = "tree1")
68 public void onTreeSelected() {
69 String current = textArea.getText();
70
71 if (current.length() > 0) {
72 current += "\r\n";
73 }
74
75 current += "NodeSelected : ";
76 for (TreeNode selection : selected) {
77 current += selection.getValue() + ", ";
78 }
79 textArea.setText(current);
80 }
81
82
83
84
85
86
87 public static class TreeNodeLabelProvider implements ILabelProvider {
88
89 public Image getImage(final Object element) {
90 return null;
91 }
92
93 public String getText(final Object element) {
94 if (element instanceof TreeNode) {
95 TreeNode treeNode = (TreeNode) element;
96 return treeNode.getValue().toString();
97 }
98 return null;
99 }
100
101 public void addListener(final ILabelProviderListener listener) {
102 }
103
104 public void dispose() {
105 }
106
107 public boolean isLabelProperty(final Object element,
108 final String property) {
109 return false;
110 }
111
112 public void removeListener(final ILabelProviderListener listener) {
113 }
114 }
115 }