changeset 98:3690482009a4

merge
author Frank Benoit <benoit@tionex.de>
date Sun, 01 Jun 2008 17:57:12 +0200
parents 781fd8aadeae (current diff) a35db4f4af8c (diff)
children 3fbc483a4599 d06432c0c931
files jface/dsss.conf snippets/dsss.conf
diffstat 6 files changed, 690 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jface/snippets/Snippet031TableViewerCustomTooltipsMultiSelection.d	Sun Jun 01 17:57:12 2008 +0200
@@ -0,0 +1,311 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Adam Neal and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Adam Neal - initial API and implementation
+ * Port to the D programming language:
+ *     yidabu at gmail dot com  ( D China http://www.d-programming-language-china.org/ ) 
+ *******************************************************************************/
+
+module jface.snippets.Snippet031TableViewerCustomTooltipsMultiSelection;
+
+// http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet031TableViewerCustomTooltipsMultiSelection.java?view=markup
+
+import tango.util.collection.ArrayBag;
+alias ArrayBag!(MyModel) ArrayList;
+import tango.util.Convert;
+
+import dwtx.jface.viewers.ArrayContentProvider;
+import dwtx.jface.viewers.ILabelProviderListener;
+import dwtx.jface.viewers.ITableLabelProvider;
+import dwtx.jface.viewers.TableViewer;
+import dwt.DWT;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.layout.FillLayout;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Label;
+import dwt.widgets.Listener;
+import dwt.widgets.Shell;
+import dwt.widgets.Table;
+import dwt.widgets.TableColumn;
+import dwt.widgets.TableItem;
+import dwt.dwthelper.System;
+import dwt.widgets.Listener;
+
+alias char[] String;
+void main(String[] args)
+{
+    Snippet031TableViewerCustomTooltipsMultiSelection.main(args);
+}
+
+/**
+ * A simple TableViewer to demonstrate how custom tooltips could be created easily while preserving 
+ * the multiple selection.
+ * 
+ * This is a modified example taken from Tom Schindl's Snippet023TreeViewerCustomTooltips.java
+ * 
+ * This code is for users pre 3.3 others could use newly added tooltip support in {@link CellLabelProvider}
+ * @author Adam Neal <Adam_Neal@ca.ibm.com>
+ * 
+ */
+public class Snippet031TableViewerCustomTooltipsMultiSelection {
+    public class MyLableProvider : ITableLabelProvider {
+
+        public Image getColumnImage(Object element, int columnIndex) {
+            return null;
+        }
+
+        public String getColumnText(Object element, int columnIndex) {
+            //if (element instanceof MyModel) {            
+                switch (columnIndex) {
+                    case 0: return (cast(MyModel)element).col1;
+                    case 1: return (cast(MyModel)element).col2;
+                }
+            //}
+
+            return "";
+        }
+
+        public void addListener(ILabelProviderListener listener) {
+            /* Ignore */
+        }
+
+        public void dispose() {
+            /* Ignore */
+        }
+
+        public bool isLabelProperty(Object element, String property) {
+            return false;
+        }
+
+        public void removeListener(ILabelProviderListener listener) {
+            /* Ignore */
+        }
+
+    }
+
+
+
+    public this(Shell shell) {
+
+
+        final Table table = new Table(shell, DWT.H_SCROLL | DWT.V_SCROLL | DWT.MULTI | DWT.FULL_SELECTION);
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+
+        final TableViewer v = new TableViewer(table);
+        TableColumn tableColumn1 = new TableColumn(table, DWT.NONE);
+        TableColumn tableColumn2 = new TableColumn(table, DWT.NONE);
+
+        String column1 = "Column 1", column2 = "Column 2";
+        /* Setup the table  columns */
+        tableColumn1.setText(column1);
+        tableColumn2.setText(column2);
+        tableColumn1.pack();
+        tableColumn2.pack();
+
+        v.setColumnProperties([ column1, column2 ]);
+        v.setLabelProvider(new MyLableProvider());
+        v.setContentProvider(new ArrayContentProvider!(MyModel));
+        v.setInput(createModel());
+
+        tooltipLabelListener = new TooltipLabelListener();
+
+        /**
+         * The listener that gets added to the table.  This listener is responsible for creating the tooltips
+         * when hovering over a cell item. This listener will listen for the following events:
+         *  <li>DWT.KeyDown     - to remove the tooltip</li>
+         *  <li>DWT.Dispose     - to remove the tooltip</li>
+         *  <li>DWT.MouseMove   - to remove the tooltip</li>
+         *  <li>DWT.MouseHover  - to set the tooltip</li>
+         */
+
+        Listener tableListener = dgListener(&handleTableListener, table);
+
+        table.addListener (DWT.Dispose, tableListener);
+        table.addListener (DWT.KeyDown, tableListener);
+        table.addListener (DWT.MouseMove, tableListener);
+        table.addListener (DWT.MouseHover, tableListener);
+    }
+
+    void handleTableListener(Event event, Table table)
+    {
+        Shell tooltip = null;
+        Label label = null;
+
+        /*
+         * (non-Javadoc)
+         * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event)
+         */
+       switch (event.type) {
+            case DWT.KeyDown:
+            case DWT.Dispose:
+            case DWT.MouseMove: {
+                if (tooltip is null) break;
+                tooltip.dispose ();
+                tooltip = null;
+                label = null;
+                break;
+            }
+            case DWT.MouseHover: {
+                Point coords = new Point(event.x, event.y);
+                TableItem item = table.getItem(coords);
+                if (item !is null) {
+                    int columnCount = table.getColumnCount();
+                    for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
+                        if (item.getBounds(columnIndex).contains(coords)) {
+                            /* Dispose of the old tooltip (if one exists */
+                            if (tooltip !is null  && !tooltip.isDisposed ()) tooltip.dispose ();
+
+                            /* Create a new Tooltip */
+                            tooltip = new Shell (table.getShell(), DWT.ON_TOP | DWT.NO_FOCUS | DWT.TOOL);
+                            tooltip.setBackground (table.getDisplay().getSystemColor (DWT.COLOR_INFO_BACKGROUND));
+                            FillLayout layout = new FillLayout ();
+                            layout.marginWidth = 2;
+                            tooltip.setLayout (layout);
+                            label = new Label (tooltip, DWT.NONE);
+                            label.setForeground (table.getDisplay().getSystemColor (DWT.COLOR_INFO_FOREGROUND));
+                            label.setBackground (table.getDisplay().getSystemColor (DWT.COLOR_INFO_BACKGROUND));
+
+                            /* Store the TableItem with the label so we can pass the mouse event later */
+                            label.setData ("_TableItem_", item);
+
+                            /* Set the tooltip text */
+                            label.setText("Tooltip: " ~ to!(char[])(item.getData()) ~ " : " ~ to!(char[])(columnIndex));
+
+                            /* Setup Listeners to remove the tooltip and transfer the received mouse events */
+                            label.addListener (DWT.MouseExit, tooltipLabelListener);
+                            label.addListener (DWT.MouseDown, tooltipLabelListener);
+
+                            /* Set the size and position of the tooltip */
+                            Point size = tooltip.computeSize (DWT.DEFAULT, DWT.DEFAULT);
+                            Rectangle rect = item.getBounds (columnIndex);
+                            Point pt = table.toDisplay (rect.x, rect.y);
+                            tooltip.setBounds (pt.x, pt.y, size.x, size.y);
+
+                            /* Show it */
+                            tooltip.setVisible (true);
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * This listener is added to the tooltip so that it can either dispose itself if the mouse
+     * exits the tooltip or so it can pass the selection event through to the table.
+     */
+    final TooltipLabelListener tooltipLabelListener;
+    final class TooltipLabelListener : Listener {
+        private bool isCTRLDown(Event e) {
+            return (e.stateMask & DWT.CTRL) != 0;
+        }
+       /*
+        * (non-Javadoc)
+        * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event)
+        */
+       public void handleEvent (Event event) {
+           Label label = cast(Label)event.widget;
+           Shell shell = label.getShell ();
+           switch (event.type) {
+                case DWT.MouseDown: /* Handle a user Click */
+                    /* Extract our Data */
+                    Event e = new Event ();
+                    e.item = cast(TableItem) label.getData ("_TableItem_");
+                    Table table = (cast(TableItem) e.item).getParent();
+
+                    /* Construct the new Selection[] to show */
+                    TableItem [] newSelection = null;
+                    if (isCTRLDown(event)) {
+                        /* We have 2 scenario's.  
+                         *  1) We are selecting an already selected element - so remove it from the selected indices
+                         *  2) We are selecting a non-selected element - so add it to the selected indices
+                         */
+                        TableItem[] sel = table.getSelection();
+                        for (int i = 0; i < sel.length; ++i) {
+                            //if (e.item.equals(sel[i])) {
+                            if (e.item is sel[i]) {
+                                // We are de-selecting this element
+                                newSelection = new TableItem[sel.length - 1];
+                                System.arraycopy(sel, 0, newSelection, 0, i);
+                                System.arraycopy(sel, i+1, newSelection, i, sel.length - i - 1);
+                                break;
+                            }
+                        }
+
+                        /*
+                         * If we haven't created the newSelection[] yet, than we are adding the newly selected element
+                         * into the list of selected indicies
+                         */
+                        if (newSelection is null) {
+                            newSelection = new TableItem[sel.length + 1];
+                            System.arraycopy(sel, 0, newSelection, 0, sel.length);
+                            newSelection[sel.length] = cast(TableItem) e.item;
+                        }
+
+                    } else {
+                        /* CTRL is not down, so we simply select the single element */
+                        newSelection = [ cast(TableItem) e.item ];
+                    }
+                    /* Set the new selection of the table and notify the listeners */
+                    table.setSelection (newSelection);
+                    table.notifyListeners (DWT.Selection, e);
+
+                    /* Remove the Tooltip */
+                    shell.dispose ();
+                    table.setFocus();
+                    break;
+                case DWT.MouseExit:
+                    shell.dispose ();
+                    break;
+            }
+        }
+    }
+
+
+    private ArrayList createModel() {
+        ArrayList list = new ArrayList;
+        list.add(new MyModel("A", "B"));
+        list.add(new MyModel("C", "D"));
+        list.add(new MyModel("E", "F"));
+        return list;
+    }
+
+    public static void main(String[] args) {
+        Display display = new Display();
+        Shell shell = new Shell(display);
+        shell.setLayout(new FillLayout());
+        new Snippet031TableViewerCustomTooltipsMultiSelection(shell);
+        shell.open();
+
+        while (!shell.isDisposed()) {
+            if (!display.readAndDispatch())
+                display.sleep();
+        }
+
+        display.dispose();
+    }
+}
+
+public class MyModel {
+    public String col1, col2;
+
+    public this(String c1, String c2) {
+        col1 = c1;
+        col2 = c2;
+    }
+
+    public String toString() {
+        return col1 ~ col2;
+    }
+}
+
--- a/snippets/dsss.conf	Sun Jun 01 17:56:11 2008 +0200
+++ b/snippets/dsss.conf	Sun Jun 01 17:57:12 2008 +0200
@@ -50,6 +50,7 @@
 [spinner/Snippet190.d]
 [styledtext/Snippet163.d]
 [styledtext/Snippet189.d]
+[tabfolder/Snippet76.d]
 [table/Snippet38.d]
 [table/Snippet144.d]
 [text/Snippet258.d]
@@ -63,7 +64,10 @@
 [tray/Snippet143.d]
 [tree/Snippet8.d]
 [tree/Snippet15.d]
+[tree/Snippet170.d]
+[tree/Snippet193.d]
 [tree/Snippet220.d]
+[tree/Snippet226.d]
 [treeeditor/Snippet111.d]
 
 version(Derelict){
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/tabfolder/Snippet76.d	Sun Jun 01 17:57:12 2008 +0200
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Bill Baxter <wbaxter> at gmail com
+ *******************************************************************************/
+module snippets.tabfolder.Snippet76;
+
+/*
+ * TabFolder example snippet: create a tab folder (six pages)
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import dwt.DWT;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+import dwt.widgets.TabFolder;
+import dwt.widgets.TabItem;
+import dwt.widgets.Button;
+
+import tango.util.Convert;
+
+void main () {
+	Display display = new Display ();
+	final Shell shell = new Shell (display);
+	final TabFolder tabFolder = new TabFolder (shell, DWT.BORDER);
+	for (int i=0; i<6; i++) {
+		TabItem item = new TabItem (tabFolder, DWT.NONE);
+		item.setText ("TabItem " ~ to!(char[])(i));
+		Button button = new Button (tabFolder, DWT.PUSH);
+		button.setText ("Page " ~ to!(char[])(i));
+		item.setControl (button);
+	}
+	tabFolder.pack ();
+	shell.pack ();
+	shell.open ();
+	while (!shell.isDisposed ()) {
+		if (!display.readAndDispatch ()) display.sleep ();
+	}
+	display.dispose ();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/tree/Snippet170.d	Sun Jun 01 17:57:12 2008 +0200
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Bill Baxter <wbaxter@gmail.com>
+ *******************************************************************************/
+module snippets.tree.Snippet170;
+
+/*
+ * Tree example snippet: Create a Tree with columns
+ * 
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ * 
+ * @since 3.1
+ */
+
+import dwt.DWT;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+import dwt.widgets.Tree;
+import dwt.widgets.TreeItem;
+import dwt.widgets.TreeColumn;
+import dwt.layout.FillLayout;
+
+import tango.util.Convert;
+
+import dwt.dwthelper.utils;
+
+void main() {
+    Display display = new Display();
+    final Shell shell = new Shell(display);
+    shell.setLayout(new FillLayout());
+    Tree tree = new Tree(shell, DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL);
+    tree.setHeaderVisible(true);
+    TreeColumn column1 = new TreeColumn(tree, DWT.LEFT);
+    column1.setText("Column 1");
+    column1.setWidth(200);
+    TreeColumn column2 = new TreeColumn(tree, DWT.CENTER);
+    column2.setText("Column 2");
+    column2.setWidth(200);
+    TreeColumn column3 = new TreeColumn(tree, DWT.RIGHT);
+    column3.setText("Column 3");
+    column3.setWidth(200);
+    for (int i = 0; i < 4; i++) {
+        TreeItem item = new TreeItem(tree, DWT.NONE);
+        item.setText([ "item " ~ to!(String)(i), "abc", "defghi" ]);
+        for (int j = 0; j < 4; j++) {
+            TreeItem subItem = new TreeItem(item, DWT.NONE);
+            subItem.setText([ "subitem " ~ to!(String)(j), "jklmnop", "qrs" ]);
+            for (int k = 0; k < 4; k++) {
+                TreeItem subsubItem = new TreeItem(subItem, DWT.NONE);
+                subsubItem.setText([ "subsubitem " ~ to!(String)(k), "tuv", "wxyz" ]);
+            }
+        }
+    }
+    shell.pack();
+    shell.open();
+    while (!shell.isDisposed()) {
+        if (!display.readAndDispatch()) {
+            display.sleep();
+        }
+    }
+    display.dispose();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/tree/Snippet193.d	Sun Jun 01 17:57:12 2008 +0200
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Bill Baxter <wbaxter@gmail.com>
+ *******************************************************************************/
+module snippets.tree.Snippet193;
+
+/*
+ * Tree example snippet: allow user to reorder columns by dragging and programmatically.
+ * 
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ * 
+ * @since 3.2
+ */
+import dwt.DWT;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+import dwt.widgets.Tree;
+import dwt.widgets.TreeItem;
+import dwt.widgets.TreeColumn;
+import dwt.widgets.Button;
+import dwt.widgets.Listener;
+import dwt.widgets.Event;
+import dwt.layout.RowLayout;
+import dwt.layout.RowData;
+
+import tango.util.Convert;
+import tango.io.Stdout;
+
+import dwt.dwthelper.utils;
+
+
+void main() {
+    Display display = new Display();
+    Shell shell = new Shell(display);
+    shell.setLayout(new RowLayout(DWT.HORIZONTAL));
+    final Tree tree = new Tree(shell, DWT.BORDER | DWT.CHECK);
+    tree.setLayoutData(new RowData(-1, 300));
+    tree.setHeaderVisible(true);
+    TreeColumn column = new TreeColumn(tree, DWT.LEFT);
+    column.setText("Column 0");
+    column = new TreeColumn(tree, DWT.CENTER);
+    column.setText("Column 1");
+    column = new TreeColumn(tree, DWT.LEFT);
+    column.setText("Column 2");
+    column = new TreeColumn(tree, DWT.RIGHT);
+    column.setText("Column 3");
+    column = new TreeColumn(tree, DWT.CENTER);
+    column.setText("Column 4");
+    for (int i = 0; i < 5; i++) {
+        TreeItem item = new TreeItem(tree, DWT.NONE);
+        auto istr = to!(String)(i);
+        String[] text = [istr~":0",
+                         istr~":1",
+                         istr~":2",
+                         istr~":3",
+                         istr~":4"];
+        item.setText(text);
+        for (int j = 0; j < 5; j++) {
+            auto jstr = to!(String)(j);
+            TreeItem subItem = new TreeItem(item, DWT.NONE);
+            text = [istr~","~jstr~":0",
+                    istr~","~jstr~":1", 
+                    istr~","~jstr~":2",
+                    istr~","~jstr~":3",
+                    istr~","~jstr~":4"];
+            subItem.setText(text);
+            for (int k = 0; k < 5; k++) {
+                auto kstr = to!(String)(k);
+                TreeItem subsubItem = new TreeItem(subItem, DWT.NONE);
+                text = [istr~","~jstr~","~kstr~":0",
+                        istr~","~jstr~","~kstr~":1",
+                        istr~","~jstr~","~kstr~":2",
+                        istr~","~jstr~","~kstr~":3",
+                        istr~","~jstr~","~kstr~":4"];
+                subsubItem.setText(text);
+            }
+        }
+    }
+    Listener listener = new class Listener {
+        public void handleEvent(Event e) {
+            Stdout.print("Move "~e.widget.toString).newline;
+        }
+    };
+    TreeColumn[] columns = tree.getColumns();
+    for (int i = 0; i < columns.length; i++) {
+        columns[i].setWidth(100);
+        columns[i].setMoveable(true);
+        columns[i].addListener(DWT.Move, listener);
+    }
+    Button b = new Button(shell, DWT.PUSH);
+    b.setText("invert column order");
+    b.addListener(DWT.Selection, new class Listener {
+        public void handleEvent(Event e) {
+            int[] order = tree.getColumnOrder();
+            for (int i = 0; i < order.length / 2; i++) {
+                int temp = order[i];
+                order[i] = order[order.length - i - 1];
+                order[order.length - i - 1] = temp;
+            }
+            tree.setColumnOrder(order);
+        }
+    });
+    shell.pack();
+    shell.open();
+    while (!shell.isDisposed()) {
+        if (!display.readAndDispatch())
+            display.sleep();
+    }
+    display.dispose();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/tree/Snippet226.d	Sun Jun 01 17:57:12 2008 +0200
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * D Port:
+ *     Bill Baxter <wbaxter@gmail.com>
+ *******************************************************************************/
+module snippets.tree.Snippet226;
+
+/* 
+ * Tree example snippet: Draw a custom gradient selection
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ * 
+ * @since 3.3
+ */
+import dwt.DWT;
+import dwt.graphics.GC;
+import dwt.graphics.Rectangle;
+import dwt.graphics.Region;
+import dwt.graphics.Color;
+import dwt.layout.FillLayout;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+import dwt.widgets.Tree;
+import dwt.widgets.TreeItem;
+import dwt.widgets.TreeColumn;
+import dwt.widgets.Listener;
+import dwt.widgets.Event;
+
+import tango.util.Convert;
+
+import dwt.dwthelper.utils;
+
+void main() 
+{
+	final Display display = new Display();
+	Shell shell = new Shell(display);
+	shell.setText("Custom gradient selection for Tree");
+	shell.setLayout(new FillLayout());
+	final Tree tree = new Tree(shell, DWT.MULTI | DWT.FULL_SELECTION);
+	tree.setHeaderVisible(true);
+	tree.setLinesVisible(true);
+	int columnCount = 4;
+	for (int i=0; i<columnCount; i++) {
+        auto istr = to!(String)(i);
+		TreeColumn column = new TreeColumn(tree, DWT.NONE);
+		column.setText("Column " ~ istr);	
+	}
+	int itemCount = 3;
+	for (int i=0; i<itemCount; i++) {
+        auto istr = to!(String)(i);
+		TreeItem item1 = new TreeItem(tree, DWT.NONE);
+		item1.setText("item "~istr);
+		for (int c=1; c < columnCount; c++) {
+            auto cstr = to!(String)(c);
+			item1.setText(c, "item ["~istr~"-"~cstr~"]");
+		}
+		for (int j=0; j<itemCount; j++) {
+            auto jstr = to!(String)(j);
+			TreeItem item2 = new TreeItem(item1, DWT.NONE);
+			item2.setText("item ["~istr~" "~jstr~"]");
+			for (int c=1; c<columnCount; c++) {
+                auto cstr = to!(String)(c);
+				item2.setText(c, "item ["~istr~" "~jstr~"-"~cstr~"]");
+			}
+			for (int k=0; k<itemCount; k++) {
+                auto kstr = to!(String)(k);
+				TreeItem item3 = new TreeItem(item2, DWT.NONE);
+				item3.setText("item ["~istr~" "~jstr~" "~kstr~"]");
+				for (int c=1; c<columnCount; c++) {
+                    auto cstr = to!(String)(c);
+					item3.setText(c, "item ["~istr~" "~jstr~" "~kstr~"-"~cstr~"]");
+				}
+			}
+		}
+	}
+
+	/*
+	 * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.
+	 * Therefore, it is critical for performance that these methods be
+	 * as efficient as possible.
+	 */
+	tree.addListener(DWT.EraseItem, new class Listener {
+		public void handleEvent(Event event) {
+			event.detail &= ~DWT.HOT;
+			if ((event.detail & DWT.SELECTED) != 0) {
+				GC gc = event.gc;
+				Rectangle area = tree.getClientArea();
+				/*
+				 * If you wish to paint the selection beyond the end of
+				 * last column, you must change the clipping region.
+				 */
+				int columnCount = tree.getColumnCount();
+				if (event.index == columnCount - 1 || columnCount == 0) {
+					int width = area.x + area.width - event.x;
+					if (width > 0) {
+						Region region = new Region();
+						gc.getClipping(region);
+						region.add(event.x, event.y, width, event.height); 
+						gc.setClipping(region);
+						region.dispose();
+					}
+				}
+				gc.setAdvanced(true);
+				if (gc.getAdvanced()) gc.setAlpha(127);								
+				Rectangle rect = event.getBounds();
+				Color foreground = gc.getForeground();
+				Color background = gc.getBackground();
+				gc.setForeground(display.getSystemColor(DWT.COLOR_RED));
+				gc.setBackground(display.getSystemColor(DWT.COLOR_LIST_BACKGROUND));
+				gc.fillGradientRectangle(0, rect.y, 500, rect.height, false);
+				// restore colors for subsequent drawing
+				gc.setForeground(foreground);
+				gc.setBackground(background);
+				event.detail &= ~DWT.SELECTED;					
+			}						
+		}
+	});		
+	for (int i=0; i<columnCount; i++) {
+		tree.getColumn(i).pack();
+	}	
+	tree.setSelection(tree.getItem(0));
+	shell.setSize(500, 200);
+	shell.open();
+	while (!shell.isDisposed()) {
+		if (!display.readAndDispatch()) display.sleep();
+	}
+	display.dispose();	
+}