`
yianpuodiaotu
  • 浏览: 241545 次
  • 性别: 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

    4. **初始化插件**:在文档加载完成后,使用 `$("#filetree").fileTree({options}, function(file) {...});` 初始化文件树。 5. **服务器端设置**:根据所选编程语言,设置相应的服务器端连接器脚本,确保能正确...

    easyui tree扁平化扩展,不用再为children嵌套结构烦恼

    var opt = $(this).data().tree.options; var idField = opt.idField || 'id'; var textField = opt.textField || 'text'; var parentField = opt.parentField; // 构建临时映射表 var tmpMap = {}; for ...

    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...

    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)...

    绿色版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 ...

    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.

    实例讲解jQuery EasyUI tree中state属性慎用

    在jQuery EasyUI Tree中,除了基本的`id`, `text`, `iconCls`, `checked`, `state`和`attribute`之外,还可以通过`data-options`属性来添加自定义的节点属性。`attribute`属性是一个JSON对象,可以存储额外的信息,...

    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...

    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 ...

    red hat linux 命令

    15. **`iconv [options] input_file > output_file`**:转换文件编码。 - 示例:`iconv -f GBK -t UTF-8 input.txt > output.txt` 将 `input.txt` 从 GBK 编码转换为 UTF-8 编码。 16. **`find [path] [options] ...

    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 期望...

Global site tag (gtag.js) - Google Analytics