`
yianpuodiaotu
  • 浏览: 237663 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

tree file options

阅读更多
package jface.treeviewer;
import java.io.File;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TreeColumn;


public class TreeColumnTest {
    
    public void run(){
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        
        final TreeViewer viewer = new TreeViewer(shell, SWT.FULL_SELECTION);
        viewer.getTree().setHeaderVisible(true);
        TreeColumn column = new TreeColumn(viewer.getTree(), SWT.LEFT);
        column.setText("Name");
        column.setWidth(200);
        column = new TreeColumn(viewer.getTree(), SWT.LEFT);
        column.setText("Size");
        column.setWidth(100);
        column = new TreeColumn(viewer.getTree(), SWT.LEFT);
        column.setText("Hidden");
        column.setWidth(100);
        viewer.setContentProvider(new MyTreeContenetProvider());
        viewer.setLabelProvider(new MyTableLableProvider());
        viewer.setInput(new File("/"));

        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }

    public static void main(String[] args) {
        new TreeColumnTest().run();
    }
    
    class MyTreeContenetProvider implements ITreeContentProvider{

        public Object[] getChildren(Object parentElement) {
            File file=(File)parentElement;
            if(file.isDirectory())
                return file.listFiles();
            else
                return null;
        }

        public Object getParent(Object element) {
            File file=(File)element;
            return file.getParentFile();
        }

        public boolean hasChildren(Object element) {
            File file=(File)element;
            return file.isDirectory()/*&&file.list().length>0*/;
        }

        public Object[] getElements(Object inputElement) {
            File file=(File)inputElement;
            return file.isDirectory()?file.listFiles():new Object[]{file};
        }

        public void dispose() {
            
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            
        }
        
    }
    
    class MyTableLableProvider implements ITableLabelProvider{

        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }

        public String getColumnText(Object element, int columnIndex) {
            File file=(File)element;
            switch (columnIndex) {
            case 0:
                return file.getName();
            case 1:
                return ""+file.length();
            case 2:
                return ""+file.isHidden();
            default:
                return "";
            }
        }

        public void addListener(ILabelProviderListener listener) {
            
        }

        public void dispose() {
            
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
            
        }
        
    }
}

注:将计算机文件用树列出来。

分享到:
评论

相关推荐

    jquery-file-tree:一个高度可定制的 jQuery 文件树插件,用于显示文件夹结构

    bower install jquery-filetree 手动的 下载 ##Usage <link rel="stylesheet" href="path/to/filetree.css"> [removed][removed] [removed][removed] $ ( document ) . ready ( function ( ) { $ ( '#...

    tree-diff:一个树差异工具

    tree-diff基于babel的文件依赖树diff工具before all请手动 linknpm link使用方式自己看 tree-diff --help> tree-diff --helpUsage: tree [options]Options: -r, --root <dir> 待查找的根目录, 不写默认为当前目录 -e...

    绿色版PocketDOS 和 绿色版TC3.0

    GETOPT C - Parses options in command line GREP2MSG C - Example program for Turbo C++ filters HELLO C - Example Turbo C++ program INTRO1 CPP - Example program from User's Guide INTRO10 CPP - ...

    broccoli-flatten

    西兰花压扁 扁平化文件树,因此所有...tree = flatten ( tree , options ) ; 选项 支持以下选项: destDir目录存放所有文件的位置 ###例子 var pickFiles = require ( 'broccoli-static-compiler' ) ; var flatten

    'FrontEnd Plus' The GUI for the fast JAva Decompiler.

    options -o and -sjava together, because Jad can accidentally overwrite your own source files. Jad uses JAVA class name as an output file name. For example, if class file 'example1.class' contains ...

    pybootchartgui

    sample.util) for sample in disk_stats], proc_tree) File "/usr/lib/pymodules/python2.6/pybootchartgui/draw.py", line 201, in draw_chart yscale = float(chart_bounds[3]) / max(y for (x,y) in data)...

    Event_Log_Explorer_4.3.8.zi

    4.3.7 (2014-Oct-06) ...+ Added import tree options (when you import from a text file). + Option to show Record number. + Tooltips on tabs to display helpful information. * Minor fixes and improvements.

    word自动转化为chm

    The format and style are kept and the topic tree is created according to the outline of the Word file in the CHM file created by Word-2-CHM. The command line of Word-2-CHM can be used to generate CHM...

    broccoli-umd

    var outputTree = umdify ( sourceTrees , inputFile , outputFile , options ) sourceTrees :充当inputFile搜索路径的树数组。 如果您只有一棵树,请通过[tree] 。 inputFile :要 umdify 的主.js文件的相对路径。...

    broccoli-sass-rhel:红帽企业 linux 的 broccoli-sass 分支(node-sass 1.1.2 友好)

    var outputTree = compileSass ( inputTrees , inputFile , outputFile , options ) ; inputTrees :充当 libsass 包含路径的树数组。 如果您只有一棵树,请通过[tree] 。 inputFile :主要的相对路径.scss或.sass...

    EGit用户指南

    3.9.1.4 Merge options 3.9.1.5 Possible merge results 3.9.1.5.1 Merge Result dialog 3.9.2 Resolving a merge conflict 3.9.2.1 Using Merge Tool 3.9.2.2 Manual conflict resolution 3.9.2.3 Finding...

    broccoli-sweetjs:转换Sweet.js宏

    tree = sweetjs ( tree , options ) ; 原料药 sweetjs(树,[选项]) 选项 模组 类型: array 默认值: [] 您要使用的宏列表。 使用与require()相同的语法: npm模块: 'module-name' 本地文件: './file-name'...

    Java反编译软件JAD1

    in the input file names, it automatically skips matching inner classes. On UNIX Jad skips inner classes if there is more than one class specified in the command line. Jad looks for inner classes in ...

    Data Collector

    All these nodes will be organized like a tree, in fact, the tree structure is stored in one database file, so you need not to save a lot of small note files in your disk. With DC's support, you'll ...

    riscv-emu:用Rust编写的RISC-V模拟器。 支持Linux,xv6,NuttX,FreeRTOS,Zephyr OS等

    用法 $ ../target/release/riscv_emu_desktop [options]Options: -k, --kernel Kernel image file -f, --filesystem File system image file -d, --dtb Device tree binary file -m, --machine Target machine ...

    java反编译工具jad 1.5.8g(可以反编译jdk1.5,1.6)

    For example, if file 'tree/a/b/c.class' contains class 'c' from package 'a.b', then output file will have a name 'src/a/b/c.java'. <br>Note the use of the "two stars" wildcard ('**') in ...

    broccoli-istanbul:伊斯坦布尔仪器的西兰花插件

    var outputTree = IstanbulCompiler ( inputTrees , inputFile , outputFile , options ) ; inputTrees :一系列树,用作伊斯坦布尔的包含路径。 inputFile :要检测的主.js文件的相对路径。 Broccoli-Istanbul 期望...

    pugixml1.0

    You can control many aspects of file parsing and DOM tree building via parsing options. ·Lacks validation, DTD processing, XML namespaces, proper handling of encoding. ·Lacks UTF-16/32 parsing.

    ISS.rar_Loaded_jvcl iss

    5. Modify the package options if necessary, e.g. to specify other than the standard output or search pathes. 6. Compile and build the package. This will generate a .bpl file of the package in the BPL ...

    DITidy v5.6.3 for D4-XE10 HTML XML 解析

    DITidy is an embedded HTML parser and pretty printer for Delphi ...Built-in English language descriptions of library options. Completely self-contained in a smart-linking, single file source code unit.

Global site tag (gtag.js) - Google Analytics