SWT.PaintItem
イベントを使用してカスタム描画を追加できるようです:
https://www.eclipse.org/articles/Article-CustomDrawingTableAndTreeItems/customDraw.htm
ソース:
カスタム ウィジェットを SWT ツリーまたはテーブルに埋め込む
1 Display display = new Display();
2 Shell shell = new Shell(display);
3 shell.setBounds(10, 10, 350, 200);
4 Image xImage = new Image (display, 16, 16);
5 GC gc = new GC(xImage);
6 gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
7 gc.drawLine(1, 1, 14, 14);
8 gc.drawLine(1, 14, 14, 1);
9 gc.drawOval(2, 2, 11, 11);
10 gc.dispose();
11 final int IMAGE_MARGIN = 2;
12 final Tree tree = new Tree(shell, SWT.CHECK);
13 tree.setBounds(10, 10, 300, 150);
14 TreeItem item = new TreeItem(tree, SWT.NONE);
15 item.setText("root item");
16 for (int i = 0; i < 4; i++) {
17 TreeItem newItem = new TreeItem(item, SWT.NONE);
18 newItem.setText("descendent " + i);
19 if (i % 2 == 0) newItem.setData(xImage);
20 item.setExpanded(true);
21 item = newItem;
22 }
23 tree.addListener(SWT.MeasureItem, new Listener() {
24 public void handleEvent(Event event) {
25 TreeItem item = (TreeItem)event.item;
26 Image trailingImage = (Image)item.getData();
27 if (trailingImage != null) {
28 event.width += trailingImage.getBounds().width + IMAGE_MARGIN;
29 }
30 }
31 });
32 tree.addListener(SWT.PaintItem, new Listener() {
33 public void handleEvent(Event event) {
34 TreeItem item = (TreeItem)event.item;
35 Image trailingImage = (Image)item.getData();
36 if (trailingImage != null) {
37 int x = event.x + event.width + IMAGE_MARGIN;
38 int itemHeight = tree.getItemHeight();
39 int imageHeight = trailingImage.getBounds().height;
40 int y = event.y + (itemHeight - imageHeight) / 2;
41 event.gc.drawImage(trailingImage, x, y);
42 }
43 }
44 });
45 shell.open();
46 while (!shell.isDisposed()) {
47 if (!display.readAndDispatch()) display.sleep();
48 }
49 xImage.dispose();
50 display.dispose();