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

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/SWT/TreeViewer&amp;diff=2983&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/SWT/TreeViewer&amp;diff=2983&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://www.jexp.ru/index.php?title=Java_Tutorial/SWT/TreeViewer&amp;diff=2984&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/SWT/TreeViewer&amp;diff=2984&amp;oldid=prev"/>
				<updated>2010-05-31T15:19:43Z</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 CheckBoxTreeView and react to CheckStateListener ==&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;
import java.io.File;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.FileNotFoundException;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import org.eclipse.jface.viewers.CheckStateChangedEvent;&lt;br /&gt;
import org.eclipse.jface.viewers.CheckboxTreeViewer;&lt;br /&gt;
import org.eclipse.jface.viewers.ICheckStateListener;&lt;br /&gt;
import org.eclipse.jface.viewers.ILabelProvider;&lt;br /&gt;
import org.eclipse.jface.viewers.ILabelProviderListener;&lt;br /&gt;
import org.eclipse.jface.viewers.ITreeContentProvider;&lt;br /&gt;
import org.eclipse.jface.viewers.Viewer;&lt;br /&gt;
import org.eclipse.jface.window.ApplicationWindow;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Image;&lt;br /&gt;
import org.eclipse.swt.layout.GridData;&lt;br /&gt;
import org.eclipse.swt.layout.GridLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.ruposite;&lt;br /&gt;
import org.eclipse.swt.widgets.Control;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class CheckFileTreeViewer {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    CheckFileTree main = new CheckFileTree();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class CheckFileTree extends ApplicationWindow{&lt;br /&gt;
  public CheckFileTree() {&lt;br /&gt;
    super(null);&lt;br /&gt;
    // Don&amp;quot;t return from open() until window closes&lt;br /&gt;
    setBlockOnOpen(true);&lt;br /&gt;
    open();&lt;br /&gt;
    Display.getCurrent().dispose();&lt;br /&gt;
  }&lt;br /&gt;
  protected void configureShell(Shell shell) {&lt;br /&gt;
    super.configureShell(shell);&lt;br /&gt;
    shell.setSize(400, 400);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates the main window&amp;quot;s contents&lt;br /&gt;
   *&lt;br /&gt;
   * @param parent the main window&lt;br /&gt;
   * @return Control&lt;br /&gt;
   */&lt;br /&gt;
  protected Control createContents(Composite parent) {&lt;br /&gt;
    Composite composite = new Composite(parent, SWT.NONE);&lt;br /&gt;
    composite.setLayout(new GridLayout(1, false));&lt;br /&gt;
    // Create the tree viewer to display the file tree&lt;br /&gt;
    final CheckboxTreeViewer tv = new CheckboxTreeViewer(composite);&lt;br /&gt;
    tv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));&lt;br /&gt;
    tv.setContentProvider(new FileTreeContentProvider());&lt;br /&gt;
    tv.setLabelProvider(new FileTreeLabelProvider());&lt;br /&gt;
    tv.setInput(&amp;quot;root&amp;quot;); // pass a non-null that will be ignored&lt;br /&gt;
    // When user checks a checkbox in the tree, check all its children&lt;br /&gt;
    tv.addCheckStateListener(new ICheckStateListener() {&lt;br /&gt;
      public void checkStateChanged(CheckStateChangedEvent event) {&lt;br /&gt;
        if (event.getChecked()) {&lt;br /&gt;
          tv.setSubtreeChecked(event.getElement(), true);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    return composite;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class FileTreeContentProvider implements ITreeContentProvider {&lt;br /&gt;
  public Object[] getChildren(Object arg0) {&lt;br /&gt;
    return ((File) arg0).listFiles();&lt;br /&gt;
  }&lt;br /&gt;
  public Object getParent(Object arg0) {&lt;br /&gt;
    return ((File) arg0).getParentFile();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean hasChildren(Object arg0) {&lt;br /&gt;
    Object[] obj = getChildren(arg0);&lt;br /&gt;
    return obj == null ? false : obj.length &amp;gt; 0;&lt;br /&gt;
  }&lt;br /&gt;
  public Object[] getElements(Object arg0) {&lt;br /&gt;
    return File.listRoots();&lt;br /&gt;
  }&lt;br /&gt;
  public void dispose() {&lt;br /&gt;
  }&lt;br /&gt;
  public void inputChanged(Viewer arg0, Object arg1, Object arg2) {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class FileTreeLabelProvider implements ILabelProvider {&lt;br /&gt;
  private List listeners;&lt;br /&gt;
  private Image file;&lt;br /&gt;
  private Image dir;&lt;br /&gt;
  public FileTreeLabelProvider() {&lt;br /&gt;
    listeners = new ArrayList();&lt;br /&gt;
    try {&lt;br /&gt;
      file = new Image(null, new FileInputStream(&amp;quot;images/file.gif&amp;quot;));&lt;br /&gt;
      dir = new Image(null, new FileInputStream(&amp;quot;images/directory.gif&amp;quot;));&lt;br /&gt;
    } catch (FileNotFoundException e) {&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public Image getImage(Object arg0) {&lt;br /&gt;
    return ((File) arg0).isDirectory() ? dir : file;&lt;br /&gt;
  }&lt;br /&gt;
  public String getText(Object arg0) {&lt;br /&gt;
    String text = ((File) arg0).getName();&lt;br /&gt;
    if (((File) arg0).getName().length() == 0) {&lt;br /&gt;
      text = ((File) arg0).getPath();&lt;br /&gt;
    }&lt;br /&gt;
    return text;&lt;br /&gt;
  }&lt;br /&gt;
  public void addListener(ILabelProviderListener arg0) {&lt;br /&gt;
    listeners.add(arg0);&lt;br /&gt;
  }&lt;br /&gt;
  public void dispose() {&lt;br /&gt;
    // Dispose the images&lt;br /&gt;
    if (dir != null)&lt;br /&gt;
      dir.dispose();&lt;br /&gt;
    if (file != null)&lt;br /&gt;
      file.dispose();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isLabelProperty(Object arg0, String arg1) {&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  public void removeListener(ILabelProviderListener arg0) {&lt;br /&gt;
    listeners.remove(arg0);&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;
==  Create TreeView based on your own tree node structure ==&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;
import java.util.Vector;&lt;br /&gt;
import org.eclipse.jface.viewers.ILabelProvider;&lt;br /&gt;
import org.eclipse.jface.viewers.ILabelProviderListener;&lt;br /&gt;
import org.eclipse.jface.viewers.ITreeContentProvider;&lt;br /&gt;
import org.eclipse.jface.viewers.TreeViewer;&lt;br /&gt;
import org.eclipse.jface.viewers.Viewer;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Image;&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.TreeItem;&lt;br /&gt;
public class TreeViewBasedOnNode {&lt;br /&gt;
  static Display display = new Display();&lt;br /&gt;
  static Shell shell = new Shell(display);&lt;br /&gt;
  static final Tree tree = new Tree(shell, SWT.BORDER);&lt;br /&gt;
  static Vector nodes = new Vector();&lt;br /&gt;
  public static void traditional() {&lt;br /&gt;
    for (int i = 0; nodes != null &amp;amp;&amp;amp; i &amp;lt; nodes.size(); i++) {&lt;br /&gt;
      Node node = (Node) nodes.elementAt(i);&lt;br /&gt;
      addNode(null, node);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private static void addNode(TreeItem parentItem, Node node) {&lt;br /&gt;
    TreeItem item = null;&lt;br /&gt;
    if (parentItem == null)&lt;br /&gt;
      item = new TreeItem(tree, SWT.NONE);&lt;br /&gt;
    else&lt;br /&gt;
      item = new TreeItem(parentItem, SWT.NONE);&lt;br /&gt;
    item.setText(node.getName());&lt;br /&gt;
    Vector subs = node.getSubCategories();&lt;br /&gt;
    for (int i = 0; subs != null &amp;amp;&amp;amp; i &amp;lt; subs.size(); i++)&lt;br /&gt;
      addNode(item, (Node) subs.elementAt(i));&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Node category = new Node(&amp;quot;A&amp;quot;, null);&lt;br /&gt;
    nodes.add(category);&lt;br /&gt;
    category = new Node(&amp;quot;a1&amp;quot;, category);&lt;br /&gt;
    new Node(&amp;quot;a11&amp;quot;, category);&lt;br /&gt;
    new Node(&amp;quot;a12&amp;quot;, category);&lt;br /&gt;
    category = new Node(&amp;quot;B&amp;quot;, null);&lt;br /&gt;
    nodes.add(category);&lt;br /&gt;
    new Node(&amp;quot;b1&amp;quot;, category);&lt;br /&gt;
    new Node(&amp;quot;b2&amp;quot;, category);&lt;br /&gt;
    TreeViewer treeViewer = new TreeViewer(tree);&lt;br /&gt;
    treeViewer.setContentProvider(new MyTreeContentProvider());&lt;br /&gt;
    treeViewer.setLabelProvider(new MyLabelProvider());&lt;br /&gt;
    treeViewer.setInput(nodes);&lt;br /&gt;
    tree.setSize(300, 200);&lt;br /&gt;
    shell.setSize(300, 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;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class MyLabelProvider implements ILabelProvider {&lt;br /&gt;
  public String getText(Object element) {&lt;br /&gt;
    return ((Node) element).getName();&lt;br /&gt;
  }&lt;br /&gt;
  public Image getImage(Object arg0) {&lt;br /&gt;
    return null;&lt;br /&gt;
  }&lt;br /&gt;
  public void addListener(ILabelProviderListener arg0) {&lt;br /&gt;
  }&lt;br /&gt;
  public void dispose() {&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isLabelProperty(Object arg0, String arg1) {&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  public void removeListener(ILabelProviderListener arg0) {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class MyTreeContentProvider implements ITreeContentProvider{&lt;br /&gt;
  public Object[] getChildren(Object parentElement) {&lt;br /&gt;
    Vector subcats = ((Node) parentElement).getSubCategories();&lt;br /&gt;
    return subcats == null ? new Object[0] : subcats.toArray();&lt;br /&gt;
  }&lt;br /&gt;
  public Object getParent(Object element) {&lt;br /&gt;
    return ((Node) element).getParent();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean hasChildren(Object element) {&lt;br /&gt;
    return ((Node) element).getSubCategories() != null;&lt;br /&gt;
  }&lt;br /&gt;
  public Object[] getElements(Object inputElement) {&lt;br /&gt;
    if (inputElement != null &amp;amp;&amp;amp; inputElement instanceof Vector) {&lt;br /&gt;
      return ((Vector) inputElement).toArray();&lt;br /&gt;
    }&lt;br /&gt;
    return new Object[0];&lt;br /&gt;
  }&lt;br /&gt;
  public void dispose() {&lt;br /&gt;
  }&lt;br /&gt;
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Node {&lt;br /&gt;
  private String name;&lt;br /&gt;
  private Vector subCategories;&lt;br /&gt;
  private Node parent;&lt;br /&gt;
  public Node(String name, Node parent) {&lt;br /&gt;
    this.name = name;&lt;br /&gt;
    this.parent = parent;&lt;br /&gt;
    if (parent != null)&lt;br /&gt;
      parent.addSubCategory(this);&lt;br /&gt;
  }&lt;br /&gt;
  public Vector getSubCategories() {&lt;br /&gt;
    return subCategories;&lt;br /&gt;
  }&lt;br /&gt;
  private void addSubCategory(Node subcategory) {&lt;br /&gt;
    if (subCategories == null)&lt;br /&gt;
      subCategories = new Vector();&lt;br /&gt;
    if (!subCategories.contains(subcategory))&lt;br /&gt;
      subCategories.add(subcategory);&lt;br /&gt;
  }&lt;br /&gt;
  public String getName() {&lt;br /&gt;
    return name;&lt;br /&gt;
  }&lt;br /&gt;
  public Node getParent() {&lt;br /&gt;
    return parent;&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 Viewers ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;JFace wraps SWT&amp;quot;s Tree widget with a class called TreeViewer.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Creating a TreeViewer&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;TreeViewer treeViewer = new TreeViewer(shell);&amp;lt;/p&amp;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;
Create a TreeViewer to wrap an existing Tree control, like this:&lt;br /&gt;
Tree tree = new Tree(shell, SWT.SINGLE);&lt;br /&gt;
TreeViewer treeViewer = new TreeViewer(tree);&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;
==  Using a TreeViewer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The general way to use a TreeViewer:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;Creating a TreeViewer&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Creating a content provider class and setting it on the TreeViewer using setContentProvider()&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Creating a label provider class and setting it on the TreeViewer using setLabelProvider()&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Setting the root input for the tree using setInput()&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;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;
import java.io.File;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.FileNotFoundException;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
import org.eclipse.jface.viewers.ILabelProvider;&lt;br /&gt;
import org.eclipse.jface.viewers.ILabelProviderListener;&lt;br /&gt;
import org.eclipse.jface.viewers.ITreeContentProvider;&lt;br /&gt;
import org.eclipse.jface.viewers.TreeViewer;&lt;br /&gt;
import org.eclipse.jface.viewers.Viewer;&lt;br /&gt;
import org.eclipse.jface.window.ApplicationWindow;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Image;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.layout.GridData;&lt;br /&gt;
import org.eclipse.swt.widgets.ruposite;&lt;br /&gt;
import org.eclipse.swt.widgets.Control;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FileTreeWindowApplication {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    FileTreeWindow main = new FileTreeWindow();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class FileTreeWindow extends ApplicationWindow {&lt;br /&gt;
  public FileTreeWindow() {&lt;br /&gt;
    super(null);&lt;br /&gt;
    // Don&amp;quot;t return from open() until window closes&lt;br /&gt;
    setBlockOnOpen(true);&lt;br /&gt;
    open();&lt;br /&gt;
    Display.getCurrent().dispose();&lt;br /&gt;
  }&lt;br /&gt;
  protected void configureShell(Shell shell) {&lt;br /&gt;
    super.configureShell(shell);&lt;br /&gt;
    shell.setSize(400, 400);&lt;br /&gt;
  }&lt;br /&gt;
  protected Control createContents(Composite parent) {&lt;br /&gt;
    Composite composite = new Composite(parent, SWT.NONE);&lt;br /&gt;
    composite.setLayout(new FillLayout());&lt;br /&gt;
    final TreeViewer tv = new TreeViewer(composite);&lt;br /&gt;
    tv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));&lt;br /&gt;
    tv.setContentProvider(new FileTreeContentProvider());&lt;br /&gt;
    tv.setLabelProvider(new FileTreeLabelProvider());&lt;br /&gt;
    tv.setInput(&amp;quot;root&amp;quot;);&lt;br /&gt;
    return composite;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class FileTreeContentProvider implements ITreeContentProvider {&lt;br /&gt;
  public Object[] getChildren(Object arg0) {&lt;br /&gt;
    return ((File) arg0).listFiles();&lt;br /&gt;
  }&lt;br /&gt;
  public Object getParent(Object arg0) {&lt;br /&gt;
    return ((File) arg0).getParentFile();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean hasChildren(Object arg0) {&lt;br /&gt;
    Object[] obj = getChildren(arg0);&lt;br /&gt;
    return obj == null ? false : obj.length &amp;gt; 0;&lt;br /&gt;
  }&lt;br /&gt;
  public Object[] getElements(Object arg0) {&lt;br /&gt;
    return File.listRoots();&lt;br /&gt;
  }&lt;br /&gt;
  public void dispose() {&lt;br /&gt;
  }&lt;br /&gt;
  public void inputChanged(Viewer arg0, Object arg1, Object arg2) {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class FileTreeLabelProvider implements ILabelProvider {&lt;br /&gt;
  private List listeners;&lt;br /&gt;
  private Image file;&lt;br /&gt;
  private Image dir;&lt;br /&gt;
  public FileTreeLabelProvider() {&lt;br /&gt;
    listeners = new ArrayList();&lt;br /&gt;
    try {&lt;br /&gt;
      file = new Image(null, new FileInputStream(&amp;quot;images/file.gif&amp;quot;));&lt;br /&gt;
      dir = new Image(null, new FileInputStream(&amp;quot;images/directory.gif&amp;quot;));&lt;br /&gt;
    } catch (FileNotFoundException e) {&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public Image getImage(Object arg0) {&lt;br /&gt;
    return ((File) arg0).isDirectory() ? dir : file;&lt;br /&gt;
  }&lt;br /&gt;
  public String getText(Object arg0) {&lt;br /&gt;
    String text = ((File) arg0).getName();&lt;br /&gt;
    if (((File) arg0).getName().length() == 0) {&lt;br /&gt;
      text = ((File) arg0).getPath();&lt;br /&gt;
    }&lt;br /&gt;
    return text;&lt;br /&gt;
  }&lt;br /&gt;
  public void addListener(ILabelProviderListener arg0) {&lt;br /&gt;
    listeners.add(arg0);&lt;br /&gt;
  }&lt;br /&gt;
  public void dispose() {&lt;br /&gt;
    // Dispose the images&lt;br /&gt;
    if (dir != null)&lt;br /&gt;
      dir.dispose();&lt;br /&gt;
    if (file != null)&lt;br /&gt;
      file.dispose();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isLabelProperty(Object arg0, String arg1) {&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  public void removeListener(ILabelProviderListener arg0) {&lt;br /&gt;
    listeners.remove(arg0);&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>