<?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%2FFile_Tree</id>
		<title>Java Tutorial/SWT/File Tree - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT%2FFile_Tree"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/File_Tree&amp;action=history"/>
		<updated>2026-04-10T14:20:57Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/File_Tree&amp;diff=3149&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/File_Tree&amp;diff=3149&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/File_Tree&amp;diff=3150&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/File_Tree&amp;diff=3150&amp;oldid=prev"/>
				<updated>2010-05-31T15:21:20Z</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 lazy file tree ==&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, 2004 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;
/*&lt;br /&gt;
 * Tree example snippet: create a tree (lazy)&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;
import java.io.File;&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.TreeItem;&lt;br /&gt;
public class FileTreeLazy{&lt;br /&gt;
  &lt;br /&gt;
public static void main (String [] args) {&lt;br /&gt;
  final Display display = new Display ();&lt;br /&gt;
  final Shell shell = new Shell (display);&lt;br /&gt;
  shell.setText (&amp;quot;Lazy Tree&amp;quot;);&lt;br /&gt;
  shell.setLayout (new FillLayout ());&lt;br /&gt;
  final Tree tree = new Tree (shell, SWT.BORDER);&lt;br /&gt;
  File [] roots = File.listRoots ();&lt;br /&gt;
  for (int i=0; i&amp;lt;roots.length; i++) {&lt;br /&gt;
    TreeItem root = new TreeItem (tree, 0);&lt;br /&gt;
    root.setText (roots [i].toString ());&lt;br /&gt;
    root.setData (roots [i]);&lt;br /&gt;
    new TreeItem (root, 0);&lt;br /&gt;
  }&lt;br /&gt;
  tree.addListener (SWT.Expand, new Listener () {&lt;br /&gt;
    public void handleEvent (final Event event) {&lt;br /&gt;
      final TreeItem root = (TreeItem) event.item;&lt;br /&gt;
      TreeItem [] items = root.getItems ();&lt;br /&gt;
      for (int i= 0; i&amp;lt;items.length; i++) {&lt;br /&gt;
        if (items [i].getData () != null) return;&lt;br /&gt;
        items [i].dispose ();&lt;br /&gt;
      }&lt;br /&gt;
      File file = (File) root.getData ();&lt;br /&gt;
      File [] files = file.listFiles ();&lt;br /&gt;
      if (files == null) return;&lt;br /&gt;
      for (int i= 0; i&amp;lt;files.length; i++) {&lt;br /&gt;
        TreeItem item = new TreeItem (root, 0);&lt;br /&gt;
        item.setText (files [i].getName ());&lt;br /&gt;
        item.setData (files [i]);&lt;br /&gt;
        if (files [i].isDirectory()) {&lt;br /&gt;
          new TreeItem (item, 0);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  });&lt;br /&gt;
  Point size = tree.ruputeSize (300, SWT.DEFAULT);&lt;br /&gt;
  int width = Math.max (300, size.x);&lt;br /&gt;
  int height = Math.max (300, size.y);&lt;br /&gt;
  shell.setSize (shell.ruputeSize (width, height));&lt;br /&gt;
  shell.open ();&lt;br /&gt;
  while (!shell.isDisposed ()) {&lt;br /&gt;
    if (!display.readAndDispatch ()) 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;
==  System File Tree ==&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, 2004 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;
 &lt;br /&gt;
 &lt;br /&gt;
import java.io.File;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.awt.SWT_AWT;&lt;br /&gt;
import org.eclipse.swt.graphics.RGB;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&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.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Label;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Sash;&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 SystemFileTree {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    RGB color = shell.getBackground().getRGB();&lt;br /&gt;
    Label separator1 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);&lt;br /&gt;
    Label locationLb = new Label(shell, SWT.NONE);&lt;br /&gt;
    locationLb.setText(&amp;quot;Location:&amp;quot;);&lt;br /&gt;
    Composite locationComp = new Composite(shell, SWT.EMBEDDED);&lt;br /&gt;
    Label separator2 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);&lt;br /&gt;
    final Composite comp = new Composite(shell, SWT.NONE);&lt;br /&gt;
    final Tree fileTree = new Tree(comp, SWT.SINGLE | SWT.BORDER);&lt;br /&gt;
    Sash sash = new Sash(comp, SWT.VERTICAL);&lt;br /&gt;
    Composite tableComp = new Composite(comp, SWT.EMBEDDED);&lt;br /&gt;
    Label separator3 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);&lt;br /&gt;
    Composite statusComp = new Composite(shell, SWT.EMBEDDED);&lt;br /&gt;
    java.awt.Frame locationFrame = SWT_AWT.new_Frame(locationComp);&lt;br /&gt;
    final java.awt.TextField locationText = new java.awt.TextField();&lt;br /&gt;
    locationFrame.add(locationText);&lt;br /&gt;
    java.awt.Frame statusFrame = SWT_AWT.new_Frame(statusComp);&lt;br /&gt;
    statusFrame.setBackground(new java.awt.Color(color.red, color.green, color.blue));&lt;br /&gt;
    final java.awt.Label statusLabel = new java.awt.Label();&lt;br /&gt;
    statusFrame.add(statusLabel);&lt;br /&gt;
    statusLabel.setText(&amp;quot;Select a file&amp;quot;);&lt;br /&gt;
    sash.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        if (e.detail == SWT.DRAG)&lt;br /&gt;
          return;&lt;br /&gt;
        GridData data = (GridData) fileTree.getLayoutData();&lt;br /&gt;
        Rectangle trim = fileTree.ruputeTrim(0, 0, 0, 0);&lt;br /&gt;
        data.widthHint = e.x - trim.width;&lt;br /&gt;
        comp.layout();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    File[] roots = File.listRoots();&lt;br /&gt;
    for (int i = 0; i &amp;lt; roots.length; i++) {&lt;br /&gt;
      File file = roots[i];&lt;br /&gt;
      TreeItem treeItem = new TreeItem(fileTree, SWT.NONE);&lt;br /&gt;
      treeItem.setText(file.getAbsolutePath());&lt;br /&gt;
      treeItem.setData(file);&lt;br /&gt;
      new TreeItem(treeItem, SWT.NONE);&lt;br /&gt;
    }&lt;br /&gt;
    fileTree.addListener(SWT.Expand, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        TreeItem item = (TreeItem) e.item;&lt;br /&gt;
        if (item == null)&lt;br /&gt;
          return;&lt;br /&gt;
        if (item.getItemCount() == 1) {&lt;br /&gt;
          TreeItem firstItem = item.getItems()[0];&lt;br /&gt;
          if (firstItem.getData() != null)&lt;br /&gt;
            return;&lt;br /&gt;
          firstItem.dispose();&lt;br /&gt;
        } else {&lt;br /&gt;
          return;&lt;br /&gt;
        }&lt;br /&gt;
        File root = (File) item.getData();&lt;br /&gt;
        File[] files = root.listFiles();&lt;br /&gt;
        if (files == null)&lt;br /&gt;
          return;&lt;br /&gt;
        for (int i = 0; i &amp;lt; files.length; i++) {&lt;br /&gt;
          File file = files[i];&lt;br /&gt;
          if (file.isDirectory()) {&lt;br /&gt;
            TreeItem treeItem = new TreeItem(item, SWT.NONE);&lt;br /&gt;
            treeItem.setText(file.getName());&lt;br /&gt;
            treeItem.setData(file);&lt;br /&gt;
            new TreeItem(treeItem, SWT.NONE);&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    fileTree.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        TreeItem item = (TreeItem) e.item;&lt;br /&gt;
        if (item == null)&lt;br /&gt;
          return;&lt;br /&gt;
        final File root = (File) item.getData();&lt;br /&gt;
        statusLabel.setText(root.getAbsolutePath());&lt;br /&gt;
        locationText.setText(root.getAbsolutePath());&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    GridLayout layout = new GridLayout(4, false);&lt;br /&gt;
    layout.marginWidth = layout.marginHeight = 0;&lt;br /&gt;
    layout.horizontalSpacing = layout.verticalSpacing = 1;&lt;br /&gt;
    shell.setLayout(layout);&lt;br /&gt;
    GridData data;&lt;br /&gt;
    data = new GridData(GridData.FILL_HORIZONTAL);&lt;br /&gt;
    data.horizontalSpan = 4;&lt;br /&gt;
    separator1.setLayoutData(data);&lt;br /&gt;
    data = new GridData();&lt;br /&gt;
    data.horizontalSpan = 1;&lt;br /&gt;
    data.horizontalIndent = 10;&lt;br /&gt;
    locationLb.setLayoutData(data);&lt;br /&gt;
    data = new GridData(GridData.FILL_HORIZONTAL);&lt;br /&gt;
    data.horizontalSpan = 2;&lt;br /&gt;
    data.heightHint = locationText.getPreferredSize().height;&lt;br /&gt;
    locationComp.setLayoutData(data);&lt;br /&gt;
    data = new GridData(GridData.FILL_HORIZONTAL);&lt;br /&gt;
    data.horizontalSpan = 1;&lt;br /&gt;
    data = new GridData(GridData.FILL_HORIZONTAL);&lt;br /&gt;
    data.horizontalSpan = 4;&lt;br /&gt;
    separator2.setLayoutData(data);&lt;br /&gt;
    data = new GridData(GridData.FILL_BOTH);&lt;br /&gt;
    data.horizontalSpan = 4;&lt;br /&gt;
    comp.setLayoutData(data);&lt;br /&gt;
    data = new GridData(GridData.FILL_HORIZONTAL);&lt;br /&gt;
    data.horizontalSpan = 4;&lt;br /&gt;
    separator3.setLayoutData(data);&lt;br /&gt;
    data = new GridData(GridData.FILL_HORIZONTAL);&lt;br /&gt;
    data.horizontalSpan = 4;&lt;br /&gt;
    data.heightHint = statusLabel.getPreferredSize().height;&lt;br /&gt;
    statusComp.setLayoutData(data);&lt;br /&gt;
    layout = new GridLayout(3, false);&lt;br /&gt;
    layout.marginWidth = layout.marginHeight = 0;&lt;br /&gt;
    layout.horizontalSpacing = layout.verticalSpacing = 1;&lt;br /&gt;
    comp.setLayout(layout);&lt;br /&gt;
    data = new GridData(GridData.FILL_VERTICAL);&lt;br /&gt;
    data.widthHint = 200;&lt;br /&gt;
    fileTree.setLayoutData(data);&lt;br /&gt;
    data = new GridData(GridData.FILL_VERTICAL);&lt;br /&gt;
    sash.setLayoutData(data);&lt;br /&gt;
    data = new GridData(GridData.FILL_BOTH);&lt;br /&gt;
    tableComp.setLayoutData(data);&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>