<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT%2FTreeColumn_TreeTable</id>
		<title>Java Tutorial/SWT/TreeColumn TreeTable - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT%2FTreeColumn_TreeTable"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/TreeColumn_TreeTable&amp;action=history"/>
		<updated>2026-04-07T11:02:06Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/TreeColumn_TreeTable&amp;diff=3163&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/TreeColumn_TreeTable&amp;diff=3163&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:26Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 17:44, 31 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/TreeColumn_TreeTable&amp;diff=3164&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/TreeColumn_TreeTable&amp;diff=3164&amp;oldid=prev"/>
				<updated>2010-05-31T15:21:33Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Create a TreeTable ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/*&lt;br /&gt;
 * Create a Tree with columns&lt;br /&gt;
 * &lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.1&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Tree;&lt;br /&gt;
import org.eclipse.swt.widgets.TreeColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TreeItem;&lt;br /&gt;
public class TreeTableCreation {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    Tree tree = new Tree(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);&lt;br /&gt;
    tree.setHeaderVisible(true);&lt;br /&gt;
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);&lt;br /&gt;
    column1.setText(&amp;quot;Column 1&amp;quot;);&lt;br /&gt;
    column1.setWidth(200);&lt;br /&gt;
    TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);&lt;br /&gt;
    column2.setText(&amp;quot;Column 2&amp;quot;);&lt;br /&gt;
    column2.setWidth(200);&lt;br /&gt;
    TreeColumn column3 = new TreeColumn(tree, SWT.RIGHT);&lt;br /&gt;
    column3.setText(&amp;quot;Column 3&amp;quot;);&lt;br /&gt;
    column3.setWidth(200);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 4; i++) {&lt;br /&gt;
      TreeItem item = new TreeItem(tree, SWT.NONE);&lt;br /&gt;
      item.setText(new String[] { &amp;quot;item &amp;quot; + i, &amp;quot;abc&amp;quot;, &amp;quot;defghi&amp;quot; });&lt;br /&gt;
      for (int j = 0; j &amp;lt; 4; j++) {&lt;br /&gt;
        TreeItem subItem = new TreeItem(item, SWT.NONE);&lt;br /&gt;
        subItem.setText(new String[] { &amp;quot;subitem &amp;quot; + j, &amp;quot;jklmnop&amp;quot;, &amp;quot;qrs&amp;quot; });&lt;br /&gt;
        for (int k = 0; k &amp;lt; 4; k++) {&lt;br /&gt;
          TreeItem subsubItem = new TreeItem(subItem, SWT.NONE);&lt;br /&gt;
          subsubItem.setText(new String[] { &amp;quot;subsubitem &amp;quot; + k, &amp;quot;tuv&amp;quot;, &amp;quot;wxyz&amp;quot; });&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Multi-line TreeTable ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2006 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/* &lt;br /&gt;
 * Tree example snippet: Multiple lines in a TreeItem&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.2&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Tree;&lt;br /&gt;
import org.eclipse.swt.widgets.TreeColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TreeItem;&lt;br /&gt;
public class TreeItemLines {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Multiple lines in a TreeItem&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final Tree tree = new Tree(shell, SWT.MULTI | SWT.FULL_SELECTION);&lt;br /&gt;
    tree.setHeaderVisible(true);&lt;br /&gt;
    tree.setLinesVisible(true);&lt;br /&gt;
    int columnCount = 4;&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      TreeColumn column = new TreeColumn(tree, SWT.NONE);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + i);&lt;br /&gt;
      column.setWidth(100);&lt;br /&gt;
    }&lt;br /&gt;
    int itemCount = 3;&lt;br /&gt;
    for (int i = 0; i &amp;lt; itemCount; i++) {&lt;br /&gt;
      TreeItem item1 = new TreeItem(tree, SWT.NONE);&lt;br /&gt;
      item1.setText(&amp;quot;item &amp;quot; + i);&lt;br /&gt;
      for (int c = 1; c &amp;lt; columnCount; c++) {&lt;br /&gt;
        item1.setText(c, &amp;quot;item [&amp;quot; + i + &amp;quot;-&amp;quot; + c + &amp;quot;]&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      for (int j = 0; j &amp;lt; itemCount; j++) {&lt;br /&gt;
        TreeItem item2 = new TreeItem(item1, SWT.NONE);&lt;br /&gt;
        item2.setText(&amp;quot;item [&amp;quot; + i + &amp;quot; &amp;quot; + j + &amp;quot;]&amp;quot;);&lt;br /&gt;
        for (int c = 1; c &amp;lt; columnCount; c++) {&lt;br /&gt;
          item2.setText(c, &amp;quot;item [&amp;quot; + i + &amp;quot; &amp;quot; + j + &amp;quot;-&amp;quot; + c + &amp;quot;]&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        for (int k = 0; k &amp;lt; itemCount; k++) {&lt;br /&gt;
          TreeItem item3 = new TreeItem(item2, SWT.NONE);&lt;br /&gt;
          item3.setText(&amp;quot;item [&amp;quot; + i + &amp;quot; &amp;quot; + j + &amp;quot; &amp;quot; + k + &amp;quot;]&amp;quot;);&lt;br /&gt;
          for (int c = 1; c &amp;lt; columnCount; c++) {&lt;br /&gt;
            item3.setText(c, &amp;quot;item [&amp;quot; + i + &amp;quot; &amp;quot; + j + &amp;quot; &amp;quot; + k + &amp;quot;-&amp;quot; + c + &amp;quot;]&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.&lt;br /&gt;
     * Therefore, it is critical for performance that these methods be as&lt;br /&gt;
     * efficient as possible.&lt;br /&gt;
     */&lt;br /&gt;
    Listener paintListener = new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        switch (event.type) {&lt;br /&gt;
        case SWT.MeasureItem: {&lt;br /&gt;
          TreeItem item = (TreeItem) event.item;&lt;br /&gt;
          String text = getText(item, event.index);&lt;br /&gt;
          Point size = event.gc.textExtent(text);&lt;br /&gt;
          event.width = size.x;&lt;br /&gt;
          event.height = Math.max(event.height, size.y);&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        case SWT.PaintItem: {&lt;br /&gt;
          TreeItem item = (TreeItem) event.item;&lt;br /&gt;
          String text = getText(item, event.index);&lt;br /&gt;
          Point size = event.gc.textExtent(text);&lt;br /&gt;
          int offset2 = event.index == 0 ? Math.max(0, (event.height - size.y) / 2) : 0;&lt;br /&gt;
          event.gc.drawText(text, event.x, event.y + offset2, true);&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        case SWT.EraseItem: {&lt;br /&gt;
          event.detail &amp;amp;= ~SWT.FOREGROUND;&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      String getText(TreeItem item, int column) {&lt;br /&gt;
        String text = item.getText(column);&lt;br /&gt;
        if (column != 0) {&lt;br /&gt;
          TreeItem parent = item.getParentItem();&lt;br /&gt;
          int index = parent == null ? tree.indexOf(item) : parent.indexOf(item);&lt;br /&gt;
          if ((index + column) % 3 == 1) {&lt;br /&gt;
            text += &amp;quot;\nnew line&amp;quot;;&lt;br /&gt;
          }&lt;br /&gt;
          if ((index + column) % 3 == 2) {&lt;br /&gt;
            text += &amp;quot;\nnew line\nnew line&amp;quot;;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        return text;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    tree.addListener(SWT.MeasureItem, paintListener);&lt;br /&gt;
    tree.addListener(SWT.PaintItem, paintListener);&lt;br /&gt;
    tree.addListener(SWT.EraseItem, paintListener);&lt;br /&gt;
    shell.setSize(600, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Show Barchar in TreeTable ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2006 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/* &lt;br /&gt;
 * Tree example snippet: Draw a bar graph&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.2&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Color;&lt;br /&gt;
import org.eclipse.swt.graphics.GC;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Tree;&lt;br /&gt;
import org.eclipse.swt.widgets.TreeColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TreeItem;&lt;br /&gt;
public class TreeTableBarChart {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    shell.setText(&amp;quot;Show results as a bar chart in Tree&amp;quot;);&lt;br /&gt;
    final Tree tree = new Tree(shell, SWT.BORDER);&lt;br /&gt;
    tree.setHeaderVisible(true);&lt;br /&gt;
    tree.setLinesVisible(true);&lt;br /&gt;
    TreeColumn column1 = new TreeColumn(tree, SWT.NONE);&lt;br /&gt;
    column1.setText(&amp;quot;Bug Status&amp;quot;);&lt;br /&gt;
    column1.setWidth(100);&lt;br /&gt;
    final TreeColumn column2 = new TreeColumn(tree, SWT.NONE);&lt;br /&gt;
    column2.setText(&amp;quot;Percent&amp;quot;);&lt;br /&gt;
    column2.setWidth(200);&lt;br /&gt;
    String[] states = new String[] { &amp;quot;Resolved&amp;quot;, &amp;quot;New&amp;quot;, &amp;quot;Won&amp;quot;t Fix&amp;quot;, &amp;quot;Invalid&amp;quot; };&lt;br /&gt;
    String[] teams = new String[] { &amp;quot;UI&amp;quot;, &amp;quot;SWT&amp;quot;, &amp;quot;OSGI&amp;quot; };&lt;br /&gt;
    for (int i = 0; i &amp;lt; teams.length; i++) {&lt;br /&gt;
      TreeItem item = new TreeItem(tree, SWT.NONE);&lt;br /&gt;
      item.setText(teams[i]);&lt;br /&gt;
      for (int j = 0; j &amp;lt; states.length; j++) {&lt;br /&gt;
        TreeItem subItem = new TreeItem(item, SWT.NONE);&lt;br /&gt;
        subItem.setText(states[j]);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.&lt;br /&gt;
     * Therefore, it is critical for performance that these methods be as&lt;br /&gt;
     * efficient as possible.&lt;br /&gt;
     */&lt;br /&gt;
    tree.addListener(SWT.PaintItem, new Listener() {&lt;br /&gt;
      int[] percents = new int[] { 50, 30, 5, 15 };&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        if (event.index == 1) {&lt;br /&gt;
          TreeItem item = (TreeItem) event.item;&lt;br /&gt;
          TreeItem parent = item.getParentItem();&lt;br /&gt;
          if (parent != null) {&lt;br /&gt;
            GC gc = event.gc;&lt;br /&gt;
            int index = parent.indexOf(item);&lt;br /&gt;
            int percent = percents[index];&lt;br /&gt;
            Color foreground = gc.getForeground();&lt;br /&gt;
            Color background = gc.getBackground();&lt;br /&gt;
            gc.setForeground(display.getSystemColor(SWT.COLOR_RED));&lt;br /&gt;
            gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));&lt;br /&gt;
            int width = (column2.getWidth() - 1) * percent / 100;&lt;br /&gt;
            gc.fillGradientRectangle(event.x, event.y, width, event.height, true);&lt;br /&gt;
            Rectangle rect2 = new Rectangle(event.x, event.y, width - 1, event.height - 1);&lt;br /&gt;
            gc.drawRectangle(rect2);&lt;br /&gt;
            gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));&lt;br /&gt;
            String text = percent + &amp;quot;%&amp;quot;;&lt;br /&gt;
            Point size = event.gc.textExtent(text);&lt;br /&gt;
            int offset = Math.max(0, (event.height - size.y) / 2);&lt;br /&gt;
            gc.drawText(text, event.x + 2, event.y + offset, true);&lt;br /&gt;
            gc.setForeground(background);&lt;br /&gt;
            gc.setBackground(foreground);&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  TreeTable: Allow user to reorder columns and reorder columns programmatically. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/*&lt;br /&gt;
 * Allow user to reorder columns and reorder columns programmatically.&lt;br /&gt;
 * &lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.2&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.RowData;&lt;br /&gt;
import org.eclipse.swt.layout.RowLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Tree;&lt;br /&gt;
import org.eclipse.swt.widgets.TreeColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TreeItem;&lt;br /&gt;
public class TreeTableReorderColumn {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new RowLayout(SWT.HORIZONTAL));&lt;br /&gt;
    final Tree tree = new Tree(shell, SWT.BORDER | SWT.CHECK);&lt;br /&gt;
    tree.setLayoutData(new RowData(-1, 300));&lt;br /&gt;
    tree.setHeaderVisible(true);&lt;br /&gt;
    TreeColumn column = new TreeColumn(tree, SWT.LEFT);&lt;br /&gt;
    column.setText(&amp;quot;Column 0&amp;quot;);&lt;br /&gt;
    column = new TreeColumn(tree, SWT.CENTER);&lt;br /&gt;
    column.setText(&amp;quot;Column 1&amp;quot;);&lt;br /&gt;
    column = new TreeColumn(tree, SWT.LEFT);&lt;br /&gt;
    column.setText(&amp;quot;Column 2&amp;quot;);&lt;br /&gt;
    column = new TreeColumn(tree, SWT.RIGHT);&lt;br /&gt;
    column.setText(&amp;quot;Column 3&amp;quot;);&lt;br /&gt;
    column = new TreeColumn(tree, SWT.CENTER);&lt;br /&gt;
    column.setText(&amp;quot;Column 4&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
      TreeItem item = new TreeItem(tree, SWT.NONE);&lt;br /&gt;
      String[] text = new String[] { i + &amp;quot;:0&amp;quot;, i + &amp;quot;:1&amp;quot;, i + &amp;quot;:2&amp;quot;, i + &amp;quot;:3&amp;quot;, i + &amp;quot;:4&amp;quot; };&lt;br /&gt;
      item.setText(text);&lt;br /&gt;
      for (int j = 0; j &amp;lt; 5; j++) {&lt;br /&gt;
        TreeItem subItem = new TreeItem(item, SWT.NONE);&lt;br /&gt;
        text = new String[] { i + &amp;quot;,&amp;quot; + j + &amp;quot;:0&amp;quot;, i + &amp;quot;,&amp;quot; + j + &amp;quot;:1&amp;quot;, i + &amp;quot;,&amp;quot; + j + &amp;quot;:2&amp;quot;,&lt;br /&gt;
            i + &amp;quot;,&amp;quot; + j + &amp;quot;:3&amp;quot;, i + &amp;quot;,&amp;quot; + j + &amp;quot;:4&amp;quot; };&lt;br /&gt;
        subItem.setText(text);&lt;br /&gt;
        for (int k = 0; k &amp;lt; 5; k++) {&lt;br /&gt;
          TreeItem subsubItem = new TreeItem(subItem, SWT.NONE);&lt;br /&gt;
          text = new String[] { i + &amp;quot;,&amp;quot; + j + &amp;quot;,&amp;quot; + k + &amp;quot;:0&amp;quot;, i + &amp;quot;,&amp;quot; + j + &amp;quot;,&amp;quot; + k + &amp;quot;:1&amp;quot;,&lt;br /&gt;
              i + &amp;quot;,&amp;quot; + j + &amp;quot;,&amp;quot; + k + &amp;quot;:2&amp;quot;, i + &amp;quot;,&amp;quot; + j + &amp;quot;,&amp;quot; + k + &amp;quot;:3&amp;quot;,&lt;br /&gt;
              i + &amp;quot;,&amp;quot; + j + &amp;quot;,&amp;quot; + k + &amp;quot;:4&amp;quot; };&lt;br /&gt;
          subsubItem.setText(text);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    Listener listener = new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        System.out.println(&amp;quot;Move &amp;quot; + e.widget);&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    TreeColumn[] columns = tree.getColumns();&lt;br /&gt;
    for (int i = 0; i &amp;lt; columns.length; i++) {&lt;br /&gt;
      columns[i].setWidth(100);&lt;br /&gt;
      columns[i].setMoveable(true);&lt;br /&gt;
      columns[i].addListener(SWT.Move, listener);&lt;br /&gt;
    }&lt;br /&gt;
    Button b = new Button(shell, SWT.PUSH);&lt;br /&gt;
    b.setText(&amp;quot;invert column order&amp;quot;);&lt;br /&gt;
    b.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        int[] order = tree.getColumnOrder();&lt;br /&gt;
        for (int i = 0; i &amp;lt; order.length / 2; i++) {&lt;br /&gt;
          int temp = order[i];&lt;br /&gt;
          order[i] = order[order.length - i - 1];&lt;br /&gt;
          order[order.length - i - 1] = temp;&lt;br /&gt;
        }&lt;br /&gt;
        tree.setColumnOrder(order);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Tree Table: Draw a custom gradient selection ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2006 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/* &lt;br /&gt;
 * Tree example snippet: Draw a custom gradient selection&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.2&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Color;&lt;br /&gt;
import org.eclipse.swt.graphics.GC;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.graphics.Region;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Tree;&lt;br /&gt;
import org.eclipse.swt.widgets.TreeColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TreeItem;&lt;br /&gt;
public class TreeTableGradient {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Custom gradient selection for Tree&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final Tree tree = new Tree(shell, SWT.MULTI | SWT.FULL_SELECTION);&lt;br /&gt;
    tree.setHeaderVisible(true);&lt;br /&gt;
    tree.setLinesVisible(true);&lt;br /&gt;
    int columnCount = 4;&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      TreeColumn column = new TreeColumn(tree, SWT.NONE);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + i);&lt;br /&gt;
    }&lt;br /&gt;
    int itemCount = 3;&lt;br /&gt;
    for (int i = 0; i &amp;lt; itemCount; i++) {&lt;br /&gt;
      TreeItem item1 = new TreeItem(tree, SWT.NONE);&lt;br /&gt;
      item1.setText(&amp;quot;item &amp;quot; + i);&lt;br /&gt;
      for (int c = 1; c &amp;lt; columnCount; c++) {&lt;br /&gt;
        item1.setText(c, &amp;quot;item [&amp;quot; + i + &amp;quot;-&amp;quot; + c + &amp;quot;]&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      for (int j = 0; j &amp;lt; itemCount; j++) {&lt;br /&gt;
        TreeItem item2 = new TreeItem(item1, SWT.NONE);&lt;br /&gt;
        item2.setText(&amp;quot;item [&amp;quot; + i + &amp;quot; &amp;quot; + j + &amp;quot;]&amp;quot;);&lt;br /&gt;
        for (int c = 1; c &amp;lt; columnCount; c++) {&lt;br /&gt;
          item2.setText(c, &amp;quot;item [&amp;quot; + i + &amp;quot; &amp;quot; + j + &amp;quot;-&amp;quot; + c + &amp;quot;]&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        for (int k = 0; k &amp;lt; itemCount; k++) {&lt;br /&gt;
          TreeItem item3 = new TreeItem(item2, SWT.NONE);&lt;br /&gt;
          item3.setText(&amp;quot;item [&amp;quot; + i + &amp;quot; &amp;quot; + j + &amp;quot; &amp;quot; + k + &amp;quot;]&amp;quot;);&lt;br /&gt;
          for (int c = 1; c &amp;lt; columnCount; c++) {&lt;br /&gt;
            item3.setText(c, &amp;quot;item [&amp;quot; + i + &amp;quot; &amp;quot; + j + &amp;quot; &amp;quot; + k + &amp;quot;-&amp;quot; + c + &amp;quot;]&amp;quot;);&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.&lt;br /&gt;
     * Therefore, it is critical for performance that these methods be as&lt;br /&gt;
     * efficient as possible.&lt;br /&gt;
     */&lt;br /&gt;
    tree.addListener(SWT.EraseItem, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        if ((event.detail &amp;amp; SWT.SELECTED) != 0) {&lt;br /&gt;
          GC gc = event.gc;&lt;br /&gt;
          Rectangle area = tree.getClientArea();&lt;br /&gt;
          /*&lt;br /&gt;
           * If you wish to paint the selection beyond the end of last column,&lt;br /&gt;
           * you must change the clipping region.&lt;br /&gt;
           */&lt;br /&gt;
          int columnCount = tree.getColumnCount();&lt;br /&gt;
          if (event.index == columnCount - 1 || columnCount == 0) {&lt;br /&gt;
            int width = area.x + area.width - event.x;&lt;br /&gt;
            if (width &amp;gt; 0) {&lt;br /&gt;
              Region region = new Region();&lt;br /&gt;
              gc.getClipping(region);&lt;br /&gt;
              region.add(event.x, event.y, width, event.height);&lt;br /&gt;
              gc.setClipping(region);&lt;br /&gt;
              region.dispose();&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
          gc.setAdvanced(true);&lt;br /&gt;
          if (gc.getAdvanced())&lt;br /&gt;
            gc.setAlpha(127);&lt;br /&gt;
          Rectangle rect = event.getBounds();&lt;br /&gt;
          Color foreground = gc.getForeground();&lt;br /&gt;
          Color background = gc.getBackground();&lt;br /&gt;
          gc.setForeground(display.getSystemColor(SWT.COLOR_RED));&lt;br /&gt;
          gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));&lt;br /&gt;
          gc.fillGradientRectangle(0, rect.y, 500, rect.height, false);&lt;br /&gt;
          // restore colors for subsequent drawing&lt;br /&gt;
          gc.setForeground(foreground);&lt;br /&gt;
          gc.setBackground(background);&lt;br /&gt;
          event.detail &amp;amp;= ~SWT.SELECTED;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      tree.getColumn(i).pack();&lt;br /&gt;
    }&lt;br /&gt;
    tree.setSelection(tree.getItem(0));&lt;br /&gt;
    shell.setSize(500, 200);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>